qmk_firmware

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

octagon.c (3737B)


      1 /* Copyright 2022 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 "quantum.h"
     18 
     19 const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
     20 /* Refer to IS31 manual for these locations
     21  *    driver
     22  *    |  LED address
     23  *    |  | */
     24     { 0, C1_1  },  { 0, C1_2 },  { 0, C1_3  },  { 0, C1_4 },  { 0, C1_5  },  { 0, C1_6 },  { 0, C1_7  },  { 0, C1_8 },  { 0, C1_9  },  { 0, C1_10 },  { 0, C1_11  },  { 0, C1_12 },  { 0, C1_13  },  { 0, C1_14 },  { 0, C1_15  },  { 0, C1_16 },
     25     { 0, C2_1  },  { 0, C2_2 },  { 0, C2_3  },  { 0, C2_4 },  { 0, C2_5  },  { 0, C2_6 },  { 0, C2_7  },  { 0, C2_8 },  { 0, C2_9  },  { 0, C2_10 },  { 0, C2_11  },  { 0, C2_12 },  { 0, C2_13  },  { 0, C2_14 },  { 0, C2_15  },  { 0, C2_16 },
     26     { 0, C3_1  },  { 0, C3_2 },  { 0, C3_3  },  { 0, C3_4 },  { 0, C3_5  },  { 0, C3_6 },  { 0, C3_7  },  { 0, C3_8 },  { 0, C3_9  },  { 0, C3_10 },  { 0, C3_11  },  { 0, C3_12 },  { 0, C3_13  },  { 0, C3_14 },                  { 0, C3_16 },
     27     { 0, C4_1  },  { 0, C4_2 },  { 0, C4_3  },  { 0, C4_4 },  { 0, C4_5  },  { 0, C4_6 },  { 0, C4_7  },  { 0, C4_8 },  { 0, C4_9  },  { 0, C4_10 },  { 0, C4_11  },  { 0, C4_12 },  { 0, C4_13  },  { 0, C4_14 },                  { 0, C4_16 },
     28     { 0, C5_1  },  { 0, C5_2 },  { 0, C5_3  },  { 0, C5_4 },  { 0, C5_5  },  { 0, C5_6 },  { 0, C5_7  },  { 0, C5_8 },  { 0, C5_9  },  { 0, C5_10 },  { 0, C5_11  },  { 0, C5_12 },  { 0, C5_13  },  { 0, C5_14 },                  { 0, C5_16 },
     29     { 0, C6_1  },  { 0, C6_2 },  { 0, C6_3  },                                             { 0, C6_7  },                                              { 0, C6_11  },  { 0, C6_12 },  { 0, C6_13  },  { 0, C6_14 },  { 0, C6_15  },  { 0, C6_16 },
     30     { 0, C3_15 },  { 0, C4_15 }, { 0, C5_15 },  // Lock Indicator
     31     { 0, C7_13 },  { 0, C7_14 }, { 0, C7_15 }, { 0, C7_16 }, // Layer Indicator
     32 };
     33 
     34 bool led_matrix_indicators_kb(void) {
     35     if (!led_matrix_indicators_user()) {
     36         return false;
     37     }
     38     if (host_keyboard_led_state().caps_lock) {
     39         led_matrix_set_value(87, 0xFF);
     40         led_matrix_set_value(47, 0xFF);
     41     } else {
     42         led_matrix_set_value(87, 0x00);
     43     }
     44     if (host_keyboard_led_state().num_lock) {
     45         led_matrix_set_value(88, 0xFF);
     46     } else {
     47         led_matrix_set_value(88, 0x00);
     48     }
     49     if (host_keyboard_led_state().scroll_lock) {
     50         led_matrix_set_value(89, 0xFF);
     51     } else {
     52         led_matrix_set_value(89, 0x00);
     53     }
     54     return true;
     55 }
     56 
     57 layer_state_t layer_state_set_kb(layer_state_t state) {
     58     switch (get_highest_layer(state)) {
     59         case 0:
     60             led_matrix_set_value(90, 0xFF);
     61             break;
     62         case 1:
     63             led_matrix_set_value(91, 0xFF);
     64             break;
     65         case 2:
     66             led_matrix_set_value(92, 0xFF);
     67             break;
     68         case 3:
     69             led_matrix_set_value(93, 0xFF);
     70             break;
     71         default:
     72             led_matrix_set_value(90, 0x00);
     73             led_matrix_set_value(91, 0x00);
     74             led_matrix_set_value(92, 0x00);
     75             led_matrix_set_value(93, 0x00);
     76     }
     77     return layer_state_set_user(state);
     78 }