From d312c6d0ed4d84d3114e9fdda24bd7ebd4fe2810 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Thu, 1 Jul 2021 00:02:23 +0200 Subject: [PATCH 01/12] Hard reset from develop and added Glorious-gmmk stuff --- common_features.mk | 9 +- drivers/awinic/aw20216s.c | 136 +++++++ drivers/awinic/aw20216s.h | 273 ++++++++++++++ keyboards/gmmk/pro/config.h | 36 +- keyboards/gmmk/pro/halconf.h | 1 - keyboards/gmmk/pro/keymaps/default/keymap.c | 14 +- keyboards/gmmk/pro/pro.c | 382 +++++++++----------- keyboards/gmmk/pro/rules.mk | 3 +- quantum/quantum.h | 4 +- quantum/rgb_matrix/rgb_matrix.h | 4 +- quantum/rgb_matrix/rgb_matrix_drivers.c | 32 ++ 11 files changed, 652 insertions(+), 242 deletions(-) create mode 100644 drivers/awinic/aw20216s.c create mode 100644 drivers/awinic/aw20216s.h diff --git a/common_features.mk b/common_features.mk index 2d3f00d216dd..495c544c6f16 100644 --- a/common_features.mk +++ b/common_features.mk @@ -248,7 +248,7 @@ endif endif RGB_MATRIX_ENABLE ?= no -VALID_RGB_MATRIX_TYPES := AW20216 IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 WS2812 custom +VALID_RGB_MATRIX_TYPES := AW20216 IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 WS2812 AW20216S custom ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),) @@ -308,6 +308,13 @@ endif WS2812_DRIVER_REQUIRED := yes endif + ifeq ($(strip $(RGB_MATRIX_DRIVER)), AW20216S) + OPT_DEFS += -DAW20216S -DSTM32_SPI -DHAL_USE_SPI=TRUE + COMMON_VPATH += $(DRIVER_PATH)/awinic + SRC += aw20216s.c + QUANTUM_LIB_SRC += spi_master.c + endif + ifeq ($(strip $(RGB_MATRIX_DRIVER)), APA102) OPT_DEFS += -DAPA102 APA102_DRIVER_REQUIRED := yes diff --git a/drivers/awinic/aw20216s.c b/drivers/awinic/aw20216s.c new file mode 100644 index 000000000000..a288fd0a91e4 --- /dev/null +++ b/drivers/awinic/aw20216s.c @@ -0,0 +1,136 @@ +/* Copyright 2017 Jason Williams + * Copyright 2018 Jack Humbert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "quantum.h" +#include "spi_master.h" +#include "aw20216s.h" +#include +#include + +#define COMMAND_CHIP_ID 0xA0 +#define US_POR_DELAY 5000 // Min is 2000 us +#define US_ENABLE_DELAY 500 // Min is 100 us +#define PAGE_0 0 +#define PAGE_1 1 +#define PAGE_2 2 +#define PAGE_3 3 +#define PAGE_0_REG_GCR 0x00 +#define REG_GCR_BIT_CHIPEN_MASK 0x01 +#define PAGE_0_REG_GCCR 0x01 +#define US_BETWEEN_REG_WRITE_DELAY 100 +#define PWM_REGISTER_COUNT 216 + +#define SPI_CLOCK_SPEED 2000000 +#define SPI_MODE 3 +//#define SPI_DIVISOR (F_CPU / SPI_CLOCK_SPEED) +#define SPI_DIVISOR 4 // around 8 MHz (smooth transitions) + +// These buffers match the AW20216S PWM registers 0x00-0xD7. +uint8_t g_pwm_buffer[DRIVER_COUNT][PWM_REGISTER_COUNT]; +bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false}; + +void AW20216S_spi_start(int32_t csPin) { spi_start(csPin, false, SPI_MODE, SPI_DIVISOR); } + +void AW20216S_write_register(int32_t csPin, uint8_t page, uint8_t reg, uint8_t data) { + uint8_t cmd = COMMAND_CHIP_ID | ((page & 0x07) << 1); + + AW20216S_spi_start(csPin); + spi_write(cmd); + spi_write(reg); + spi_write(data); + spi_stop(); +} + +void AW20216S_write_pwm_buffer(int32_t csPin, uint8_t *pwm_buffer) { + uint8_t cmd = COMMAND_CHIP_ID | (PAGE_1 << 1); + + AW20216S_spi_start(csPin); + spi_write(cmd); + spi_write(0); + + for (int i = 0; i < PWM_REGISTER_COUNT; i++) { + spi_write(pwm_buffer[i]); + } + + spi_stop(); +} + +void AW20216S_enable(int32_t csPin, int32_t enablePin) { + // Configure chip select pin as output and set high level. + palSetLineMode(csPin, PAL_MODE_OUTPUT_PUSHPULL); + palSetLine(csPin); + + // Delay for POR to complete + wait_us(US_POR_DELAY); + + // Configure enable pin as output and set high level. + palSetLineMode(enablePin, PAL_MODE_OUTPUT_PUSHPULL); + palSetLine(enablePin); + + // Delay for enable to complete + wait_us(US_ENABLE_DELAY); +} + +void AW20216S_init(int32_t csPin, uint8_t swLinesEnabled) { + // Enable SW lines and chip + uint8_t valueGCR = (swLinesEnabled << 4) | REG_GCR_BIT_CHIPEN_MASK; + AW20216S_write_register(csPin, PAGE_0, PAGE_0_REG_GCR, valueGCR); + + wait_us(US_BETWEEN_REG_WRITE_DELAY); + + // Maximum sink current + uint8_t valueGCCR = RGB_MATRIX_MAXIMUM_BRIGHTNESS; + AW20216S_write_register(csPin, PAGE_0, PAGE_0_REG_GCCR, valueGCCR); + + wait_us(US_BETWEEN_REG_WRITE_DELAY); + + // Set Constant Current for LEDs (Registers SL) + for (uint8_t i = 0; i < PWM_REGISTER_COUNT; i++) { + AW20216S_write_register(csPin, PAGE_2, i, 0xFF); + wait_us(US_BETWEEN_REG_WRITE_DELAY); + } + + // Turn off all LEDs (Registers PWM) + for (uint8_t i = 0; i < PWM_REGISTER_COUNT; i++) { + AW20216S_write_register(csPin, PAGE_1, i, 0x00); + wait_us(US_BETWEEN_REG_WRITE_DELAY); + } +} + +void AW20216S_set_color(int indexLED, uint8_t red, uint8_t green, uint8_t blue) { + if (indexLED >= 0 && indexLED < DRIVER_LED_TOTAL) { + aw_led led = g_aw_leds[indexLED]; + + g_pwm_buffer[led.driver][led.r] = red; + g_pwm_buffer[led.driver][led.g] = green; + g_pwm_buffer[led.driver][led.b] = blue; + g_pwm_buffer_update_required[led.driver] = true; + } +} + +void AW20216S_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { + for (int i = 0; i < DRIVER_LED_TOTAL; i++) { + AW20216S_set_color(i, red, green, blue); + } +} + +void AW20216S_update_pwm_buffers(int32_t csPin, uint8_t driver) { + if (g_pwm_buffer_update_required[driver]) { + AW20216S_write_pwm_buffer(csPin, g_pwm_buffer[driver]); + } + g_pwm_buffer_update_required[driver] = false; +} diff --git a/drivers/awinic/aw20216s.h b/drivers/awinic/aw20216s.h new file mode 100644 index 000000000000..1ab3958b4790 --- /dev/null +++ b/drivers/awinic/aw20216s.h @@ -0,0 +1,273 @@ +/* Copyright 2017 Jason Williams + * Copyright 2018 Jack Humbert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include +#include + +typedef struct ag_led { + uint8_t driver : 2; + uint8_t r; + uint8_t g; + uint8_t b; +} __attribute__((packed)) aw_led; + +#define SW_LINES_ENABLED_1_TO_1 0x0 +#define SW_LINES_ENABLED_1_TO_2 0x1 +#define SW_LINES_ENABLED_1_TO_3 0x2 +#define SW_LINES_ENABLED_1_TO_4 0x3 +#define SW_LINES_ENABLED_1_TO_5 0x4 +#define SW_LINES_ENABLED_1_TO_6 0x5 +#define SW_LINES_ENABLED_1_TO_7 0x6 +#define SW_LINES_ENABLED_1_TO_8 0x7 +#define SW_LINES_ENABLED_1_TO_9 0x8 +#define SW_LINES_ENABLED_1_TO_10 0x9 +#define SW_LINES_ENABLED_1_TO_11 0xA +#define SW_LINES_ENABLED_1_TO_12 0xB + +extern const aw_led g_aw_leds[DRIVER_LED_TOTAL]; + +void AW20216S_enable(int32_t csPin, int32_t enablePin); +void AW20216S_init(int32_t csPin, uint8_t swLinesEnabled); +void AW20216S_set_color(int indexLED, uint8_t red, uint8_t green, uint8_t blue); +void AW20216S_set_color_all(uint8_t red, uint8_t green, uint8_t blue); +void AW20216S_write_register(int32_t csPin, uint8_t page, uint8_t reg, uint8_t data); +void AW20216S_write_pwm_buffer(int32_t csPin, uint8_t *pwm_buffer); + +// This should not be called from an interrupt +// (eg. from a timer interrupt). +// Call this while idle (in between matrix scans). +// If the buffer is dirty, it will update the driver with the buffer. +void AW20216S_update_pwm_buffers(int32_t csPin, uint8_t driver); + +#define CS1_SW1 0 +#define CS2_SW1 1 +#define CS3_SW1 2 +#define CS4_SW1 3 +#define CS5_SW1 4 +#define CS6_SW1 5 +#define CS7_SW1 6 +#define CS8_SW1 7 +#define CS9_SW1 8 +#define CS10_SW1 9 +#define CS11_SW1 10 +#define CS12_SW1 11 +#define CS13_SW1 12 +#define CS14_SW1 13 +#define CS15_SW1 14 +#define CS16_SW1 15 +#define CS17_SW1 16 +#define CS18_SW1 17 +#define CS1_SW2 18 +#define CS2_SW2 19 +#define CS3_SW2 20 +#define CS4_SW2 21 +#define CS5_SW2 22 +#define CS6_SW2 23 +#define CS7_SW2 24 +#define CS8_SW2 25 +#define CS9_SW2 26 +#define CS10_SW2 27 +#define CS11_SW2 28 +#define CS12_SW2 29 +#define CS13_SW2 30 +#define CS14_SW2 31 +#define CS15_SW2 32 +#define CS16_SW2 33 +#define CS17_SW2 34 +#define CS18_SW2 35 +#define CS1_SW3 36 +#define CS2_SW3 37 +#define CS3_SW3 38 +#define CS4_SW3 39 +#define CS5_SW3 40 +#define CS6_SW3 41 +#define CS7_SW3 42 +#define CS8_SW3 43 +#define CS9_SW3 44 +#define CS10_SW3 45 +#define CS11_SW3 46 +#define CS12_SW3 47 +#define CS13_SW3 48 +#define CS14_SW3 49 +#define CS15_SW3 50 +#define CS16_SW3 51 +#define CS17_SW3 52 +#define CS18_SW3 53 +#define CS1_SW4 54 +#define CS2_SW4 55 +#define CS3_SW4 56 +#define CS4_SW4 57 +#define CS5_SW4 58 +#define CS6_SW4 59 +#define CS7_SW4 60 +#define CS8_SW4 61 +#define CS9_SW4 62 +#define CS10_SW4 63 +#define CS11_SW4 64 +#define CS12_SW4 65 +#define CS13_SW4 66 +#define CS14_SW4 67 +#define CS15_SW4 68 +#define CS16_SW4 69 +#define CS17_SW4 70 +#define CS18_SW4 71 +#define CS1_SW5 72 +#define CS2_SW5 73 +#define CS3_SW5 74 +#define CS4_SW5 75 +#define CS5_SW5 76 +#define CS6_SW5 77 +#define CS7_SW5 78 +#define CS8_SW5 79 +#define CS9_SW5 80 +#define CS10_SW5 81 +#define CS11_SW5 82 +#define CS12_SW5 83 +#define CS13_SW5 84 +#define CS14_SW5 85 +#define CS15_SW5 86 +#define CS16_SW5 87 +#define CS17_SW5 88 +#define CS18_SW5 89 +#define CS1_SW6 90 +#define CS2_SW6 91 +#define CS3_SW6 92 +#define CS4_SW6 93 +#define CS5_SW6 94 +#define CS6_SW6 95 +#define CS7_SW6 96 +#define CS8_SW6 97 +#define CS9_SW6 98 +#define CS10_SW6 99 +#define CS11_SW6 100 +#define CS12_SW6 101 +#define CS13_SW6 102 +#define CS14_SW6 103 +#define CS15_SW6 104 +#define CS16_SW6 105 +#define CS17_SW6 106 +#define CS18_SW6 107 +#define CS1_SW7 108 +#define CS2_SW7 109 +#define CS3_SW7 110 +#define CS4_SW7 111 +#define CS5_SW7 112 +#define CS6_SW7 113 +#define CS7_SW7 114 +#define CS8_SW7 115 +#define CS9_SW7 116 +#define CS10_SW7 117 +#define CS11_SW7 118 +#define CS12_SW7 119 +#define CS13_SW7 120 +#define CS14_SW7 121 +#define CS15_SW7 122 +#define CS16_SW7 123 +#define CS17_SW7 124 +#define CS18_SW7 125 +#define CS1_SW8 126 +#define CS2_SW8 127 +#define CS3_SW8 128 +#define CS4_SW8 129 +#define CS5_SW8 130 +#define CS6_SW8 131 +#define CS7_SW8 132 +#define CS8_SW8 133 +#define CS9_SW8 134 +#define CS10_SW8 135 +#define CS11_SW8 136 +#define CS12_SW8 137 +#define CS13_SW8 138 +#define CS14_SW8 139 +#define CS15_SW8 140 +#define CS16_SW8 141 +#define CS17_SW8 142 +#define CS18_SW8 143 +#define CS1_SW9 144 +#define CS2_SW9 145 +#define CS3_SW9 146 +#define CS4_SW9 147 +#define CS5_SW9 148 +#define CS6_SW9 149 +#define CS7_SW9 150 +#define CS8_SW9 151 +#define CS9_SW9 152 +#define CS10_SW9 153 +#define CS11_SW9 154 +#define CS12_SW9 155 +#define CS13_SW9 156 +#define CS14_SW9 157 +#define CS15_SW9 158 +#define CS16_SW9 159 +#define CS17_SW9 160 +#define CS18_SW9 161 +#define CS1_SW10 162 +#define CS2_SW10 163 +#define CS3_SW10 164 +#define CS4_SW10 165 +#define CS5_SW10 166 +#define CS6_SW10 167 +#define CS7_SW10 168 +#define CS8_SW10 169 +#define CS9_SW10 170 +#define CS10_SW10 171 +#define CS11_SW10 172 +#define CS12_SW10 173 +#define CS13_SW10 174 +#define CS14_SW10 175 +#define CS15_SW10 176 +#define CS16_SW10 177 +#define CS17_SW10 178 +#define CS18_SW10 179 +#define CS1_SW11 180 +#define CS2_SW11 181 +#define CS3_SW11 182 +#define CS4_SW11 183 +#define CS5_SW11 184 +#define CS6_SW11 185 +#define CS7_SW11 186 +#define CS8_SW11 187 +#define CS9_SW11 188 +#define CS10_SW11 189 +#define CS11_SW11 190 +#define CS12_SW11 191 +#define CS13_SW11 192 +#define CS14_SW11 193 +#define CS15_SW11 194 +#define CS16_SW11 195 +#define CS17_SW11 196 +#define CS18_SW11 197 +#define CS1_SW12 198 +#define CS2_SW12 199 +#define CS3_SW12 200 +#define CS4_SW12 201 +#define CS5_SW12 202 +#define CS6_SW12 203 +#define CS7_SW12 204 +#define CS8_SW12 205 +#define CS9_SW12 206 +#define CS10_SW12 207 +#define CS11_SW12 208 +#define CS12_SW12 209 +#define CS13_SW12 210 +#define CS14_SW12 211 +#define CS15_SW12 212 +#define CS16_SW12 213 +#define CS17_SW12 214 +#define CS18_SW12 215 diff --git a/keyboards/gmmk/pro/config.h b/keyboards/gmmk/pro/config.h index 64062beceaff..506cc1e1650e 100644 --- a/keyboards/gmmk/pro/config.h +++ b/keyboards/gmmk/pro/config.h @@ -19,18 +19,20 @@ #include "config_common.h" /* USB Device descriptor parameter */ -#define DEVICE_VER 0x0001 -#define VENDOR_ID 0x320F -#define PRODUCT_ID 0x5044 -#define MANUFACTURER Glorious -#define PRODUCT GMMK Pro +#define DEVICE_VER 0x0001 +#define VENDOR_ID 0x320F +#define PRODUCT_ID 0x5044 +#define MANUFACTURER Glorious +#define PRODUCT GMMK Pro /* key matrix size */ #define MATRIX_ROWS 11 #define MATRIX_COLS 8 -#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10 } -#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A8, A9, A10 } +#define MATRIX_ROW_PINS \ + { B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10 } +#define MATRIX_COL_PINS \ + { A0, A1, A2, A3, A4, A8, A9, A10 } /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -39,27 +41,33 @@ #define BOOTMAGIC_LITE_COLUMN 3 #define TAP_CODE_DELAY 10 -#define ENCODERS_PAD_A { C15 } -#define ENCODERS_PAD_B { C14 } +#define ENCODERS_PAD_A \ + { C15 } +#define ENCODERS_PAD_B \ + { C14 } /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE +#define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 +#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_12 /* SPI Config for LED Driver */ #define SPI_DRIVER SPID1 #define SPI_SCK_PIN A5 #define SPI_MOSI_PIN A6 #define SPI_MISO_PIN A7 -#define DRIVER_1_CS B13 -#define DRIVER_2_CS B14 -#define DRIVER_1_EN C13 -#define DRIVER_2_EN C13 +#define SPI_SS_DRIVER_1_PIN B13 +#define SPI_SS_DRIVER_2_PIN B14 +#define ENABLE_DRIVERS_PIN C13 +#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175 + +#define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 +#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_12 #define DRIVER_COUNT 2 #define DRIVER_1_LED_TOTAL 66 #define DRIVER_2_LED_TOTAL 32 #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) - diff --git a/keyboards/gmmk/pro/halconf.h b/keyboards/gmmk/pro/halconf.h index 23ecb202a1d1..a172bf0c9ac6 100644 --- a/keyboards/gmmk/pro/halconf.h +++ b/keyboards/gmmk/pro/halconf.h @@ -3,5 +3,4 @@ #define HAL_USE_SPI TRUE #define SPI_USE_WAIT TRUE #define SPI_SELECT_MODE SPI_SELECT_MODE_PAD - #include_next diff --git a/keyboards/gmmk/pro/keymaps/default/keymap.c b/keyboards/gmmk/pro/keymaps/default/keymap.c index b08400cd8dc3..2c4decb86248 100644 --- a/keyboards/gmmk/pro/keymaps/default/keymap.c +++ b/keyboards/gmmk/pro/keymaps/default/keymap.c @@ -43,19 +43,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [1] = LAYOUT( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + _______, KC_MYCM, KC_WHOM, KC_CALC, KC_MSEL, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______, + _______, RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, RGB_VAI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, _______, + _______, _______, RGB_VAD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, RGB_HUI, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_MOD, _______, + _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_RMOD, RGB_SPI ), }; - bool encoder_update_user(uint8_t index, bool clockwise) { + if (clockwise) { tap_code(KC_VOLU); } else { diff --git a/keyboards/gmmk/pro/pro.c b/keyboards/gmmk/pro/pro.c index 9ed7ac8865a8..27ac97a3b5d7 100644 --- a/keyboards/gmmk/pro/pro.c +++ b/keyboards/gmmk/pro/pro.c @@ -16,223 +16,175 @@ #include "pro.h" #ifdef RGB_MATRIX_ENABLE -led_config_t g_led_config = { { - { 4, NO_LED, NO_LED, 95, 65, 79, 5, 28 }, - { 8, 2, 9, 0, 10, 75, 1, 7 }, - { 14, 3, 15, NO_LED, 16, 86, 6, 13 }, - { 20, 18, 21, 23, 22, 94, 12, 19 }, - { 25, 30, 26, 31, 27, 32, 29, 24 }, - { 41, 36, 42, 37, 43, 38, 35, 40 }, - { 46, 89, 47, 34, 48, 72, 78, 45 }, - { 52, 39, 53, 97, 54, 82, 44, 51 }, - { 58, 63, 59, 64, NO_LED, 60, 62, 57 }, - { 11, 90, 55, 17, 33, 49, NO_LED, 69 }, - { NO_LED, 85, 93, 61, 96, 66, 50, 56 } -}, { - { 0, 0 }, // 0, ESC, k13 - { 0, 15 }, // 1, ~, k16 - { 4, 26 }, // 2, Tab, k11 - { 5, 38 }, // 3, Caps, k21 - { 9, 49 }, // 4, Sh_L, k00 - { 2, 61 }, // 5, Ct_L, k06 - { 18, 0 }, // 6, F1, k26 - { 14, 15 }, // 7, 1, k17 - { 22, 26 }, // 8, Q, k10 - { 25, 38 }, // 9, A, k12 - { 33, 49 }, // 10, Z, k14 - { 20, 61 }, // 11, Win_L, k90 - { 33, 0 }, // 12, F2, k36 - { 29, 15 }, // 13, 2, k27 - { 36, 26 }, // 14, W, k20 - { 40, 38 }, // 15, S, k22 - { 47, 49 }, // 16, X, k24 - { 38, 61 }, // 17, Alt_L, k93 - { 47, 0 }, // 18, F3, k31 - { 43, 15 }, // 19, 3, k37 - { 51, 26 }, // 20, E, k30 - { 54, 38 }, // 21, D, k32 - { 61, 49 }, // 22, C, k34 - { 61, 0 }, // 23, F4, k33 - { 58, 15 }, // 24, 4, k47 - { 65, 26 }, // 25, R, k40 - { 69, 38 }, // 26, F, k42 - { 76, 49 }, // 27, V, k44 - { 79, 0 }, // 28, F5, k07 - { 72, 15 }, // 29, 5, k46 - { 79, 26 }, // 30, T, k41 - { 83, 38 }, // 31, G, k43 - { 90, 49 }, // 32, B, k45 - { 92, 61 }, // 33, SPACE, k94 - { 94, 0 }, // 34, F6, k63 - { 87, 15 }, // 35, 6, k56 - { 94, 26 }, // 36, Y, k51 - { 98, 38 }, // 37, H, k53 - { 105, 49 }, // 38, N, k55 - { 108, 0 }, // 39, F7, k71 - { 101, 15 }, // 40, 7, k57 - { 108, 26 }, // 41, U, k50 - { 112, 38 }, // 42, J, k52 - { 119, 49 }, // 43, M, k54 - { 123, 0 }, // 44, F8, k76 - { 116, 15 }, // 45, 8, k67 - { 123, 26 }, // 46, I, k60 - { 126, 38 }, // 47, K, k62 - { 134, 49 }, // 48, ,, k64 - { 145, 61 }, // 49, Alt_R, k95 - { 141, 0 }, // 50, F9, ka6 - { 130, 15 }, // 51, 9, k77 - { 137, 26 }, // 52, O, k70 - { 141, 38 }, // 53, L, k72 - { 148, 49 }, // 54, ., k74 - { 159, 61 }, // 55, FN, k92 - { 155, 0 }, // 56, F10, ka7 - { 145, 15 }, // 57, 0, k87 - { 152, 26 }, // 58, P, k80 - { 155, 38 }, // 59, ;, k82 - { 163, 49 }, // 60, ?, k85 - { 170, 0 }, // 61, F11, ka3 - { 159, 15 }, // 62, -, k86 - { 166, 26 }, // 63, [, k81 - { 170, 38 }, // 64, ", k83 - { 173, 61 }, // 65, Ct_R, k04 - { 184, 0 }, // 66, F12, ka5 - { 0, 8 }, // 67, LED, l01 - { 224, 8 }, // 68, LED, l11 - { 202, 0 }, // 69, Prt, k97 - { 0, 15 }, // 70, LED, l02 - { 224, 15 }, // 71, LED, l12 - { 224, 15 }, // 72, Del, k65 - { 0, 21 }, // 73, LED, l03 - { 224, 21 }, // 74, LED, l13 - { 224, 26 }, // 75, PgUp, k15 - { 0, 28 }, // 76, LED, l04 - { 224, 28 }, // 77, LED, l14 - { 173, 15 }, // 78, =, k66 - { 220, 64 }, // 79, Right, k05 - { 0, 35 }, // 80, LED, l05 - { 224, 35 }, // 81, LED, l15 - { 224, 49 }, // 82, End, k75 - { 0, 42 }, // 83, LED, l06 - { 224, 42 }, // 84, LED, l16 - { 195, 15 }, // 85, BSpc, ka1 - { 224, 38 }, // 86, PgDn, k25 - { 0, 48 }, // 87, LED, l07 - { 224, 48 }, // 88, LED, l17 - { 181, 26 }, // 89, ], k61 - { 182, 49 }, // 90, Sh_R, k91 - { 0, 55 }, // 91, LED, l08 - { 224, 55 }, // 92, LED, l18 - { 199, 26 }, // 93, \, ka2 - { 206, 52 }, // 94, Up, k35 - { 191, 64 }, // 95, Left, k03 - { 193, 38 }, // 96, Enter, ka4 - { 206, 64 } // 97, Down, k73 -}, { - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 2, 2, 4, 2, 2, - 4, 2, 2, 4, 4, 2, 2, 4, 2, 2, 4, 4, 2, 2, 4, 4, 2, 2, 4, 4, 4, 4, 4 -} }; const aw_led g_aw_leds[DRIVER_LED_TOTAL] = { - { 0, CS1_SW1, CS2_SW1, CS3_SW1 }, // 0, ESC, k13 - { 0, CS4_SW1, CS5_SW1, CS6_SW1 }, // 1, ~, k16 - { 0, CS7_SW1, CS8_SW1, CS9_SW1 }, // 2, Tab, k11 - { 0, CS10_SW1, CS11_SW1, CS12_SW1 }, // 3, Caps, k21 - { 0, CS13_SW1, CS14_SW1, CS15_SW1 }, // 4, Sh_L, k00 - { 0, CS16_SW1, CS17_SW1, CS18_SW1 }, // 5, Ct_L, k06 - { 0, CS1_SW2, CS2_SW2, CS3_SW2 }, // 6, F1, k26 - { 0, CS4_SW2, CS5_SW2, CS6_SW2 }, // 7, 1, k17 - { 0, CS7_SW2, CS8_SW2, CS9_SW2 }, // 8, Q, k10 - { 0, CS10_SW2, CS11_SW2, CS12_SW2 }, // 9, A, k12 - { 0, CS13_SW2, CS14_SW2, CS15_SW2 }, // 10, Z, k14 - { 0, CS16_SW2, CS17_SW2, CS18_SW2 }, // 11, Win_L, k90 - { 0, CS1_SW3, CS2_SW3, CS3_SW3 }, // 12, F2, k36 - { 0, CS4_SW3, CS5_SW3, CS6_SW3 }, // 13, 2, k27 - { 0, CS7_SW3, CS8_SW3, CS9_SW3 }, // 14, W, k20 - { 0, CS10_SW3, CS11_SW3, CS12_SW3 }, // 15, S, k22 - { 0, CS13_SW3, CS14_SW3, CS15_SW3 }, // 16, X, k24 - { 0, CS16_SW3, CS17_SW3, CS18_SW3 }, // 17, Alt_L, k93 - { 0, CS1_SW4, CS2_SW4, CS3_SW4 }, // 18, F3, k31 - { 0, CS4_SW4, CS5_SW4, CS6_SW4 }, // 19, 3, k37 - { 0, CS7_SW4, CS8_SW4, CS9_SW4 }, // 20, E, k30 - { 0, CS10_SW4, CS11_SW4, CS12_SW4 }, // 21, D, k32 - { 0, CS13_SW4, CS14_SW4, CS15_SW4 }, // 22, C, k34 - { 0, CS1_SW5, CS2_SW5, CS3_SW5 }, // 23, F4, k33 - { 0, CS4_SW5, CS5_SW5, CS6_SW5 }, // 24, 4, k47 - { 0, CS7_SW5, CS8_SW5, CS9_SW5 }, // 25, R, k40 - { 0, CS10_SW5, CS11_SW5, CS12_SW5 }, // 26, F, k42 - { 0, CS13_SW5, CS14_SW5, CS15_SW5 }, // 27, V, k44 - { 0, CS1_SW6, CS2_SW6, CS3_SW6 }, // 28, F5, k07 - { 0, CS4_SW6, CS5_SW6, CS6_SW6 }, // 29, 5, k46 - { 0, CS7_SW6, CS8_SW6, CS9_SW6 }, // 30, T, k41 - { 0, CS10_SW6, CS11_SW6, CS12_SW6 }, // 31, G, k43 - { 0, CS13_SW6, CS14_SW6, CS15_SW6 }, // 32, B, k45 - { 0, CS16_SW6, CS17_SW6, CS18_SW6 }, // 33, SPACE, k94 - { 0, CS1_SW7, CS2_SW7, CS3_SW7 }, // 34, F6, k63 - { 0, CS4_SW7, CS5_SW7, CS6_SW7 }, // 35, 6, k56 - { 0, CS7_SW7, CS8_SW7, CS9_SW7 }, // 36, Y, k51 - { 0, CS10_SW7, CS11_SW7, CS12_SW7 }, // 37, H, k53 - { 0, CS13_SW7, CS14_SW7, CS15_SW7 }, // 38, N, k55 - { 0, CS1_SW8, CS2_SW8, CS3_SW8 }, // 39, F7, k71 - { 0, CS4_SW8, CS5_SW8, CS6_SW8 }, // 40, 7, k57 - { 0, CS7_SW8, CS8_SW8, CS9_SW8 }, // 41, U, k50 - { 0, CS10_SW8, CS11_SW8, CS12_SW8 }, // 42, J, k52 - { 0, CS13_SW8, CS14_SW8, CS15_SW8 }, // 43, M, k54 - { 0, CS1_SW9, CS2_SW9, CS3_SW9 }, // 44, F8, k76 - { 0, CS4_SW9, CS5_SW9, CS6_SW9 }, // 45, 8, k67 - { 0, CS7_SW9, CS8_SW9, CS9_SW9 }, // 46, I, k60 - { 0, CS10_SW9, CS11_SW9, CS12_SW9 }, // 47, K, k62 - { 0, CS13_SW9, CS14_SW9, CS15_SW9 }, // 48, ,, k64 - { 0, CS16_SW9, CS17_SW9, CS18_SW9 }, // 49, Alt_R, k95 - { 0, CS1_SW10, CS2_SW10, CS3_SW10 }, // 50, F9, ka6 - { 0, CS4_SW10, CS5_SW10, CS6_SW10 }, // 51, 9, k77 - { 0, CS7_SW10, CS8_SW10, CS9_SW10 }, // 52, O, k70 - { 0, CS10_SW10, CS11_SW10, CS12_SW10 }, // 53, L, k72 - { 0, CS13_SW10, CS14_SW10, CS15_SW10 }, // 54, ., k74 - { 0, CS16_SW10, CS17_SW10, CS18_SW10 }, // 55, FN, k92 - { 0, CS1_SW11, CS2_SW11, CS3_SW11 }, // 56, F10, ka7 - { 0, CS4_SW11, CS5_SW11, CS6_SW11 }, // 57, 0, k87 - { 0, CS7_SW11, CS8_SW11, CS9_SW11 }, // 58, P, k80 - { 0, CS10_SW11, CS11_SW11, CS12_SW11 }, // 59, ;, k82 - { 0, CS13_SW11, CS14_SW11, CS15_SW11 }, // 60, ?, k85 - { 0, CS1_SW12, CS2_SW12, CS3_SW12 }, // 61, F11, ka3 - { 0, CS4_SW12, CS5_SW12, CS6_SW12 }, // 62, -, k86 - { 0, CS7_SW12, CS8_SW12, CS9_SW12 }, // 63, [, k81 - { 0, CS10_SW12, CS11_SW12, CS12_SW12 }, // 64, ", k83 - { 0, CS16_SW12, CS17_SW12, CS18_SW12 }, // 65, Ct_R, k04 +/* Refer to AW20216S manual for these locations + * driver + * | R location + * | | G location + * | | | B location + * | | | | Key Flag Row y-cm x-cm + */ + {0, CS13_SW1, CS14_SW1, CS15_SW1 }, // 0 : R0-S0 //KC_LSFT 1 4 8.2 2.5 + // // R1-S0 //KC_MUTE + // // R2-S0 // + {1, CS4_SW10, CS5_SW10, CS6_SW10 }, // 1 : R3-S0 //KC_LEFT 1 5 10 26 + {0, CS16_SW12, CS17_SW12, CS18_SW12 }, // 2 : R4-S0 //KC_RCTL 1 5 10 23.7 + {1, CS10_SW5, CS11_SW5, CS12_SW5 }, // 3 : R5-S0 //KC_RGHT 1 5 10 29.9 + {0, CS16_SW1, CS17_SW1, CS18_SW1 }, // 4 : R6-S0 //KC_LCTL 1 5 10 1.2 + {0, CS1_SW6, CS2_SW6, CS3_SW6 }, // 5 : R7-S0 //KC_F5 4 0 0 11.2 + // + {0, CS7_SW2, CS8_SW2, CS9_SW2 }, // 6 : R0-S1 //KC_Q 4 2 4.3 3.7 + {0, CS7_SW1, CS8_SW1, CS9_SW1 }, // 7 : R1-S1 //KC_TAB 1 2 4.3 1.5 + {0, CS10_SW2, CS11_SW2, CS12_SW2 }, // 8 : R2-S1 //KC_A 4 3 6.2 4.3 + {0, CS1_SW1, CS2_SW1, CS3_SW1 }, // 9 : R3-S1 //KC_ESC 1 0 0 0.9 + {0, CS13_SW2, CS14_SW2, CS15_SW2 }, //10 : R4-S1 //KC_Z 4 4 8.2 5.3 + {1, CS4_SW4, CS5_SW4, CS6_SW4 }, //11 : R5-S1 //KC_PGUP 4 2 4.3 30.2 + {0, CS4_SW1, CS5_SW1, CS6_SW1 }, //12 : R6-S1 //KC_GRV 1 1 2.9 0.9 + {0, CS4_SW2, CS5_SW2, CS6_SW2 }, //13 : R7-S1 //KC_1 4 1 2.9 2.6 + // + {0, CS7_SW3, CS8_SW3, CS9_SW3 }, //14 : R0-S2 //KC_W 4 2 4.3 5.8 + {0, CS10_SW1, CS11_SW1, CS12_SW1 }, //15 : R1-S2 //KC_CAPS 1 3 6.2 1.8 + {0, CS10_SW3, CS11_SW3, CS12_SW3 }, //16 : R2-S2 //KC_S 4 3 6.2 6.2 + // // R3-S2 // + {0, CS13_SW3, CS14_SW3, CS15_SW3 }, //17 : R4-S2 //KC_X 4 4 8.2 7.1 + {1, CS4_SW7, CS5_SW7, CS6_SW7 }, //18 : R5-S2 //KC_PGDN 4 3 6.2 30.2 + {0, CS1_SW2, CS2_SW2, CS3_SW2 }, //19 : R6-S2 //KC_F1 4 0 0 3.3 + {0, CS4_SW3, CS5_SW3, CS6_SW3 }, //20 : R7-S2 //KC_2 4 1 2.9 4.6 + // + {0, CS7_SW4, CS8_SW4, CS9_SW4 }, //21 : R0-S3 //KC_E 4 2 4.3 7.6 + {0, CS1_SW4, CS2_SW4, CS3_SW4 }, //22 : R1-S3 //KC_F3 4 0 0 7 + {0, CS10_SW4, CS11_SW4, CS12_SW4 }, //23 : R2-S3 //KC_D 4 3 6.2 8 + {0, CS1_SW5, CS2_SW5, CS3_SW5 }, //24 : R3-S3 //KC_F4 4 0 0 9 + {0, CS13_SW4, CS14_SW4, CS15_SW4 }, //25 : R4-S3 //KC_C 4 4 8.2 9 + {1, CS4_SW9, CS5_SW9, CS6_SW9 }, //26 : R5-S3 //KC_UP 1 4 8.2 28 + {0, CS1_SW3, CS2_SW3, CS3_SW3 }, //27 : R6-S3 //KC_F2 4 0 0 5.2 + {0, CS4_SW4, CS5_SW4, CS6_SW4 }, //28 : R7-S3 //KC_3 4 1 2.9 6.6 + // + {0, CS7_SW5, CS8_SW5, CS9_SW5 }, //29 : R0-S4 //KC_R 4 2 4.3 9.5 + {0, CS7_SW6, CS8_SW6, CS9_SW6 }, //30 : R1-S4 //KC_T 4 2 4.3 11.4 + {0, CS10_SW5, CS11_SW5, CS12_SW5 }, //31 : R2-S4 //KC_F 4 3 6.2 10 + {0, CS10_SW6, CS11_SW6, CS12_SW6 }, //32 : R3-S4 //KC_G 4 3 6.2 11.9 + {0, CS13_SW5, CS14_SW5, CS15_SW5 }, //33 : R4-S4 //KC_V 4 4 8.2 11 + {0, CS13_SW6, CS14_SW6, CS15_SW6 }, //34 : R5-S4 //KC_B 4 4 8.2 12.9 + {0, CS4_SW6, CS5_SW6, CS6_SW6 }, //35 : R6-S4 //KC_5 4 1 2.9 10.4 + {0, CS4_SW5, CS5_SW5, CS6_SW5 }, //36 : R7-S4 //KC_4 4 1 2.9 8.5 + // + {0, CS7_SW8, CS8_SW8, CS9_SW8 }, //37 : R0-S5 //KC_U 4 2 4.3 15.3 + {0, CS7_SW7, CS8_SW7, CS9_SW7 }, //38 : R1-S5 //KC_Y 4 2 4.3 13.4 + {0, CS10_SW8, CS11_SW8, CS12_SW8 }, //39 : R2-S5 //KC_J 4 3 6.2 15.7 + {0, CS10_SW7, CS11_SW7, CS12_SW7 }, //40 : R3-S5 //KC_H 4 3 6.2 13.8 + {0, CS13_SW8, CS14_SW8, CS15_SW8 }, //41 : R4-S5 //KC_M 4 4 8.2 16.5 + {0, CS13_SW7, CS14_SW7, CS15_SW7 }, //42 : R5-S5 //KC_N 4 4 8.2 14.7 + {0, CS4_SW7, CS5_SW7, CS6_SW7 }, //43 : R6-S5 //KC_6 4 1 2.9 12.3 + {0, CS4_SW8, CS5_SW8, CS6_SW8 }, //44 : R7-S5 //KC_7 4 1 2.9 14.2 + // + {0, CS7_SW9, CS8_SW9, CS9_SW9 }, //45 : R0-S6 //KC_I 4 2 4.3 17.2 + {1, CS1_SW8, CS2_SW8, CS3_SW8 }, //46 : R1-S6 //KC_RBRC 4 2 4.3 24.5 + {0, CS10_SW9, CS11_SW9, CS12_SW9 }, //47 : R2-S6 //KC_K 4 3 6.2 17.5 + {0, CS1_SW7, CS2_SW7, CS3_SW7 }, //48 : R3-S6 //KC_F6 4 0 0 13.2 + {0, CS13_SW9, CS14_SW9, CS15_SW9 }, //49 : R4-S6 //KC_COMM 4 4 8.2 18.5 + {1, CS4_SW3, CS5_SW3, CS6_SW3 }, //50 : R5-S6 //KC_DEL 4 1 2.9 30.2 + {1, CS1_SW5, CS2_SW5, CS3_SW5 }, //51 : R6-S6 //KC_EQL 4 1 2.9 23.7 + {0, CS4_SW9, CS5_SW9, CS6_SW9 }, //52 : R7-S6 //KC_8 4 1 2.9 16.1 + // + {0, CS7_SW10, CS8_SW10, CS9_SW10 }, //53 : R0-S7 //KC_O 4 2 4.3 19 + {0, CS1_SW8, CS2_SW8, CS3_SW8 }, //54 : R1-S7 //KC_F7 4 0 0 15.1 + {0, CS10_SW10, CS11_SW10, CS12_SW10}, //55 : R2-S7 //KC_L 4 3 6.2 19.5 + {1, CS4_SW11, CS5_SW11, CS6_SW11 }, //56 : R3-S7 //KC_DOWN 1 5 10 28 + {0, CS13_SW10, CS14_SW10, CS15_SW10}, //57 : R4-S7 //KC_DOT 4 4 8.2 20.5 + {1, CS4_SW6, CS5_SW6, CS6_SW6 }, //58 : R5-S7 //KC_END 4 4 8.2 30.2 + {0, CS1_SW9, CS2_SW9, CS3_SW9 }, //59 : R6-S7 //KC_F8 4 0 0 17 + {0, CS4_SW10, CS5_SW10, CS6_SW10 }, //60 : R7-S7 //KC_9 4 1 2.9 18 + // + {0, CS7_SW11, CS8_SW11, CS9_SW11 }, //61 : R0-S8 //KC_P 4 2 4.3 21 + {0, CS7_SW12, CS8_SW12, CS9_SW12 }, //62 : R1-S8 //KC_LBRC 4 2 4.3 22.7 + {0, CS10_SW11, CS11_SW11, CS12_SW11}, //63 : R2-S8 //KC_SCLN 4 3 6.2 21.5 + {0, CS10_SW12, CS11_SW12, CS12_SW12}, //64 : R3-S8 //KC_QUOT 4 3 6.2 23.2 + // // R4-S8 // + {0, CS13_SW11, CS14_SW11, CS15_SW11}, //65 : R5-S8 //KC_SLSH 4 4 8.2 22.3 + {0, CS4_SW12, CS5_SW12, CS6_SW12 }, //66 : R6-S8 //KC_MINS 4 1 2.9 21.7 + {0, CS4_SW11, CS5_SW11, CS6_SW11 }, //67 : R7-S8 //KC_0 4 1 2.9 19.8 + // + {0, CS16_SW2, CS17_SW2, CS18_SW2 }, //68 : R0-S9 //KC_LGUI 1 5 10 3.7 + {1, CS4_SW8, CS5_SW8, CS6_SW8 }, //69 : R1-S9 //KC_RSFT 1 4 8.2 25 + {0, CS16_SW10, CS17_SW10, CS18_SW10}, //70 : R2-S9 //MO(1) 1 5 10 21.9 + {0, CS16_SW3, CS17_SW3, CS18_SW3 }, //71 : R3-S9 //KC_LALT 1 5 10 6 + {0, CS16_SW6, CS17_SW6, CS18_SW6 }, //72 : R4-S9 //KC_SPC 4 5 10 13.2 + {0, CS16_SW9, CS17_SW9, CS18_SW9 }, //73 : R5-S9 //KC_RALT 1 5 10 20 + // // R6-S9 // + {1, CS4_SW2, CS5_SW2, CS6_SW2 }, //74 : R7-S9 //KC_PSCR 4 0 0 27.5 + // + // // R0-S10 // + {1, CS1_SW7, CS2_SW7, CS3_SW7 }, //75 : R1-S10 //KC_BSPC 1 1 2.9 26.5 + {1, CS1_SW9, CS2_SW9, CS3_SW9 }, //76 : R2-S10 //KC_BSLS 1 2 4.3 27 + {0, CS1_SW12, CS2_SW12, CS3_SW12 }, //77 : R3-S10 //KC_F11 4 0 0 23.2 + {1, CS1_SW11, CS2_SW11, CS3_SW11 }, //78 : R4-S10 //KC_ENT 1 3 6.2 26.5 + {1, CS1_SW1, CS2_SW1, CS3_SW1 }, //79 : R5-S10 //KC_F12 4 0 0 25.1 + {0, CS1_SW10, CS2_SW10, CS3_SW10 }, //80 : R6-S10 //KC_F9 4 0 0 19.5 + {0, CS1_SW11, CS2_SW11, CS3_SW11 }, //81 : R7-S10 //KC_F10 4 0 0 21.3 + + //Underglow + {1, CS13_SW1, CS14_SW1, CS15_SW1 }, //82 : //LED1 2 0.8 0 + {1, CS13_SW2, CS14_SW2, CS15_SW2 }, //83 : //LED2 2 1.9 0 + {1, CS13_SW3, CS14_SW3, CS15_SW3 }, //84 : //LED3 2 3.0 0 + {1, CS13_SW4, CS14_SW4, CS15_SW4 }, //85 : //LED4 2 4.1 0 + {1, CS13_SW5, CS14_SW5, CS15_SW5 }, //86 : //LED5 2 5.2 0 + {1, CS13_SW6, CS14_SW6, CS15_SW6 }, //87 : //LED6 2 6.3 0 + {1, CS13_SW7, CS14_SW7, CS15_SW7 }, //88 : //LED7 2 7.4 0 + {1, CS13_SW8, CS14_SW8, CS15_SW8 }, //89 : //LED8 2 8.5 0 - { 1, CS1_SW1, CS2_SW1, CS3_SW1 }, // 66, F12, ka5 - { 1, CS13_SW1, CS14_SW1, CS15_SW1 }, // 67, LED, l01 - { 1, CS16_SW1, CS17_SW1, CS18_SW1 }, // 68, LED, l11 - { 1, CS4_SW2, CS5_SW2, CS6_SW2 }, // 69, Prt, k97 - { 1, CS13_SW2, CS14_SW2, CS15_SW2 }, // 70, LED, l02 - { 1, CS16_SW2, CS17_SW2, CS18_SW2 }, // 71, LED, l12 - { 1, CS4_SW3, CS5_SW3, CS6_SW3 }, // 72, Del, k65 - { 1, CS13_SW3, CS14_SW3, CS15_SW3 }, // 73, LED, l03 - { 1, CS16_SW3, CS17_SW3, CS18_SW3 }, // 74, LED, l13 - { 1, CS4_SW4, CS5_SW4, CS6_SW4 }, // 75, PgUp, k15 - { 1, CS13_SW4, CS14_SW4, CS15_SW4 }, // 76, LED, l04 - { 1, CS16_SW4, CS17_SW4, CS18_SW4 }, // 77, LED, l14 - { 1, CS1_SW5, CS2_SW5, CS3_SW5 }, // 78, =, k66 - { 1, CS10_SW5, CS11_SW5, CS12_SW5 }, // 79, Right, k05 - { 1, CS13_SW5, CS14_SW5, CS15_SW5 }, // 80, LED, l05 - { 1, CS16_SW5, CS17_SW5, CS18_SW5 }, // 81, LED, l15 - { 1, CS4_SW6, CS5_SW6, CS6_SW6 }, // 82, End, k75 - { 1, CS13_SW6, CS14_SW6, CS15_SW6 }, // 83, LED, l06 - { 1, CS16_SW6, CS17_SW6, CS18_SW6 }, // 84, LED, l16 - { 1, CS1_SW7, CS2_SW7, CS3_SW7 }, // 85, BSpc, ka1 - { 1, CS4_SW7, CS5_SW7, CS6_SW7 }, // 86, PgDn, k25 - { 1, CS13_SW7, CS14_SW7, CS15_SW7 }, // 87, LED, l07 - { 1, CS16_SW7, CS17_SW7, CS18_SW7 }, // 88, LED, l17 - { 1, CS1_SW8, CS2_SW8, CS3_SW8 }, // 89, ], k61 - { 1, CS4_SW8, CS5_SW8, CS6_SW8 }, // 90, Sh_R, k91 - { 1, CS13_SW8, CS14_SW8, CS15_SW8 }, // 91, LED, l08 - { 1, CS16_SW8, CS17_SW8, CS18_SW8 }, // 92, LED, l18 - { 1, CS1_SW9, CS2_SW9, CS3_SW9 }, // 93, \, ka2 - { 1, CS4_SW9, CS5_SW9, CS6_SW9 }, // 94, Up, k35 - { 1, CS4_SW10, CS5_SW10, CS6_SW10 }, // 95, Left, k03 - { 1, CS1_SW11, CS2_SW11, CS3_SW11 }, // 96, Enter, ka4 - { 1, CS4_SW11, CS5_SW11, CS6_SW11 }, // 97, Down, k73 + {1, CS16_SW1, CS17_SW1, CS18_SW1 }, //90 : //LED11 2 0.8 32 + {1, CS16_SW2, CS17_SW2, CS18_SW2 }, //91 : //LED12 2 1.9 32 + {1, CS16_SW3, CS17_SW3, CS18_SW3 }, //92 : //LED13 2 3.0 32 + {1, CS16_SW4, CS17_SW4, CS18_SW4 }, //93 : //LED14 2 4.1 32 + {1, CS16_SW5, CS17_SW5, CS18_SW5 }, //94 : //LED15 2 5.2 32 + {1, CS16_SW6, CS17_SW6, CS18_SW6 }, //95 : //LED16 2 6.3 32 + {1, CS16_SW7, CS17_SW7, CS18_SW7 }, //96 : //LED17 2 7.4 32 + {1, CS16_SW8, CS17_SW8, CS18_SW8 }, //97 : //LED18 2 8.5 32 }; + +//See definition in 'rgb_matrix_types.h' +led_config_t g_led_config = { { + //R0 R1 R2 R3 R4 R5 R6 R7 + { 0, NO_LED, NO_LED, 1, 2, 3, 4, 5 }, /*S0 */ \ + { 6, 7, 8, 9, 10, 11, 12, 13}, /*S1 */ \ + { 14, 15, 16, NO_LED, 17, 18, 19, 20}, /*S2 */ \ + { 21, 22, 23, 24, 25, 26, 27, 28}, /*S3 */ \ + { 29, 30, 31, 32, 33, 34, 35, 36}, /*S4 */ \ + { 37, 38, 39, 40, 41, 42, 43, 44}, /*S5 */ \ + { 45, 46, 47, 48, 49, 50, 51, 52}, /*S6 */ \ + { 53, 54, 55, 56, 57, 58, 59, 60}, /*S7 */ \ + { 61, 62, 63, 64, NO_LED, 65, 66, 67}, /*S8 */ \ + { 68, 69, 70, 71, 72, 73, NO_LED, 74}, /*S9 */ \ + { NO_LED, 75, 76, 77, 78, 79, 80, 81} /*S10*/ \ +}, { + {17,52},{182,64},{165,64},{209,64},{8,64},{78,0},{25,27},{10,27}, + {30,39},{6,0},{37,52},{211,27},{6,18},{18,18},{40,27},{12,39}, + {43,39},{49,52},{211,39},{23,0},{32,18},{53,27},{49,0},{56,39}, + {63,0},{63,52},{196,52},{36,0},{46,18},{66,27},{79,27},{70,39}, + {83,39},{77,52},{90,52},{72,18},{59,18},{107,27},{93,27},{109,39}, + {96,39},{115,52},{102,52},{86,18},{99,18},{120,27},{171,27},{122,39}, + {92,0},{129,52},{211,18},{165,18},{112,18},{133,27},{105,0},{136,39}, + {196,64},{143,52},{211,52},{119,0},{126,18},{147,27},{158,27},{150,39}, + {162,39},{156,52},{151,18},{138,18},{25,64},{175,52},{153,64},{42,64}, + {92,64},{140,64},{192,0},{185,18},{189,27},{162,0},{185,39},{175,0}, + {136,0},{149,0},{0,5},{0,12},{0,19},{0,26},{0,33},{0,40}, + {0,47},{0,54},{224,5},{224,12},{224,19},{224,26},{224,33},{224,40}, + {224,47},{224,54}, +}, { + 1,1,1,1,1,4,4,1, + 4,1,4,4,1,4,4,1, + 4,4,4,4,4,4,4,4, + 4,4,1,4,4,4,4,4, + 4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4, + 1,4,4,4,4,4,4,4, + 4,4,4,4,1,1,1,1, + 4,1,4,1,1,4,1,4, + 4,4,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2, + 2,2 +} }; #endif diff --git a/keyboards/gmmk/pro/rules.mk b/keyboards/gmmk/pro/rules.mk index 6221d6408272..d2500c1df10d 100644 --- a/keyboards/gmmk/pro/rules.mk +++ b/keyboards/gmmk/pro/rules.mk @@ -21,5 +21,6 @@ RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow BLUETOOTH_ENABLE = no # Enable Bluetooth AUDIO_ENABLE = no # Audio output ENCODER_ENABLE = yes + RGB_MATRIX_ENABLE = yes -RGB_MATRIX_DRIVER = AW20216 +RGB_MATRIX_DRIVER = AW20216S diff --git a/quantum/quantum.h b/quantum/quantum.h index 66ba96fde83f..27cc1bc79771 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -38,11 +38,11 @@ #endif #if defined(RGBLIGHT_ENABLE) -# include "rgblight.h" +# include "rgblight\rgblight.h" #elif defined(RGB_MATRIX_ENABLE) // Dummy define RGBLIGHT_MODE_xxxx # define RGBLIGHT_H_DUMMY_DEFINE -# include "rgblight.h" +# include "rgblight\rgblight.h" #endif #ifdef RGB_MATRIX_ENABLE diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 28f07c84d6e4..270da69bba4f 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -23,7 +23,7 @@ #include "rgb_matrix_types.h" #include "color.h" #include "quantum.h" -#include "rgblight_list.h" +#include "rgblight\rgblight_list.h" #ifdef IS31FL3731 # include "is31fl3731.h" @@ -37,6 +37,8 @@ # include "aw20216.h" #elif defined(WS2812) # include "ws2812.h" +#elif defined(AW20216S) +# include "aw20216s.h" #endif #ifndef RGB_MATRIX_LED_FLUSH_LIMIT diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 6a11d4791e5f..1f8ca41a4f1e 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -225,4 +225,36 @@ const rgb_matrix_driver_t rgb_matrix_driver = { .set_color = setled, .set_color_all = setled_all, }; + +#elif defined(AW20216S) +# include "spi_master.h" + +static void init(void) { + AW20216S_enable(SPI_SS_DRIVER_1_PIN, ENABLE_DRIVERS_PIN); +# ifdef SPI_SS_DRIVER_2_PIN + AW20216S_enable(SPI_SS_DRIVER_2_PIN, ENABLE_DRIVERS_PIN); +# endif + + spi_init(); + + AW20216S_init(SPI_SS_DRIVER_1_PIN, SW_LINES_ENABLE_DRIVER_1); +# ifdef SPI_SS_DRIVER_2_PIN + AW20216S_init(SPI_SS_DRIVER_2_PIN, SW_LINES_ENABLE_DRIVER_2); +# endif +} + +static void flush(void) { + AW20216S_update_pwm_buffers(SPI_SS_DRIVER_1_PIN, 0); +# ifdef SPI_SS_DRIVER_2_PIN + AW20216S_update_pwm_buffers(SPI_SS_DRIVER_2_PIN, 1); +# endif +} + +const rgb_matrix_driver_t rgb_matrix_driver = { + .init = init, + .flush = flush, + .set_color = AW20216S_set_color, + .set_color_all = AW20216S_set_color_all, +}; + #endif From 887c36214ea49e977d805118a40c92e7389b2b97 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Thu, 1 Jul 2021 06:55:36 +0200 Subject: [PATCH 02/12] Changed to linux-style dir separator in includes --- quantum/quantum.h | 4 ++-- quantum/rgb_matrix/rgb_matrix.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/quantum/quantum.h b/quantum/quantum.h index 27cc1bc79771..3ac7d22b9045 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -38,11 +38,11 @@ #endif #if defined(RGBLIGHT_ENABLE) -# include "rgblight\rgblight.h" +# include "rgblight/rgblight.h" #elif defined(RGB_MATRIX_ENABLE) // Dummy define RGBLIGHT_MODE_xxxx # define RGBLIGHT_H_DUMMY_DEFINE -# include "rgblight\rgblight.h" +# include "rgblight/rgblight.h" #endif #ifdef RGB_MATRIX_ENABLE diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 270da69bba4f..82ab0418129a 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -23,7 +23,7 @@ #include "rgb_matrix_types.h" #include "color.h" #include "quantum.h" -#include "rgblight\rgblight_list.h" +#include "rgblight/rgblight_list.h" #ifdef IS31FL3731 # include "is31fl3731.h" From e05b5d98f7bb6aa5fcec11fea8f1debbfc336850 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Fri, 2 Jul 2021 21:31:04 +0200 Subject: [PATCH 03/12] Modified SW_LINES_ENABLE_DRIVER_2 constant. --- drivers/awinic/aw20216s.c | 10 ++++++---- keyboards/gmmk/pro/config.h | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/awinic/aw20216s.c b/drivers/awinic/aw20216s.c index a288fd0a91e4..1931c8b3c127 100644 --- a/drivers/awinic/aw20216s.c +++ b/drivers/awinic/aw20216s.c @@ -34,10 +34,12 @@ #define US_BETWEEN_REG_WRITE_DELAY 100 #define PWM_REGISTER_COUNT 216 -#define SPI_CLOCK_SPEED 2000000 -#define SPI_MODE 3 -//#define SPI_DIVISOR (F_CPU / SPI_CLOCK_SPEED) -#define SPI_DIVISOR 4 // around 8 MHz (smooth transitions) +#ifndef SPI_MODE +# define SPI_MODE 0 +#endif +#ifndef SPI_DIVISOR +# define SPI_DIVISOR 4 +#endif // These buffers match the AW20216S PWM registers 0x00-0xD7. uint8_t g_pwm_buffer[DRIVER_COUNT][PWM_REGISTER_COUNT]; diff --git a/keyboards/gmmk/pro/config.h b/keyboards/gmmk/pro/config.h index 506cc1e1650e..e5dd186c9bab 100644 --- a/keyboards/gmmk/pro/config.h +++ b/keyboards/gmmk/pro/config.h @@ -51,8 +51,6 @@ /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE -#define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 -#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_12 /* SPI Config for LED Driver */ #define SPI_DRIVER SPID1 #define SPI_SCK_PIN A5 @@ -65,7 +63,7 @@ #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175 #define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 -#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_12 +#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_11 #define DRIVER_COUNT 2 #define DRIVER_1_LED_TOTAL 66 From 0d06451d2c3dc47a3c2b5eb533a601f2799bd793 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Sat, 3 Jul 2021 07:14:56 +0200 Subject: [PATCH 04/12] 2 enable pins. --- keyboards/gmmk/pro/config.h | 3 ++- quantum/rgb_matrix/rgb_matrix_drivers.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/keyboards/gmmk/pro/config.h b/keyboards/gmmk/pro/config.h index e5dd186c9bab..121fe5fe6b70 100644 --- a/keyboards/gmmk/pro/config.h +++ b/keyboards/gmmk/pro/config.h @@ -58,8 +58,9 @@ #define SPI_MISO_PIN A7 #define SPI_SS_DRIVER_1_PIN B13 +#define ENABLE_DRIVER_1_PIN C13 #define SPI_SS_DRIVER_2_PIN B14 -#define ENABLE_DRIVERS_PIN C13 +#define ENABLE_DRIVER_2_PIN C13 #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175 #define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 1f8ca41a4f1e..18fef3d047c4 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -230,9 +230,9 @@ const rgb_matrix_driver_t rgb_matrix_driver = { # include "spi_master.h" static void init(void) { - AW20216S_enable(SPI_SS_DRIVER_1_PIN, ENABLE_DRIVERS_PIN); + AW20216S_enable(SPI_SS_DRIVER_1_PIN, ENABLE_DRIVER_1_PIN); # ifdef SPI_SS_DRIVER_2_PIN - AW20216S_enable(SPI_SS_DRIVER_2_PIN, ENABLE_DRIVERS_PIN); + AW20216S_enable(SPI_SS_DRIVER_2_PIN, ENABLE_DRIVER_2_PIN); # endif spi_init(); From 3d5de6836a1e06e9fd0599ca0cfa4d62a0626181 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Tue, 6 Jul 2021 17:18:15 +0200 Subject: [PATCH 05/12] cformat --- drivers/awinic/aw20216s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/awinic/aw20216s.c b/drivers/awinic/aw20216s.c index 1931c8b3c127..820edda3fc44 100644 --- a/drivers/awinic/aw20216s.c +++ b/drivers/awinic/aw20216s.c @@ -38,7 +38,7 @@ # define SPI_MODE 0 #endif #ifndef SPI_DIVISOR -# define SPI_DIVISOR 4 +# define SPI_DIVISOR 4 #endif // These buffers match the AW20216S PWM registers 0x00-0xD7. From 11522a0f790fb6a8c8563f5e5dde4cfc2d8eecf6 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Wed, 7 Jul 2021 06:24:44 +0200 Subject: [PATCH 06/12] Only one AW20216 implementation --- common_features.mk | 9 +- drivers/awinic/aw20216.c | 170 ---------------- drivers/awinic/aw20216.h | 251 ------------------------ quantum/rgb_matrix/rgb_matrix.h | 2 - quantum/rgb_matrix/rgb_matrix_drivers.c | 16 -- 5 files changed, 1 insertion(+), 447 deletions(-) delete mode 100644 drivers/awinic/aw20216.c delete mode 100644 drivers/awinic/aw20216.h diff --git a/common_features.mk b/common_features.mk index 495c544c6f16..88b0d3d45005 100644 --- a/common_features.mk +++ b/common_features.mk @@ -248,7 +248,7 @@ endif endif RGB_MATRIX_ENABLE ?= no -VALID_RGB_MATRIX_TYPES := AW20216 IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 WS2812 AW20216S custom +VALID_RGB_MATRIX_TYPES := IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 WS2812 AW20216S custom ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),) @@ -268,13 +268,6 @@ endif CIE1931_CURVE := yes RGB_KEYCODES_ENABLE := yes - ifeq ($(strip $(RGB_MATRIX_DRIVER)), AW20216) - OPT_DEFS += -DAW20216 -DSTM32_SPI -DHAL_USE_SPI=TRUE - COMMON_VPATH += $(DRIVER_PATH)/awinic - SRC += aw20216.c - QUANTUM_LIB_SRC += spi_master.c - endif - ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3731) OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE COMMON_VPATH += $(DRIVER_PATH)/issi diff --git a/drivers/awinic/aw20216.c b/drivers/awinic/aw20216.c deleted file mode 100644 index 269bb3a59a76..000000000000 --- a/drivers/awinic/aw20216.c +++ /dev/null @@ -1,170 +0,0 @@ -/* Copyright 2021 Jasper Chan - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "aw20216.h" -#include "spi_master.h" - -/* The AW20216 appears to be somewhat similar to the IS31FL743, although quite - * a few things are different, such as the command byte format and page ordering. - * The LED addresses start from 0x00 instead of 0x01. - */ -#define AWINIC_ID 0b1010 << 4 - -#define AW_PAGE_FUNCTION 0x00 << 1 // PG0, Function registers -#define AW_PAGE_PWM 0x01 << 1 // PG1, LED PWM control -#define AW_PAGE_SCALING 0x02 << 1 // PG2, LED current scaling control -#define AW_PAGE_PATCHOICE 0x03 << 1 // PG3, Pattern choice? -#define AW_PAGE_PWMSCALING 0x04 << 1 // PG4, LED PWM + Scaling control? - -#define AW_WRITE 0 -#define AW_READ 1 - -#define AW_REG_CONFIGURATION 0x00 // PG0 -#define AW_REG_GLOBALCURRENT 0x01 // PG0 - -// Default value of AW_REG_CONFIGURATION -// D7:D4 = 1011, SWSEL (SW1~SW12 active) -// D3 = 0?, reserved (apparently this should be 1 but it doesn't seem to matter) -// D2:D1 = 00, OSDE (open/short detection enable) -// D0 = 0, CHIPEN (write 1 to enable LEDs when hardware enable pulled high) -#define AW_CONFIG_DEFAULT 0b10110000 -#define AW_CHIPEN 1 - -#ifndef AW_SCALING_MAX -# define AW_SCALING_MAX 150 -#endif - -#ifndef AW_GLOBAL_CURRENT_MAX -# define AW_GLOBAL_CURRENT_MAX 150 -#endif - -#ifndef DRIVER_1_CS -# define DRIVER_1_CS B13 -#endif - -#ifndef DRIVER_1_EN -# define DRIVER_1_EN C13 -#endif - -#ifndef AW_SPI_DIVISOR -# define AW_SPI_DIVISOR 4 -#endif - -uint8_t g_spi_transfer_buffer[20] = {0}; -aw_led g_pwm_buffer[DRIVER_LED_TOTAL]; -bool g_pwm_buffer_update_required[DRIVER_LED_TOTAL]; - -bool AW20216_write_register(pin_t slave_pin, uint8_t page, uint8_t reg, uint8_t data) { - // Do we need to call spi_stop() if this fails? - if (!spi_start(slave_pin, false, 0, AW_SPI_DIVISOR)) { - return false; - } - - g_spi_transfer_buffer[0] = (AWINIC_ID | page | AW_WRITE); - g_spi_transfer_buffer[1] = reg; - g_spi_transfer_buffer[2] = data; - - if (spi_transmit(g_spi_transfer_buffer, 3) != SPI_STATUS_SUCCESS) { - spi_stop(); - return false; - } - spi_stop(); - return true; -} - -bool AW20216_init_scaling(void) { - // Set constant current to the max, control brightness with PWM - aw_led led; - for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_aw_leds[i]; - if (led.driver == 0) { - AW20216_write_register(DRIVER_1_CS, AW_PAGE_SCALING, led.r, AW_SCALING_MAX); - AW20216_write_register(DRIVER_1_CS, AW_PAGE_SCALING, led.g, AW_SCALING_MAX); - AW20216_write_register(DRIVER_1_CS, AW_PAGE_SCALING, led.b, AW_SCALING_MAX); - } -#ifdef DRIVER_2_CS - else if (led.driver == 1) { - AW20216_write_register(DRIVER_2_CS, AW_PAGE_SCALING, led.r, AW_SCALING_MAX); - AW20216_write_register(DRIVER_2_CS, AW_PAGE_SCALING, led.g, AW_SCALING_MAX); - AW20216_write_register(DRIVER_2_CS, AW_PAGE_SCALING, led.b, AW_SCALING_MAX); - } -#endif - } - return true; -} - -bool AW20216_soft_enable(void) { - AW20216_write_register(DRIVER_1_CS, AW_PAGE_FUNCTION, AW_REG_CONFIGURATION, AW_CONFIG_DEFAULT | AW_CHIPEN); -#ifdef DRIVER_2_CS - AW20216_write_register(DRIVER_2_CS, AW_PAGE_FUNCTION, AW_REG_CONFIGURATION, AW_CONFIG_DEFAULT | AW_CHIPEN); -#endif - return true; -} - -void AW20216_update_pwm(int index, uint8_t red, uint8_t green, uint8_t blue) { - aw_led led = g_aw_leds[index]; - if (led.driver == 0) { - AW20216_write_register(DRIVER_1_CS, AW_PAGE_PWM, led.r, red); - AW20216_write_register(DRIVER_1_CS, AW_PAGE_PWM, led.g, green); - AW20216_write_register(DRIVER_1_CS, AW_PAGE_PWM, led.b, blue); - } -#ifdef DRIVER_2_CS - else if (led.driver == 1) { - AW20216_write_register(DRIVER_2_CS, AW_PAGE_PWM, led.r, red); - AW20216_write_register(DRIVER_2_CS, AW_PAGE_PWM, led.g, green); - AW20216_write_register(DRIVER_2_CS, AW_PAGE_PWM, led.b, blue); - } -#endif - return; -} - -void AW20216_init(void) { - // All LEDs should start with all scaling and PWM registers as off - setPinOutput(DRIVER_1_EN); - writePinHigh(DRIVER_1_EN); - AW20216_write_register(DRIVER_1_CS, AW_PAGE_FUNCTION, AW_REG_GLOBALCURRENT, AW_GLOBAL_CURRENT_MAX); -#ifdef DRIVER_2_EN - setPinOutput(DRIVER_2_EN); - writePinHigh(DRIVER_2_EN); - AW20216_write_register(DRIVER_2_CS, AW_PAGE_FUNCTION, AW_REG_GLOBALCURRENT, AW_GLOBAL_CURRENT_MAX); -#endif - AW20216_init_scaling(); - AW20216_soft_enable(); - return; -} - -void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { - g_pwm_buffer[index].r = red; - g_pwm_buffer[index].g = green; - g_pwm_buffer[index].b = blue; - g_pwm_buffer_update_required[index] = true; - return; -} -void AW20216_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { - for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { - AW20216_set_color(i, red, green, blue); - } - return; -} -void AW20216_update_pwm_buffers(void) { - for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { - if (g_pwm_buffer_update_required[i]) { - AW20216_update_pwm(i, g_pwm_buffer[i].r, g_pwm_buffer[i].g, g_pwm_buffer[i].b); - g_pwm_buffer_update_required[i] = false; - } - } - return; -} diff --git a/drivers/awinic/aw20216.h b/drivers/awinic/aw20216.h deleted file mode 100644 index 9c6865cc8248..000000000000 --- a/drivers/awinic/aw20216.h +++ /dev/null @@ -1,251 +0,0 @@ -/* Copyright 2021 Jasper Chan (Gigahawk) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include -#include - -typedef struct aw_led { - uint8_t driver : 2; - uint8_t r; - uint8_t g; - uint8_t b; -} aw_led; - -extern const aw_led g_aw_leds[DRIVER_LED_TOTAL]; - -void AW20216_init(void); -void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); -void AW20216_set_color_all(uint8_t red, uint8_t green, uint8_t blue); -void AW20216_update_pwm_buffers(void); - -#define CS1_SW1 0x00 -#define CS2_SW1 0x01 -#define CS3_SW1 0x02 -#define CS4_SW1 0x03 -#define CS5_SW1 0x04 -#define CS6_SW1 0x05 -#define CS7_SW1 0x06 -#define CS8_SW1 0x07 -#define CS9_SW1 0x08 -#define CS10_SW1 0x09 -#define CS11_SW1 0x0A -#define CS12_SW1 0x0B -#define CS13_SW1 0x0C -#define CS14_SW1 0x0D -#define CS15_SW1 0x0E -#define CS16_SW1 0x0F -#define CS17_SW1 0x10 -#define CS18_SW1 0x11 -#define CS1_SW2 0x12 -#define CS2_SW2 0x13 -#define CS3_SW2 0x14 -#define CS4_SW2 0x15 -#define CS5_SW2 0x16 -#define CS6_SW2 0x17 -#define CS7_SW2 0x18 -#define CS8_SW2 0x19 -#define CS9_SW2 0x1A -#define CS10_SW2 0x1B -#define CS11_SW2 0x1C -#define CS12_SW2 0x1D -#define CS13_SW2 0x1E -#define CS14_SW2 0x1F -#define CS15_SW2 0x20 -#define CS16_SW2 0x21 -#define CS17_SW2 0x22 -#define CS18_SW2 0x23 -#define CS1_SW3 0x24 -#define CS2_SW3 0x25 -#define CS3_SW3 0x26 -#define CS4_SW3 0x27 -#define CS5_SW3 0x28 -#define CS6_SW3 0x29 -#define CS7_SW3 0x2A -#define CS8_SW3 0x2B -#define CS9_SW3 0x2C -#define CS10_SW3 0x2D -#define CS11_SW3 0x2E -#define CS12_SW3 0x2F -#define CS13_SW3 0x30 -#define CS14_SW3 0x31 -#define CS15_SW3 0x32 -#define CS16_SW3 0x33 -#define CS17_SW3 0x34 -#define CS18_SW3 0x35 -#define CS1_SW4 0x36 -#define CS2_SW4 0x37 -#define CS3_SW4 0x38 -#define CS4_SW4 0x39 -#define CS5_SW4 0x3A -#define CS6_SW4 0x3B -#define CS7_SW4 0x3C -#define CS8_SW4 0x3D -#define CS9_SW4 0x3E -#define CS10_SW4 0x3F -#define CS11_SW4 0x40 -#define CS12_SW4 0x41 -#define CS13_SW4 0x42 -#define CS14_SW4 0x43 -#define CS15_SW4 0x44 -#define CS16_SW4 0x45 -#define CS17_SW4 0x46 -#define CS18_SW4 0x47 -#define CS1_SW5 0x48 -#define CS2_SW5 0x49 -#define CS3_SW5 0x4A -#define CS4_SW5 0x4B -#define CS5_SW5 0x4C -#define CS6_SW5 0x4D -#define CS7_SW5 0x4E -#define CS8_SW5 0x4F -#define CS9_SW5 0x50 -#define CS10_SW5 0x51 -#define CS11_SW5 0x52 -#define CS12_SW5 0x53 -#define CS13_SW5 0x54 -#define CS14_SW5 0x55 -#define CS15_SW5 0x56 -#define CS16_SW5 0x57 -#define CS17_SW5 0x58 -#define CS18_SW5 0x59 -#define CS1_SW6 0x5A -#define CS2_SW6 0x5B -#define CS3_SW6 0x5C -#define CS4_SW6 0x5D -#define CS5_SW6 0x5E -#define CS6_SW6 0x5F -#define CS7_SW6 0x60 -#define CS8_SW6 0x61 -#define CS9_SW6 0x62 -#define CS10_SW6 0x63 -#define CS11_SW6 0x64 -#define CS12_SW6 0x65 -#define CS13_SW6 0x66 -#define CS14_SW6 0x67 -#define CS15_SW6 0x68 -#define CS16_SW6 0x69 -#define CS17_SW6 0x6A -#define CS18_SW6 0x6B -#define CS1_SW7 0x6C -#define CS2_SW7 0x6D -#define CS3_SW7 0x6E -#define CS4_SW7 0x6F -#define CS5_SW7 0x70 -#define CS6_SW7 0x71 -#define CS7_SW7 0x72 -#define CS8_SW7 0x73 -#define CS9_SW7 0x74 -#define CS10_SW7 0x75 -#define CS11_SW7 0x76 -#define CS12_SW7 0x77 -#define CS13_SW7 0x78 -#define CS14_SW7 0x79 -#define CS15_SW7 0x7A -#define CS16_SW7 0x7B -#define CS17_SW7 0x7C -#define CS18_SW7 0x7D -#define CS1_SW8 0x7E -#define CS2_SW8 0x7F -#define CS3_SW8 0x80 -#define CS4_SW8 0x81 -#define CS5_SW8 0x82 -#define CS6_SW8 0x83 -#define CS7_SW8 0x84 -#define CS8_SW8 0x85 -#define CS9_SW8 0x86 -#define CS10_SW8 0x87 -#define CS11_SW8 0x88 -#define CS12_SW8 0x89 -#define CS13_SW8 0x8A -#define CS14_SW8 0x8B -#define CS15_SW8 0x8C -#define CS16_SW8 0x8D -#define CS17_SW8 0x8E -#define CS18_SW8 0x8F -#define CS1_SW9 0x90 -#define CS2_SW9 0x91 -#define CS3_SW9 0x92 -#define CS4_SW9 0x93 -#define CS5_SW9 0x94 -#define CS6_SW9 0x95 -#define CS7_SW9 0x96 -#define CS8_SW9 0x97 -#define CS9_SW9 0x98 -#define CS10_SW9 0x99 -#define CS11_SW9 0x9A -#define CS12_SW9 0x9B -#define CS13_SW9 0x9C -#define CS14_SW9 0x9D -#define CS15_SW9 0x9E -#define CS16_SW9 0x9F -#define CS17_SW9 0xA0 -#define CS18_SW9 0xA1 -#define CS1_SW10 0xA2 -#define CS2_SW10 0xA3 -#define CS3_SW10 0xA4 -#define CS4_SW10 0xA5 -#define CS5_SW10 0xA6 -#define CS6_SW10 0xA7 -#define CS7_SW10 0xA8 -#define CS8_SW10 0xA9 -#define CS9_SW10 0xAA -#define CS10_SW10 0xAB -#define CS11_SW10 0xAC -#define CS12_SW10 0xAD -#define CS13_SW10 0xAE -#define CS14_SW10 0xAF -#define CS15_SW10 0xB0 -#define CS16_SW10 0xB1 -#define CS17_SW10 0xB2 -#define CS18_SW10 0xB3 -#define CS1_SW11 0xB4 -#define CS2_SW11 0xB5 -#define CS3_SW11 0xB6 -#define CS4_SW11 0xB7 -#define CS5_SW11 0xB8 -#define CS6_SW11 0xB9 -#define CS7_SW11 0xBA -#define CS8_SW11 0xBB -#define CS9_SW11 0xBC -#define CS10_SW11 0xBD -#define CS11_SW11 0xBE -#define CS12_SW11 0xBF -#define CS13_SW11 0xC0 -#define CS14_SW11 0xC1 -#define CS15_SW11 0xC2 -#define CS16_SW11 0xC3 -#define CS17_SW11 0xC4 -#define CS18_SW11 0xC5 -#define CS1_SW12 0xC6 -#define CS2_SW12 0xC7 -#define CS3_SW12 0xC8 -#define CS4_SW12 0xC9 -#define CS5_SW12 0xCA -#define CS6_SW12 0xCB -#define CS7_SW12 0xCC -#define CS8_SW12 0xCD -#define CS9_SW12 0xCE -#define CS10_SW12 0xCF -#define CS11_SW12 0xD0 -#define CS12_SW12 0xD1 -#define CS13_SW12 0xD2 -#define CS14_SW12 0xD3 -#define CS15_SW12 0xD4 -#define CS16_SW12 0xD5 -#define CS17_SW12 0xD6 -#define CS18_SW12 0xD7 diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 82ab0418129a..69b19bebaa58 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -33,8 +33,6 @@ # include "is31fl3737.h" #elif defined(IS31FL3741) # include "is31fl3741.h" -#elif defined(AW20216) -# include "aw20216.h" #elif defined(WS2812) # include "ws2812.h" #elif defined(AW20216S) diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 18fef3d047c4..754921c72c85 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -171,22 +171,6 @@ const rgb_matrix_driver_t rgb_matrix_driver = { }; # endif -#elif defined(AW20216) -# include "spi_master.h" -static void init(void) { - spi_init(); - AW20216_init(); -} - -static void flush(void) { AW20216_update_pwm_buffers(); } - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = AW20216_set_color, - .set_color_all = AW20216_set_color_all, -}; - #elif defined(WS2812) # if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_CUSTOM_DRIVER) # pragma message "Cannot use RGBLIGHT and RGB Matrix using WS2812 at the same time." From b71ea5720fb8a989dac5ebed2de1279ef3aa5025 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Thu, 1 Jul 2021 00:02:23 +0200 Subject: [PATCH 07/12] Hard reset from develop and added Glorious-gmmk stuff --- common_features.mk | 9 +- drivers/awinic/aw20216s.c | 136 +++++++ drivers/awinic/aw20216s.h | 273 ++++++++++++++ keyboards/gmmk/pro/config.h | 36 +- keyboards/gmmk/pro/halconf.h | 1 - keyboards/gmmk/pro/keymaps/default/keymap.c | 14 +- keyboards/gmmk/pro/pro.c | 382 +++++++++----------- keyboards/gmmk/pro/rules.mk | 3 +- quantum/quantum.h | 4 +- quantum/rgb_matrix/rgb_matrix.h | 4 +- quantum/rgb_matrix/rgb_matrix_drivers.c | 32 ++ 11 files changed, 652 insertions(+), 242 deletions(-) create mode 100644 drivers/awinic/aw20216s.c create mode 100644 drivers/awinic/aw20216s.h diff --git a/common_features.mk b/common_features.mk index f7bdedf2ff17..0f578a26cf43 100644 --- a/common_features.mk +++ b/common_features.mk @@ -248,7 +248,7 @@ endif endif RGB_MATRIX_ENABLE ?= no -VALID_RGB_MATRIX_TYPES := AW20216 IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 WS2812 custom +VALID_RGB_MATRIX_TYPES := AW20216 IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 WS2812 AW20216S custom ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),) @@ -311,6 +311,13 @@ endif WS2812_DRIVER_REQUIRED := yes endif + ifeq ($(strip $(RGB_MATRIX_DRIVER)), AW20216S) + OPT_DEFS += -DAW20216S -DSTM32_SPI -DHAL_USE_SPI=TRUE + COMMON_VPATH += $(DRIVER_PATH)/awinic + SRC += aw20216s.c + QUANTUM_LIB_SRC += spi_master.c + endif + ifeq ($(strip $(RGB_MATRIX_DRIVER)), APA102) OPT_DEFS += -DAPA102 APA102_DRIVER_REQUIRED := yes diff --git a/drivers/awinic/aw20216s.c b/drivers/awinic/aw20216s.c new file mode 100644 index 000000000000..a288fd0a91e4 --- /dev/null +++ b/drivers/awinic/aw20216s.c @@ -0,0 +1,136 @@ +/* Copyright 2017 Jason Williams + * Copyright 2018 Jack Humbert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "quantum.h" +#include "spi_master.h" +#include "aw20216s.h" +#include +#include + +#define COMMAND_CHIP_ID 0xA0 +#define US_POR_DELAY 5000 // Min is 2000 us +#define US_ENABLE_DELAY 500 // Min is 100 us +#define PAGE_0 0 +#define PAGE_1 1 +#define PAGE_2 2 +#define PAGE_3 3 +#define PAGE_0_REG_GCR 0x00 +#define REG_GCR_BIT_CHIPEN_MASK 0x01 +#define PAGE_0_REG_GCCR 0x01 +#define US_BETWEEN_REG_WRITE_DELAY 100 +#define PWM_REGISTER_COUNT 216 + +#define SPI_CLOCK_SPEED 2000000 +#define SPI_MODE 3 +//#define SPI_DIVISOR (F_CPU / SPI_CLOCK_SPEED) +#define SPI_DIVISOR 4 // around 8 MHz (smooth transitions) + +// These buffers match the AW20216S PWM registers 0x00-0xD7. +uint8_t g_pwm_buffer[DRIVER_COUNT][PWM_REGISTER_COUNT]; +bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false}; + +void AW20216S_spi_start(int32_t csPin) { spi_start(csPin, false, SPI_MODE, SPI_DIVISOR); } + +void AW20216S_write_register(int32_t csPin, uint8_t page, uint8_t reg, uint8_t data) { + uint8_t cmd = COMMAND_CHIP_ID | ((page & 0x07) << 1); + + AW20216S_spi_start(csPin); + spi_write(cmd); + spi_write(reg); + spi_write(data); + spi_stop(); +} + +void AW20216S_write_pwm_buffer(int32_t csPin, uint8_t *pwm_buffer) { + uint8_t cmd = COMMAND_CHIP_ID | (PAGE_1 << 1); + + AW20216S_spi_start(csPin); + spi_write(cmd); + spi_write(0); + + for (int i = 0; i < PWM_REGISTER_COUNT; i++) { + spi_write(pwm_buffer[i]); + } + + spi_stop(); +} + +void AW20216S_enable(int32_t csPin, int32_t enablePin) { + // Configure chip select pin as output and set high level. + palSetLineMode(csPin, PAL_MODE_OUTPUT_PUSHPULL); + palSetLine(csPin); + + // Delay for POR to complete + wait_us(US_POR_DELAY); + + // Configure enable pin as output and set high level. + palSetLineMode(enablePin, PAL_MODE_OUTPUT_PUSHPULL); + palSetLine(enablePin); + + // Delay for enable to complete + wait_us(US_ENABLE_DELAY); +} + +void AW20216S_init(int32_t csPin, uint8_t swLinesEnabled) { + // Enable SW lines and chip + uint8_t valueGCR = (swLinesEnabled << 4) | REG_GCR_BIT_CHIPEN_MASK; + AW20216S_write_register(csPin, PAGE_0, PAGE_0_REG_GCR, valueGCR); + + wait_us(US_BETWEEN_REG_WRITE_DELAY); + + // Maximum sink current + uint8_t valueGCCR = RGB_MATRIX_MAXIMUM_BRIGHTNESS; + AW20216S_write_register(csPin, PAGE_0, PAGE_0_REG_GCCR, valueGCCR); + + wait_us(US_BETWEEN_REG_WRITE_DELAY); + + // Set Constant Current for LEDs (Registers SL) + for (uint8_t i = 0; i < PWM_REGISTER_COUNT; i++) { + AW20216S_write_register(csPin, PAGE_2, i, 0xFF); + wait_us(US_BETWEEN_REG_WRITE_DELAY); + } + + // Turn off all LEDs (Registers PWM) + for (uint8_t i = 0; i < PWM_REGISTER_COUNT; i++) { + AW20216S_write_register(csPin, PAGE_1, i, 0x00); + wait_us(US_BETWEEN_REG_WRITE_DELAY); + } +} + +void AW20216S_set_color(int indexLED, uint8_t red, uint8_t green, uint8_t blue) { + if (indexLED >= 0 && indexLED < DRIVER_LED_TOTAL) { + aw_led led = g_aw_leds[indexLED]; + + g_pwm_buffer[led.driver][led.r] = red; + g_pwm_buffer[led.driver][led.g] = green; + g_pwm_buffer[led.driver][led.b] = blue; + g_pwm_buffer_update_required[led.driver] = true; + } +} + +void AW20216S_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { + for (int i = 0; i < DRIVER_LED_TOTAL; i++) { + AW20216S_set_color(i, red, green, blue); + } +} + +void AW20216S_update_pwm_buffers(int32_t csPin, uint8_t driver) { + if (g_pwm_buffer_update_required[driver]) { + AW20216S_write_pwm_buffer(csPin, g_pwm_buffer[driver]); + } + g_pwm_buffer_update_required[driver] = false; +} diff --git a/drivers/awinic/aw20216s.h b/drivers/awinic/aw20216s.h new file mode 100644 index 000000000000..1ab3958b4790 --- /dev/null +++ b/drivers/awinic/aw20216s.h @@ -0,0 +1,273 @@ +/* Copyright 2017 Jason Williams + * Copyright 2018 Jack Humbert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include +#include + +typedef struct ag_led { + uint8_t driver : 2; + uint8_t r; + uint8_t g; + uint8_t b; +} __attribute__((packed)) aw_led; + +#define SW_LINES_ENABLED_1_TO_1 0x0 +#define SW_LINES_ENABLED_1_TO_2 0x1 +#define SW_LINES_ENABLED_1_TO_3 0x2 +#define SW_LINES_ENABLED_1_TO_4 0x3 +#define SW_LINES_ENABLED_1_TO_5 0x4 +#define SW_LINES_ENABLED_1_TO_6 0x5 +#define SW_LINES_ENABLED_1_TO_7 0x6 +#define SW_LINES_ENABLED_1_TO_8 0x7 +#define SW_LINES_ENABLED_1_TO_9 0x8 +#define SW_LINES_ENABLED_1_TO_10 0x9 +#define SW_LINES_ENABLED_1_TO_11 0xA +#define SW_LINES_ENABLED_1_TO_12 0xB + +extern const aw_led g_aw_leds[DRIVER_LED_TOTAL]; + +void AW20216S_enable(int32_t csPin, int32_t enablePin); +void AW20216S_init(int32_t csPin, uint8_t swLinesEnabled); +void AW20216S_set_color(int indexLED, uint8_t red, uint8_t green, uint8_t blue); +void AW20216S_set_color_all(uint8_t red, uint8_t green, uint8_t blue); +void AW20216S_write_register(int32_t csPin, uint8_t page, uint8_t reg, uint8_t data); +void AW20216S_write_pwm_buffer(int32_t csPin, uint8_t *pwm_buffer); + +// This should not be called from an interrupt +// (eg. from a timer interrupt). +// Call this while idle (in between matrix scans). +// If the buffer is dirty, it will update the driver with the buffer. +void AW20216S_update_pwm_buffers(int32_t csPin, uint8_t driver); + +#define CS1_SW1 0 +#define CS2_SW1 1 +#define CS3_SW1 2 +#define CS4_SW1 3 +#define CS5_SW1 4 +#define CS6_SW1 5 +#define CS7_SW1 6 +#define CS8_SW1 7 +#define CS9_SW1 8 +#define CS10_SW1 9 +#define CS11_SW1 10 +#define CS12_SW1 11 +#define CS13_SW1 12 +#define CS14_SW1 13 +#define CS15_SW1 14 +#define CS16_SW1 15 +#define CS17_SW1 16 +#define CS18_SW1 17 +#define CS1_SW2 18 +#define CS2_SW2 19 +#define CS3_SW2 20 +#define CS4_SW2 21 +#define CS5_SW2 22 +#define CS6_SW2 23 +#define CS7_SW2 24 +#define CS8_SW2 25 +#define CS9_SW2 26 +#define CS10_SW2 27 +#define CS11_SW2 28 +#define CS12_SW2 29 +#define CS13_SW2 30 +#define CS14_SW2 31 +#define CS15_SW2 32 +#define CS16_SW2 33 +#define CS17_SW2 34 +#define CS18_SW2 35 +#define CS1_SW3 36 +#define CS2_SW3 37 +#define CS3_SW3 38 +#define CS4_SW3 39 +#define CS5_SW3 40 +#define CS6_SW3 41 +#define CS7_SW3 42 +#define CS8_SW3 43 +#define CS9_SW3 44 +#define CS10_SW3 45 +#define CS11_SW3 46 +#define CS12_SW3 47 +#define CS13_SW3 48 +#define CS14_SW3 49 +#define CS15_SW3 50 +#define CS16_SW3 51 +#define CS17_SW3 52 +#define CS18_SW3 53 +#define CS1_SW4 54 +#define CS2_SW4 55 +#define CS3_SW4 56 +#define CS4_SW4 57 +#define CS5_SW4 58 +#define CS6_SW4 59 +#define CS7_SW4 60 +#define CS8_SW4 61 +#define CS9_SW4 62 +#define CS10_SW4 63 +#define CS11_SW4 64 +#define CS12_SW4 65 +#define CS13_SW4 66 +#define CS14_SW4 67 +#define CS15_SW4 68 +#define CS16_SW4 69 +#define CS17_SW4 70 +#define CS18_SW4 71 +#define CS1_SW5 72 +#define CS2_SW5 73 +#define CS3_SW5 74 +#define CS4_SW5 75 +#define CS5_SW5 76 +#define CS6_SW5 77 +#define CS7_SW5 78 +#define CS8_SW5 79 +#define CS9_SW5 80 +#define CS10_SW5 81 +#define CS11_SW5 82 +#define CS12_SW5 83 +#define CS13_SW5 84 +#define CS14_SW5 85 +#define CS15_SW5 86 +#define CS16_SW5 87 +#define CS17_SW5 88 +#define CS18_SW5 89 +#define CS1_SW6 90 +#define CS2_SW6 91 +#define CS3_SW6 92 +#define CS4_SW6 93 +#define CS5_SW6 94 +#define CS6_SW6 95 +#define CS7_SW6 96 +#define CS8_SW6 97 +#define CS9_SW6 98 +#define CS10_SW6 99 +#define CS11_SW6 100 +#define CS12_SW6 101 +#define CS13_SW6 102 +#define CS14_SW6 103 +#define CS15_SW6 104 +#define CS16_SW6 105 +#define CS17_SW6 106 +#define CS18_SW6 107 +#define CS1_SW7 108 +#define CS2_SW7 109 +#define CS3_SW7 110 +#define CS4_SW7 111 +#define CS5_SW7 112 +#define CS6_SW7 113 +#define CS7_SW7 114 +#define CS8_SW7 115 +#define CS9_SW7 116 +#define CS10_SW7 117 +#define CS11_SW7 118 +#define CS12_SW7 119 +#define CS13_SW7 120 +#define CS14_SW7 121 +#define CS15_SW7 122 +#define CS16_SW7 123 +#define CS17_SW7 124 +#define CS18_SW7 125 +#define CS1_SW8 126 +#define CS2_SW8 127 +#define CS3_SW8 128 +#define CS4_SW8 129 +#define CS5_SW8 130 +#define CS6_SW8 131 +#define CS7_SW8 132 +#define CS8_SW8 133 +#define CS9_SW8 134 +#define CS10_SW8 135 +#define CS11_SW8 136 +#define CS12_SW8 137 +#define CS13_SW8 138 +#define CS14_SW8 139 +#define CS15_SW8 140 +#define CS16_SW8 141 +#define CS17_SW8 142 +#define CS18_SW8 143 +#define CS1_SW9 144 +#define CS2_SW9 145 +#define CS3_SW9 146 +#define CS4_SW9 147 +#define CS5_SW9 148 +#define CS6_SW9 149 +#define CS7_SW9 150 +#define CS8_SW9 151 +#define CS9_SW9 152 +#define CS10_SW9 153 +#define CS11_SW9 154 +#define CS12_SW9 155 +#define CS13_SW9 156 +#define CS14_SW9 157 +#define CS15_SW9 158 +#define CS16_SW9 159 +#define CS17_SW9 160 +#define CS18_SW9 161 +#define CS1_SW10 162 +#define CS2_SW10 163 +#define CS3_SW10 164 +#define CS4_SW10 165 +#define CS5_SW10 166 +#define CS6_SW10 167 +#define CS7_SW10 168 +#define CS8_SW10 169 +#define CS9_SW10 170 +#define CS10_SW10 171 +#define CS11_SW10 172 +#define CS12_SW10 173 +#define CS13_SW10 174 +#define CS14_SW10 175 +#define CS15_SW10 176 +#define CS16_SW10 177 +#define CS17_SW10 178 +#define CS18_SW10 179 +#define CS1_SW11 180 +#define CS2_SW11 181 +#define CS3_SW11 182 +#define CS4_SW11 183 +#define CS5_SW11 184 +#define CS6_SW11 185 +#define CS7_SW11 186 +#define CS8_SW11 187 +#define CS9_SW11 188 +#define CS10_SW11 189 +#define CS11_SW11 190 +#define CS12_SW11 191 +#define CS13_SW11 192 +#define CS14_SW11 193 +#define CS15_SW11 194 +#define CS16_SW11 195 +#define CS17_SW11 196 +#define CS18_SW11 197 +#define CS1_SW12 198 +#define CS2_SW12 199 +#define CS3_SW12 200 +#define CS4_SW12 201 +#define CS5_SW12 202 +#define CS6_SW12 203 +#define CS7_SW12 204 +#define CS8_SW12 205 +#define CS9_SW12 206 +#define CS10_SW12 207 +#define CS11_SW12 208 +#define CS12_SW12 209 +#define CS13_SW12 210 +#define CS14_SW12 211 +#define CS15_SW12 212 +#define CS16_SW12 213 +#define CS17_SW12 214 +#define CS18_SW12 215 diff --git a/keyboards/gmmk/pro/config.h b/keyboards/gmmk/pro/config.h index 64062beceaff..506cc1e1650e 100644 --- a/keyboards/gmmk/pro/config.h +++ b/keyboards/gmmk/pro/config.h @@ -19,18 +19,20 @@ #include "config_common.h" /* USB Device descriptor parameter */ -#define DEVICE_VER 0x0001 -#define VENDOR_ID 0x320F -#define PRODUCT_ID 0x5044 -#define MANUFACTURER Glorious -#define PRODUCT GMMK Pro +#define DEVICE_VER 0x0001 +#define VENDOR_ID 0x320F +#define PRODUCT_ID 0x5044 +#define MANUFACTURER Glorious +#define PRODUCT GMMK Pro /* key matrix size */ #define MATRIX_ROWS 11 #define MATRIX_COLS 8 -#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10 } -#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A8, A9, A10 } +#define MATRIX_ROW_PINS \ + { B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10 } +#define MATRIX_COL_PINS \ + { A0, A1, A2, A3, A4, A8, A9, A10 } /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -39,27 +41,33 @@ #define BOOTMAGIC_LITE_COLUMN 3 #define TAP_CODE_DELAY 10 -#define ENCODERS_PAD_A { C15 } -#define ENCODERS_PAD_B { C14 } +#define ENCODERS_PAD_A \ + { C15 } +#define ENCODERS_PAD_B \ + { C14 } /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE +#define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 +#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_12 /* SPI Config for LED Driver */ #define SPI_DRIVER SPID1 #define SPI_SCK_PIN A5 #define SPI_MOSI_PIN A6 #define SPI_MISO_PIN A7 -#define DRIVER_1_CS B13 -#define DRIVER_2_CS B14 -#define DRIVER_1_EN C13 -#define DRIVER_2_EN C13 +#define SPI_SS_DRIVER_1_PIN B13 +#define SPI_SS_DRIVER_2_PIN B14 +#define ENABLE_DRIVERS_PIN C13 +#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175 + +#define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 +#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_12 #define DRIVER_COUNT 2 #define DRIVER_1_LED_TOTAL 66 #define DRIVER_2_LED_TOTAL 32 #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) - diff --git a/keyboards/gmmk/pro/halconf.h b/keyboards/gmmk/pro/halconf.h index 23ecb202a1d1..a172bf0c9ac6 100644 --- a/keyboards/gmmk/pro/halconf.h +++ b/keyboards/gmmk/pro/halconf.h @@ -3,5 +3,4 @@ #define HAL_USE_SPI TRUE #define SPI_USE_WAIT TRUE #define SPI_SELECT_MODE SPI_SELECT_MODE_PAD - #include_next diff --git a/keyboards/gmmk/pro/keymaps/default/keymap.c b/keyboards/gmmk/pro/keymaps/default/keymap.c index b08400cd8dc3..2c4decb86248 100644 --- a/keyboards/gmmk/pro/keymaps/default/keymap.c +++ b/keyboards/gmmk/pro/keymaps/default/keymap.c @@ -43,19 +43,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [1] = LAYOUT( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + _______, KC_MYCM, KC_WHOM, KC_CALC, KC_MSEL, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______, + _______, RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, RGB_VAI, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, _______, + _______, _______, RGB_VAD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, RGB_HUI, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_MOD, _______, + _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_RMOD, RGB_SPI ), }; - bool encoder_update_user(uint8_t index, bool clockwise) { + if (clockwise) { tap_code(KC_VOLU); } else { diff --git a/keyboards/gmmk/pro/pro.c b/keyboards/gmmk/pro/pro.c index 9ed7ac8865a8..27ac97a3b5d7 100644 --- a/keyboards/gmmk/pro/pro.c +++ b/keyboards/gmmk/pro/pro.c @@ -16,223 +16,175 @@ #include "pro.h" #ifdef RGB_MATRIX_ENABLE -led_config_t g_led_config = { { - { 4, NO_LED, NO_LED, 95, 65, 79, 5, 28 }, - { 8, 2, 9, 0, 10, 75, 1, 7 }, - { 14, 3, 15, NO_LED, 16, 86, 6, 13 }, - { 20, 18, 21, 23, 22, 94, 12, 19 }, - { 25, 30, 26, 31, 27, 32, 29, 24 }, - { 41, 36, 42, 37, 43, 38, 35, 40 }, - { 46, 89, 47, 34, 48, 72, 78, 45 }, - { 52, 39, 53, 97, 54, 82, 44, 51 }, - { 58, 63, 59, 64, NO_LED, 60, 62, 57 }, - { 11, 90, 55, 17, 33, 49, NO_LED, 69 }, - { NO_LED, 85, 93, 61, 96, 66, 50, 56 } -}, { - { 0, 0 }, // 0, ESC, k13 - { 0, 15 }, // 1, ~, k16 - { 4, 26 }, // 2, Tab, k11 - { 5, 38 }, // 3, Caps, k21 - { 9, 49 }, // 4, Sh_L, k00 - { 2, 61 }, // 5, Ct_L, k06 - { 18, 0 }, // 6, F1, k26 - { 14, 15 }, // 7, 1, k17 - { 22, 26 }, // 8, Q, k10 - { 25, 38 }, // 9, A, k12 - { 33, 49 }, // 10, Z, k14 - { 20, 61 }, // 11, Win_L, k90 - { 33, 0 }, // 12, F2, k36 - { 29, 15 }, // 13, 2, k27 - { 36, 26 }, // 14, W, k20 - { 40, 38 }, // 15, S, k22 - { 47, 49 }, // 16, X, k24 - { 38, 61 }, // 17, Alt_L, k93 - { 47, 0 }, // 18, F3, k31 - { 43, 15 }, // 19, 3, k37 - { 51, 26 }, // 20, E, k30 - { 54, 38 }, // 21, D, k32 - { 61, 49 }, // 22, C, k34 - { 61, 0 }, // 23, F4, k33 - { 58, 15 }, // 24, 4, k47 - { 65, 26 }, // 25, R, k40 - { 69, 38 }, // 26, F, k42 - { 76, 49 }, // 27, V, k44 - { 79, 0 }, // 28, F5, k07 - { 72, 15 }, // 29, 5, k46 - { 79, 26 }, // 30, T, k41 - { 83, 38 }, // 31, G, k43 - { 90, 49 }, // 32, B, k45 - { 92, 61 }, // 33, SPACE, k94 - { 94, 0 }, // 34, F6, k63 - { 87, 15 }, // 35, 6, k56 - { 94, 26 }, // 36, Y, k51 - { 98, 38 }, // 37, H, k53 - { 105, 49 }, // 38, N, k55 - { 108, 0 }, // 39, F7, k71 - { 101, 15 }, // 40, 7, k57 - { 108, 26 }, // 41, U, k50 - { 112, 38 }, // 42, J, k52 - { 119, 49 }, // 43, M, k54 - { 123, 0 }, // 44, F8, k76 - { 116, 15 }, // 45, 8, k67 - { 123, 26 }, // 46, I, k60 - { 126, 38 }, // 47, K, k62 - { 134, 49 }, // 48, ,, k64 - { 145, 61 }, // 49, Alt_R, k95 - { 141, 0 }, // 50, F9, ka6 - { 130, 15 }, // 51, 9, k77 - { 137, 26 }, // 52, O, k70 - { 141, 38 }, // 53, L, k72 - { 148, 49 }, // 54, ., k74 - { 159, 61 }, // 55, FN, k92 - { 155, 0 }, // 56, F10, ka7 - { 145, 15 }, // 57, 0, k87 - { 152, 26 }, // 58, P, k80 - { 155, 38 }, // 59, ;, k82 - { 163, 49 }, // 60, ?, k85 - { 170, 0 }, // 61, F11, ka3 - { 159, 15 }, // 62, -, k86 - { 166, 26 }, // 63, [, k81 - { 170, 38 }, // 64, ", k83 - { 173, 61 }, // 65, Ct_R, k04 - { 184, 0 }, // 66, F12, ka5 - { 0, 8 }, // 67, LED, l01 - { 224, 8 }, // 68, LED, l11 - { 202, 0 }, // 69, Prt, k97 - { 0, 15 }, // 70, LED, l02 - { 224, 15 }, // 71, LED, l12 - { 224, 15 }, // 72, Del, k65 - { 0, 21 }, // 73, LED, l03 - { 224, 21 }, // 74, LED, l13 - { 224, 26 }, // 75, PgUp, k15 - { 0, 28 }, // 76, LED, l04 - { 224, 28 }, // 77, LED, l14 - { 173, 15 }, // 78, =, k66 - { 220, 64 }, // 79, Right, k05 - { 0, 35 }, // 80, LED, l05 - { 224, 35 }, // 81, LED, l15 - { 224, 49 }, // 82, End, k75 - { 0, 42 }, // 83, LED, l06 - { 224, 42 }, // 84, LED, l16 - { 195, 15 }, // 85, BSpc, ka1 - { 224, 38 }, // 86, PgDn, k25 - { 0, 48 }, // 87, LED, l07 - { 224, 48 }, // 88, LED, l17 - { 181, 26 }, // 89, ], k61 - { 182, 49 }, // 90, Sh_R, k91 - { 0, 55 }, // 91, LED, l08 - { 224, 55 }, // 92, LED, l18 - { 199, 26 }, // 93, \, ka2 - { 206, 52 }, // 94, Up, k35 - { 191, 64 }, // 95, Left, k03 - { 193, 38 }, // 96, Enter, ka4 - { 206, 64 } // 97, Down, k73 -}, { - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 2, 2, 4, 2, 2, - 4, 2, 2, 4, 4, 2, 2, 4, 2, 2, 4, 4, 2, 2, 4, 4, 2, 2, 4, 4, 4, 4, 4 -} }; const aw_led g_aw_leds[DRIVER_LED_TOTAL] = { - { 0, CS1_SW1, CS2_SW1, CS3_SW1 }, // 0, ESC, k13 - { 0, CS4_SW1, CS5_SW1, CS6_SW1 }, // 1, ~, k16 - { 0, CS7_SW1, CS8_SW1, CS9_SW1 }, // 2, Tab, k11 - { 0, CS10_SW1, CS11_SW1, CS12_SW1 }, // 3, Caps, k21 - { 0, CS13_SW1, CS14_SW1, CS15_SW1 }, // 4, Sh_L, k00 - { 0, CS16_SW1, CS17_SW1, CS18_SW1 }, // 5, Ct_L, k06 - { 0, CS1_SW2, CS2_SW2, CS3_SW2 }, // 6, F1, k26 - { 0, CS4_SW2, CS5_SW2, CS6_SW2 }, // 7, 1, k17 - { 0, CS7_SW2, CS8_SW2, CS9_SW2 }, // 8, Q, k10 - { 0, CS10_SW2, CS11_SW2, CS12_SW2 }, // 9, A, k12 - { 0, CS13_SW2, CS14_SW2, CS15_SW2 }, // 10, Z, k14 - { 0, CS16_SW2, CS17_SW2, CS18_SW2 }, // 11, Win_L, k90 - { 0, CS1_SW3, CS2_SW3, CS3_SW3 }, // 12, F2, k36 - { 0, CS4_SW3, CS5_SW3, CS6_SW3 }, // 13, 2, k27 - { 0, CS7_SW3, CS8_SW3, CS9_SW3 }, // 14, W, k20 - { 0, CS10_SW3, CS11_SW3, CS12_SW3 }, // 15, S, k22 - { 0, CS13_SW3, CS14_SW3, CS15_SW3 }, // 16, X, k24 - { 0, CS16_SW3, CS17_SW3, CS18_SW3 }, // 17, Alt_L, k93 - { 0, CS1_SW4, CS2_SW4, CS3_SW4 }, // 18, F3, k31 - { 0, CS4_SW4, CS5_SW4, CS6_SW4 }, // 19, 3, k37 - { 0, CS7_SW4, CS8_SW4, CS9_SW4 }, // 20, E, k30 - { 0, CS10_SW4, CS11_SW4, CS12_SW4 }, // 21, D, k32 - { 0, CS13_SW4, CS14_SW4, CS15_SW4 }, // 22, C, k34 - { 0, CS1_SW5, CS2_SW5, CS3_SW5 }, // 23, F4, k33 - { 0, CS4_SW5, CS5_SW5, CS6_SW5 }, // 24, 4, k47 - { 0, CS7_SW5, CS8_SW5, CS9_SW5 }, // 25, R, k40 - { 0, CS10_SW5, CS11_SW5, CS12_SW5 }, // 26, F, k42 - { 0, CS13_SW5, CS14_SW5, CS15_SW5 }, // 27, V, k44 - { 0, CS1_SW6, CS2_SW6, CS3_SW6 }, // 28, F5, k07 - { 0, CS4_SW6, CS5_SW6, CS6_SW6 }, // 29, 5, k46 - { 0, CS7_SW6, CS8_SW6, CS9_SW6 }, // 30, T, k41 - { 0, CS10_SW6, CS11_SW6, CS12_SW6 }, // 31, G, k43 - { 0, CS13_SW6, CS14_SW6, CS15_SW6 }, // 32, B, k45 - { 0, CS16_SW6, CS17_SW6, CS18_SW6 }, // 33, SPACE, k94 - { 0, CS1_SW7, CS2_SW7, CS3_SW7 }, // 34, F6, k63 - { 0, CS4_SW7, CS5_SW7, CS6_SW7 }, // 35, 6, k56 - { 0, CS7_SW7, CS8_SW7, CS9_SW7 }, // 36, Y, k51 - { 0, CS10_SW7, CS11_SW7, CS12_SW7 }, // 37, H, k53 - { 0, CS13_SW7, CS14_SW7, CS15_SW7 }, // 38, N, k55 - { 0, CS1_SW8, CS2_SW8, CS3_SW8 }, // 39, F7, k71 - { 0, CS4_SW8, CS5_SW8, CS6_SW8 }, // 40, 7, k57 - { 0, CS7_SW8, CS8_SW8, CS9_SW8 }, // 41, U, k50 - { 0, CS10_SW8, CS11_SW8, CS12_SW8 }, // 42, J, k52 - { 0, CS13_SW8, CS14_SW8, CS15_SW8 }, // 43, M, k54 - { 0, CS1_SW9, CS2_SW9, CS3_SW9 }, // 44, F8, k76 - { 0, CS4_SW9, CS5_SW9, CS6_SW9 }, // 45, 8, k67 - { 0, CS7_SW9, CS8_SW9, CS9_SW9 }, // 46, I, k60 - { 0, CS10_SW9, CS11_SW9, CS12_SW9 }, // 47, K, k62 - { 0, CS13_SW9, CS14_SW9, CS15_SW9 }, // 48, ,, k64 - { 0, CS16_SW9, CS17_SW9, CS18_SW9 }, // 49, Alt_R, k95 - { 0, CS1_SW10, CS2_SW10, CS3_SW10 }, // 50, F9, ka6 - { 0, CS4_SW10, CS5_SW10, CS6_SW10 }, // 51, 9, k77 - { 0, CS7_SW10, CS8_SW10, CS9_SW10 }, // 52, O, k70 - { 0, CS10_SW10, CS11_SW10, CS12_SW10 }, // 53, L, k72 - { 0, CS13_SW10, CS14_SW10, CS15_SW10 }, // 54, ., k74 - { 0, CS16_SW10, CS17_SW10, CS18_SW10 }, // 55, FN, k92 - { 0, CS1_SW11, CS2_SW11, CS3_SW11 }, // 56, F10, ka7 - { 0, CS4_SW11, CS5_SW11, CS6_SW11 }, // 57, 0, k87 - { 0, CS7_SW11, CS8_SW11, CS9_SW11 }, // 58, P, k80 - { 0, CS10_SW11, CS11_SW11, CS12_SW11 }, // 59, ;, k82 - { 0, CS13_SW11, CS14_SW11, CS15_SW11 }, // 60, ?, k85 - { 0, CS1_SW12, CS2_SW12, CS3_SW12 }, // 61, F11, ka3 - { 0, CS4_SW12, CS5_SW12, CS6_SW12 }, // 62, -, k86 - { 0, CS7_SW12, CS8_SW12, CS9_SW12 }, // 63, [, k81 - { 0, CS10_SW12, CS11_SW12, CS12_SW12 }, // 64, ", k83 - { 0, CS16_SW12, CS17_SW12, CS18_SW12 }, // 65, Ct_R, k04 +/* Refer to AW20216S manual for these locations + * driver + * | R location + * | | G location + * | | | B location + * | | | | Key Flag Row y-cm x-cm + */ + {0, CS13_SW1, CS14_SW1, CS15_SW1 }, // 0 : R0-S0 //KC_LSFT 1 4 8.2 2.5 + // // R1-S0 //KC_MUTE + // // R2-S0 // + {1, CS4_SW10, CS5_SW10, CS6_SW10 }, // 1 : R3-S0 //KC_LEFT 1 5 10 26 + {0, CS16_SW12, CS17_SW12, CS18_SW12 }, // 2 : R4-S0 //KC_RCTL 1 5 10 23.7 + {1, CS10_SW5, CS11_SW5, CS12_SW5 }, // 3 : R5-S0 //KC_RGHT 1 5 10 29.9 + {0, CS16_SW1, CS17_SW1, CS18_SW1 }, // 4 : R6-S0 //KC_LCTL 1 5 10 1.2 + {0, CS1_SW6, CS2_SW6, CS3_SW6 }, // 5 : R7-S0 //KC_F5 4 0 0 11.2 + // + {0, CS7_SW2, CS8_SW2, CS9_SW2 }, // 6 : R0-S1 //KC_Q 4 2 4.3 3.7 + {0, CS7_SW1, CS8_SW1, CS9_SW1 }, // 7 : R1-S1 //KC_TAB 1 2 4.3 1.5 + {0, CS10_SW2, CS11_SW2, CS12_SW2 }, // 8 : R2-S1 //KC_A 4 3 6.2 4.3 + {0, CS1_SW1, CS2_SW1, CS3_SW1 }, // 9 : R3-S1 //KC_ESC 1 0 0 0.9 + {0, CS13_SW2, CS14_SW2, CS15_SW2 }, //10 : R4-S1 //KC_Z 4 4 8.2 5.3 + {1, CS4_SW4, CS5_SW4, CS6_SW4 }, //11 : R5-S1 //KC_PGUP 4 2 4.3 30.2 + {0, CS4_SW1, CS5_SW1, CS6_SW1 }, //12 : R6-S1 //KC_GRV 1 1 2.9 0.9 + {0, CS4_SW2, CS5_SW2, CS6_SW2 }, //13 : R7-S1 //KC_1 4 1 2.9 2.6 + // + {0, CS7_SW3, CS8_SW3, CS9_SW3 }, //14 : R0-S2 //KC_W 4 2 4.3 5.8 + {0, CS10_SW1, CS11_SW1, CS12_SW1 }, //15 : R1-S2 //KC_CAPS 1 3 6.2 1.8 + {0, CS10_SW3, CS11_SW3, CS12_SW3 }, //16 : R2-S2 //KC_S 4 3 6.2 6.2 + // // R3-S2 // + {0, CS13_SW3, CS14_SW3, CS15_SW3 }, //17 : R4-S2 //KC_X 4 4 8.2 7.1 + {1, CS4_SW7, CS5_SW7, CS6_SW7 }, //18 : R5-S2 //KC_PGDN 4 3 6.2 30.2 + {0, CS1_SW2, CS2_SW2, CS3_SW2 }, //19 : R6-S2 //KC_F1 4 0 0 3.3 + {0, CS4_SW3, CS5_SW3, CS6_SW3 }, //20 : R7-S2 //KC_2 4 1 2.9 4.6 + // + {0, CS7_SW4, CS8_SW4, CS9_SW4 }, //21 : R0-S3 //KC_E 4 2 4.3 7.6 + {0, CS1_SW4, CS2_SW4, CS3_SW4 }, //22 : R1-S3 //KC_F3 4 0 0 7 + {0, CS10_SW4, CS11_SW4, CS12_SW4 }, //23 : R2-S3 //KC_D 4 3 6.2 8 + {0, CS1_SW5, CS2_SW5, CS3_SW5 }, //24 : R3-S3 //KC_F4 4 0 0 9 + {0, CS13_SW4, CS14_SW4, CS15_SW4 }, //25 : R4-S3 //KC_C 4 4 8.2 9 + {1, CS4_SW9, CS5_SW9, CS6_SW9 }, //26 : R5-S3 //KC_UP 1 4 8.2 28 + {0, CS1_SW3, CS2_SW3, CS3_SW3 }, //27 : R6-S3 //KC_F2 4 0 0 5.2 + {0, CS4_SW4, CS5_SW4, CS6_SW4 }, //28 : R7-S3 //KC_3 4 1 2.9 6.6 + // + {0, CS7_SW5, CS8_SW5, CS9_SW5 }, //29 : R0-S4 //KC_R 4 2 4.3 9.5 + {0, CS7_SW6, CS8_SW6, CS9_SW6 }, //30 : R1-S4 //KC_T 4 2 4.3 11.4 + {0, CS10_SW5, CS11_SW5, CS12_SW5 }, //31 : R2-S4 //KC_F 4 3 6.2 10 + {0, CS10_SW6, CS11_SW6, CS12_SW6 }, //32 : R3-S4 //KC_G 4 3 6.2 11.9 + {0, CS13_SW5, CS14_SW5, CS15_SW5 }, //33 : R4-S4 //KC_V 4 4 8.2 11 + {0, CS13_SW6, CS14_SW6, CS15_SW6 }, //34 : R5-S4 //KC_B 4 4 8.2 12.9 + {0, CS4_SW6, CS5_SW6, CS6_SW6 }, //35 : R6-S4 //KC_5 4 1 2.9 10.4 + {0, CS4_SW5, CS5_SW5, CS6_SW5 }, //36 : R7-S4 //KC_4 4 1 2.9 8.5 + // + {0, CS7_SW8, CS8_SW8, CS9_SW8 }, //37 : R0-S5 //KC_U 4 2 4.3 15.3 + {0, CS7_SW7, CS8_SW7, CS9_SW7 }, //38 : R1-S5 //KC_Y 4 2 4.3 13.4 + {0, CS10_SW8, CS11_SW8, CS12_SW8 }, //39 : R2-S5 //KC_J 4 3 6.2 15.7 + {0, CS10_SW7, CS11_SW7, CS12_SW7 }, //40 : R3-S5 //KC_H 4 3 6.2 13.8 + {0, CS13_SW8, CS14_SW8, CS15_SW8 }, //41 : R4-S5 //KC_M 4 4 8.2 16.5 + {0, CS13_SW7, CS14_SW7, CS15_SW7 }, //42 : R5-S5 //KC_N 4 4 8.2 14.7 + {0, CS4_SW7, CS5_SW7, CS6_SW7 }, //43 : R6-S5 //KC_6 4 1 2.9 12.3 + {0, CS4_SW8, CS5_SW8, CS6_SW8 }, //44 : R7-S5 //KC_7 4 1 2.9 14.2 + // + {0, CS7_SW9, CS8_SW9, CS9_SW9 }, //45 : R0-S6 //KC_I 4 2 4.3 17.2 + {1, CS1_SW8, CS2_SW8, CS3_SW8 }, //46 : R1-S6 //KC_RBRC 4 2 4.3 24.5 + {0, CS10_SW9, CS11_SW9, CS12_SW9 }, //47 : R2-S6 //KC_K 4 3 6.2 17.5 + {0, CS1_SW7, CS2_SW7, CS3_SW7 }, //48 : R3-S6 //KC_F6 4 0 0 13.2 + {0, CS13_SW9, CS14_SW9, CS15_SW9 }, //49 : R4-S6 //KC_COMM 4 4 8.2 18.5 + {1, CS4_SW3, CS5_SW3, CS6_SW3 }, //50 : R5-S6 //KC_DEL 4 1 2.9 30.2 + {1, CS1_SW5, CS2_SW5, CS3_SW5 }, //51 : R6-S6 //KC_EQL 4 1 2.9 23.7 + {0, CS4_SW9, CS5_SW9, CS6_SW9 }, //52 : R7-S6 //KC_8 4 1 2.9 16.1 + // + {0, CS7_SW10, CS8_SW10, CS9_SW10 }, //53 : R0-S7 //KC_O 4 2 4.3 19 + {0, CS1_SW8, CS2_SW8, CS3_SW8 }, //54 : R1-S7 //KC_F7 4 0 0 15.1 + {0, CS10_SW10, CS11_SW10, CS12_SW10}, //55 : R2-S7 //KC_L 4 3 6.2 19.5 + {1, CS4_SW11, CS5_SW11, CS6_SW11 }, //56 : R3-S7 //KC_DOWN 1 5 10 28 + {0, CS13_SW10, CS14_SW10, CS15_SW10}, //57 : R4-S7 //KC_DOT 4 4 8.2 20.5 + {1, CS4_SW6, CS5_SW6, CS6_SW6 }, //58 : R5-S7 //KC_END 4 4 8.2 30.2 + {0, CS1_SW9, CS2_SW9, CS3_SW9 }, //59 : R6-S7 //KC_F8 4 0 0 17 + {0, CS4_SW10, CS5_SW10, CS6_SW10 }, //60 : R7-S7 //KC_9 4 1 2.9 18 + // + {0, CS7_SW11, CS8_SW11, CS9_SW11 }, //61 : R0-S8 //KC_P 4 2 4.3 21 + {0, CS7_SW12, CS8_SW12, CS9_SW12 }, //62 : R1-S8 //KC_LBRC 4 2 4.3 22.7 + {0, CS10_SW11, CS11_SW11, CS12_SW11}, //63 : R2-S8 //KC_SCLN 4 3 6.2 21.5 + {0, CS10_SW12, CS11_SW12, CS12_SW12}, //64 : R3-S8 //KC_QUOT 4 3 6.2 23.2 + // // R4-S8 // + {0, CS13_SW11, CS14_SW11, CS15_SW11}, //65 : R5-S8 //KC_SLSH 4 4 8.2 22.3 + {0, CS4_SW12, CS5_SW12, CS6_SW12 }, //66 : R6-S8 //KC_MINS 4 1 2.9 21.7 + {0, CS4_SW11, CS5_SW11, CS6_SW11 }, //67 : R7-S8 //KC_0 4 1 2.9 19.8 + // + {0, CS16_SW2, CS17_SW2, CS18_SW2 }, //68 : R0-S9 //KC_LGUI 1 5 10 3.7 + {1, CS4_SW8, CS5_SW8, CS6_SW8 }, //69 : R1-S9 //KC_RSFT 1 4 8.2 25 + {0, CS16_SW10, CS17_SW10, CS18_SW10}, //70 : R2-S9 //MO(1) 1 5 10 21.9 + {0, CS16_SW3, CS17_SW3, CS18_SW3 }, //71 : R3-S9 //KC_LALT 1 5 10 6 + {0, CS16_SW6, CS17_SW6, CS18_SW6 }, //72 : R4-S9 //KC_SPC 4 5 10 13.2 + {0, CS16_SW9, CS17_SW9, CS18_SW9 }, //73 : R5-S9 //KC_RALT 1 5 10 20 + // // R6-S9 // + {1, CS4_SW2, CS5_SW2, CS6_SW2 }, //74 : R7-S9 //KC_PSCR 4 0 0 27.5 + // + // // R0-S10 // + {1, CS1_SW7, CS2_SW7, CS3_SW7 }, //75 : R1-S10 //KC_BSPC 1 1 2.9 26.5 + {1, CS1_SW9, CS2_SW9, CS3_SW9 }, //76 : R2-S10 //KC_BSLS 1 2 4.3 27 + {0, CS1_SW12, CS2_SW12, CS3_SW12 }, //77 : R3-S10 //KC_F11 4 0 0 23.2 + {1, CS1_SW11, CS2_SW11, CS3_SW11 }, //78 : R4-S10 //KC_ENT 1 3 6.2 26.5 + {1, CS1_SW1, CS2_SW1, CS3_SW1 }, //79 : R5-S10 //KC_F12 4 0 0 25.1 + {0, CS1_SW10, CS2_SW10, CS3_SW10 }, //80 : R6-S10 //KC_F9 4 0 0 19.5 + {0, CS1_SW11, CS2_SW11, CS3_SW11 }, //81 : R7-S10 //KC_F10 4 0 0 21.3 + + //Underglow + {1, CS13_SW1, CS14_SW1, CS15_SW1 }, //82 : //LED1 2 0.8 0 + {1, CS13_SW2, CS14_SW2, CS15_SW2 }, //83 : //LED2 2 1.9 0 + {1, CS13_SW3, CS14_SW3, CS15_SW3 }, //84 : //LED3 2 3.0 0 + {1, CS13_SW4, CS14_SW4, CS15_SW4 }, //85 : //LED4 2 4.1 0 + {1, CS13_SW5, CS14_SW5, CS15_SW5 }, //86 : //LED5 2 5.2 0 + {1, CS13_SW6, CS14_SW6, CS15_SW6 }, //87 : //LED6 2 6.3 0 + {1, CS13_SW7, CS14_SW7, CS15_SW7 }, //88 : //LED7 2 7.4 0 + {1, CS13_SW8, CS14_SW8, CS15_SW8 }, //89 : //LED8 2 8.5 0 - { 1, CS1_SW1, CS2_SW1, CS3_SW1 }, // 66, F12, ka5 - { 1, CS13_SW1, CS14_SW1, CS15_SW1 }, // 67, LED, l01 - { 1, CS16_SW1, CS17_SW1, CS18_SW1 }, // 68, LED, l11 - { 1, CS4_SW2, CS5_SW2, CS6_SW2 }, // 69, Prt, k97 - { 1, CS13_SW2, CS14_SW2, CS15_SW2 }, // 70, LED, l02 - { 1, CS16_SW2, CS17_SW2, CS18_SW2 }, // 71, LED, l12 - { 1, CS4_SW3, CS5_SW3, CS6_SW3 }, // 72, Del, k65 - { 1, CS13_SW3, CS14_SW3, CS15_SW3 }, // 73, LED, l03 - { 1, CS16_SW3, CS17_SW3, CS18_SW3 }, // 74, LED, l13 - { 1, CS4_SW4, CS5_SW4, CS6_SW4 }, // 75, PgUp, k15 - { 1, CS13_SW4, CS14_SW4, CS15_SW4 }, // 76, LED, l04 - { 1, CS16_SW4, CS17_SW4, CS18_SW4 }, // 77, LED, l14 - { 1, CS1_SW5, CS2_SW5, CS3_SW5 }, // 78, =, k66 - { 1, CS10_SW5, CS11_SW5, CS12_SW5 }, // 79, Right, k05 - { 1, CS13_SW5, CS14_SW5, CS15_SW5 }, // 80, LED, l05 - { 1, CS16_SW5, CS17_SW5, CS18_SW5 }, // 81, LED, l15 - { 1, CS4_SW6, CS5_SW6, CS6_SW6 }, // 82, End, k75 - { 1, CS13_SW6, CS14_SW6, CS15_SW6 }, // 83, LED, l06 - { 1, CS16_SW6, CS17_SW6, CS18_SW6 }, // 84, LED, l16 - { 1, CS1_SW7, CS2_SW7, CS3_SW7 }, // 85, BSpc, ka1 - { 1, CS4_SW7, CS5_SW7, CS6_SW7 }, // 86, PgDn, k25 - { 1, CS13_SW7, CS14_SW7, CS15_SW7 }, // 87, LED, l07 - { 1, CS16_SW7, CS17_SW7, CS18_SW7 }, // 88, LED, l17 - { 1, CS1_SW8, CS2_SW8, CS3_SW8 }, // 89, ], k61 - { 1, CS4_SW8, CS5_SW8, CS6_SW8 }, // 90, Sh_R, k91 - { 1, CS13_SW8, CS14_SW8, CS15_SW8 }, // 91, LED, l08 - { 1, CS16_SW8, CS17_SW8, CS18_SW8 }, // 92, LED, l18 - { 1, CS1_SW9, CS2_SW9, CS3_SW9 }, // 93, \, ka2 - { 1, CS4_SW9, CS5_SW9, CS6_SW9 }, // 94, Up, k35 - { 1, CS4_SW10, CS5_SW10, CS6_SW10 }, // 95, Left, k03 - { 1, CS1_SW11, CS2_SW11, CS3_SW11 }, // 96, Enter, ka4 - { 1, CS4_SW11, CS5_SW11, CS6_SW11 }, // 97, Down, k73 + {1, CS16_SW1, CS17_SW1, CS18_SW1 }, //90 : //LED11 2 0.8 32 + {1, CS16_SW2, CS17_SW2, CS18_SW2 }, //91 : //LED12 2 1.9 32 + {1, CS16_SW3, CS17_SW3, CS18_SW3 }, //92 : //LED13 2 3.0 32 + {1, CS16_SW4, CS17_SW4, CS18_SW4 }, //93 : //LED14 2 4.1 32 + {1, CS16_SW5, CS17_SW5, CS18_SW5 }, //94 : //LED15 2 5.2 32 + {1, CS16_SW6, CS17_SW6, CS18_SW6 }, //95 : //LED16 2 6.3 32 + {1, CS16_SW7, CS17_SW7, CS18_SW7 }, //96 : //LED17 2 7.4 32 + {1, CS16_SW8, CS17_SW8, CS18_SW8 }, //97 : //LED18 2 8.5 32 }; + +//See definition in 'rgb_matrix_types.h' +led_config_t g_led_config = { { + //R0 R1 R2 R3 R4 R5 R6 R7 + { 0, NO_LED, NO_LED, 1, 2, 3, 4, 5 }, /*S0 */ \ + { 6, 7, 8, 9, 10, 11, 12, 13}, /*S1 */ \ + { 14, 15, 16, NO_LED, 17, 18, 19, 20}, /*S2 */ \ + { 21, 22, 23, 24, 25, 26, 27, 28}, /*S3 */ \ + { 29, 30, 31, 32, 33, 34, 35, 36}, /*S4 */ \ + { 37, 38, 39, 40, 41, 42, 43, 44}, /*S5 */ \ + { 45, 46, 47, 48, 49, 50, 51, 52}, /*S6 */ \ + { 53, 54, 55, 56, 57, 58, 59, 60}, /*S7 */ \ + { 61, 62, 63, 64, NO_LED, 65, 66, 67}, /*S8 */ \ + { 68, 69, 70, 71, 72, 73, NO_LED, 74}, /*S9 */ \ + { NO_LED, 75, 76, 77, 78, 79, 80, 81} /*S10*/ \ +}, { + {17,52},{182,64},{165,64},{209,64},{8,64},{78,0},{25,27},{10,27}, + {30,39},{6,0},{37,52},{211,27},{6,18},{18,18},{40,27},{12,39}, + {43,39},{49,52},{211,39},{23,0},{32,18},{53,27},{49,0},{56,39}, + {63,0},{63,52},{196,52},{36,0},{46,18},{66,27},{79,27},{70,39}, + {83,39},{77,52},{90,52},{72,18},{59,18},{107,27},{93,27},{109,39}, + {96,39},{115,52},{102,52},{86,18},{99,18},{120,27},{171,27},{122,39}, + {92,0},{129,52},{211,18},{165,18},{112,18},{133,27},{105,0},{136,39}, + {196,64},{143,52},{211,52},{119,0},{126,18},{147,27},{158,27},{150,39}, + {162,39},{156,52},{151,18},{138,18},{25,64},{175,52},{153,64},{42,64}, + {92,64},{140,64},{192,0},{185,18},{189,27},{162,0},{185,39},{175,0}, + {136,0},{149,0},{0,5},{0,12},{0,19},{0,26},{0,33},{0,40}, + {0,47},{0,54},{224,5},{224,12},{224,19},{224,26},{224,33},{224,40}, + {224,47},{224,54}, +}, { + 1,1,1,1,1,4,4,1, + 4,1,4,4,1,4,4,1, + 4,4,4,4,4,4,4,4, + 4,4,1,4,4,4,4,4, + 4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4, + 4,4,4,4,4,4,4,4, + 1,4,4,4,4,4,4,4, + 4,4,4,4,1,1,1,1, + 4,1,4,1,1,4,1,4, + 4,4,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2, + 2,2 +} }; #endif diff --git a/keyboards/gmmk/pro/rules.mk b/keyboards/gmmk/pro/rules.mk index 6221d6408272..d2500c1df10d 100644 --- a/keyboards/gmmk/pro/rules.mk +++ b/keyboards/gmmk/pro/rules.mk @@ -21,5 +21,6 @@ RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow BLUETOOTH_ENABLE = no # Enable Bluetooth AUDIO_ENABLE = no # Audio output ENCODER_ENABLE = yes + RGB_MATRIX_ENABLE = yes -RGB_MATRIX_DRIVER = AW20216 +RGB_MATRIX_DRIVER = AW20216S diff --git a/quantum/quantum.h b/quantum/quantum.h index 66ba96fde83f..27cc1bc79771 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -38,11 +38,11 @@ #endif #if defined(RGBLIGHT_ENABLE) -# include "rgblight.h" +# include "rgblight\rgblight.h" #elif defined(RGB_MATRIX_ENABLE) // Dummy define RGBLIGHT_MODE_xxxx # define RGBLIGHT_H_DUMMY_DEFINE -# include "rgblight.h" +# include "rgblight\rgblight.h" #endif #ifdef RGB_MATRIX_ENABLE diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 28f07c84d6e4..270da69bba4f 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -23,7 +23,7 @@ #include "rgb_matrix_types.h" #include "color.h" #include "quantum.h" -#include "rgblight_list.h" +#include "rgblight\rgblight_list.h" #ifdef IS31FL3731 # include "is31fl3731.h" @@ -37,6 +37,8 @@ # include "aw20216.h" #elif defined(WS2812) # include "ws2812.h" +#elif defined(AW20216S) +# include "aw20216s.h" #endif #ifndef RGB_MATRIX_LED_FLUSH_LIMIT diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 6a11d4791e5f..1f8ca41a4f1e 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -225,4 +225,36 @@ const rgb_matrix_driver_t rgb_matrix_driver = { .set_color = setled, .set_color_all = setled_all, }; + +#elif defined(AW20216S) +# include "spi_master.h" + +static void init(void) { + AW20216S_enable(SPI_SS_DRIVER_1_PIN, ENABLE_DRIVERS_PIN); +# ifdef SPI_SS_DRIVER_2_PIN + AW20216S_enable(SPI_SS_DRIVER_2_PIN, ENABLE_DRIVERS_PIN); +# endif + + spi_init(); + + AW20216S_init(SPI_SS_DRIVER_1_PIN, SW_LINES_ENABLE_DRIVER_1); +# ifdef SPI_SS_DRIVER_2_PIN + AW20216S_init(SPI_SS_DRIVER_2_PIN, SW_LINES_ENABLE_DRIVER_2); +# endif +} + +static void flush(void) { + AW20216S_update_pwm_buffers(SPI_SS_DRIVER_1_PIN, 0); +# ifdef SPI_SS_DRIVER_2_PIN + AW20216S_update_pwm_buffers(SPI_SS_DRIVER_2_PIN, 1); +# endif +} + +const rgb_matrix_driver_t rgb_matrix_driver = { + .init = init, + .flush = flush, + .set_color = AW20216S_set_color, + .set_color_all = AW20216S_set_color_all, +}; + #endif From a2c0b44d57fc005b004dc32f4a2b316b1c8c9232 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Thu, 1 Jul 2021 06:55:36 +0200 Subject: [PATCH 08/12] Changed to linux-style dir separator in includes --- quantum/quantum.h | 4 ++-- quantum/rgb_matrix/rgb_matrix.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/quantum/quantum.h b/quantum/quantum.h index 27cc1bc79771..3ac7d22b9045 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -38,11 +38,11 @@ #endif #if defined(RGBLIGHT_ENABLE) -# include "rgblight\rgblight.h" +# include "rgblight/rgblight.h" #elif defined(RGB_MATRIX_ENABLE) // Dummy define RGBLIGHT_MODE_xxxx # define RGBLIGHT_H_DUMMY_DEFINE -# include "rgblight\rgblight.h" +# include "rgblight/rgblight.h" #endif #ifdef RGB_MATRIX_ENABLE diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 270da69bba4f..82ab0418129a 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -23,7 +23,7 @@ #include "rgb_matrix_types.h" #include "color.h" #include "quantum.h" -#include "rgblight\rgblight_list.h" +#include "rgblight/rgblight_list.h" #ifdef IS31FL3731 # include "is31fl3731.h" From 4b05c6fa6d1f8375c9463b91fa731e13cba8eba5 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Fri, 2 Jul 2021 21:31:04 +0200 Subject: [PATCH 09/12] Modified SW_LINES_ENABLE_DRIVER_2 constant. --- drivers/awinic/aw20216s.c | 10 ++++++---- keyboards/gmmk/pro/config.h | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/awinic/aw20216s.c b/drivers/awinic/aw20216s.c index a288fd0a91e4..1931c8b3c127 100644 --- a/drivers/awinic/aw20216s.c +++ b/drivers/awinic/aw20216s.c @@ -34,10 +34,12 @@ #define US_BETWEEN_REG_WRITE_DELAY 100 #define PWM_REGISTER_COUNT 216 -#define SPI_CLOCK_SPEED 2000000 -#define SPI_MODE 3 -//#define SPI_DIVISOR (F_CPU / SPI_CLOCK_SPEED) -#define SPI_DIVISOR 4 // around 8 MHz (smooth transitions) +#ifndef SPI_MODE +# define SPI_MODE 0 +#endif +#ifndef SPI_DIVISOR +# define SPI_DIVISOR 4 +#endif // These buffers match the AW20216S PWM registers 0x00-0xD7. uint8_t g_pwm_buffer[DRIVER_COUNT][PWM_REGISTER_COUNT]; diff --git a/keyboards/gmmk/pro/config.h b/keyboards/gmmk/pro/config.h index 506cc1e1650e..e5dd186c9bab 100644 --- a/keyboards/gmmk/pro/config.h +++ b/keyboards/gmmk/pro/config.h @@ -51,8 +51,6 @@ /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE -#define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 -#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_12 /* SPI Config for LED Driver */ #define SPI_DRIVER SPID1 #define SPI_SCK_PIN A5 @@ -65,7 +63,7 @@ #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175 #define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 -#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_12 +#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_11 #define DRIVER_COUNT 2 #define DRIVER_1_LED_TOTAL 66 From 39b481e9251446d8ee653b2286b34bd43740d402 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Sat, 3 Jul 2021 07:14:56 +0200 Subject: [PATCH 10/12] 2 enable pins. --- keyboards/gmmk/pro/config.h | 3 ++- quantum/rgb_matrix/rgb_matrix_drivers.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/keyboards/gmmk/pro/config.h b/keyboards/gmmk/pro/config.h index e5dd186c9bab..121fe5fe6b70 100644 --- a/keyboards/gmmk/pro/config.h +++ b/keyboards/gmmk/pro/config.h @@ -58,8 +58,9 @@ #define SPI_MISO_PIN A7 #define SPI_SS_DRIVER_1_PIN B13 +#define ENABLE_DRIVER_1_PIN C13 #define SPI_SS_DRIVER_2_PIN B14 -#define ENABLE_DRIVERS_PIN C13 +#define ENABLE_DRIVER_2_PIN C13 #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175 #define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 1f8ca41a4f1e..18fef3d047c4 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -230,9 +230,9 @@ const rgb_matrix_driver_t rgb_matrix_driver = { # include "spi_master.h" static void init(void) { - AW20216S_enable(SPI_SS_DRIVER_1_PIN, ENABLE_DRIVERS_PIN); + AW20216S_enable(SPI_SS_DRIVER_1_PIN, ENABLE_DRIVER_1_PIN); # ifdef SPI_SS_DRIVER_2_PIN - AW20216S_enable(SPI_SS_DRIVER_2_PIN, ENABLE_DRIVERS_PIN); + AW20216S_enable(SPI_SS_DRIVER_2_PIN, ENABLE_DRIVER_2_PIN); # endif spi_init(); From 8dce49b2f07427c4d108d1b4a9d8d19a30568807 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Tue, 6 Jul 2021 17:18:15 +0200 Subject: [PATCH 11/12] cformat --- drivers/awinic/aw20216s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/awinic/aw20216s.c b/drivers/awinic/aw20216s.c index 1931c8b3c127..820edda3fc44 100644 --- a/drivers/awinic/aw20216s.c +++ b/drivers/awinic/aw20216s.c @@ -38,7 +38,7 @@ # define SPI_MODE 0 #endif #ifndef SPI_DIVISOR -# define SPI_DIVISOR 4 +# define SPI_DIVISOR 4 #endif // These buffers match the AW20216S PWM registers 0x00-0xD7. From 311bc8a9aa0087b989b89d8a13a6e897ab4b4ab8 Mon Sep 17 00:00:00 2001 From: Francisco Tortosa Date: Thu, 15 Jul 2021 19:02:35 +0200 Subject: [PATCH 12/12] Removed define of SW_LINES_ENABLE_DRIVER_1/2 in config.h --- drivers/awinic/aw20216.h | 7 +++++++ keyboards/gmmk/pro/config.h | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/awinic/aw20216.h b/drivers/awinic/aw20216.h index 1ab3958b4790..d7ab59917a8a 100644 --- a/drivers/awinic/aw20216.h +++ b/drivers/awinic/aw20216.h @@ -40,6 +40,13 @@ typedef struct ag_led { #define SW_LINES_ENABLED_1_TO_11 0xA #define SW_LINES_ENABLED_1_TO_12 0xB +#ifndef SW_LINES_ENABLE_DRIVER_1 +# define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 +#endif +#ifndef SW_LINES_ENABLE_DRIVER_2 +# define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_12 +#endif + extern const aw_led g_aw_leds[DRIVER_LED_TOTAL]; void AW20216S_enable(int32_t csPin, int32_t enablePin); diff --git a/keyboards/gmmk/pro/config.h b/keyboards/gmmk/pro/config.h index 121fe5fe6b70..53483d767b2a 100644 --- a/keyboards/gmmk/pro/config.h +++ b/keyboards/gmmk/pro/config.h @@ -63,9 +63,6 @@ #define ENABLE_DRIVER_2_PIN C13 #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175 -#define SW_LINES_ENABLE_DRIVER_1 SW_LINES_ENABLED_1_TO_12 -#define SW_LINES_ENABLE_DRIVER_2 SW_LINES_ENABLED_1_TO_11 - #define DRIVER_COUNT 2 #define DRIVER_1_LED_TOTAL 66 #define DRIVER_2_LED_TOTAL 32