Compare commits

...
10 Commits
Author SHA1 Message Date
Jack Humbert fa09bc76c4 Merge b4e30d3929 into d639bd2021 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
Jack Humbert 13c394fba4 Merge pull request #1071 from dungdung/rgb_tweaks
RGB tweaks
2017-02-07 13:32:31 -05:00
Nic Aitch 3dbdd15304 Check for a new serial port every second 2017-02-06 19:57:34 -06:00
dungdung a7882b1ffc Added non-animated gradient mode 2017-02-06 14:18:20 -08:00
dungdung 5a1b68d562 Added mode reverse step function 2017-02-06 14:18:20 -08:00
dungdung 0e548f8b5d Christmas mode now works with even RGBED_NUM
Added Christmas mode steps to reduce red and green colors blending into each other
Added Christmas mode interval
Increased green hue to 120
2017-02-06 14:18:20 -08:00
Luiz Ribeiro a3da586505 Fix V-USB bug on Windows 10 2017-02-01 21:57:44 -05:00
5 changed files with 111 additions and 43 deletions

No files matched your search

+6 -4
View File
@@ -76,10 +76,12 @@ CUSTOM_MATRIX = yes
avrdude: build avrdude: build
ls /dev/tty* > /tmp/1; \ ls /dev/tty* > /tmp/1; \
echo "Reset your Pro Micro then hit any key to continue..."; \ echo "Reset your Pro Micro now"; \
read -n 1 -s; \ while [[ -z $$USB ]]; do \
ls /dev/tty* > /tmp/2; \ sleep 1; \
USB=`diff /tmp/1 /tmp/2 | grep '>' | sed -e 's/> //'`; \ 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 avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex
.PHONY: avrdude .PHONY: avrdude
+62 -32
View File
@@ -594,34 +594,45 @@ static const uint8_t backlight_pin = BACKLIGHT_PIN;
# define COM1x1 COM1A1 # define COM1x1 COM1A1
# define OCR1x OCR1A # define OCR1x OCR1A
#else #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 #endif
__attribute__ ((weak)) __attribute__ ((weak))
void backlight_init_ports(void) 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 // DDRx |= n
_SFR_IO8((backlight_pin >> 4) + 1) |= _BV(backlight_pin & 0xF); _SFR_IO8((backlight_pin >> 4) + 1) |= _BV(backlight_pin & 0xF);
// PORTx &= ~n #if BACKLIGHT_ON_STATE == 0
_SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); // 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. #ifndef NO_BACKLIGHT_CLOCK
ICR1 = 0xFFFF; // Use full 16-bit resolution.
ICR1 = 0xFFFF;
// I could write a wall of text here to explain... but TL;DW // I could write a wall of text here to explain... but TL;DW
// Go read the ATmega32u4 datasheet. // Go read the ATmega32u4 datasheet.
// And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
// Pin PB7 = OCR1C (Timer 1, Channel C) // Pin PB7 = OCR1C (Timer 1, Channel C)
// Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
// (i.e. start high, go low when counter matches.) // (i.e. start high, go low when counter matches.)
// WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 // 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 // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010; TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010;
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
#endif
backlight_init(); backlight_init();
#ifdef BACKLIGHT_BREATHING #ifdef BACKLIGHT_BREATHING
@@ -633,24 +644,43 @@ __attribute__ ((weak))
void backlight_set(uint8_t level) void backlight_set(uint8_t level)
{ {
// Prevent backlight blink on lowest level // Prevent backlight blink on lowest level
// PORTx &= ~n #if BACKLIGHT_ON_STATE == 0
_SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); // 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 ) { if ( level == 0 ) {
// Turn off PWM control on backlight pin, revert to output low. #ifndef NO_BACKLIGHT_CLOCK
TCCR1A &= ~(_BV(COM1x1)); // Turn off PWM control on backlight pin, revert to output low.
OCR1x = 0x0; TCCR1A &= ~(_BV(COM1x1));
} else if ( level == BACKLIGHT_LEVELS ) { OCR1x = 0x0;
// Turn on PWM control of backlight pin #else
TCCR1A |= _BV(COM1x1); #if BACKLIGHT_ON_STATE == 0
// Set the brightness // PORTx |= n
OCR1x = 0xFFFF; _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
} else { #else
// Turn on PWM control of backlight pin // PORTx &= ~n
TCCR1A |= _BV(COM1x1); _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
// Set the brightness #endif
OCR1x = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); #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 #ifdef BACKLIGHT_BREATHING
breathing_intensity_default(); breathing_intensity_default();
+31 -4
View File
@@ -66,6 +66,8 @@ __attribute__ ((weak))
const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20};
__attribute__ ((weak)) __attribute__ ((weak))
const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20};
__attribute__ ((weak))
const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
rgblight_config_t rgblight_config; rgblight_config_t rgblight_config;
rgblight_config_t inmem_config; rgblight_config_t inmem_config;
@@ -219,6 +221,14 @@ void rgblight_step(void) {
} }
rgblight_mode(mode); rgblight_mode(mode);
} }
void rgblight_step_reverse(void) {
uint8_t mode = 0;
mode = rgblight_config.mode - 1;
if (mode < 1) {
mode = RGBLIGHT_MODES;
}
rgblight_mode(mode);
}
void rgblight_mode(uint8_t mode) { void rgblight_mode(uint8_t mode) {
if (!rgblight_config.enable) { if (!rgblight_config.enable) {
@@ -237,7 +247,7 @@ void rgblight_mode(uint8_t mode) {
#ifdef RGBLIGHT_ANIMATIONS #ifdef RGBLIGHT_ANIMATIONS
rgblight_timer_disable(); rgblight_timer_disable();
#endif #endif
} else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 23) { } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 24) {
// MODE 2-5, breathing // MODE 2-5, breathing
// MODE 6-8, rainbow mood // MODE 6-8, rainbow mood
// MODE 9-14, rainbow swirl // MODE 9-14, rainbow swirl
@@ -247,6 +257,12 @@ void rgblight_mode(uint8_t mode) {
#ifdef RGBLIGHT_ANIMATIONS #ifdef RGBLIGHT_ANIMATIONS
rgblight_timer_enable(); rgblight_timer_enable();
#endif #endif
} else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) {
// MODE 25-34, static gradient
#ifdef RGBLIGHT_ANIMATIONS
rgblight_timer_disable();
#endif
} }
rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
} }
@@ -350,6 +366,17 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
} else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) {
// rainbow mood and rainbow swirl, ignore the change of hue // rainbow mood and rainbow swirl, ignore the change of hue
hue = rgblight_config.hue; hue = rgblight_config.hue;
} else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) {
// static gradient
uint16_t _hue;
int8_t direction = ((rgblight_config.mode - 25) % 2) ? -1 : 1;
uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - 25) / 2]);
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
_hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360;
dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range);
sethsv(_hue, sat, val, (LED_TYPE *)&led[i]);
}
rgblight_set();
} }
} }
rgblight_config.hue = hue; rgblight_config.hue = hue;
@@ -450,7 +477,7 @@ void rgblight_task(void) {
} else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) { } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) {
// mode = 21 to 23, knight mode // mode = 21 to 23, knight mode
rgblight_effect_knight(rgblight_config.mode - 21); rgblight_effect_knight(rgblight_config.mode - 21);
} else { } else if (rgblight_config.mode == 24) {
// mode = 24, christmas mode // mode = 24, christmas mode
rgblight_effect_christmas(); rgblight_effect_christmas();
} }
@@ -604,13 +631,13 @@ void rgblight_effect_christmas(void) {
static uint16_t last_timer = 0; static uint16_t last_timer = 0;
uint16_t hue; uint16_t hue;
uint8_t i; uint8_t i;
if (timer_elapsed(last_timer) < 1000) { if (timer_elapsed(last_timer) < RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL) {
return; return;
} }
last_timer = timer_read(); last_timer = timer_read();
current_offset = (current_offset + 1) % 2; current_offset = (current_offset + 1) % 2;
for (i = 0; i < RGBLED_NUM; i++) { for (i = 0; i < RGBLED_NUM; i++) {
hue = 0 + ((RGBLED_NUM * (i + current_offset)) % 2) * 80; hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + current_offset) % 2) * 120;
sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]);
} }
rgblight_set(); rgblight_set();
+10 -1
View File
@@ -2,7 +2,7 @@
#define RGBLIGHT_H #define RGBLIGHT_H
#ifdef RGBLIGHT_ANIMATIONS #ifdef RGBLIGHT_ANIMATIONS
#define RGBLIGHT_MODES 24 #define RGBLIGHT_MODES 34
#else #else
#define RGBLIGHT_MODES 1 #define RGBLIGHT_MODES 1
#endif #endif
@@ -22,6 +22,14 @@
#define RGBLIGHT_EFFECT_DUALKNIGHT_LENGTH 4 #define RGBLIGHT_EFFECT_DUALKNIGHT_LENGTH 4
#endif #endif
#ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL
#define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000
#endif
#ifndef RGBLIGHT_EFFECT_CHRISTMAS_STEP
#define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2
#endif
#ifndef RGBLIGHT_HUE_STEP #ifndef RGBLIGHT_HUE_STEP
#define RGBLIGHT_HUE_STEP 10 #define RGBLIGHT_HUE_STEP 10
#endif #endif
@@ -65,6 +73,7 @@ void rgblight_decrease(void);
void rgblight_toggle(void); void rgblight_toggle(void);
void rgblight_enable(void); void rgblight_enable(void);
void rgblight_step(void); void rgblight_step(void);
void rgblight_step_reverse(void);
void rgblight_mode(uint8_t mode); void rgblight_mode(uint8_t mode);
void rgblight_set(void); void rgblight_set(void);
void rgblight_update_dword(uint32_t dword); void rgblight_update_dword(uint32_t dword);
+2 -2
View File
@@ -280,7 +280,7 @@ const PROGMEM uchar keyboard_hid_report[] = {
0x95, 0x06, // Report Count (6), 0x95, 0x06, // Report Count (6),
0x75, 0x08, // Report Size (8), 0x75, 0x08, // Report Size (8),
0x15, 0x00, // Logical Minimum (0), 0x15, 0x00, // Logical Minimum (0),
0x25, 0xFF, 0x00, // Logical Maximum(255), 0x26, 0xFF, 0x00, // Logical Maximum(255),
0x05, 0x07, // Usage Page (Key Codes), 0x05, 0x07, // Usage Page (Key Codes),
0x19, 0x00, // Usage Minimum (0), 0x19, 0x00, // Usage Minimum (0),
0x29, 0xFF, // Usage Maximum (255), 0x29, 0xFF, // Usage Maximum (255),
@@ -350,7 +350,7 @@ const PROGMEM uchar mouse_hid_report[] = {
0xa1, 0x01, // COLLECTION (Application) 0xa1, 0x01, // COLLECTION (Application)
0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2)
0x15, 0x01, // LOGICAL_MINIMUM (0x1) 0x15, 0x01, // LOGICAL_MINIMUM (0x1)
0x25, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) 0x26, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7)
0x19, 0x01, // USAGE_MINIMUM (0x1) 0x19, 0x01, // USAGE_MINIMUM (0x1)
0x29, 0xb7, // USAGE_MAXIMUM (0xb7) 0x29, 0xb7, // USAGE_MAXIMUM (0xb7)
0x75, 0x10, // REPORT_SIZE (16) 0x75, 0x10, // REPORT_SIZE (16)