qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

rev2.c (6236B)


      1 /* Copyright 2020 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 "quantum.h"
     18 
     19 #ifdef RGB_MATRIX_ENABLE
     20 const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
     21 /* Refer to IS31 manual for these locations
     22  *   driver
     23  *   |  R location
     24  *   |  |       G location
     25  *   |  |       |       B location
     26  *   |  |       |       | */
     27 // left CA
     28     {0, C1_1,   C3_2,   C4_2}, //D9-0-0
     29     {0, C5_2,   C6_2,   C7_2}, //D59-1-1
     30     {0, C2_1,   C3_1,   C4_1}, //D68-2-2
     31     {0, C5_1,   C6_1,   C7_1}, //D76-3-3
     32     {0, C1_2,   C2_2,   C4_3}, //D10-15-4
     33     {0, C5_3,   C6_3,   C7_3}, //D60-16-5
     34     {0, C1_3,   C2_3,   C3_3}, //D72-17-6
     35     {0, C5_4,   C6_4,   C7_4}, //D77-18-7
     36     {0, C1_4,   C2_4,   C3_4}, //D46-30-8
     37     {0, C4_4,   C6_5,   C7_5}, //D61-31-9
     38     {0, C1_5,   C2_5,   C3_5}, //D73-32-10
     39     {0, C4_5,   C5_5,   C7_6}, //D78-33-11
     40     {0, C1_6,   C2_6,   C3_6}, //D126-44-12
     41     {0, C4_6,   C5_6,   C6_6}, //D51-45-13
     42     {0, C1_7,   C2_7,   C3_7}, //D63-46-14
     43     {0, C4_7,   C5_7,   C6_7}, //D74-47-15
     44     {0, C1_8,   C2_8,   C3_8}, //D56-60-16
     45     {0, C4_8,   C5_8,   C6_8}, //D67-61-17
     46 
     47 // left CB
     48     {0, C2_9,   C3_9,   C4_9},  //D80-4-18
     49     {0, C5_9,   C6_9,   C7_9},  //D84-5-19
     50     {0, C1_9,   C3_10,  C4_10}, //D89-6-20
     51     {0, C5_10,  C6_10,  C7_10}, //D94-7-21
     52     {0, C1_10,  C2_10,  C4_11}, //D81-19-22
     53     {0, C5_11,  C6_11,  C7_11}, //D85-20-23
     54     {0, C1_11,  C2_11,  C3_11}, //D90-21-24
     55     {0, C5_12,  C6_12,  C7_12}, //D95-22-25
     56     {0, C1_12,  C2_12,  C3_12}, //D82-34-26
     57     {0, C4_12,  C6_13,  C7_13}, //D86-35-27
     58     {0, C1_13,  C2_13,  C3_13}, //D91-36-28
     59     {0, C4_13,  C5_13,  C7_14}, //D96-37-29
     60     {0, C1_14,  C2_14,  C3_14}, //D79-48-30
     61     {0, C4_14,  C5_14,  C6_14}, //D83-49-31
     62     {0, C1_15,  C2_15,  C3_15}, //D87-50-32
     63     {0, C4_15,  C5_15,  C6_15}, //D92-51-33
     64     {0, C1_16,  C2_16,  C3_16}, //D75-62-34
     65     {0, C4_16,  C5_16,  C6_16}, //D93-63-35
     66 
     67 // right CA
     68     {1, C2_1,   C3_1,   C4_1},  //D98-8-36
     69     {1, C5_1,   C6_1,   C7_1},  //D102-9-37
     70     {1, C1_1,   C3_2,   C4_2},  //D106-10-38
     71     {1, C5_2,   C6_2,   C7_2},  //D111-11-39
     72     {1, C2_9,   C3_9,   C4_9},  //D116-12-40
     73     {1, C5_9,   C6_9,   C7_9},  //D130-13-41
     74     {1, C1_13,  C2_13,  C3_13}, //D121-14-42
     75     {1, C1_2,   C2_2,   C4_3},  //D99-23-43
     76     {1, C5_3,   C6_3,   C7_3},  //D103-24-44
     77     {1, C1_3,   C2_3,   C3_3},  //D107-25-45
     78     {1, C5_4,   C6_4,   C7_4},  //D112-26-46
     79     {1, C1_9,   C3_10,  C4_10}, //D117-27-47
     80     {1, C5_10,  C6_10,  C7_10}, //D129-28-48
     81     {1, C4_13,  C5_13,  C7_14}, //D122-29-49
     82     {1, C1_4,   C2_4,   C3_4},  //D100-38-50
     83     {1, C4_4,   C6_5,   C7_5},  //D104-39-51
     84     {1, C1_5,   C2_5,   C3_5},  //D108-40-52
     85     {1, C4_5,   C5_5,   C7_6},  //D113-41-53
     86 // right CB
     87     {1, C1_10,  C2_10,  C4_11}, //D118-42-54
     88     {1, C5_11,  C6_11,  C7_11}, //D123-43-55
     89     {1, C1_6,   C2_6,   C3_6},  //D97-52-56
     90     {1, C4_6,   C5_6,   C6_6},  //D101-53-57
     91     {1, C1_7,   C2_7,   C3_7},  //D105-54-58
     92     {1, C4_7,   C5_7,   C6_7},  //D109-55-59
     93     {1, C1_11,  C2_11,  C3_11}, //D114-56-60
     94     {1, C5_12,  C6_12,  C7_12}, //D128-57-61
     95     {1, C1_14,  C2_14,  C3_14}, //D119-58-62
     96     {1, C4_14,  C5_14,  C6_14}, //D124-59-63
     97     {1, C1_8,   C2_8,   C3_8}, //D127-64-64
     98     {1, C4_8,   C5_8,   C6_8}, //D110-65-65
     99     {1, C1_12,  C2_12,  C3_12}, //D115-66-66
    100     {1, C4_12,  C6_13,  C7_13}, //D120-67-67
    101     {1, C1_15,  C2_15,  C3_15}, //D125-68-68
    102     {1, C4_15,  C5_15,  C6_15}, //D140-69-69
    103     {0, C8_7,   C7_7,   C7_8}, //INDICATOR LED-70
    104     {0, C8_8,   C8_1,   C8_2}, //INDICATOR LED-71
    105     {0, C9_7,   C8_6,   C9_6}, //INDICATOR LED-72
    106     {0, C9_8,   C8_4,   C8_5},//INDICATOR LED-73
    107     {0, C8_15,  C9_1,   C9_2},//INDICATOR LED-74
    108     {0, C8_16,  C8_3,   C9_3},//INDICATOR LED-75
    109     {0, C9_15,  C9_9,   C9_10},//INDICATOR LED-76
    110     {0, C9_16,  C9_11,  C7_12},//INDICATOR LED-77
    111 };
    112 
    113 bool rgb_matrix_indicators_kb(void) {
    114     if (!rgb_matrix_indicators_user()) {
    115         return false;
    116     }
    117     if (host_keyboard_led_state().caps_lock) {
    118         rgb_matrix_set_color(8, 255, 255, 255);
    119         rgb_matrix_set_color(70, 255, 0, 0);
    120     } else {
    121         rgb_matrix_set_color(70, 0, 0, 0);
    122     }
    123     if (host_keyboard_led_state().num_lock) {
    124         rgb_matrix_set_color(71, 255, 0, 0);
    125     } else {
    126         rgb_matrix_set_color(71, 0, 0, 0);
    127     }
    128     if (host_keyboard_led_state().scroll_lock) {
    129         rgb_matrix_set_color(72, 255, 0, 0);
    130     } else {
    131         rgb_matrix_set_color(72, 0, 0, 0);
    132     }
    133     return true;
    134 }
    135 
    136 __attribute__((weak))
    137 layer_state_t layer_state_set_user(layer_state_t state) {
    138   // if on layer 1, turn on L1 LED, otherwise off.
    139     if (get_highest_layer(state) == 0) {
    140         rgb_matrix_set_color(73, 255, 0, 0);
    141     } else {
    142         rgb_matrix_set_color(73, 0, 0, 0);
    143     }
    144   // if on layer 2, turn on L2 LED, otherwise off.
    145     if (get_highest_layer(state) == 1) {
    146         rgb_matrix_set_color(74, 255, 0, 0);
    147     } else {
    148         rgb_matrix_set_color(74, 0, 0, 0);
    149     }
    150 
    151   // if on layer 3, turn on L3 LED, otherwise off.
    152     if (get_highest_layer(state) == 2) {
    153         rgb_matrix_set_color(75, 255, 0, 0);
    154     } else {
    155         rgb_matrix_set_color(75, 0, 0, 0);
    156     }
    157 
    158   // if on layer 4, turn on L4 LED, otherwise off.
    159     if (get_highest_layer(state) == 3) {
    160         rgb_matrix_set_color(76, 255, 0, 0);
    161     } else {
    162         rgb_matrix_set_color(76, 0, 0, 0);
    163     }
    164 
    165   // if on layer 5, turn on L5 LED, otherwise off.
    166     if (get_highest_layer(state) == 4) {
    167         rgb_matrix_set_color(77, 255, 0, 0);
    168     } else {
    169         rgb_matrix_set_color(77, 0, 0, 0);
    170     }
    171 
    172     return state;
    173 }
    174 
    175 #endif