aboutsummaryrefslogtreecommitdiff
path: root/keyboards/wilba_tech
diff options
context:
space:
mode:
authoryiancar <yiangosyiangou@cytanet.com.cy>2020-06-18 06:16:26 +0100
committerGitHub <noreply@github.com>2020-06-17 22:16:26 -0700
commit3e27ceee4220a56ec35d5567773cf9cda4b22842 (patch)
tree85759930eff8fbe4098d22b1e9328fb271307d46 /keyboards/wilba_tech
parent67f374029df96bec9f5adc26e23a7d7e1139a129 (diff)
downloadqmk_firmware-3e27ceee4220a56ec35d5567773cf9cda4b22842.tar.gz
qmk_firmware-3e27ceee4220a56ec35d5567773cf9cda4b22842.zip
[Keyboard] Nebula12 keyboard (#9397)
Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'keyboards/wilba_tech')
-rw-r--r--keyboards/wilba_tech/wt_rgb_backlight.c109
1 files changed, 100 insertions, 9 deletions
diff --git a/keyboards/wilba_tech/wt_rgb_backlight.c b/keyboards/wilba_tech/wt_rgb_backlight.c
index 221d924c4..e2506bf3f 100644
--- a/keyboards/wilba_tech/wt_rgb_backlight.c
+++ b/keyboards/wilba_tech/wt_rgb_backlight.c
@@ -21,6 +21,7 @@
21 defined(RGB_BACKLIGHT_KOYU) || \ 21 defined(RGB_BACKLIGHT_KOYU) || \
22 defined(RGB_BACKLIGHT_HS60) || \ 22 defined(RGB_BACKLIGHT_HS60) || \
23 defined(RGB_BACKLIGHT_NK65) || \ 23 defined(RGB_BACKLIGHT_NK65) || \
24 defined(RGB_BACKLIGHT_NEBULA12) || \
24 defined(RGB_BACKLIGHT_NEBULA65) || \ 25 defined(RGB_BACKLIGHT_NEBULA65) || \
25 defined(RGB_BACKLIGHT_U80_A) || \ 26 defined(RGB_BACKLIGHT_U80_A) || \
26 defined(RGB_BACKLIGHT_DAWN60) || \ 27 defined(RGB_BACKLIGHT_DAWN60) || \
@@ -44,7 +45,7 @@
44#include "wt_rgb_backlight_api.h" 45#include "wt_rgb_backlight_api.h"
45#include "wt_rgb_backlight_keycodes.h" 46#include "wt_rgb_backlight_keycodes.h"
46 47
47#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA65) 48#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA65) && !defined(RGB_BACKLIGHT_NEBULA12)
48#include <avr/interrupt.h> 49#include <avr/interrupt.h>
49#include "drivers/avr/i2c_master.h" 50#include "drivers/avr/i2c_master.h"
50#else 51#else
@@ -84,6 +85,8 @@ LED_TYPE g_ws2812_leds[WS2812_LED_TOTAL];
84#define BACKLIGHT_LED_COUNT 108 85#define BACKLIGHT_LED_COUNT 108
85#elif defined(RGB_BACKLIGHT_DAWN60) 86#elif defined(RGB_BACKLIGHT_DAWN60)
86#define BACKLIGHT_LED_COUNT 84 //64 + 20 87#define BACKLIGHT_LED_COUNT 84 //64 + 20
88#elif defined(RGB_BACKLIGHT_NEBULA12)
89#define BACKLIGHT_LED_COUNT 16
87#else 90#else
88#define BACKLIGHT_LED_COUNT 72 91#define BACKLIGHT_LED_COUNT 72
89#endif 92#endif
@@ -358,6 +361,36 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
358 {1, K_16, J_16, L_16}, //LB64 361 {1, K_16, J_16, L_16}, //LB64
359}; 362};
360 363
364#elif defined(RGB_BACKLIGHT_NEBULA12)
365// This is a 7-bit address, that gets left-shifted and bit 0
366// set to 0 for write, 1 for read (as per I2C protocol)
367#define ISSI_ADDR_1 0x74
368
369const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
370/* Refer to IS31 manual for these locations
371 * driver
372 * | R location
373 * | | G location
374 * | | | B location
375 * | | | | */
376 {0, C1_1, C3_2, C4_2}, //A1
377 {0, C1_2, C2_2, C4_3}, //A2
378 {0, C1_3, C2_3, C3_3}, //A3
379 {0, C1_4, C2_4, C3_4}, //A4
380 {0, C1_5, C2_5, C3_5}, //A5
381 {0, C1_6, C2_6, C3_6}, //A6
382 {0, C1_7, C2_7, C3_7}, //A7
383 {0, C1_8, C2_8, C3_8}, //A8
384 {0, C9_1, C8_1, C7_1}, //A9
385 {0, C9_2, C8_2, C7_2}, //A10
386 {0, C9_3, C8_3, C7_3}, //A11
387 {0, C9_4, C8_4, C7_4}, //A12
388 {0, C9_5, C8_5, C7_5}, //A13
389 {0, C9_6, C8_6, C7_6}, //A14
390 {0, C9_7, C8_7, C6_6}, //A15
391 {0, C9_8, C7_7, C6_7}, //A16
392};
393
361#elif defined(RGB_BACKLIGHT_U80_A) 394#elif defined(RGB_BACKLIGHT_U80_A)
362 395
363// U80-A prototype uses 3 ISSI drivers 396// U80-A prototype uses 3 ISSI drivers
@@ -928,6 +961,21 @@ const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
928 //LA62..LB5 961 //LA62..LB5
929 {221,255}, {225,255}, {229,255}, {22,255}, {12,255}, {244,255}, {234,255}, {255,255} 962 {221,255}, {225,255}, {229,255}, {22,255}, {12,255}, {244,255}, {234,255}, {255,255}
930}; 963};
964
965#elif defined(RGB_BACKLIGHT_NEBULA12)
966const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
967 // A1..A16
968 {0,0}, {16,0}, {32,0}, {0,16}, {16,16}, {32,16}, {0,32}, {16,32},
969 {255,255}, {255,255}, {255,255}, {255,255},
970 {32,48}, {16,48}, {0,48}, {32,32}
971};
972const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
973 // A1..A16
974 {72,197}, {64,194}, {56,197}, {85,74}, {64,64}, {43,74}, {171,74}, {192,64},
975 {255,255}, {255,255}, {255,255}, {255,255},
976 {200,196}, {192,192}, {184,196}, {213,74}
977};
978
931#elif defined(RGB_BACKLIGHT_NEBULA65) 979#elif defined(RGB_BACKLIGHT_NEBULA65)
932const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = { 980const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
933 // LA1..LA60 981 // LA1..LA60
@@ -951,6 +999,7 @@ const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
951 //LA62..LB5 999 //LA62..LB5
952 {207,255}, {213,255}, {218,255}, {35,255}, {21,255}, {19,255}, {224,255}, {32,255} 1000 {207,255}, {213,255}, {218,255}, {35,255}, {21,255}, {19,255}, {224,255}, {32,255}
953}; 1001};
1002
954#elif defined(RGB_BACKLIGHT_M6_B) 1003#elif defined(RGB_BACKLIGHT_M6_B)
955// M6-B is really simple: 1004// M6-B is really simple:
956// 0 3 5 1005// 0 3 5
@@ -1018,7 +1067,7 @@ void map_led_to_point( uint8_t index, Point *point )
1018 point->x = pgm_read_byte(addr); 1067 point->x = pgm_read_byte(addr);
1019 point->y = pgm_read_byte(addr+1); 1068 point->y = pgm_read_byte(addr+1);
1020 1069
1021#if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_HS60) || defined(RGB_BACKLIGHT_NK65) || defined(RGB_BACKLIGHT_NEBULA65) 1070#if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_HS60) || defined(RGB_BACKLIGHT_NK65) || defined(RGB_BACKLIGHT_NEBULA65) || defined(RGB_BACKLIGHT_NEBULA12)
1022 return; 1071 return;
1023#endif 1072#endif
1024 1073
@@ -1219,6 +1268,18 @@ const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
1219 { 4-1, 255, 8-1, 12-1, 16-1, 20-1, 24-1, 28-1, 32-1, 36-1, 40-1, 44-1, 51-1, 52-1, 3+64-1 }, 1268 { 4-1, 255, 8-1, 12-1, 16-1, 20-1, 24-1, 28-1, 32-1, 36-1, 40-1, 44-1, 51-1, 52-1, 3+64-1 },
1220 { 57-1, 58-1, 59-1, 255, 255, 255, 60-1, 255, 255, 48-1, 62-1, 63-1, 64-1, 56-1, 4+64-1 } 1269 { 57-1, 58-1, 59-1, 255, 255, 255, 60-1, 255, 255, 48-1, 62-1, 63-1, 64-1, 56-1, 4+64-1 }
1221}; 1270};
1271#elif defined(RGB_BACKLIGHT_NEBULA12)
1272//
1273// A1, A2, A3,
1274// A4, A5, A6,
1275// A7, A8, A16,
1276// A15, A14, A13,
1277const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
1278 { 1-1, 2-1, 3-1 },
1279 { 4-1, 5-1, 6-1 },
1280 { 7-1, 8-1, 16-1 },
1281 { 15-1, 14-1, 13-1 }
1282};
1222#elif defined(RGB_BACKLIGHT_M6_B) 1283#elif defined(RGB_BACKLIGHT_M6_B)
1223// M6-B is really simple: 1284// M6-B is really simple:
1224// 0 3 5 1285// 0 3 5
@@ -1263,6 +1324,9 @@ void backlight_update_pwm_buffers(void)
1263 IS31FL3733_update_pwm_buffers( ISSI_ADDR_2, 1 ); 1324 IS31FL3733_update_pwm_buffers( ISSI_ADDR_2, 1 );
1264 IS31FL3733_update_led_control_registers( ISSI_ADDR_1, 0 ); 1325 IS31FL3733_update_led_control_registers( ISSI_ADDR_1, 0 );
1265 IS31FL3733_update_led_control_registers( ISSI_ADDR_2, 1 ); 1326 IS31FL3733_update_led_control_registers( ISSI_ADDR_2, 1 );
1327#elif defined(RGB_BACKLIGHT_NEBULA12)
1328 IS31FL3731_update_pwm_buffers( ISSI_ADDR_1, 0 );
1329 IS31FL3731_update_led_control_registers( ISSI_ADDR_1, 0 );
1266#elif defined(RGB_BACKLIGHT_U80_A) 1330#elif defined(RGB_BACKLIGHT_U80_A)
1267 static uint8_t driver = 0; 1331 static uint8_t driver = 0;
1268 switch ( driver ) 1332 switch ( driver )
@@ -1340,7 +1404,7 @@ void backlight_set_key_hit(uint8_t row, uint8_t column)
1340 g_any_key_hit = 0; 1404 g_any_key_hit = 0;
1341} 1405}
1342 1406
1343#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA65) 1407#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA65) && !defined(RGB_BACKLIGHT_NEBULA12)
1344// This is (F_CPU/1024) / 20 Hz 1408// This is (F_CPU/1024) / 20 Hz
1345// = 15625 Hz / 20 Hz 1409// = 15625 Hz / 20 Hz
1346// = 781 1410// = 781
@@ -1376,6 +1440,28 @@ void backlight_timer_disable(void)
1376{ 1440{
1377 TIMSK3 &= ~_BV(OCIE3A); 1441 TIMSK3 &= ~_BV(OCIE3A);
1378} 1442}
1443#elif defined(RGB_BACKLIGHT_NEBULA12) //STM32, use GPT with TIM3. Enable in halconf.h
1444static void gpt_backlight_timer_task(GPTDriver *gptp);
1445// Timer setup at 200Khz, callback at 10k ticks = 20Hz
1446static GPTConfig gpt3cfg1 = {
1447 .frequency = 200000U,
1448 .callback = gpt_backlight_timer_task
1449};
1450
1451void backlight_timer_init(void)
1452{
1453 gptStart(&GPTD3, &gpt3cfg1);
1454}
1455
1456void backlight_timer_enable(void)
1457{
1458 gptStartContinuous(&GPTD3, 10000);
1459}
1460
1461void backlight_timer_disable(void)
1462{
1463 gptStopTimer(&GPTD3);
1464}
1379#else //STM32, use GPT with TIM4. Enable in halconf.h 1465#else //STM32, use GPT with TIM4. Enable in halconf.h
1380static void gpt_backlight_timer_task(GPTDriver *gptp); 1466static void gpt_backlight_timer_task(GPTDriver *gptp);
1381// Timer setup at 200Khz, callback at 10k ticks = 20Hz 1467// Timer setup at 200Khz, callback at 10k ticks = 20Hz
@@ -1398,7 +1484,7 @@ void backlight_timer_disable(void)
1398{ 1484{
1399 gptStopTimer(&GPTD4); 1485 gptStopTimer(&GPTD4);
1400} 1486}
1401#endif //!defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) 1487#endif //!defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA12)
1402 1488
1403void backlight_set_suspend_state(bool state) 1489void backlight_set_suspend_state(bool state)
1404{ 1490{
@@ -1635,7 +1721,7 @@ void backlight_effect_cycle_all(void)
1635 for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) 1721 for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
1636 { 1722 {
1637 uint16_t offset2 = g_key_hit[i]<<2; 1723 uint16_t offset2 = g_key_hit[i]<<2;
1638#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_DAWN60) && !defined(RGB_BACKLIGHT_NEBULA65) 1724#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_DAWN60) && !defined(RGB_BACKLIGHT_NEBULA65) && !defined(RGB_BACKLIGHT_NEBULA12)
1639 // stabilizer LEDs use spacebar hits 1725 // stabilizer LEDs use spacebar hits
1640 if ( i == 36+6 || i == 54+13 || // LC6, LD13 1726 if ( i == 36+6 || i == 54+13 || // LC6, LD13
1641 ( g_config.use_7u_spacebar && i == 54+14 ) ) // LD14 1727 ( g_config.use_7u_spacebar && i == 54+14 ) ) // LD14
@@ -1660,7 +1746,7 @@ void backlight_effect_cycle_left_right(void)
1660 for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) 1746 for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
1661 { 1747 {
1662 uint16_t offset2 = g_key_hit[i]<<2; 1748 uint16_t offset2 = g_key_hit[i]<<2;
1663#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_DAWN60) && !defined(RGB_BACKLIGHT_NEBULA65) 1749#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_DAWN60) && !defined(RGB_BACKLIGHT_NEBULA65) && !defined(RGB_BACKLIGHT_NEBULA12)
1664 // stabilizer LEDs use spacebar hits 1750 // stabilizer LEDs use spacebar hits
1665 if ( i == 36+6 || i == 54+13 || // LC6, LD13 1751 if ( i == 36+6 || i == 54+13 || // LC6, LD13
1666 ( g_config.use_7u_spacebar && i == 54+14 ) ) // LD14 1752 ( g_config.use_7u_spacebar && i == 54+14 ) ) // LD14
@@ -1687,7 +1773,7 @@ void backlight_effect_cycle_up_down(void)
1687 for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) 1773 for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
1688 { 1774 {
1689 uint16_t offset2 = g_key_hit[i]<<2; 1775 uint16_t offset2 = g_key_hit[i]<<2;
1690#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_DAWN60) && !defined(RGB_BACKLIGHT_NEBULA65) 1776#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_DAWN60) && !defined(RGB_BACKLIGHT_NEBULA65) && !defined(RGB_BACKLIGHT_NEBULA12)
1691 // stabilizer LEDs use spacebar hits 1777 // stabilizer LEDs use spacebar hits
1692 if ( i == 36+6 || i == 54+13 || // LC6, LD13 1778 if ( i == 36+6 || i == 54+13 || // LC6, LD13
1693 ( g_config.use_7u_spacebar && i == 54+14 ) ) // LD14 1779 ( g_config.use_7u_spacebar && i == 54+14 ) ) // LD14
@@ -1861,7 +1947,7 @@ void backlight_effect_indicators(void)
1861 } 1947 }
1862} 1948}
1863 1949
1864#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA65) 1950#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA65) && !defined(RGB_BACKLIGHT_NEBULA12)
1865ISR(TIMER3_COMPA_vect) 1951ISR(TIMER3_COMPA_vect)
1866#else //STM32 interrupt 1952#else //STM32 interrupt
1867static void gpt_backlight_timer_task(GPTDriver *gptp) 1953static void gpt_backlight_timer_task(GPTDriver *gptp)
@@ -2374,8 +2460,9 @@ void backlight_init_drivers(void)
2374 IS31FL3733_update_led_control_registers( ISSI_ADDR_2, 1 ); 2460 IS31FL3733_update_led_control_registers( ISSI_ADDR_2, 1 );
2375#else 2461#else
2376 IS31FL3731_init( ISSI_ADDR_1 ); 2462 IS31FL3731_init( ISSI_ADDR_1 );
2463#if !defined(RGB_BACKLIGHT_NEBULA12)
2377 IS31FL3731_init( ISSI_ADDR_2 ); 2464 IS31FL3731_init( ISSI_ADDR_2 );
2378 2465#endif
2379#if defined(RGB_BACKLIGHT_U80_A) 2466#if defined(RGB_BACKLIGHT_U80_A)
2380 IS31FL3731_init( ISSI_ADDR_3 ); 2467 IS31FL3731_init( ISSI_ADDR_3 );
2381#endif 2468#endif
@@ -2461,13 +2548,17 @@ void backlight_init_drivers(void)
2461 bool enabled = !( ( index == 15+7 && !g_config.use_split_backspace ) || //other backspace 2548 bool enabled = !( ( index == 15+7 && !g_config.use_split_backspace ) || //other backspace
2462 ( index == 47+13 && g_config.use_7u_spacebar ) || //LD13 2549 ( index == 47+13 && g_config.use_7u_spacebar ) || //LD13
2463 ( index == 47+15 && g_config.use_7u_spacebar ) ); //LD15 2550 ( index == 47+15 && g_config.use_7u_spacebar ) ); //LD15
2551#elif defined(RGB_BACKLIGHT_NEBULA12)
2552 bool enabled = !( ( index >= 9-1 && index <= 12-1 ) ); // A9-A12
2464#endif 2553#endif
2465 // This only caches it for later 2554 // This only caches it for later
2466 IS31FL3731_set_led_control_register( index, enabled, enabled, enabled ); 2555 IS31FL3731_set_led_control_register( index, enabled, enabled, enabled );
2467 } 2556 }
2468 // This actually updates the LED drivers 2557 // This actually updates the LED drivers
2469 IS31FL3731_update_led_control_registers( ISSI_ADDR_1, 0 ); 2558 IS31FL3731_update_led_control_registers( ISSI_ADDR_1, 0 );
2559#if !defined(RGB_BACKLIGHT_NEBULA12)
2470 IS31FL3731_update_led_control_registers( ISSI_ADDR_2, 1 ); 2560 IS31FL3731_update_led_control_registers( ISSI_ADDR_2, 1 );
2561#endif
2471#if defined(RGB_BACKLIGHT_U80_A) 2562#if defined(RGB_BACKLIGHT_U80_A)
2472 IS31FL3731_update_led_control_registers( ISSI_ADDR_3, 2 ); 2563 IS31FL3731_update_led_control_registers( ISSI_ADDR_3, 2 );
2473#endif 2564#endif