diff options
Diffstat (limited to 'keyboards/zeal60/rgb_backlight.c')
| -rw-r--r-- | keyboards/zeal60/rgb_backlight.c | 122 |
1 files changed, 87 insertions, 35 deletions
diff --git a/keyboards/zeal60/rgb_backlight.c b/keyboards/zeal60/rgb_backlight.c index ce8b1cb17..c3dade123 100644 --- a/keyboards/zeal60/rgb_backlight.c +++ b/keyboards/zeal60/rgb_backlight.c | |||
| @@ -15,12 +15,12 @@ | |||
| 15 | */ | 15 | */ |
| 16 | #if RGB_BACKLIGHT_ENABLED | 16 | #if RGB_BACKLIGHT_ENABLED |
| 17 | 17 | ||
| 18 | #if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_ZEAL65) || defined (RGB_BACKLIGHT_M60_A) | 18 | #if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_ZEAL65) || defined (RGB_BACKLIGHT_M60_A) || defined(RGB_BACKLIGHT_M6_B) |
| 19 | #else | 19 | #else |
| 20 | #error None of the following was defined: RGB_BACKLIGHT_ZEAL60, RGB_BACKLIGHT_ZEAL65, RGB_BACKLIGHT_M60_A | 20 | #error None of the following was defined: RGB_BACKLIGHT_ZEAL60, RGB_BACKLIGHT_ZEAL65, RGB_BACKLIGHT_M60_A, RGB_BACKLIGHT_M6_B |
| 21 | #endif | 21 | #endif |
| 22 | 22 | ||
| 23 | #include "zeal60.h" | 23 | #include "quantum.h" |
| 24 | #include "rgb_backlight.h" | 24 | #include "rgb_backlight.h" |
| 25 | #include "rgb_backlight_api.h" | 25 | #include "rgb_backlight_api.h" |
| 26 | #include "rgb_backlight_keycodes.h" | 26 | #include "rgb_backlight_keycodes.h" |
| @@ -32,7 +32,14 @@ | |||
| 32 | 32 | ||
| 33 | #include "quantum/color.h" | 33 | #include "quantum/color.h" |
| 34 | #include "drivers/avr/i2c_master.h" | 34 | #include "drivers/avr/i2c_master.h" |
| 35 | |||
| 36 | #if defined (RGB_BACKLIGHT_M6_B) | ||
| 37 | #include "drivers/issi/is31fl3218.h" | ||
| 38 | #define BACKLIGHT_LED_COUNT 6 | ||
| 39 | #else | ||
| 35 | #include "drivers/issi/is31fl3731.h" | 40 | #include "drivers/issi/is31fl3731.h" |
| 41 | #define BACKLIGHT_LED_COUNT 72 | ||
| 42 | #endif | ||
| 36 | 43 | ||
| 37 | #define BACKLIGHT_EFFECT_MAX 10 | 44 | #define BACKLIGHT_EFFECT_MAX 10 |
| 38 | 45 | ||
| @@ -69,11 +76,12 @@ uint8_t g_indicator_state = 0; | |||
| 69 | uint32_t g_tick = 0; | 76 | uint32_t g_tick = 0; |
| 70 | 77 | ||
| 71 | // Ticks since this key was last hit. | 78 | // Ticks since this key was last hit. |
| 72 | uint8_t g_key_hit[72]; | 79 | uint8_t g_key_hit[BACKLIGHT_LED_COUNT]; |
| 73 | 80 | ||
| 74 | // Ticks since any key was last hit. | 81 | // Ticks since any key was last hit. |
| 75 | uint32_t g_any_key_hit = 0; | 82 | uint32_t g_any_key_hit = 0; |
| 76 | 83 | ||
| 84 | #if !defined(RGB_BACKLIGHT_M6_B) | ||
| 77 | // This is a 7-bit address, that gets left-shifted and bit 0 | 85 | // This is a 7-bit address, that gets left-shifted and bit 0 |
| 78 | // set to 0 for write, 1 for read (as per I2C protocol) | 86 | // set to 0 for write, 1 for read (as per I2C protocol) |
| 79 | #define ISSI_ADDR_1 0x74 | 87 | #define ISSI_ADDR_1 0x74 |
| @@ -162,7 +170,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { | |||
| 162 | {1, C9_16, C7_15, C6_15}, // LD16 | 170 | {1, C9_16, C7_15, C6_15}, // LD16 |
| 163 | {1, C8_16, C7_16, C6_16}, // LD17 | 171 | {1, C8_16, C7_16, C6_16}, // LD17 |
| 164 | }; | 172 | }; |
| 165 | 173 | #endif // !defined(RGB_BACKLIGHT_M6_B) | |
| 166 | 174 | ||
| 167 | 175 | ||
| 168 | typedef struct Point { | 176 | typedef struct Point { |
| @@ -175,7 +183,7 @@ typedef struct Point { | |||
| 175 | // point values in range x=0..224 y=0..64 | 183 | // point values in range x=0..224 y=0..64 |
| 176 | // origin is center of top-left key (i.e Esc) | 184 | // origin is center of top-left key (i.e Esc) |
| 177 | #if defined (RGB_BACKLIGHT_ZEAL65) | 185 | #if defined (RGB_BACKLIGHT_ZEAL65) |
| 178 | const Point g_map_led_to_point[72] PROGMEM = { | 186 | const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = { |
| 179 | // LA0..LA17 | 187 | // LA0..LA17 |
| 180 | {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32}, | 188 | {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32}, |
| 181 | {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0}, | 189 | {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0}, |
| @@ -189,7 +197,7 @@ const Point g_map_led_to_point[72] PROGMEM = { | |||
| 189 | {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {202,48}, {224,48}, | 197 | {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {202,48}, {224,48}, |
| 190 | {116,48}, {132,48}, {148,48}, {164,48}, {255,255}, {144,60}, {164,64}, {188,64}, {208,64} | 198 | {116,48}, {132,48}, {148,48}, {164,48}, {255,255}, {144,60}, {164,64}, {188,64}, {208,64} |
| 191 | }; | 199 | }; |
| 192 | const Point g_map_led_to_point_polar[72] PROGMEM = { | 200 | const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = { |
| 193 | // LA0..LA17 | 201 | // LA0..LA17 |
| 194 | {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,247}, | 202 | {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,247}, |
| 195 | {61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255}, | 203 | {61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255}, |
| @@ -204,7 +212,7 @@ const Point g_map_led_to_point_polar[72] PROGMEM = { | |||
| 204 | {189,128}, {200,131}, {210,141}, {218,159}, {201,228}, {201,228}, {206,255}, {213,255}, {218,255} | 212 | {189,128}, {200,131}, {210,141}, {218,159}, {201,228}, {201,228}, {206,255}, {213,255}, {218,255} |
| 205 | }; | 213 | }; |
| 206 | #elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) | 214 | #elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) |
| 207 | const Point g_map_led_to_point[72] PROGMEM = { | 215 | const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = { |
| 208 | // LA0..LA17 | 216 | // LA0..LA17 |
| 209 | {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32}, | 217 | {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32}, |
| 210 | {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0}, | 218 | {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0}, |
| @@ -218,7 +226,7 @@ const Point g_map_led_to_point[72] PROGMEM = { | |||
| 218 | {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {210,48}, {224,48}, | 226 | {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {210,48}, {224,48}, |
| 219 | {116,48}, {132,48}, {148,48}, {164,48}, {144,64}, {161,64}, {181,64}, {201,64}, {221,64} | 227 | {116,48}, {132,48}, {148,48}, {164,48}, {144,64}, {161,64}, {181,64}, {201,64}, {221,64} |
| 220 | }; | 228 | }; |
| 221 | const Point g_map_led_to_point_polar[72] PROGMEM = { | 229 | const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = { |
| 222 | // LA0..LA17 | 230 | // LA0..LA17 |
| 223 | {58,129}, {70,129}, {80,139}, {89,157}, {96,181}, {101,208}, {105,238}, {109,255}, {128,247}, {58,255}, | 231 | {58,129}, {70,129}, {80,139}, {89,157}, {96,181}, {101,208}, {105,238}, {109,255}, {128,247}, {58,255}, |
| 224 | {64,255}, {70,255}, {75,255}, {80,255}, {85,255}, {89,255}, {93,255}, {96,255}, | 232 | {64,255}, {70,255}, {75,255}, {80,255}, {85,255}, {89,255}, {93,255}, {96,255}, |
| @@ -232,6 +240,16 @@ const Point g_map_led_to_point_polar[72] PROGMEM = { | |||
| 232 | {0,27}, {0,64}, {0,101}, {0,137}, {0,174}, {255,233}, {228,201}, {235,255}, {237,255}, | 240 | {0,27}, {0,64}, {0,101}, {0,137}, {0,174}, {255,233}, {228,201}, {235,255}, {237,255}, |
| 233 | {195,128}, {206,136}, {215,152}, {222,175}, {205,234}, {209,255}, {214,255}, {219,255}, {223,255} | 241 | {195,128}, {206,136}, {215,152}, {222,175}, {205,234}, {209,255}, {214,255}, {219,255}, {223,255} |
| 234 | }; | 242 | }; |
| 243 | #elif defined (RGB_BACKLIGHT_M6_B) | ||
| 244 | // M6-B is really simple: | ||
| 245 | // 0 3 5 | ||
| 246 | // 1 2 4 | ||
| 247 | const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = { | ||
| 248 | {0,0}, {0,16}, {16,16}, {16,0}, {32,16}, {32,0} | ||
| 249 | }; | ||
| 250 | const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = { | ||
| 251 | {0,0}, {0,16}, {16,16}, {16,0}, {32,16}, {32,0} | ||
| 252 | }; | ||
| 235 | #endif | 253 | #endif |
| 236 | 254 | ||
| 237 | // This may seem counter-intuitive, but it's quite flexible. | 255 | // This may seem counter-intuitive, but it's quite flexible. |
| @@ -245,16 +263,30 @@ void map_led_to_point( uint8_t index, Point *point ) | |||
| 245 | point->x = pgm_read_byte(addr); | 263 | point->x = pgm_read_byte(addr); |
| 246 | point->y = pgm_read_byte(addr+1); | 264 | point->y = pgm_read_byte(addr+1); |
| 247 | 265 | ||
| 266 | #if defined (RGB_BACKLIGHT_M6_B) | ||
| 267 | return; | ||
| 268 | #endif | ||
| 269 | |||
| 248 | switch (index) | 270 | switch (index) |
| 249 | { | 271 | { |
| 250 | case 18+4: // LB4A | 272 | case 18+4: // LB4A |
| 251 | if ( g_config.use_split_backspace ) | 273 | if ( g_config.use_split_backspace ) |
| 252 | point->x -= 8; | 274 | point->x -= 8; |
| 253 | break; | 275 | break; |
| 276 | #if defined (RGB_BACKLIGHT_ZEAL60) | ||
| 254 | case 18+14: // LB14A | 277 | case 18+14: // LB14A |
| 255 | if ( g_config.use_iso_enter ) | 278 | if ( g_config.use_iso_enter ) |
| 256 | point->y += 8; // extremely pedantic | 279 | point->y += 8; // extremely pedantic |
| 257 | break; | 280 | break; |
| 281 | case 54+5: // LD5A | ||
| 282 | if ( !g_config.use_iso_enter ) | ||
| 283 | point->x -= 10; | ||
| 284 | break; | ||
| 285 | case 36+16: // LC16A | ||
| 286 | if ( !g_config.use_split_left_shift ) | ||
| 287 | point->x += 8; | ||
| 288 | break; | ||
| 289 | #endif | ||
| 258 | #if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) | 290 | #if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) |
| 259 | case 36+0: // LC0A | 291 | case 36+0: // LC0A |
| 260 | if ( g_config.use_7u_spacebar ) | 292 | if ( g_config.use_7u_spacebar ) |
| @@ -264,19 +296,11 @@ void map_led_to_point( uint8_t index, Point *point ) | |||
| 264 | if ( g_config.use_7u_spacebar ) | 296 | if ( g_config.use_7u_spacebar ) |
| 265 | point->x += 4; | 297 | point->x += 4; |
| 266 | break; | 298 | break; |
| 267 | #endif | ||
| 268 | case 36+16: // LC16A | ||
| 269 | if ( !g_config.use_split_left_shift ) | ||
| 270 | point->x += 8; | ||
| 271 | break; | ||
| 272 | case 54+5: // LD5A | ||
| 273 | if ( !g_config.use_iso_enter ) | ||
| 274 | point->x -= 10; | ||
| 275 | break; | ||
| 276 | case 54+7: // LD7A | 299 | case 54+7: // LD7A |
| 277 | if ( !g_config.use_split_right_shift ) | 300 | if ( !g_config.use_split_right_shift ) |
| 278 | point->x -= 8; | 301 | point->x -= 8; |
| 279 | break; | 302 | break; |
| 303 | #endif | ||
| 280 | } | 304 | } |
| 281 | } | 305 | } |
| 282 | 306 | ||
| @@ -325,6 +349,13 @@ const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = { | |||
| 325 | { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8 }, | 349 | { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8 }, |
| 326 | { 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 54+13, 54+14, 54+15, 54+16, 54+17 } | 350 | { 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 54+13, 54+14, 54+15, 54+16, 54+17 } |
| 327 | }; | 351 | }; |
| 352 | #elif defined (RGB_BACKLIGHT_M6_B) | ||
| 353 | // M6-B is really simple: | ||
| 354 | // 0 3 5 | ||
| 355 | // 1 2 4 | ||
| 356 | const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = { | ||
| 357 | { 0, 3, 5, 1, 2, 4 } | ||
| 358 | }; | ||
| 328 | #endif | 359 | #endif |
| 329 | 360 | ||
| 330 | void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led ) | 361 | void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led ) |
| @@ -338,18 +369,30 @@ void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led ) | |||
| 338 | 369 | ||
| 339 | void backlight_update_pwm_buffers(void) | 370 | void backlight_update_pwm_buffers(void) |
| 340 | { | 371 | { |
| 372 | #if defined (RGB_BACKLIGHT_M6_B) | ||
| 373 | IS31FL3218_update_pwm_buffers(); | ||
| 374 | #else | ||
| 341 | IS31FL3731_update_pwm_buffers( ISSI_ADDR_1, ISSI_ADDR_2 ); | 375 | IS31FL3731_update_pwm_buffers( ISSI_ADDR_1, ISSI_ADDR_2 ); |
| 342 | IS31FL3731_update_led_control_registers( ISSI_ADDR_1, ISSI_ADDR_2 ); | 376 | IS31FL3731_update_led_control_registers( ISSI_ADDR_1, ISSI_ADDR_2 ); |
| 377 | #endif | ||
| 343 | } | 378 | } |
| 344 | 379 | ||
| 345 | void backlight_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) | 380 | void backlight_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) |
| 346 | { | 381 | { |
| 382 | #if defined (RGB_BACKLIGHT_M6_B) | ||
| 383 | IS31FL3218_set_color( index, red, green, blue ); | ||
| 384 | #else | ||
| 347 | IS31FL3731_set_color( index, red, green, blue ); | 385 | IS31FL3731_set_color( index, red, green, blue ); |
| 386 | #endif | ||
| 348 | } | 387 | } |
| 349 | 388 | ||
| 350 | void backlight_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) | 389 | void backlight_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) |
| 351 | { | 390 | { |
| 391 | #if defined (RGB_BACKLIGHT_M6_B) | ||
| 392 | IS31FL3218_set_color_all( red, green, blue ); | ||
| 393 | #else | ||
| 352 | IS31FL3731_set_color_all( red, green, blue ); | 394 | IS31FL3731_set_color_all( red, green, blue ); |
| 395 | #endif | ||
| 353 | } | 396 | } |
| 354 | 397 | ||
| 355 | void backlight_set_key_hit(uint8_t row, uint8_t column) | 398 | void backlight_set_key_hit(uint8_t row, uint8_t column) |
| @@ -436,6 +479,7 @@ void backlight_effect_rgb_test(void) | |||
| 436 | } | 479 | } |
| 437 | } | 480 | } |
| 438 | 481 | ||
| 482 | #if defined(RGB_DEBUGGING_ONLY) | ||
| 439 | // This tests the LEDs | 483 | // This tests the LEDs |
| 440 | // Note that it will change the LED control registers | 484 | // Note that it will change the LED control registers |
| 441 | // in the LED drivers, and leave them in an invalid | 485 | // in the LED drivers, and leave them in an invalid |
| @@ -475,6 +519,7 @@ void backlight_effect_single_LED_test(void) | |||
| 475 | backlight_set_color_all( 255, 255, 255 ); | 519 | backlight_set_color_all( 255, 255, 255 ); |
| 476 | backlight_test_led( led, color==0, color==1, color==2 ); | 520 | backlight_test_led( led, color==0, color==1, color==2 ); |
| 477 | } | 521 | } |
| 522 | #endif // defined(RGB_DEBUGGING_ONLY) | ||
| 478 | 523 | ||
| 479 | // All LEDs off | 524 | // All LEDs off |
| 480 | void backlight_effect_all_off(void) | 525 | void backlight_effect_all_off(void) |
| @@ -502,7 +547,7 @@ void backlight_effect_alphas_mods(void) | |||
| 502 | { | 547 | { |
| 503 | uint8_t index; | 548 | uint8_t index; |
| 504 | map_row_column_to_led( row, column, &index ); | 549 | map_row_column_to_led( row, column, &index ); |
| 505 | if ( index < 72 ) | 550 | if ( index < BACKLIGHT_LED_COUNT ) |
| 506 | { | 551 | { |
| 507 | if ( ( g_config.alphas_mods[row] & (1<<column) ) == 0 ) | 552 | if ( ( g_config.alphas_mods[row] & (1<<column) ) == 0 ) |
| 508 | { | 553 | { |
| @@ -542,7 +587,7 @@ void backlight_effect_gradient_up_down(void) | |||
| 542 | HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; | 587 | HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; |
| 543 | RGB rgb; | 588 | RGB rgb; |
| 544 | Point point; | 589 | Point point; |
| 545 | for ( int i=0; i<72; i++ ) | 590 | for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) |
| 546 | { | 591 | { |
| 547 | map_led_to_point( i, &point ); | 592 | map_led_to_point( i, &point ); |
| 548 | // The y range will be 0..64, map this to 0..4 | 593 | // The y range will be 0..64, map this to 0..4 |
| @@ -580,9 +625,9 @@ void backlight_effect_raindrops(bool initialize) | |||
| 580 | RGB rgb; | 625 | RGB rgb; |
| 581 | 626 | ||
| 582 | // Change one LED every tick | 627 | // Change one LED every tick |
| 583 | uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % 72 : 255; | 628 | uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % BACKLIGHT_LED_COUNT : 255; |
| 584 | 629 | ||
| 585 | for ( int i=0; i<72; i++ ) | 630 | for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) |
| 586 | { | 631 | { |
| 587 | // If initialize, all get set to random colors | 632 | // If initialize, all get set to random colors |
| 588 | // If not, all but one will stay the same as before. | 633 | // If not, all but one will stay the same as before. |
| @@ -604,7 +649,7 @@ void backlight_effect_cycle_all(void) | |||
| 604 | uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF; | 649 | uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF; |
| 605 | 650 | ||
| 606 | // Relies on hue being 8-bit and wrapping | 651 | // Relies on hue being 8-bit and wrapping |
| 607 | for ( int i=0; i<72; i++ ) | 652 | for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) |
| 608 | { | 653 | { |
| 609 | uint16_t offset2 = g_key_hit[i]<<2; | 654 | uint16_t offset2 = g_key_hit[i]<<2; |
| 610 | // stabilizer LEDs use spacebar hits | 655 | // stabilizer LEDs use spacebar hits |
| @@ -627,7 +672,7 @@ void backlight_effect_cycle_left_right(void) | |||
| 627 | HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; | 672 | HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; |
| 628 | RGB rgb; | 673 | RGB rgb; |
| 629 | Point point; | 674 | Point point; |
| 630 | for ( int i=0; i<72; i++ ) | 675 | for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) |
| 631 | { | 676 | { |
| 632 | uint16_t offset2 = g_key_hit[i]<<2; | 677 | uint16_t offset2 = g_key_hit[i]<<2; |
| 633 | // stabilizer LEDs use spacebar hits | 678 | // stabilizer LEDs use spacebar hits |
| @@ -652,7 +697,7 @@ void backlight_effect_cycle_up_down(void) | |||
| 652 | HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; | 697 | HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; |
| 653 | RGB rgb; | 698 | RGB rgb; |
| 654 | Point point; | 699 | Point point; |
| 655 | for ( int i=0; i<72; i++ ) | 700 | for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) |
| 656 | { | 701 | { |
| 657 | uint16_t offset2 = g_key_hit[i]<<2; | 702 | uint16_t offset2 = g_key_hit[i]<<2; |
| 658 | // stabilizer LEDs use spacebar hits | 703 | // stabilizer LEDs use spacebar hits |
| @@ -677,9 +722,9 @@ void backlight_effect_jellybean_raindrops( bool initialize ) | |||
| 677 | RGB rgb; | 722 | RGB rgb; |
| 678 | 723 | ||
| 679 | // Change one LED every tick | 724 | // Change one LED every tick |
| 680 | uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % 72 : 255; | 725 | uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % BACKLIGHT_LED_COUNT : 255; |
| 681 | 726 | ||
| 682 | for ( int i=0; i<72; i++ ) | 727 | for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) |
| 683 | { | 728 | { |
| 684 | // If initialize, all get set to random colors | 729 | // If initialize, all get set to random colors |
| 685 | // If not, all but one will stay the same as before. | 730 | // If not, all but one will stay the same as before. |
| @@ -702,7 +747,7 @@ void backlight_effect_cycle_radial1(void) | |||
| 702 | HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; | 747 | HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; |
| 703 | RGB rgb; | 748 | RGB rgb; |
| 704 | Point point; | 749 | Point point; |
| 705 | for ( int i=0; i<72; i++ ) | 750 | for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) |
| 706 | { | 751 | { |
| 707 | map_led_to_point_polar( i, &point ); | 752 | map_led_to_point_polar( i, &point ); |
| 708 | // Relies on hue being 8-bit and wrapping | 753 | // Relies on hue being 8-bit and wrapping |
| @@ -720,7 +765,7 @@ void backlight_effect_cycle_radial2(void) | |||
| 720 | HSV hsv = { .h = 0, .s = g_config.color_1.s, .v = g_config.brightness }; | 765 | HSV hsv = { .h = 0, .s = g_config.color_1.s, .v = g_config.brightness }; |
| 721 | RGB rgb; | 766 | RGB rgb; |
| 722 | Point point; | 767 | Point point; |
| 723 | for ( int i=0; i<72; i++ ) | 768 | for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) |
| 724 | { | 769 | { |
| 725 | map_led_to_point_polar( i, &point ); | 770 | map_led_to_point_polar( i, &point ); |
| 726 | uint8_t offset2 = offset + point.x; | 771 | uint8_t offset2 = offset + point.x; |
| @@ -826,7 +871,7 @@ ISR(TIMER3_COMPA_vect) | |||
| 826 | g_any_key_hit++; | 871 | g_any_key_hit++; |
| 827 | } | 872 | } |
| 828 | 873 | ||
| 829 | for ( int led = 0; led < 72; led++ ) | 874 | for ( int led = 0; led < BACKLIGHT_LED_COUNT; led++ ) |
| 830 | { | 875 | { |
| 831 | if ( g_key_hit[led] < 255 ) | 876 | if ( g_key_hit[led] < 255 ) |
| 832 | { | 877 | { |
| @@ -899,7 +944,9 @@ ISR(TIMER3_COMPA_vect) | |||
| 899 | 944 | ||
| 900 | if ( ! suspend_backlight ) | 945 | if ( ! suspend_backlight ) |
| 901 | { | 946 | { |
| 947 | #if !defined(RGB_BACKLIGHT_M6_B) | ||
| 902 | backlight_effect_indicators(); | 948 | backlight_effect_indicators(); |
| 949 | #endif | ||
| 903 | } | 950 | } |
| 904 | } | 951 | } |
| 905 | 952 | ||
| @@ -1239,17 +1286,19 @@ void backlight_init_drivers(void) | |||
| 1239 | { | 1286 | { |
| 1240 | // Initialize I2C | 1287 | // Initialize I2C |
| 1241 | i2c_init(); | 1288 | i2c_init(); |
| 1289 | |||
| 1290 | #if defined(RGB_BACKLIGHT_M6_B) | ||
| 1291 | IS31FL3218_init(); | ||
| 1292 | #else | ||
| 1242 | IS31FL3731_init( ISSI_ADDR_1 ); | 1293 | IS31FL3731_init( ISSI_ADDR_1 ); |
| 1243 | IS31FL3731_init( ISSI_ADDR_2 ); | 1294 | IS31FL3731_init( ISSI_ADDR_2 ); |
| 1244 | 1295 | ||
| 1245 | for ( int index = 0; index < 72; index++ ) | 1296 | for ( int index = 0; index < BACKLIGHT_LED_COUNT; index++ ) |
| 1246 | { | 1297 | { |
| 1247 | // OR the possible "disabled" cases together, then NOT the result to get the enabled state | 1298 | // OR the possible "disabled" cases together, then NOT the result to get the enabled state |
| 1248 | // LC6 LD13 not present on Zeal65 | 1299 | // LC6 LD13 not present on Zeal65 |
| 1249 | #if defined (RGB_BACKLIGHT_ZEAL65) | 1300 | #if defined (RGB_BACKLIGHT_ZEAL65) |
| 1250 | bool enabled = !( ( index == 18+5 && !g_config.use_split_backspace ) || // LB5 | 1301 | bool enabled = !( ( index == 18+5 && !g_config.use_split_backspace ) || // LB5 |
| 1251 | ( index == 36+15 && !g_config.use_split_left_shift ) || // LC15 | ||
| 1252 | ( index == 54+8 && !g_config.use_split_right_shift ) || // LD8 | ||
| 1253 | ( index == 36+6 ) || // LC6 | 1302 | ( index == 36+6 ) || // LC6 |
| 1254 | ( index == 54+13 ) ); // LD13 | 1303 | ( index == 54+13 ) ); // LD13 |
| 1255 | #elif defined (RGB_BACKLIGHT_M60_A) | 1304 | #elif defined (RGB_BACKLIGHT_M60_A) |
| @@ -1286,11 +1335,12 @@ void backlight_init_drivers(void) | |||
| 1286 | } | 1335 | } |
| 1287 | // This actually updates the LED drivers | 1336 | // This actually updates the LED drivers |
| 1288 | IS31FL3731_update_led_control_registers( ISSI_ADDR_1, ISSI_ADDR_2 ); | 1337 | IS31FL3731_update_led_control_registers( ISSI_ADDR_1, ISSI_ADDR_2 ); |
| 1338 | #endif // !defined(RGB_BACKLIGHT_M6_B) | ||
| 1289 | 1339 | ||
| 1290 | // TODO: put the 1 second startup delay here? | 1340 | // TODO: put the 1 second startup delay here? |
| 1291 | 1341 | ||
| 1292 | // clear the key hits | 1342 | // clear the key hits |
| 1293 | for ( int led=0; led<72; led++ ) | 1343 | for ( int led=0; led<BACKLIGHT_LED_COUNT; led++ ) |
| 1294 | { | 1344 | { |
| 1295 | g_key_hit[led] = 255; | 1345 | g_key_hit[led] = 255; |
| 1296 | } | 1346 | } |
| @@ -1510,9 +1560,10 @@ void backlight_color_2_sat_decrease(void) | |||
| 1510 | backlight_config_save(); | 1560 | backlight_config_save(); |
| 1511 | } | 1561 | } |
| 1512 | 1562 | ||
| 1563 | #if defined(RGB_DEBUGGING_ONLY) | ||
| 1513 | void backlight_test_led( uint8_t index, bool red, bool green, bool blue ) | 1564 | void backlight_test_led( uint8_t index, bool red, bool green, bool blue ) |
| 1514 | { | 1565 | { |
| 1515 | for ( int i=0; i<72; i++ ) | 1566 | for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) |
| 1516 | { | 1567 | { |
| 1517 | if ( i == index ) | 1568 | if ( i == index ) |
| 1518 | { | 1569 | { |
| @@ -1524,6 +1575,7 @@ void backlight_test_led( uint8_t index, bool red, bool green, bool blue ) | |||
| 1524 | } | 1575 | } |
| 1525 | } | 1576 | } |
| 1526 | } | 1577 | } |
| 1578 | #endif // defined(RGB_DEBUGGING_ONLY) | ||
| 1527 | 1579 | ||
| 1528 | void backlight_debug_led( bool state ) | 1580 | void backlight_debug_led( bool state ) |
| 1529 | { | 1581 | { |
