diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2016-11-13 23:02:38 -0500 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2016-11-13 23:02:38 -0500 |
| commit | e9f748751808de2f1e85cf7fb670d78773bd5e76 (patch) | |
| tree | 1e52f15aed8e83f3784a6c10b1a04e3d8b6df4fe | |
| parent | 33e62c080c9161a0fc921c90ed299a67fc2e1799 (diff) | |
| download | qmk_firmware-e9f748751808de2f1e85cf7fb670d78773bd5e76.tar.gz qmk_firmware-e9f748751808de2f1e85cf7fb670d78773bd5e76.zip | |
mostly working
| -rw-r--r-- | keyboards/ergodox/ez/ez.c | 10 | ||||
| -rw-r--r-- | keyboards/ergodox/ez/matrix.c | 2 | ||||
| -rw-r--r-- | keyboards/ergodox/keymaps/jack/Makefile | 1 | ||||
| -rw-r--r-- | keyboards/ergodox/keymaps/jack/config.h | 4 | ||||
| -rwxr-xr-x | quantum/light_ws2812.c | 21 | ||||
| -rwxr-xr-x | quantum/light_ws2812.h | 14 | ||||
| -rw-r--r-- | quantum/quantum.c | 1 | ||||
| -rw-r--r-- | quantum/rgblight.c | 101 | ||||
| -rw-r--r-- | quantum/rgblight.h | 10 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 33 |
10 files changed, 125 insertions, 72 deletions
diff --git a/keyboards/ergodox/ez/ez.c b/keyboards/ergodox/ez/ez.c index ddb8ff0cf..039e4c6bb 100644 --- a/keyboards/ergodox/ez/ez.c +++ b/keyboards/ergodox/ez/ez.c | |||
| @@ -16,10 +16,10 @@ void matrix_init_kb(void) { | |||
| 16 | // unused pins - C7, D4, D5, D7, E6 | 16 | // unused pins - C7, D4, D5, D7, E6 |
| 17 | // set as input with internal pull-ip enabled | 17 | // set as input with internal pull-ip enabled |
| 18 | DDRC &= ~(1<<7); | 18 | DDRC &= ~(1<<7); |
| 19 | DDRD &= ~(1<<7 | 1<<5 | 1<<4); | 19 | DDRD &= ~(1<<5 | 1<<4); |
| 20 | DDRE &= ~(1<<6); | 20 | DDRE &= ~(1<<6); |
| 21 | PORTC |= (1<<7); | 21 | PORTC |= (1<<7); |
| 22 | PORTD |= (1<<7 | 1<<5 | 1<<4); | 22 | PORTD |= (1<<5 | 1<<4); |
| 23 | PORTE |= (1<<6); | 23 | PORTE |= (1<<6); |
| 24 | 24 | ||
| 25 | ergodox_blink_all_leds(); | 25 | ergodox_blink_all_leds(); |
| @@ -51,6 +51,10 @@ uint8_t init_mcp23018(void) { | |||
| 51 | mcp23018_status = 0x20; | 51 | mcp23018_status = 0x20; |
| 52 | 52 | ||
| 53 | // I2C subsystem | 53 | // I2C subsystem |
| 54 | |||
| 55 | uint8_t sreg_prev; | ||
| 56 | sreg_prev=SREG; | ||
| 57 | cli(); | ||
| 54 | if (i2c_initialized == 0) { | 58 | if (i2c_initialized == 0) { |
| 55 | i2c_init(); // on pins D(1,0) | 59 | i2c_init(); // on pins D(1,0) |
| 56 | i2c_initialized++; | 60 | i2c_initialized++; |
| @@ -79,6 +83,8 @@ uint8_t init_mcp23018(void) { | |||
| 79 | out: | 83 | out: |
| 80 | i2c_stop(); | 84 | i2c_stop(); |
| 81 | 85 | ||
| 86 | SREG=sreg_prev; | ||
| 87 | |||
| 82 | return mcp23018_status; | 88 | return mcp23018_status; |
| 83 | } | 89 | } |
| 84 | 90 | ||
diff --git a/keyboards/ergodox/ez/matrix.c b/keyboards/ergodox/ez/matrix.c index a19bab90b..43f515259 100644 --- a/keyboards/ergodox/ez/matrix.c +++ b/keyboards/ergodox/ez/matrix.c | |||
| @@ -121,7 +121,7 @@ void matrix_init(void) | |||
| 121 | matrix_scan_count = 0; | 121 | matrix_scan_count = 0; |
| 122 | #endif | 122 | #endif |
| 123 | 123 | ||
| 124 | matrix_init_kb(); | 124 | matrix_init_quantum(); |
| 125 | 125 | ||
| 126 | } | 126 | } |
| 127 | 127 | ||
diff --git a/keyboards/ergodox/keymaps/jack/Makefile b/keyboards/ergodox/keymaps/jack/Makefile index 1e5761278..7c257af50 100644 --- a/keyboards/ergodox/keymaps/jack/Makefile +++ b/keyboards/ergodox/keymaps/jack/Makefile | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | RGBLIGHT_ENABLE = yes | 1 | RGBLIGHT_ENABLE = yes |
| 2 | MIDI_ENABLE = yes | ||
| 2 | 3 | ||
| 3 | ifndef QUANTUM_DIR | 4 | ifndef QUANTUM_DIR |
| 4 | include ../../../../Makefile | 5 | include ../../../../Makefile |
diff --git a/keyboards/ergodox/keymaps/jack/config.h b/keyboards/ergodox/keymaps/jack/config.h index 1781563b8..5bf109c18 100644 --- a/keyboards/ergodox/keymaps/jack/config.h +++ b/keyboards/ergodox/keymaps/jack/config.h | |||
| @@ -5,10 +5,12 @@ | |||
| 5 | 5 | ||
| 6 | /* ws2812 RGB LED */ | 6 | /* ws2812 RGB LED */ |
| 7 | #define RGB_DI_PIN D7 | 7 | #define RGB_DI_PIN D7 |
| 8 | // #define RGBLIGHT_TIMER | 8 | #define RGBLIGHT_TIMER |
| 9 | #define RGBLED_NUM 15 // Number of LEDs | 9 | #define RGBLED_NUM 15 // Number of LEDs |
| 10 | #define RGBLIGHT_HUE_STEP 12 | 10 | #define RGBLIGHT_HUE_STEP 12 |
| 11 | #define RGBLIGHT_SAT_STEP 255 | 11 | #define RGBLIGHT_SAT_STEP 255 |
| 12 | #define RGBLIGHT_VAL_STEP 12 | 12 | #define RGBLIGHT_VAL_STEP 12 |
| 13 | 13 | ||
| 14 | #define RGB_MIDI | ||
| 15 | |||
| 14 | #endif \ No newline at end of file | 16 | #endif \ No newline at end of file |
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c index 497543339..6edbc0f2b 100755 --- a/quantum/light_ws2812.c +++ b/quantum/light_ws2812.c | |||
| @@ -133,13 +133,13 @@ unsigned char I2C_Write(unsigned char c) | |||
| 133 | #endif | 133 | #endif |
| 134 | 134 | ||
| 135 | // Setleds for standard RGB | 135 | // Setleds for standard RGB |
| 136 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) | 136 | void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) |
| 137 | { | 137 | { |
| 138 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); | 138 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); |
| 139 | ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF)); | 139 | ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF)); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pinmask) | 142 | void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask) |
| 143 | { | 143 | { |
| 144 | // ws2812_DDRREG |= pinmask; // Enable DDR | 144 | // ws2812_DDRREG |= pinmask; // Enable DDR |
| 145 | // new universal format (DDR) | 145 | // new universal format (DDR) |
| @@ -150,12 +150,15 @@ void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pin | |||
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | // Setleds for SK6812RGBW | 152 | // Setleds for SK6812RGBW |
| 153 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | 153 | void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) |
| 154 | { | 154 | { |
| 155 | 155 | ||
| 156 | #ifdef RGBW_BB_TWI | 156 | #ifdef RGBW_BB_TWI |
| 157 | uint8_t sreg_prev, twcr_prev; | ||
| 158 | sreg_prev=SREG; | ||
| 159 | twcr_prev=TWCR; | ||
| 157 | cli(); | 160 | cli(); |
| 158 | TWCR = 0; | 161 | TWCR &= ~(1<<TWEN); |
| 159 | I2C_Init(); | 162 | I2C_Init(); |
| 160 | I2C_Start(); | 163 | I2C_Start(); |
| 161 | I2C_Write(0x84); | 164 | I2C_Write(0x84); |
| @@ -167,9 +170,9 @@ void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | |||
| 167 | I2C_Write(curbyte); | 170 | I2C_Write(curbyte); |
| 168 | } | 171 | } |
| 169 | I2C_Stop(); | 172 | I2C_Stop(); |
| 170 | sei(); | 173 | SREG=sreg_prev; |
| 171 | #else | 174 | // TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN); |
| 172 | _delay_us(80); | 175 | TWCR=twcr_prev; |
| 173 | #endif | 176 | #endif |
| 174 | 177 | ||
| 175 | 178 | ||
| @@ -180,7 +183,9 @@ void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | |||
| 180 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); | 183 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); |
| 181 | 184 | ||
| 182 | 185 | ||
| 183 | 186 | #ifndef RGBW_BB_TWI | |
| 187 | _delay_us(80); | ||
| 188 | #endif | ||
| 184 | } | 189 | } |
| 185 | 190 | ||
| 186 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) | 191 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) |
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h index 576c3bc48..0bef93d5e 100755 --- a/quantum/light_ws2812.h +++ b/quantum/light_ws2812.h | |||
| @@ -23,6 +23,14 @@ | |||
| 23 | #define LIGHT_I2C_ADDR_WRITE ( (LIGHT_I2C_ADDR<<1) | I2C_WRITE ) | 23 | #define LIGHT_I2C_ADDR_WRITE ( (LIGHT_I2C_ADDR<<1) | I2C_WRITE ) |
| 24 | #define LIGHT_I2C_ADDR_READ ( (LIGHT_I2C_ADDR<<1) | I2C_READ ) | 24 | #define LIGHT_I2C_ADDR_READ ( (LIGHT_I2C_ADDR<<1) | I2C_READ ) |
| 25 | 25 | ||
| 26 | #define RGBW 1 | ||
| 27 | |||
| 28 | #ifdef RGBW | ||
| 29 | #define LED_TYPE struct cRGBW | ||
| 30 | #else | ||
| 31 | #define LED_TYPE struct cRGB | ||
| 32 | #endif | ||
| 33 | |||
| 26 | 34 | ||
| 27 | /* | 35 | /* |
| 28 | * Structure of the LED array | 36 | * Structure of the LED array |
| @@ -49,9 +57,9 @@ struct cRGBW { uint8_t g; uint8_t r; uint8_t b; uint8_t w;}; | |||
| 49 | * - Wait 50�s to reset the LEDs | 57 | * - Wait 50�s to reset the LEDs |
| 50 | */ | 58 | */ |
| 51 | 59 | ||
| 52 | void ws2812_setleds (struct cRGB *ledarray, uint16_t number_of_leds); | 60 | void ws2812_setleds (LED_TYPE *ledarray, uint16_t number_of_leds); |
| 53 | void ws2812_setleds_pin (struct cRGB *ledarray, uint16_t number_of_leds,uint8_t pinmask); | 61 | void ws2812_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask); |
| 54 | void ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t number_of_leds); | 62 | void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds); |
| 55 | 63 | ||
| 56 | /* | 64 | /* |
| 57 | * Old interface / Internal functions | 65 | * Old interface / Internal functions |
diff --git a/quantum/quantum.c b/quantum/quantum.c index b8a81a76b..9fd9a6ef7 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -131,6 +131,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 131 | #endif | 131 | #endif |
| 132 | #ifdef PRINTING_ENABLE | 132 | #ifdef PRINTING_ENABLE |
| 133 | process_printer(keycode, record) && | 133 | process_printer(keycode, record) && |
| 134 | #endif | ||
| 134 | #ifdef UNICODEMAP_ENABLE | 135 | #ifdef UNICODEMAP_ENABLE |
| 135 | process_unicode_map(keycode, record) && | 136 | process_unicode_map(keycode, record) && |
| 136 | #endif | 137 | #endif |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 221a16402..1901010bf 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -69,15 +69,12 @@ const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; | |||
| 69 | 69 | ||
| 70 | rgblight_config_t rgblight_config; | 70 | rgblight_config_t rgblight_config; |
| 71 | rgblight_config_t inmem_config; | 71 | rgblight_config_t inmem_config; |
| 72 | #ifdef RGBW | ||
| 73 | struct cRGBW led[RGBLED_NUM]; | ||
| 74 | #else | ||
| 75 | struct cRGB led[RGBLED_NUM]; | ||
| 76 | #endif | ||
| 77 | uint8_t rgblight_inited = 0; | ||
| 78 | 72 | ||
| 73 | LED_TYPE led[RGBLED_NUM]; | ||
| 74 | uint8_t rgblight_inited = 0; | ||
| 75 | bool rgblight_timer_enabled = false; | ||
| 79 | 76 | ||
| 80 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, struct cRGB *led1) { | 77 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { |
| 81 | uint8_t r = 0, g = 0, b = 0, base, color; | 78 | uint8_t r = 0, g = 0, b = 0, base, color; |
| 82 | 79 | ||
| 83 | if (sat == 0) { // Acromatic color (gray). Hue doesn't mind. | 80 | if (sat == 0) { // Acromatic color (gray). Hue doesn't mind. |
| @@ -128,7 +125,7 @@ void sethsv(uint16_t hue, uint8_t sat, uint8_t val, struct cRGB *led1) { | |||
| 128 | setrgb(r, g, b, led1); | 125 | setrgb(r, g, b, led1); |
| 129 | } | 126 | } |
| 130 | 127 | ||
| 131 | void setrgb(uint8_t r, uint8_t g, uint8_t b, struct cRGB *led1) { | 128 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { |
| 132 | (*led1).r = r; | 129 | (*led1).r = r; |
| 133 | (*led1).g = g; | 130 | (*led1).g = g; |
| 134 | (*led1).b = b; | 131 | (*led1).b = b; |
| @@ -145,9 +142,9 @@ void eeconfig_update_rgblight_default(void) { | |||
| 145 | dprintf("eeconfig_update_rgblight_default\n"); | 142 | dprintf("eeconfig_update_rgblight_default\n"); |
| 146 | rgblight_config.enable = 1; | 143 | rgblight_config.enable = 1; |
| 147 | rgblight_config.mode = 1; | 144 | rgblight_config.mode = 1; |
| 148 | rgblight_config.hue = 200; | 145 | rgblight_config.hue = 0; |
| 149 | rgblight_config.sat = 204; | 146 | rgblight_config.sat = 255; |
| 150 | rgblight_config.val = 204; | 147 | rgblight_config.val = 255; |
| 151 | eeconfig_update_rgblight(rgblight_config.raw); | 148 | eeconfig_update_rgblight(rgblight_config.raw); |
| 152 | } | 149 | } |
| 153 | void eeconfig_debug_rgblight(void) { | 150 | void eeconfig_debug_rgblight(void) { |
| @@ -311,7 +308,7 @@ void rgblight_decrease_val(void) { | |||
| 311 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { | 308 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { |
| 312 | inmem_config.raw = rgblight_config.raw; | 309 | inmem_config.raw = rgblight_config.raw; |
| 313 | if (rgblight_config.enable) { | 310 | if (rgblight_config.enable) { |
| 314 | struct cRGB tmp_led; | 311 | LED_TYPE tmp_led; |
| 315 | sethsv(hue, sat, val, &tmp_led); | 312 | sethsv(hue, sat, val, &tmp_led); |
| 316 | inmem_config.hue = hue; | 313 | inmem_config.hue = hue; |
| 317 | inmem_config.sat = sat; | 314 | inmem_config.sat = sat; |
| @@ -378,51 +375,55 @@ void rgblight_set(void) { | |||
| 378 | 375 | ||
| 379 | // Animation timer -- AVR Timer3 | 376 | // Animation timer -- AVR Timer3 |
| 380 | void rgblight_timer_init(void) { | 377 | void rgblight_timer_init(void) { |
| 381 | static uint8_t rgblight_timer_is_init = 0; | 378 | // static uint8_t rgblight_timer_is_init = 0; |
| 382 | if (rgblight_timer_is_init) { | 379 | // if (rgblight_timer_is_init) { |
| 383 | return; | 380 | // return; |
| 384 | } | 381 | // } |
| 385 | rgblight_timer_is_init = 1; | 382 | // rgblight_timer_is_init = 1; |
| 386 | /* Timer 3 setup */ | 383 | // /* Timer 3 setup */ |
| 387 | TCCR3B = _BV(WGM32) //CTC mode OCR3A as TOP | 384 | // TCCR3B = _BV(WGM32) // CTC mode OCR3A as TOP |
| 388 | | _BV(CS30); //Clock selelct: clk/1 | 385 | // | _BV(CS30); // Clock selelct: clk/1 |
| 389 | /* Set TOP value */ | 386 | // /* Set TOP value */ |
| 390 | uint8_t sreg = SREG; | 387 | // uint8_t sreg = SREG; |
| 391 | cli(); | 388 | // cli(); |
| 392 | OCR3AH = (RGBLED_TIMER_TOP >> 8) & 0xff; | 389 | // OCR3AH = (RGBLED_TIMER_TOP >> 8) & 0xff; |
| 393 | OCR3AL = RGBLED_TIMER_TOP & 0xff; | 390 | // OCR3AL = RGBLED_TIMER_TOP & 0xff; |
| 394 | SREG = sreg; | 391 | // SREG = sreg; |
| 392 | |||
| 393 | rgblight_timer_enabled = true; | ||
| 395 | } | 394 | } |
| 396 | void rgblight_timer_enable(void) { | 395 | void rgblight_timer_enable(void) { |
| 397 | TIMSK3 |= _BV(OCIE3A); | 396 | rgblight_timer_enabled = true; |
| 398 | dprintf("TIMER3 enabled.\n"); | 397 | dprintf("TIMER3 enabled.\n"); |
| 399 | } | 398 | } |
| 400 | void rgblight_timer_disable(void) { | 399 | void rgblight_timer_disable(void) { |
| 401 | TIMSK3 &= ~_BV(OCIE3A); | 400 | rgblight_timer_enabled = false; |
| 402 | dprintf("TIMER3 disabled.\n"); | 401 | dprintf("TIMER3 disabled.\n"); |
| 403 | } | 402 | } |
| 404 | void rgblight_timer_toggle(void) { | 403 | void rgblight_timer_toggle(void) { |
| 405 | TIMSK3 ^= _BV(OCIE3A); | 404 | rgblight_timer_enabled ^= rgblight_timer_enabled; |
| 406 | dprintf("TIMER3 toggled.\n"); | 405 | dprintf("TIMER3 toggled.\n"); |
| 407 | } | 406 | } |
| 408 | 407 | ||
| 409 | ISR(TIMER3_COMPA_vect) { | 408 | void rgblight_task(void) { |
| 410 | // mode = 1, static light, do nothing here | 409 | if (rgblight_timer_enabled) { |
| 411 | if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { | 410 | // mode = 1, static light, do nothing here |
| 412 | // mode = 2 to 5, breathing mode | 411 | if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { |
| 413 | rgblight_effect_breathing(rgblight_config.mode - 2); | 412 | // mode = 2 to 5, breathing mode |
| 414 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 8) { | 413 | rgblight_effect_breathing(rgblight_config.mode - 2); |
| 415 | // mode = 6 to 8, rainbow mood mod | 414 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 8) { |
| 416 | rgblight_effect_rainbow_mood(rgblight_config.mode - 6); | 415 | // mode = 6 to 8, rainbow mood mod |
| 417 | } else if (rgblight_config.mode >= 9 && rgblight_config.mode <= 14) { | 416 | rgblight_effect_rainbow_mood(rgblight_config.mode - 6); |
| 418 | // mode = 9 to 14, rainbow swirl mode | 417 | } else if (rgblight_config.mode >= 9 && rgblight_config.mode <= 14) { |
| 419 | rgblight_effect_rainbow_swirl(rgblight_config.mode - 9); | 418 | // mode = 9 to 14, rainbow swirl mode |
| 420 | } else if (rgblight_config.mode >= 15 && rgblight_config.mode <= 20) { | 419 | rgblight_effect_rainbow_swirl(rgblight_config.mode - 9); |
| 421 | // mode = 15 to 20, snake mode | 420 | } else if (rgblight_config.mode >= 15 && rgblight_config.mode <= 20) { |
| 422 | rgblight_effect_snake(rgblight_config.mode - 15); | 421 | // mode = 15 to 20, snake mode |
| 423 | } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) { | 422 | rgblight_effect_snake(rgblight_config.mode - 15); |
| 424 | // mode = 21 to 23, knight mode | 423 | } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) { |
| 425 | rgblight_effect_knight(rgblight_config.mode - 21); | 424 | // mode = 21 to 23, knight mode |
| 425 | rgblight_effect_knight(rgblight_config.mode - 21); | ||
| 426 | } | ||
| 426 | } | 427 | } |
| 427 | } | 428 | } |
| 428 | 429 | ||
| @@ -461,7 +462,7 @@ void rgblight_effect_rainbow_swirl(uint8_t interval) { | |||
| 461 | last_timer = timer_read(); | 462 | last_timer = timer_read(); |
| 462 | for (i = 0; i < RGBLED_NUM; i++) { | 463 | for (i = 0; i < RGBLED_NUM; i++) { |
| 463 | hue = (360 / RGBLED_NUM * i + current_hue) % 360; | 464 | hue = (360 / RGBLED_NUM * i + current_hue) % 360; |
| 464 | sethsv(hue, rgblight_config.sat, rgblight_config.val, &led[i]); | 465 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); |
| 465 | } | 466 | } |
| 466 | rgblight_set(); | 467 | rgblight_set(); |
| 467 | 468 | ||
| @@ -498,7 +499,7 @@ void rgblight_effect_snake(uint8_t interval) { | |||
| 498 | k = k + RGBLED_NUM; | 499 | k = k + RGBLED_NUM; |
| 499 | } | 500 | } |
| 500 | if (i == k) { | 501 | if (i == k) { |
| 501 | sethsv(rgblight_config.hue, rgblight_config.sat, (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH), &led[i]); | 502 | sethsv(rgblight_config.hue, rgblight_config.sat, (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH), (LED_TYPE *)&led[i]); |
| 502 | } | 503 | } |
| 503 | } | 504 | } |
| 504 | } | 505 | } |
| @@ -518,7 +519,7 @@ void rgblight_effect_knight(uint8_t interval) { | |||
| 518 | static uint16_t last_timer = 0; | 519 | static uint16_t last_timer = 0; |
| 519 | uint8_t i, j, cur; | 520 | uint8_t i, j, cur; |
| 520 | int8_t k; | 521 | int8_t k; |
| 521 | struct cRGB preled[RGBLED_NUM]; | 522 | LED_TYPE preled[RGBLED_NUM]; |
| 522 | static int8_t increment = -1; | 523 | static int8_t increment = -1; |
| 523 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) { | 524 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) { |
| 524 | return; | 525 | return; |
| @@ -537,7 +538,7 @@ void rgblight_effect_knight(uint8_t interval) { | |||
| 537 | k = RGBLED_NUM - 1; | 538 | k = RGBLED_NUM - 1; |
| 538 | } | 539 | } |
| 539 | if (i == k) { | 540 | if (i == k) { |
| 540 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, &preled[i]); | 541 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&preled[i]); |
| 541 | } | 542 | } |
| 542 | } | 543 | } |
| 543 | } | 544 | } |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index efc685f31..d16ba24e5 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -1,8 +1,6 @@ | |||
| 1 | #ifndef RGBLIGHT_H | 1 | #ifndef RGBLIGHT_H |
| 2 | #define RGBLIGHT_H | 2 | #define RGBLIGHT_H |
| 3 | 3 | ||
| 4 | #define RGBW 1 | ||
| 5 | |||
| 6 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) | 4 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) |
| 7 | #define RGBLIGHT_MODES 23 | 5 | #define RGBLIGHT_MODES 23 |
| 8 | #else | 6 | #else |
| @@ -35,6 +33,7 @@ | |||
| 35 | #endif | 33 | #endif |
| 36 | 34 | ||
| 37 | #define RGBLED_TIMER_TOP F_CPU/(256*64) | 35 | #define RGBLED_TIMER_TOP F_CPU/(256*64) |
| 36 | // #define RGBLED_TIMER_TOP 0xFF10 | ||
| 38 | 37 | ||
| 39 | #include <stdint.h> | 38 | #include <stdint.h> |
| 40 | #include <stdbool.h> | 39 | #include <stdbool.h> |
| @@ -79,10 +78,13 @@ void eeconfig_update_rgblight(uint32_t val); | |||
| 79 | void eeconfig_update_rgblight_default(void); | 78 | void eeconfig_update_rgblight_default(void); |
| 80 | void eeconfig_debug_rgblight(void); | 79 | void eeconfig_debug_rgblight(void); |
| 81 | 80 | ||
| 82 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, struct cRGB *led1); | 81 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); |
| 83 | void setrgb(uint8_t r, uint8_t g, uint8_t b, struct cRGB *led1); | 82 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); |
| 84 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); | 83 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); |
| 85 | 84 | ||
| 85 | |||
| 86 | void rgblight_task(void); | ||
| 87 | |||
| 86 | void rgblight_timer_init(void); | 88 | void rgblight_timer_init(void); |
| 87 | void rgblight_timer_enable(void); | 89 | void rgblight_timer_enable(void); |
| 88 | void rgblight_timer_disable(void); | 90 | void rgblight_timer_disable(void); |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 01c0e45b0..fe466f604 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -71,6 +71,10 @@ | |||
| 71 | #include "virtser.h" | 71 | #include "virtser.h" |
| 72 | #endif | 72 | #endif |
| 73 | 73 | ||
| 74 | #ifdef RGB_MIDI | ||
| 75 | #include "rgblight.h" | ||
| 76 | #endif | ||
| 77 | |||
| 74 | uint8_t keyboard_idle = 0; | 78 | uint8_t keyboard_idle = 0; |
| 75 | /* 0: Boot Protocol, 1: Report Protocol(default) */ | 79 | /* 0: Boot Protocol, 1: Report Protocol(default) */ |
| 76 | uint8_t keyboard_protocol = 1; | 80 | uint8_t keyboard_protocol = 1; |
| @@ -1045,6 +1049,10 @@ int main(void) | |||
| 1045 | #endif | 1049 | #endif |
| 1046 | keyboard_task(); | 1050 | keyboard_task(); |
| 1047 | 1051 | ||
| 1052 | #ifdef RGBLIGHT_ENABLE | ||
| 1053 | rgblight_task(); | ||
| 1054 | #endif | ||
| 1055 | |||
| 1048 | #ifdef VIRTSER_ENABLE | 1056 | #ifdef VIRTSER_ENABLE |
| 1049 | virtser_task(); | 1057 | virtser_task(); |
| 1050 | CDC_Device_USBTask(&cdc_device); | 1058 | CDC_Device_USBTask(&cdc_device); |
| @@ -1077,15 +1085,34 @@ void fallthrough_callback(MidiDevice * device, | |||
| 1077 | #endif | 1085 | #endif |
| 1078 | } | 1086 | } |
| 1079 | 1087 | ||
| 1088 | #ifdef RGB_MIDI | ||
| 1089 | rgblight_config_t rgblight_config; | ||
| 1090 | #endif | ||
| 1091 | |||
| 1080 | void cc_callback(MidiDevice * device, | 1092 | void cc_callback(MidiDevice * device, |
| 1081 | uint8_t chan, uint8_t num, uint8_t val) { | 1093 | uint8_t chan, uint8_t num, uint8_t val) { |
| 1082 | //sending it back on the next channel | 1094 | //sending it back on the next channel |
| 1083 | midi_send_cc(device, (chan + 1) % 16, num, val); | 1095 | // midi_send_cc(device, (chan + 1) % 16, num, val); |
| 1096 | #ifdef RGB_MIDI | ||
| 1097 | rgblight_config.raw = eeconfig_read_rgblight(); | ||
| 1098 | switch (num) { | ||
| 1099 | case 14: | ||
| 1100 | rgblight_config.hue = val * 360 / 127; | ||
| 1101 | break; | ||
| 1102 | case 15: | ||
| 1103 | rgblight_config.sat = val << 1; | ||
| 1104 | break; | ||
| 1105 | case 16: | ||
| 1106 | rgblight_config.val = val << 1; | ||
| 1107 | break; | ||
| 1108 | } | ||
| 1109 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | ||
| 1110 | #endif | ||
| 1084 | } | 1111 | } |
| 1085 | 1112 | ||
| 1086 | void sysex_callback(MidiDevice * device, | 1113 | void sysex_callback(MidiDevice * device, |
| 1087 | uint16_t start, uint8_t length, uint8_t * data) { | 1114 | uint16_t start, uint8_t length, uint8_t * data) { |
| 1088 | for (int i = 0; i < length; i++) | 1115 | // for (int i = 0; i < length; i++) |
| 1089 | midi_send_cc(device, 15, 0x7F & data[i], 0x7F & (start + i)); | 1116 | // midi_send_cc(device, 15, 0x7F & data[i], 0x7F & (start + i)); |
| 1090 | } | 1117 | } |
| 1091 | #endif | 1118 | #endif |
