diff options
Diffstat (limited to 'keyboards/mechlovin/delphine/rgb_led/rgb_led.c')
| -rw-r--r-- | keyboards/mechlovin/delphine/rgb_led/rgb_led.c | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/keyboards/mechlovin/delphine/rgb_led/rgb_led.c b/keyboards/mechlovin/delphine/rgb_led/rgb_led.c new file mode 100644 index 000000000..6f3e3ec73 --- /dev/null +++ b/keyboards/mechlovin/delphine/rgb_led/rgb_led.c | |||
| @@ -0,0 +1,160 @@ | |||
| 1 | /* Copyright 2020 Team Mechlovin' | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "rgb_led.h" | ||
| 18 | |||
| 19 | |||
| 20 | #ifdef RGB_MATRIX_ENABLE | ||
| 21 | const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { | ||
| 22 | // left CA | ||
| 23 | {0, C5_2, C6_2, C7_2}, //D2-0 | ||
| 24 | {0, C1_1, C3_2, C4_2}, //D20-1 | ||
| 25 | {0, C5_1, C6_1, C7_1}, //D36-2 | ||
| 26 | {0, C2_1, C3_1, C4_1}, //D46-3 | ||
| 27 | {0, C5_4, C6_4, C7_4}, //D65-4 | ||
| 28 | {0, C1_3, C2_3, C3_3}, //D26-5 | ||
| 29 | {0, C5_3, C6_3, C7_3}, //D37-6 | ||
| 30 | {0, C1_2, C2_2, C4_3}, //D47-7 | ||
| 31 | {0, C4_5, C5_5, C7_6}, //D11-8 | ||
| 32 | {0, C1_5, C2_5, C3_5}, //D27-9 | ||
| 33 | {0, C4_4, C6_5, C7_5}, //D38-10 | ||
| 34 | {0, C1_4, C2_4, C3_4}, //D48-11 | ||
| 35 | |||
| 36 | // left CB | ||
| 37 | {0, C2_9, C3_9, C4_9}, //D17-12 | ||
| 38 | {0, C5_9, C6_9, C7_9}, //D28-13 | ||
| 39 | {0, C1_9, C3_10, C4_10}, //D39-14 | ||
| 40 | {0, C5_10, C6_10, C7_10}, //D49-15 | ||
| 41 | {0, C1_10, C2_10, C4_11}, //D18-16 | ||
| 42 | {0, C5_11, C6_11, C7_11}, //D29-17 | ||
| 43 | {0, C1_11, C2_11, C3_11}, //D40-18 | ||
| 44 | {0, C5_12, C6_12, C7_12}, //D50-19 | ||
| 45 | {0, C1_12, C2_12, C3_12}, //D19-20 | ||
| 46 | {0, C1_13, C2_13, C3_13}, //D61-21 | ||
| 47 | {0, C4_13, C5_13, C7_14}, //D35-22 | ||
| 48 | {0, C1_14, C2_14, C3_14}, //D41-23 | ||
| 49 | {0, C4_14, C5_14, C6_14}, //D51-24 | ||
| 50 | }; | ||
| 51 | |||
| 52 | led_config_t g_led_config = { { | ||
| 53 | // Key Matrix to LED Index | ||
| 54 | {0, 1, 2, 3}, | ||
| 55 | {4, 5, 6, 7}, | ||
| 56 | {8, 9, 10, 11}, | ||
| 57 | {12, 13, 14, 15}, | ||
| 58 | {16, 17, 18, 19}, | ||
| 59 | {20, 22, 23, 24} | ||
| 60 | }, | ||
| 61 | { | ||
| 62 | //LED Index to Physical Positon | ||
| 63 | { 0, 0}, { 75, 0}, {149, 0}, {224, 0}, | ||
| 64 | { 0, 13}, { 75, 13}, {149, 13}, {224, 13}, | ||
| 65 | { 0, 25}, { 75, 25}, {149, 25}, {224, 25}, | ||
| 66 | { 0, 38}, { 75, 38}, {149, 38}, {224, 38}, | ||
| 67 | { 0, 51}, { 75, 51}, {149, 51}, {224, 51}, | ||
| 68 | { 0, 64}, { 37, 64}, { 75, 64}, {149, 64}, {224, 64}, | ||
| 69 | }, { | ||
| 70 | 4, 4, 4, 4, | ||
| 71 | 4, 1, 1, 4, | ||
| 72 | 4, 1, 1, 4, | ||
| 73 | 4, 1, 1, 4, | ||
| 74 | 4, 1, 1, 4, | ||
| 75 | 4, 0, 1, 1, 4, | ||
| 76 | } }; | ||
| 77 | |||
| 78 | void rgb_matrix_indicators_kb(void) { | ||
| 79 | if (host_keyboard_led_state().num_lock) { | ||
| 80 | rgb_matrix_set_color(4, 255, 255, 255); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | __attribute__((weak)) | ||
| 85 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
| 86 | // if on layer 1, turn on L1 LED, otherwise off. | ||
| 87 | if (get_highest_layer(state) == 0) { | ||
| 88 | rgb_matrix_set_color(1, 255, 0, 0); | ||
| 89 | } else { | ||
| 90 | rgb_matrix_set_color(1, 0, 0, 0); | ||
| 91 | } | ||
| 92 | // if on layer 2, turn on L2 LED, otherwise off. | ||
| 93 | if (get_highest_layer(state) == 1) { | ||
| 94 | rgb_matrix_set_color(0, 255, 0, 0); | ||
| 95 | } else { | ||
| 96 | rgb_matrix_set_color(0, 0, 0, 0); | ||
| 97 | } | ||
| 98 | |||
| 99 | // if on layer 3, turn on L3 LED, otherwise off. | ||
| 100 | if (get_highest_layer(state) == 2) { | ||
| 101 | rgb_matrix_set_color(3, 255, 0, 0); | ||
| 102 | } else { | ||
| 103 | rgb_matrix_set_color(3, 0, 0, 0); | ||
| 104 | } | ||
| 105 | |||
| 106 | // if on layer 4, turn on L4 LED, otherwise off. | ||
| 107 | if (get_highest_layer(state) == 3) { | ||
| 108 | rgb_matrix_set_color(2, 255, 0, 0); | ||
| 109 | } else { | ||
| 110 | rgb_matrix_set_color(2, 0, 0, 0); | ||
| 111 | } | ||
| 112 | |||
| 113 | return state; | ||
| 114 | } | ||
| 115 | |||
| 116 | #endif | ||
| 117 | |||
| 118 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 119 | if (!process_record_user(keycode, record)) { return false; } | ||
| 120 | |||
| 121 | if (record->event.pressed) { | ||
| 122 | switch(keycode) { | ||
| 123 | #ifdef RGB_MATRIX_ENABLE | ||
| 124 | case KC_F13: // toggle rgb matrix | ||
| 125 | rgb_matrix_toggle(); | ||
| 126 | return false; | ||
| 127 | case KC_F14: | ||
| 128 | rgb_matrix_step(); | ||
| 129 | return false; | ||
| 130 | case KC_F15: | ||
| 131 | rgb_matrix_increase_speed(); | ||
| 132 | return false; | ||
| 133 | case KC_F16: | ||
| 134 | rgb_matrix_decrease_speed(); | ||
| 135 | return false; | ||
| 136 | case KC_F17: | ||
| 137 | rgb_matrix_increase_hue(); | ||
| 138 | return false; | ||
| 139 | case KC_F18: | ||
| 140 | rgb_matrix_decrease_hue(); | ||
| 141 | return false; | ||
| 142 | case KC_F19: | ||
| 143 | rgb_matrix_increase_sat(); | ||
| 144 | return false; | ||
| 145 | case KC_F20: | ||
| 146 | rgb_matrix_decrease_sat(); | ||
| 147 | return false; | ||
| 148 | case KC_F21: | ||
| 149 | rgb_matrix_increase_val(); | ||
| 150 | return false; | ||
| 151 | case KC_F22: | ||
| 152 | rgb_matrix_decrease_val(); | ||
| 153 | return false; | ||
| 154 | #endif | ||
| 155 | default: | ||
| 156 | break; | ||
| 157 | } | ||
| 158 | } | ||
| 159 | return true; | ||
| 160 | } | ||
