qmk_firmware

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

pro_48.c (4570B)


      1 // Copyright 2023 linlin012 (@linlin012)
      2 // SPDX-License-Identifier: GPL-2.0-or-later
      3 #include "quantum.h"
      4 
      5 #if defined(RGB_MATRIX_ENABLE)
      6 const is31fl3743a_led_t PROGMEM g_is31fl3743a_leds[IS31FL3743A_LED_COUNT] = {
      7 /* Refer to IS31 manual for these locations
      8  *   driver
      9  *   |  R location
     10  *   |  |          G location
     11  *   |  |          |          B location
     12  *   |  |          |          | */
     13     {0, SW1_CS1,   SW1_CS2,   SW1_CS3},
     14     {0, SW2_CS1,   SW2_CS2,   SW2_CS3},
     15     {0, SW3_CS1,   SW3_CS2,   SW3_CS3},
     16     {0, SW4_CS1,   SW4_CS2,   SW4_CS3},
     17     {0, SW5_CS1,   SW5_CS2,   SW5_CS3},
     18     {0, SW6_CS1,   SW6_CS2,   SW6_CS3},
     19     {0, SW7_CS1,   SW7_CS2,   SW7_CS3},
     20     {0, SW8_CS1,   SW8_CS2,   SW8_CS3},
     21     {0, SW9_CS1,   SW9_CS2,   SW9_CS3},
     22     {0, SW10_CS1,  SW10_CS2,  SW10_CS3},
     23     {0, SW11_CS1,  SW11_CS2,  SW11_CS3},
     24     {0, SW1_CS16,  SW1_CS17,  SW1_CS18},
     25     {0, SW2_CS16,  SW2_CS17,  SW2_CS18},
     26     {0, SW3_CS16,  SW3_CS17,  SW3_CS18},
     27 
     28     {0, SW1_CS4,   SW1_CS5,   SW1_CS6},
     29     {0, SW2_CS4,   SW2_CS5,   SW2_CS6},
     30     {0, SW3_CS4,   SW3_CS5,   SW3_CS6},
     31     {0, SW4_CS4,   SW4_CS5,   SW4_CS6},
     32     {0, SW5_CS4,   SW5_CS5,   SW5_CS6},
     33     {0, SW6_CS4,   SW6_CS5,   SW6_CS6},
     34     {0, SW7_CS4,   SW7_CS5,   SW7_CS6},
     35     {0, SW8_CS4,   SW8_CS5,   SW8_CS6},
     36     {0, SW9_CS4,   SW9_CS5,   SW9_CS6},
     37     {0, SW10_CS4,  SW10_CS5,  SW10_CS6},
     38     {0, SW11_CS4,  SW11_CS5,  SW11_CS6},
     39     {0, SW4_CS16,  SW4_CS17,  SW4_CS18},
     40     {0, SW5_CS16,  SW5_CS17,  SW5_CS18},
     41     {0, SW6_CS16,  SW6_CS17,  SW6_CS18},
     42 
     43     {0, SW1_CS7,   SW1_CS8,   SW1_CS9},
     44     {0, SW2_CS7,   SW2_CS8,   SW2_CS9},
     45     {0, SW3_CS7,   SW3_CS8,   SW3_CS9},
     46     {0, SW4_CS7,   SW4_CS8,   SW4_CS9},
     47     {0, SW5_CS7,   SW5_CS8,   SW5_CS9},
     48     {0, SW6_CS7,   SW6_CS8,   SW6_CS9},
     49     {0, SW7_CS7,   SW7_CS8,   SW7_CS9},
     50     {0, SW8_CS7,   SW8_CS8,   SW8_CS9},
     51     {0, SW9_CS7,   SW9_CS8,   SW9_CS9},
     52     {0, SW10_CS7,  SW10_CS8,  SW10_CS9},
     53     {0, SW11_CS7,  SW11_CS8,  SW11_CS9},
     54     {0, SW7_CS16,  SW7_CS17,  SW7_CS18},
     55     {0, SW8_CS16,  SW8_CS17,  SW8_CS18},
     56 
     57     {0, SW1_CS10,  SW1_CS11,  SW1_CS12},
     58     {0, SW2_CS10,  SW2_CS11,  SW2_CS12},
     59     {0, SW3_CS10,  SW3_CS11,  SW3_CS12},
     60     {0, SW4_CS10,  SW4_CS11,  SW4_CS12},
     61     {0, SW5_CS10,  SW5_CS11,  SW5_CS12},
     62     {0, SW6_CS10,  SW6_CS11,  SW6_CS12},
     63     {0, SW7_CS10,  SW7_CS11,  SW7_CS12},
     64     {0, SW8_CS10,  SW8_CS11,  SW8_CS12},
     65     {0, SW9_CS10,  SW9_CS11,  SW9_CS12},
     66     {0, SW10_CS10, SW10_CS11, SW10_CS12},
     67     {0, SW11_CS10, SW11_CS11, SW11_CS12},
     68     {0, SW9_CS16,  SW9_CS17,  SW9_CS18},
     69 
     70     {0, SW1_CS13,  SW1_CS14,  SW1_CS15},
     71     {0, SW2_CS13,  SW2_CS14,  SW2_CS15},
     72     {0, SW3_CS13,  SW3_CS14,  SW3_CS15},
     73     {0, SW4_CS13,  SW4_CS14,  SW4_CS15},
     74     {0, SW5_CS13,  SW5_CS14,  SW5_CS15},
     75     {0, SW5_CS13,  SW5_CS14,  SW5_CS15},
     76     {0, SW6_CS13,  SW6_CS14,  SW6_CS15},
     77     {0, SW7_CS13,  SW7_CS14,  SW7_CS15},
     78     {0, SW8_CS13,  SW8_CS14,  SW8_CS15},
     79     {0, SW9_CS13,  SW9_CS14,  SW9_CS15},
     80     {0, SW10_CS13, SW10_CS14, SW10_CS15}
     81 };
     82 
     83 bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
     84     if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
     85         return false;
     86     }
     87 
     88     if (host_keyboard_led_state().caps_lock) {
     89         RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 255, 255, 255);
     90     } else {
     91         if (!rgb_matrix_get_flags()) {
     92             RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 0, 0, 0);
     93         }
     94     }
     95 
     96     return false;
     97 }
     98 
     99 void suspend_power_down_kb(void) {
    100     gpio_write_pin_low(IS31FL3743A_SDB_PIN);
    101     suspend_power_down_user();
    102 }
    103 
    104 void suspend_wakeup_init_kb(void) {
    105     gpio_write_pin_high(IS31FL3743A_SDB_PIN);
    106     suspend_wakeup_init_user();
    107 }
    108 #endif
    109 
    110 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
    111     if (!process_record_user(keycode, record)) {
    112         return false;
    113     }
    114     switch (keycode) {
    115 #    ifdef RGB_MATRIX_ENABLE
    116         case QK_RGB_MATRIX_TOGGLE:
    117             if (record->event.pressed) {
    118                 switch (rgb_matrix_get_flags()) {
    119                     case LED_FLAG_ALL: {
    120                         rgb_matrix_set_flags(LED_FLAG_NONE);
    121                         rgb_matrix_set_color_all(0, 0, 0);
    122                     } break;
    123                     default: {
    124                         rgb_matrix_set_flags(LED_FLAG_ALL);
    125                     } break;
    126                 }
    127             }
    128             return false;
    129 #    endif
    130     }
    131 
    132     return true;
    133 }
    134 
    135 void board_init(void) {
    136     // JTAG-DP Disabled and SW-DP Disabled
    137     AFIO->MAPR = (AFIO->MAPR & ~AFIO_MAPR_SWJ_CFG_Msk) | AFIO_MAPR_SWJ_CFG_DISABLE;
    138 }