Compare commits

..

6 Commits

Author SHA1 Message Date
Jack Humbert
fa09bc76c4 Merge b4e30d392969b000eb9a87065fc1caaf33d670e1 into d639bd2021b697849bb11e521fc142292ab7e023 2017-02-07 20:27:07 +00:00
Jack Humbert
b4e30d3929 added functionality for just a port 2017-02-07 15:23:56 -05:00
Jack Humbert
d639bd2021 Merge pull request #1072 from nicinabox/improve-ls-avrdude-target
Check for Pro Micro serial port automatically
2017-02-07 13:52:03 -05:00
Jack Humbert
42ea912fde Merge pull request #1062 from luizribeiro/fix-win
Fix V-USB bug on Windows 10
2017-02-07 13:49:10 -05:00
Nic Aitch
3dbdd15304 Check for a new serial port every second 2017-02-06 19:57:34 -06:00
Luiz Ribeiro
a3da586505 Fix V-USB bug on Windows 10 2017-02-01 21:57:44 -05:00
3 changed files with 70 additions and 38 deletions

View File

@ -76,10 +76,12 @@ CUSTOM_MATRIX = yes
avrdude: build
ls /dev/tty* > /tmp/1; \
echo "Reset your Pro Micro then hit any key to continue..."; \
read -n 1 -s; \
ls /dev/tty* > /tmp/2; \
USB=`diff /tmp/1 /tmp/2 | grep '>' | sed -e 's/> //'`; \
echo "Reset your Pro Micro now"; \
while [[ -z $$USB ]]; do \
sleep 1; \
ls /dev/tty* > /tmp/2; \
USB=`diff /tmp/1 /tmp/2 | grep -o '/dev/tty.*'`; \
done; \
avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex
.PHONY: avrdude

View File

@ -594,34 +594,45 @@ static const uint8_t backlight_pin = BACKLIGHT_PIN;
# define COM1x1 COM1A1
# define OCR1x OCR1A
#else
# error "Backlight pin not supported - use B5, B6, or B7"
# define NO_BACKLIGHT_CLOCK
#endif
#ifndef BACKLIGHT_ON_STATE
#define BACKLIGHT_ON_STATE 0
#endif
__attribute__ ((weak))
void backlight_init_ports(void)
{
// Setup backlight pin as output and output low.
// Setup backlight pin as output and output to on state.
// DDRx |= n
_SFR_IO8((backlight_pin >> 4) + 1) |= _BV(backlight_pin & 0xF);
// PORTx &= ~n
_SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
#if BACKLIGHT_ON_STATE == 0
// PORTx &= ~n
_SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
#else
// PORTx |= n
_SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
#endif
// Use full 16-bit resolution.
ICR1 = 0xFFFF;
#ifndef NO_BACKLIGHT_CLOCK
// Use full 16-bit resolution.
ICR1 = 0xFFFF;
// I could write a wall of text here to explain... but TL;DW
// Go read the ATmega32u4 datasheet.
// And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
// I could write a wall of text here to explain... but TL;DW
// Go read the ATmega32u4 datasheet.
// And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
// Pin PB7 = OCR1C (Timer 1, Channel C)
// Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
// (i.e. start high, go low when counter matches.)
// WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
// Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
// Pin PB7 = OCR1C (Timer 1, Channel C)
// Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
// (i.e. start high, go low when counter matches.)
// WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
// Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010;
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010;
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
#endif
backlight_init();
#ifdef BACKLIGHT_BREATHING
@ -633,24 +644,43 @@ __attribute__ ((weak))
void backlight_set(uint8_t level)
{
// Prevent backlight blink on lowest level
// PORTx &= ~n
_SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
#if BACKLIGHT_ON_STATE == 0
// PORTx &= ~n
_SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
#else
// PORTx |= n
_SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
#endif
if ( level == 0 ) {
// Turn off PWM control on backlight pin, revert to output low.
TCCR1A &= ~(_BV(COM1x1));
OCR1x = 0x0;
} else if ( level == BACKLIGHT_LEVELS ) {
// Turn on PWM control of backlight pin
TCCR1A |= _BV(COM1x1);
// Set the brightness
OCR1x = 0xFFFF;
} else {
// Turn on PWM control of backlight pin
TCCR1A |= _BV(COM1x1);
// Set the brightness
OCR1x = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
}
#ifndef NO_BACKLIGHT_CLOCK
// Turn off PWM control on backlight pin, revert to output low.
TCCR1A &= ~(_BV(COM1x1));
OCR1x = 0x0;
#else
#if BACKLIGHT_ON_STATE == 0
// PORTx |= n
_SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
#else
// PORTx &= ~n
_SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
#endif
#endif
}
#ifndef NO_BACKLIGHT_CLOCK
else if ( level == BACKLIGHT_LEVELS ) {
// Turn on PWM control of backlight pin
TCCR1A |= _BV(COM1x1);
// Set the brightness
OCR1x = 0xFFFF;
}
else {
// Turn on PWM control of backlight pin
TCCR1A |= _BV(COM1x1);
// Set the brightness
OCR1x = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
}
#endif
#ifdef BACKLIGHT_BREATHING
breathing_intensity_default();

View File

@ -280,7 +280,7 @@ const PROGMEM uchar keyboard_hid_report[] = {
0x95, 0x06, // Report Count (6),
0x75, 0x08, // Report Size (8),
0x15, 0x00, // Logical Minimum (0),
0x25, 0xFF, 0x00, // Logical Maximum(255),
0x26, 0xFF, 0x00, // Logical Maximum(255),
0x05, 0x07, // Usage Page (Key Codes),
0x19, 0x00, // Usage Minimum (0),
0x29, 0xFF, // Usage Maximum (255),
@ -350,7 +350,7 @@ const PROGMEM uchar mouse_hid_report[] = {
0xa1, 0x01, // COLLECTION (Application)
0x85, REPORT_ID_SYSTEM, // REPORT_ID (2)
0x15, 0x01, // LOGICAL_MINIMUM (0x1)
0x25, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7)
0x26, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7)
0x19, 0x01, // USAGE_MINIMUM (0x1)
0x29, 0xb7, // USAGE_MAXIMUM (0xb7)
0x75, 0x10, // REPORT_SIZE (16)