diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index b7333cee938c..754918a166d8 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -448,7 +448,7 @@ RGB_MATRIX_DRIVER := snled27351 endif RGB_MATRIX_ENABLE ?= no -VALID_RGB_MATRIX_TYPES := aw20216s is31fl3218 is31fl3236 is31fl3729 is31fl3731 is31fl3733 is31fl3736 is31fl3737 is31fl3741 is31fl3742a is31fl3743a is31fl3745 is31fl3746a snled27351 ws2812 sn32f24xb sled1734x custom +VALID_RGB_MATRIX_TYPES := aw20216s is31fl3218 is31fl3236 is31fl3729 is31fl3731 is31fl3733 is31fl3736 is31fl3737 is31fl3741 is31fl3742a is31fl3743a is31fl3745 is31fl3746a snled27351 ws2812 sn32f2xx sled1734x custom ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),) @@ -566,10 +566,9 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) APA102_DRIVER_REQUIRED := yes endif - ifeq ($(strip $(RGB_MATRIX_DRIVER)), sn32f24xb) - OPT_DEFS += -DSHARED_MATRIX - COMMON_VPATH += $(DRIVER_PATH)/led/sn32 - SRC += rgb_matrix_sn32f24xb.c + ifeq ($(strip $(RGB_MATRIX_DRIVER)), sn32f2xx) + COMMON_VPATH += $(DRIVER_PATH)/led + SRC += sn32f2xx.c endif ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index acbf06599df7..8f86d52a113a 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -567,7 +567,7 @@ "snled27351", "ws2812", "sled1734x", - "sn32f24xb" + "sn32f2xx" ] }, "center_point": { diff --git a/drivers/led/sn32/sn32f24xb.h b/drivers/led/sn32/sn32f24xb.h deleted file mode 100644 index 1b2cb165c0d9..000000000000 --- a/drivers/led/sn32/sn32f24xb.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include - -#if defined(RGB_MATRIX_SN32F24XB) -# define SN32F24XB_LED_COUNT RGB_MATRIX_LED_COUNT -#endif - -void sn32f24xb_init(void); -void sn32f24xb_flush(void); -void sn32f24xb_set_color(int index, uint8_t r, uint8_t g, uint8_t b); -void sn32f24xb_set_color_all(uint8_t r, uint8_t g, uint8_t b); diff --git a/drivers/led/sn32/rgb_matrix_sn32f24xb.c b/drivers/led/sn32f2xx.c similarity index 60% rename from drivers/led/sn32/rgb_matrix_sn32f24xb.c rename to drivers/led/sn32f2xx.c index b006feed2f20..9c7231913f6c 100644 --- a/drivers/led/sn32/rgb_matrix_sn32f24xb.c +++ b/drivers/led/sn32f2xx.c @@ -1,7 +1,23 @@ +/* Copyright 2024 Dimitris Mantzouranis + * + * 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 #include "matrix.h" #include "rgb_matrix.h" -#include "sn32f24xb.h" +#include "sn32f2xx.h" #define ROWS_PER_HAND (MATRIX_ROWS) @@ -12,46 +28,12 @@ #define SN32_PWM_OUTPUT_ACTIVE_HIGH PWM_OUTPUT_ACTIVE_HIGH #define SN32_PWM_OUTPUT_ACTIVE_LOW PWM_OUTPUT_ACTIVE_LOW -#if !defined(SN32_PWM_OUTPUT_ACTIVE_LEVEL) -# define SN32_PWM_OUTPUT_ACTIVE_LEVEL SN32_PWM_OUTPUT_ACTIVE_LOW -#endif - #define SN32_RGB_OUTPUT_ACTIVE_HIGH PWM_OUTPUT_ACTIVE_HIGH #define SN32_RGB_OUTPUT_ACTIVE_LOW PWM_OUTPUT_ACTIVE_LOW -#if !defined(SN32_RGB_OUTPUT_ACTIVE_LEVEL) -# define SN32_RGB_OUTPUT_ACTIVE_LEVEL SN32_RGB_OUTPUT_ACTIVE_HIGH -#endif - #define HARDWARE_PWM 0 #define SOFTWARE_PWM 1 -#if !defined(SN32_PWM_CONTROL) -# define SN32_PWM_CONTROL HARDWARE_PWM -#endif -#if !defined(SN32_PWM_DIRECTION) -# define SN32_PWM_DIRECTION DIODE_DIRECTION -#endif - -#if !defined(SN32_RGB_MATRIX_ROW_CHANNELS) -# define SN32_RGB_MATRIX_ROW_CHANNELS 3 -#endif - -#if !defined(SN32_RGB_MATRIX_ROWS) -# define SN32_RGB_MATRIX_ROWS MATRIX_ROWS -#endif - -#if !defined(SN32_RGB_MATRIX_COLS) -# define SN32_RGB_MATRIX_COLS MATRIX_COLS -#endif - -#if !defined(SN32_RGB_MATRIX_COL_PINS) -# define SN32_RGB_MATRIX_COL_PINS MATRIX_COL_PINS -#endif - -#if !defined(SN32_RGB_MATRIX_ROWS_HW) -# define SN32_RGB_MATRIX_ROWS_HW (SN32_RGB_MATRIX_ROWS * SN32_RGB_MATRIX_ROW_CHANNELS) -#endif /* Default configuration example @@ -105,22 +87,25 @@ static uint8_t led_duty_cycle[SN32_RGB_MATRIX_ROWS_HW] = {0}; // track the chann #if (DIODE_DIRECTION == ROW2COL) static matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; #endif +#if defined(SHARED_MATRIX) extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values static matrix_row_t shared_matrix[MATRIX_ROWS]; // scan values static volatile bool matrix_locked = false; // matrix update check static volatile bool matrix_scanned = false; +#endif // SHARED MATRIX static const uint32_t periodticks = RGB_MATRIX_MAXIMUM_BRIGHTNESS; static const uint32_t freq = (RGB_MATRIX_HUE_STEP * RGB_MATRIX_SAT_STEP * RGB_MATRIX_VAL_STEP * RGB_MATRIX_SPD_STEP * RGB_MATRIX_LED_PROCESS_LIMIT); static const pin_t led_row_pins[SN32_RGB_MATRIX_ROWS_HW] = SN32_RGB_MATRIX_ROW_PINS; // We expect a R,B,G order here static const pin_t led_col_pins[SN32_RGB_MATRIX_COLS] = SN32_RGB_MATRIX_COL_PINS; -static RGB led_state[SN32F24XB_LED_COUNT]; // led state buffer -static RGB led_state_buf[SN32F24XB_LED_COUNT]; // led state buffer +static RGB led_state[SN32F2XX_LED_COUNT]; // led state buffer +static RGB led_state_buf[SN32F2XX_LED_COUNT]; // led state buffer bool led_state_buf_update_required = false; #ifdef UNDERGLOW_RBG // handle underglow with flipped B,G channels static const uint8_t underglow_leds[UNDERGLOW_LEDS] = UNDERGLOW_IDX; #endif +#if defined(SHARED_MATRIX) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { for (int i = 0; i < TIME_US2I(MATRIX_IO_DELAY); ++i) { __asm__ volatile("" ::: "memory"); @@ -129,7 +114,15 @@ void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { bool matrix_can_read(void) { return matrix_scanned; } +#endif // SHARED_MATRIX + +static void rgb_callback(PWMDriver *pwmp); +#if !defined(SN32F2) +#error Driver is MCU specific to the Sonix SN32F2 family. +#endif // !defined(SN32F2) + +#if defined(SN32F240B) /* PWM configuration structure. We use timer CT16B1 with 24 channels. */ static PWMConfig pwmcfg = { freq, /* PWM clock frequency. */ @@ -137,7 +130,7 @@ static PWMConfig pwmcfg = { NULL, /* RGB Callback */ { /* Default all channels to disabled - Channels will be configured during init */ - [0 ... 23] = {PWM_OUTPUT_DISABLED, NULL, 0}, + [0 ... PWM_CHANNELS-1] = {PWM_OUTPUT_DISABLED, NULL, 0}, }, 0 /* HW dependent part.*/ }; @@ -155,8 +148,8 @@ static void rgb_ch_ctrl(PWMConfig *cfg) { channel = (x*16+y)%24 pfpa = 1, when (x*16+y)>23 */ - uint8_t pio_value = ((uint32_t)(PAL_PORT(led_col_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(B0)) - (uint32_t)(PAL_PORT(A0))) * 16 + PAL_PAD(led_col_pins[i]); - uint8_t ch_idx = pio_value % 24; + uint8_t pio_value = ((uint32_t)(PAL_PORT(led_col_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(B0)) - (uint32_t)(PAL_PORT(A0))) * PAL_IOPORTS_WIDTH + PAL_PAD(led_col_pins[i]); + uint8_t ch_idx = pio_value % PWM_CHANNELS; chan_col_order[i] = ch_idx; #elif (SN32_PWM_DIRECTION == ROW2COL) for (uint8_t i = 0; i < SN32_RGB_MATRIX_ROWS_HW; i++) { @@ -169,23 +162,143 @@ static void rgb_ch_ctrl(PWMConfig *cfg) { channel = (x*16+y)%24 pfpa = 1, when (x*16+y)>23 */ - uint8_t pio_value = ((uint32_t)(PAL_PORT(led_row_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(B0)) - (uint32_t)(PAL_PORT(A0))) * 16 + PAL_PAD(led_row_pins[i]); - uint8_t ch_idx = pio_value % 24; + uint8_t pio_value = ((uint32_t)(PAL_PORT(led_row_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(B0)) - (uint32_t)(PAL_PORT(A0))) * PAL_IOPORTS_WIDTH + PAL_PAD(led_row_pins[i]); + uint8_t ch_idx = pio_value % PWM_CHANNELS; chan_row_order[i] = ch_idx; -#endif +#endif // SN32_PWM_DIRECTION #if (SN32_PWM_CONTROL == HARDWARE_PWM) - cfg->channels[ch_idx].pfpamsk = pio_value > 23; + cfg->channels[ch_idx].pfpamsk = pio_value > (PWM_CHANNELS -1); cfg->channels[ch_idx].mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL; #endif // SN32_PWM_CONTROL } } -static void rgb_callback(PWMDriver *pwmp); +#elif defined(SN32F260) +/* PWM configuration structure. We use timer CT16B1 with 23 channels. */ +static const PWMConfig pwmcfg = { + freq, /* PWM clock frequency. */ + periodticks, /* PWM period (in ticks) 1S (1/10kHz=0.1mS 0.1ms*10000 ticks=1S) */ + rgb_callback, /* led Callback */ + .channels = + { + /* Default all channels to disabled */ + [0 ... PWM_CHANNELS-1] = {.mode = PWM_OUTPUT_DISABLED}, + /* Enable selected channels */ +# if defined(SN32_ACTIVATE_PWM_CHAN_0) + [0] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_0 +# if defined(SN32_ACTIVATE_PWM_CHAN_1) + [1] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_1 +# if defined(SN32_ACTIVATE_PWM_CHAN_2) + [2] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_2 +# if defined(SN32_ACTIVATE_PWM_CHAN_3) + [3] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_3 +# if defined(SN32_ACTIVATE_PWM_CHAN_4) + [4] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_4 +# if defined(SN32_ACTIVATE_PWM_CHAN_5) + [5] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_5 +# if defined(SN32_ACTIVATE_PWM_CHAN_6) + [6] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_6 +# if defined(SN32_ACTIVATE_PWM_CHAN_7) + [7] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_7 +# if defined(SN32_ACTIVATE_PWM_CHAN_8) + [8] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_8 +# if defined(SN32_ACTIVATE_PWM_CHAN_9) + [9] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_9 +# if defined(SN32_ACTIVATE_PWM_CHAN_10) + [10] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_10 +# if defined(SN32_ACTIVATE_PWM_CHAN_11) + [11] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_11 +# if defined(SN32_ACTIVATE_PWM_CHAN_12) + [12] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_12 +# if defined(SN32_ACTIVATE_PWM_CHAN_13) + [13] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_13 +# if defined(SN32_ACTIVATE_PWM_CHAN_14) + [14] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_14 +# if defined(SN32_ACTIVATE_PWM_CHAN_15) + [15] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_15 +# if defined(SN32_ACTIVATE_PWM_CHAN_16) + [16] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_16 +# if defined(SN32_ACTIVATE_PWM_CHAN_17) + [17] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_17 +# if defined(SN32_ACTIVATE_PWM_CHAN_18) + [18] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_18 +# if defined(SN32_ACTIVATE_PWM_CHAN_19) + [19] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_19 +# if defined(SN32_ACTIVATE_PWM_CHAN_20) + [20] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_20 +# if defined(SN32_ACTIVATE_PWM_CHAN_21) + [21] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_21 +# if defined(SN32_ACTIVATE_PWM_CHAN_22) + [22] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32_ACTIVATE_PWM_CHAN_22 + }, + 0 /* HW dependent part.*/ +}; + +static void rgb_ch_ctrl(void) { + /* Enable PWM function, IOs and select the PWM modes for the LED pins */ +#if (SN32_PWM_DIRECTION == COL2ROW) + for (uint8_t i = 0; i < SN32_RGB_MATRIX_COLS; i++) { +# if (SN32_PWM_CONTROL == HARDWARE_PWM) + // Only P0.0 to P0.15 and P3.0 to P3.8 can be used as pwm output + if (led_col_pins[i] > A15 && led_col_pins[i] < D0) continue; +# endif // SN32_PWM_CONTROL + /* We use a tricky here, accordint to pfpa table of sn32f260 datasheet, + pwm channel and pfpa of pin Px.y can be calculated as below: + channel = (x*16+y)%23 + */ + uint8_t pio_value = ((uint32_t)(PAL_PORT(led_col_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(D0)) - (uint32_t)(PAL_PORT(A0))) * PAL_IOPORTS_WIDTH + PAL_PAD(led_col_pins[i]); + uint8_t ch_idx = pio_value % PWM_CHANNELS; + chan_col_order[i] = ch_idx; +#elif (SN32_PWM_DIRECTION == ROW2COL) + for (uint8_t i = 0; i < SN32_RGB_MATRIX_ROWS_HW; i++) { +# if (SN32_PWM_CONTROL == HARDWARE_PWM) + // Only P0.0 to P0.15 and P3.0 to P3.8 can be used as pwm output + if (led_row_pins[i] > A15 && led_row_pins[i] < D0) continue; +# endif // SN32_PWM_CONTROL + /* We use a tricky here, accordint to pfpa table of sn32f260 datasheet, + pwm channel and pfpa of pin Px.y can be calculated as below: + channel = (x*16+y)%23 + */ + uint8_t pio_value = ((uint32_t)(PAL_PORT(led_row_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(D0)) - (uint32_t)(PAL_PORT(A0))) * PAL_IOPORTS_WIDTH + PAL_PAD(led_row_pins[i]); + uint8_t ch_idx = pio_value % PWM_CHANNELS; + chan_row_order[i] = ch_idx; +#endif // SN32_PWM_DIRECTION + } +} +#else +# error Unsupported MCU. Driver instance cant be configured. +#endif // chip selection static void shared_matrix_rgb_enable(void) { +# if !defined(SN32F260) pwmcfg.callback = rgb_callback; +# endif // SN32F260 needs static allocation pwmEnablePeriodicNotification(&PWMD1); } +#if defined(SHARED_MATRIX) static void shared_matrix_scan_keys(matrix_row_t current_matrix[], uint8_t current_key, uint8_t last_key) { // Scan the key matrix row or col, depending on DIODE_DIRECTION static uint8_t first_scanned; @@ -224,6 +337,7 @@ static void shared_matrix_scan_keys(matrix_row_t current_matrix[], uint8_t curre } } } +#endif // SHARED_MATRIX #if (SN32_PWM_DIRECTION == COL2ROW) @@ -233,15 +347,15 @@ static void shared_matrix_rgb_disable_output(void) { # if (SN32_PWM_CONTROL == HARDWARE_PWM) pwmDisableChannel(&PWMD1, chan_col_order[y]); # elif (SN32_PWM_CONTROL == SOFTWARE_PWM) - setPinInput(led_col_pins[y]); + gpio_set_pin_input(led_col_pins[y]); # endif // SN32_PWM_CONTROL } // Disable LED outputs on RGB channel pins for (uint8_t x = 0; x < SN32_RGB_MATRIX_ROWS_HW; x++) { # if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) - writePinLow(led_row_pins[x]); + gpio_write_pin_low(led_row_pins[x]); # elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) - writePinHigh(led_row_pins[x]); + gpio_write_pin_high(led_row_pins[x]); # endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL } } @@ -251,7 +365,9 @@ static void update_pwm_channels(PWMDriver *pwmp) { current_row++; /* Check if counter has wrapped around, reset before the next pass */ if (current_row == SN32_RGB_MATRIX_ROWS_HW) current_row = 0; +# if defined(SHARED_MATRIX) uint8_t last_key_row = current_key_row; +# endif // SHARED_MATRIX // Advance to the next key matrix row # if (SN32_PWM_CONTROL == HARDWARE_PWM) if (current_row % SN32_RGB_MATRIX_ROW_CHANNELS == 2) current_key_row++; @@ -263,13 +379,15 @@ static void update_pwm_channels(PWMDriver *pwmp) { // Disable LED output before scanning the key matrix if (current_key_row < ROWS_PER_HAND) { shared_matrix_rgb_disable_output(); +# if defined(SHARED_MATRIX) shared_matrix_scan_keys(shared_matrix, current_key_row, last_key_row); +# endif // SHARED_MATRIX } bool enable_pwm_output = false; for (uint8_t current_key_col = 0; current_key_col < SN32_RGB_MATRIX_COLS; current_key_col++) { uint8_t led_index = g_led_config.matrix_co[current_key_row][current_key_col]; # if (SN32_PWM_CONTROL == SOFTWARE_PWM) - if (led_index >= SN32F24XB_LED_COUNT) continue; + if (led_index >= SN32F2XX_LED_COUNT) continue; # endif // SN32_PWM_CONTROL // Check if we need to enable RGB output if (led_state[led_index].b > 0) enable_pwm_output |= true; @@ -296,11 +414,11 @@ static void update_pwm_channels(PWMDriver *pwmp) { # if defined(EVISION_BOTCHED_RED_CHANNEL) // some keyboards have a 151k resistor value tied to the R channel instead of a 10k, as the rest. /* Boost the output for that channel maximizing the current draw by disabling other sinks */ # if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) - writePinLow(led_row_pins[current_row + 1]); - writePinLow(led_row_pins[current_row + 2]); + gpio_write_pin_low(led_row_pins[current_row + 1]); + gpio_write_pin_low(led_row_pins[current_row + 2]); # elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) - writePinHigh(led_row_pins[current_row + 1]); - writePinHigh(led_row_pins[current_row + 2]); + gpio_write_pin_high(led_row_pins[current_row + 1]); + gpio_write_pin_high(led_row_pins[current_row + 2]); # endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL # endif // EVISION_BOTCHED_RED_CHANNEL break; @@ -317,9 +435,9 @@ static void update_pwm_channels(PWMDriver *pwmp) { // Enable RGB output if (enable_pwm_output) { # if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) - writePinHigh(led_row_pins[current_row]); + gpio_write_pin_high(led_row_pins[current_row]); # elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) - writePinLow(led_row_pins[current_row]); + gpio_write_pin_low(led_row_pins[current_row]); # endif } } @@ -329,13 +447,13 @@ static void shared_matrix_rgb_disable_output(void) { // Disable LED outputs on RGB channel pins for (uint8_t x = 0; x < SN32_RGB_MATRIX_COLS; x++) { # if (DIODE_DIRECTION != SN32_PWM_DIRECTION) - setPinInput(led_col_pins[x]); + gpio_set_pin_input(led_col_pins[x]); # endif // DIODE_DIRECTION != SN32_PWM_DIRECTION // Unselect all columns before scanning the key matrix -# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW || defined(MATRIX_UNSELECT_DRIVE_HIGH)) - writePinHigh(led_col_pins[x]); +# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) + gpio_write_pin_high(led_col_pins[x]); # elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) - writePinLow(led_col_pins[x]); + gpio_write_pin_low(led_col_pins[x]); # endif } # if (DIODE_DIRECTION != SN32_PWM_DIRECTION) @@ -343,9 +461,12 @@ static void shared_matrix_rgb_disable_output(void) { for (uint8_t x = 0; x < SN32_RGB_MATRIX_ROWS_HW; x++) { # if (SN32_PWM_CONTROL == HARDWARE_PWM) pwmDisableChannel(&PWMD1, chan_row_order[x]); -# elif (SN32_PWM_CONTROL == SOFTWARE_PWM) - setPinInput(led_row_pins[x]); # endif // SN32_PWM_CONTROL +# if (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH) + gpio_write_pin_low(led_row_pins[x]); +# elif (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW) + gpio_write_pin_high(led_row_pins[x]); +# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL } # endif // DIODE_DIRECTION != SN32_PWM_DIRECTION } @@ -363,24 +484,22 @@ static void update_pwm_channels(PWMDriver *pwmp) { // Disable LED output before scanning the key matrix if (current_key_col < MATRIX_COLS) { shared_matrix_rgb_disable_output(); +# if defined(SHARED_MATRIX) shared_matrix_scan_keys(shared_matrix, current_key_col, last_key_col); +# endif // SHARED_MATRIX } for (uint8_t x = 0; x < SN32_RGB_MATRIX_COLS; x++) { # if (DIODE_DIRECTION != SN32_PWM_DIRECTION) - setPinOutput(led_col_pins[x]); + gpio_set_pin_output_push_pull(led_col_pins[x]); # endif // DIODE_DIRECTION != SN32_PWM_DIRECTION - // Disable all RGB columns before turning on PWM in case matrix read unselect high -# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH && defined(MATRIX_UNSELECT_DRIVE_HIGH)) - writePinLow(led_col_pins[x]); -# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH && defined(MATRIX_UNSELECT_DRIVE_HIGH) } bool enable_pwm_output = false; for (uint8_t current_key_row = 0; current_key_row < MATRIX_ROWS; current_key_row++) { uint8_t led_index = g_led_config.matrix_co[current_key_row][current_key_col]; # if (SN32_PWM_CONTROL == SOFTWARE_PWM) - if (led_index >= SN32F24XB_LED_COUNT) continue; + if (led_index >= SN32F2XX_LED_COUNT) continue; # endif uint8_t led_row_id = (current_key_row * SN32_RGB_MATRIX_ROW_CHANNELS); // Check if we need to enable RGB output @@ -396,9 +515,9 @@ static void update_pwm_channels(PWMDriver *pwmp) { // Enable RGB output if (enable_pwm_output) { # if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) - writePinHigh(led_col_pins[last_key_col]); + gpio_write_pin_high(led_col_pins[last_key_col]); # elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) - writePinLow(led_col_pins[last_key_col]); + gpio_write_pin_low(led_col_pins[last_key_col]); # endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL } # elif (SN32_PWM_CONTROL == SOFTWARE_PWM) @@ -409,9 +528,9 @@ static void update_pwm_channels(PWMDriver *pwmp) { // Enable RGB output if (enable_pwm_output) { # if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) - writePinHigh(led_col_pins[current_key_col]); + gpio_write_pin_high(led_col_pins[current_key_col]); # elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) - writePinLow(led_col_pins[current_key_col]); + gpio_write_pin_low(led_col_pins[current_key_col]); # endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL } # endif // SN32_PWM_CONTROL @@ -425,15 +544,15 @@ static void rgb_callback(PWMDriver *pwmp) { for (uint8_t pwm_cnt = 0; pwm_cnt < (SN32_RGB_MATRIX_COLS * RGB_MATRIX_HUE_STEP); pwm_cnt++) { uint8_t pwm_index = (pwm_cnt % SN32_RGB_MATRIX_COLS); if (((uint16_t)(pwmp->ct->TC) < ((uint16_t)(led_duty_cycle[pwm_index] + periodticks))) && (led_duty_cycle[pwm_index] > 0)) { - setPinOutput(led_col_pins[pwm_index]); + gpio_set_pin_output_push_pull(led_col_pins[pwm_index]); # if (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW) - writePinLow(led_col_pins[pwm_index]); + gpio_write_pin_low(led_col_pins[pwm_index]); } else { - setPinInputHigh(led_col_pins[pwm_index]); + gpio_set_pin_input_high(led_col_pins[pwm_index]); # elif (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH) - writePinHigh(led_col_pins[pwm_index]); + gpio_write_pin_high(led_col_pins[pwm_index]); } else { - setPinInputLow(led_col_pins[pwm_index]); + gpio_set_pin_input_low(led_col_pins[pwm_index]); # endif // SN32_PWM_OUTPUT_ACTIVE_LEVEL } } @@ -442,17 +561,17 @@ static void rgb_callback(PWMDriver *pwmp) { uint8_t pwm_index = (pwm_cnt % SN32_RGB_MATRIX_ROWS_HW); if (((uint16_t)(pwmp->ct->TC) < ((uint16_t)(led_duty_cycle[pwm_index] + periodticks))) && (led_duty_cycle[pwm_index] > 0)) { # if (DIODE_DIRECTION != SN32_PWM_DIRECTION) - setPinOutput(led_row_pins[pwm_index]); + gpio_set_pin_output_push_pull(led_row_pins[pwm_index]); # endif // DIODE_DIRECTION != SN32_PWM_DIRECTION # if (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW) - writePinLow(led_row_pins[pwm_index]); + gpio_write_pin_low(led_row_pins[pwm_index]); } else { - writePinHigh(led_row_pins[pwm_index]); + gpio_write_pin_high(led_row_pins[pwm_index]); # elif (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH) - writePinHigh(led_row_pins[pwm_index]); + gpio_write_pin_high(led_row_pins[pwm_index]); } else { - writePinLow(led_row_pins[pwm_index]); + gpio_write_pin_low(led_row_pins[pwm_index]); # endif // SN32_PWM_OUTPUT_ACTIVE_LEVEL } } @@ -461,35 +580,54 @@ static void rgb_callback(PWMDriver *pwmp) { update_pwm_channels(pwmp); chSysLockFromISR(); // Advance the timer to just before the wrap-around, that will start a new PWM cycle - pwm_lld_change_counter(pwmp, 0xFFFF); + pwm_lld_change_counter(pwmp, UINT16_MAX); // Enable the interrupt pwmEnablePeriodicNotificationI(pwmp); chSysUnlockFromISR(); } -void sn32f24xb_init(void) { +void sn32f2xx_init(void) { for (uint8_t x = 0; x < SN32_RGB_MATRIX_ROWS_HW; x++) { - setPinOutput(led_row_pins[x]); - writePinLow(led_row_pins[x]); + gpio_set_pin_output_push_pull(led_row_pins[x]); +# if ((SN32_PWM_DIRECTION == COL2ROW) && (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) || \ + (SN32_PWM_DIRECTION == ROW2COL) && (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH)) + gpio_write_pin_low(led_row_pins[x]); +# elif ((SN32_PWM_DIRECTION == COL2ROW) && (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) || \ + (SN32_PWM_DIRECTION == ROW2COL) && (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW)) + gpio_write_pin_high(led_row_pins[x]); +# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL } + // Determine which PWM channels we need to control +# if defined(SN32F240B) rgb_ch_ctrl(&pwmcfg); +# elif defined(SN32F260) + rgb_ch_ctrl(); +# endif // chip selection + +# if defined(SHARED_MATRIX) // initialize matrix state: all keys off for (uint8_t i = 0; i < MATRIX_ROWS; i++) { shared_matrix[i] = 0; } +# endif // SHARED_MATRIX + pwmStart(&PWMD1, &pwmcfg); shared_matrix_rgb_enable(); } -void sn32f24xb_flush(void) { +void sn32f2xx_flush(void) { if (led_state_buf_update_required) { - memcpy(led_state, led_state_buf, sizeof(RGB) * SN32F24XB_LED_COUNT); + memcpy(led_state, led_state_buf, sizeof(RGB) * SN32F2XX_LED_COUNT); led_state_buf_update_required = false; } } -void sn32f24xb_set_color(int index, uint8_t r, uint8_t g, uint8_t b) { +void sn32f2xx_set_color(int index, uint8_t r, uint8_t g, uint8_t b) { + uint8_t color_r = r * SN32_LED_OUTPUT_LUMINOSITY_R; + uint8_t color_g = g * SN32_LED_OUTPUT_LUMINOSITY_G; + uint8_t color_b = b * SN32_LED_OUTPUT_LUMINOSITY_B; + #ifdef UNDERGLOW_RBG bool flip_gb = false; for (uint8_t led_id = 0; led_id < UNDERGLOW_LEDS; led_id++) { @@ -498,35 +636,36 @@ void sn32f24xb_set_color(int index, uint8_t r, uint8_t g, uint8_t b) { } } if (flip_gb) { - if (led_state_buf[index].r == r && led_state_buf[index].b == g && led_state_buf[index].g == b) { + if (led_state_buf[index].r == color_r && led_state_buf[index].b == color_g && led_state_buf[index].g == color_b) { return; } - led_state_buf[index].r = r; - led_state_buf[index].b = g; - led_state_buf[index].g = b; + led_state_buf[index].r = color_r; + led_state_buf[index].b = color_g; + led_state_buf[index].g = color_b; led_state_buf_update_required = true; } else { #endif // UNDERGLOW_RBG - if (led_state_buf[index].r == r && led_state_buf[index].b == b && led_state_buf[index].g == g) { + if (led_state_buf[index].r == color_r && led_state_buf[index].b == color_b && led_state_buf[index].g == color_g) { return; } - led_state_buf[index].r = r; - led_state_buf[index].b = b; - led_state_buf[index].g = g; + led_state_buf[index].r = color_r; + led_state_buf[index].b = color_b; + led_state_buf[index].g = color_g; led_state_buf_update_required = true; #ifdef UNDERGLOW_RBG } #endif // UNDERGLOW_RBG } -void sn32f24xb_set_color_all(uint8_t r, uint8_t g, uint8_t b) { - for (int i = 0; i < SN32F24XB_LED_COUNT; i++) { - sn32f24xb_set_color(i, r, g, b); +void sn32f2xx_set_color_all(uint8_t r, uint8_t g, uint8_t b) { + for (int i = 0; i < SN32F2XX_LED_COUNT; i++) { + sn32f2xx_set_color(i, r, g, b); } } +#if defined(SHARED_MATRIX) bool matrix_scan_custom(matrix_row_t current_matrix[]) { if (!matrix_scanned) return false; // Nothing to process until we have the matrix scanned @@ -536,4 +675,5 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { matrix_scanned = false; return changed; -} \ No newline at end of file +} +#endif // SHARED_MATRIX \ No newline at end of file diff --git a/drivers/led/sn32f2xx.h b/drivers/led/sn32f2xx.h new file mode 100644 index 000000000000..e07c086efa7f --- /dev/null +++ b/drivers/led/sn32f2xx.h @@ -0,0 +1,80 @@ +/* Copyright 2024 Dimitris Mantzouranis + * + * 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 + +#if !defined(SN32_LED_OUTPUT_LUMINOSITY_R) +# define SN32_LED_OUTPUT_LUMINOSITY_R 1 +#endif +#if !defined(SN32_LED_OUTPUT_LUMINOSITY_G) +# define SN32_LED_OUTPUT_LUMINOSITY_G 1 +#endif +#if !defined(SN32_LED_OUTPUT_LUMINOSITY_B) +# define SN32_LED_OUTPUT_LUMINOSITY_B 1 +#endif + +#if defined(RGB_MATRIX_SN32F2XX) +# define SN32F2XX_LED_COUNT RGB_MATRIX_LED_COUNT +#endif + +#if !defined(SN32_PWM_OUTPUT_ACTIVE_LEVEL) +# define SN32_PWM_OUTPUT_ACTIVE_LEVEL SN32_PWM_OUTPUT_ACTIVE_LOW +#endif + +#if !defined(SN32_RGB_OUTPUT_ACTIVE_LEVEL) +# define SN32_RGB_OUTPUT_ACTIVE_LEVEL SN32_RGB_OUTPUT_ACTIVE_HIGH +#endif + +#if !defined(SN32_PWM_CONTROL) +# define SN32_PWM_CONTROL HARDWARE_PWM +#endif + +#if !defined(SN32_PWM_DIRECTION) +# define SN32_PWM_DIRECTION DIODE_DIRECTION +#endif + +#if !defined(SN32_RGB_MATRIX_ROW_CHANNELS) +# define SN32_RGB_MATRIX_ROW_CHANNELS 3 +#endif + +#if !defined(SN32_RGB_MATRIX_ROWS) +# define SN32_RGB_MATRIX_ROWS MATRIX_ROWS +#endif + +#if !defined(SN32_RGB_MATRIX_COLS) +# define SN32_RGB_MATRIX_COLS MATRIX_COLS +#endif + +#if !defined(SN32_RGB_MATRIX_ROW_PINS) +# error Missing definition for SN32_RGB_MATRIX_ROW_PINS +#endif + +#if !defined(SN32_RGB_MATRIX_COL_PINS) +# define SHARED_MATRIX +# define SN32_RGB_MATRIX_COL_PINS MATRIX_COL_PINS +#endif + +#if !defined(SN32_RGB_MATRIX_ROWS_HW) +# define SN32_RGB_MATRIX_ROWS_HW (SN32_RGB_MATRIX_ROWS * SN32_RGB_MATRIX_ROW_CHANNELS) +#endif + +void sn32f2xx_init(void); +void sn32f2xx_flush(void); +void sn32f2xx_set_color(int index, uint8_t r, uint8_t g, uint8_t b); +void sn32f2xx_set_color_all(uint8_t r, uint8_t g, uint8_t b); diff --git a/keyboards/czc/dwarf/info.json b/keyboards/czc/dwarf/info.json index 2ea2cdd29943..39b91ae95760 100644 --- a/keyboards/czc/dwarf/info.json +++ b/keyboards/czc/dwarf/info.json @@ -173,7 +173,7 @@ "splash" : true, "typing_heatmap" : true, }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ {"matrix": [0, 0],"flags": 1,"x":0, "y":0}, {"matrix": [0, 1],"flags": 1,"x":26, "y":0}, diff --git a/keyboards/designedbygg/berserker/info.json b/keyboards/designedbygg/berserker/info.json index 8c42a7af8bb2..24e0ed51bd79 100644 --- a/keyboards/designedbygg/berserker/info.json +++ b/keyboards/designedbygg/berserker/info.json @@ -184,7 +184,7 @@ "splash" : true, "typing_heatmap" : true, }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ {"matrix": [0, 0],"flags": 1,"x":0, "y":0}, {"matrix": [0, 2],"flags": 1,"x":26, "y":0}, diff --git a/keyboards/designedbygg/ironclad/icl01/info.json b/keyboards/designedbygg/ironclad/icl01/info.json index 02208f106a40..de2d1b0a1182 100644 --- a/keyboards/designedbygg/ironclad/icl01/info.json +++ b/keyboards/designedbygg/ironclad/icl01/info.json @@ -195,7 +195,7 @@ "splash" : true, "typing_heatmap" : true, }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ {"matrix": [0, 0],"flags": 1,"x":0, "y":0}, {"matrix": [0, 2],"flags": 1,"x":21, "y":0}, diff --git a/keyboards/designedbygg/ironclad/icl03/info.json b/keyboards/designedbygg/ironclad/icl03/info.json index 20b0abc1a466..1b068c5467c8 100644 --- a/keyboards/designedbygg/ironclad/icl03/info.json +++ b/keyboards/designedbygg/ironclad/icl03/info.json @@ -211,7 +211,7 @@ "splash" : true, "typing_heatmap" : true }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ {"matrix": [0, 0],"flags": 1,"x":0, "y":0}, {"matrix": [0, 2],"flags": 1,"x":21, "y":0}, diff --git a/keyboards/designedbygg/redblade/info.json b/keyboards/designedbygg/redblade/info.json index cf8340b16506..67a74e1050b6 100644 --- a/keyboards/designedbygg/redblade/info.json +++ b/keyboards/designedbygg/redblade/info.json @@ -206,7 +206,7 @@ "splash" : true, "typing_heatmap" : true }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ {"matrix": [0, 0],"flags": 1,"x":0, "y":0}, {"matrix": [0, 2],"flags": 1,"x":21, "y":0}, diff --git a/keyboards/flesports/fl980/config.h b/keyboards/flesports/fl980/config.h index 14d7b23c77ef..9c9589108458 100644 --- a/keyboards/flesports/fl980/config.h +++ b/keyboards/flesports/fl980/config.h @@ -18,8 +18,6 @@ #define SN32_RGB_MATRIX_ROW_PINS { C0,C1,C3, C4,C5,C6, C7,C8,C9, C10,C11,C12, C13,C14,B13, C15,B15,B14 } -#define SN32_RGB_MATRIX_COL_PINS { B9, A8, A9, A10, A11, A12, A13, A14, A15, B0, B1, B2, B3, B4, B5, B6, B7, B8 } - #define RGB_MATRIX_LED_COUNT 98 #define MATRIX_UNSELECT_DRIVE_HIGH #define SN32_PWM_OUTPUT_ACTIVE_LEVEL SN32_PWM_OUTPUT_ACTIVE_HIGH diff --git a/keyboards/flesports/fl980/info.json b/keyboards/flesports/fl980/info.json index 2b9a6e5e8e28..754e371bc825 100644 --- a/keyboards/flesports/fl980/info.json +++ b/keyboards/flesports/fl980/info.json @@ -74,111 +74,111 @@ "splash" : true, "typing_heatmap" : true, }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ - { "matrix":[0, 0], "flags":4, "x":0, "y":0 }, - { "matrix":[0, 1], "flags":4, "x":24, "y":0 }, - { "matrix":[0, 2], "flags":4, "x":36, "y":0 }, - { "matrix":[0, 3], "flags":4, "x":48, "y":0 }, - { "matrix":[0, 4], "flags":4, "x":61, "y":0 }, - { "matrix":[0, 5], "flags":4, "x":79, "y":0 }, - { "matrix":[0, 6], "flags":4, "x":91, "y":0 }, - { "matrix":[0, 7], "flags":4, "x":103, "y":0 }, - { "matrix":[0, 8], "flags":4, "x":115, "y":0 }, - { "matrix":[0, 9], "flags":4, "x":133, "y":0 }, - { "matrix":[0, 10], "flags":4, "x":145, "y":0 }, - { "matrix":[0, 11], "flags":4, "x":157, "y":0 }, - { "matrix":[0, 12], "flags":4, "x":170, "y":0 }, - { "matrix":[0, 14], "flags":4, "x":188, "y":0 }, - { "matrix":[0, 15], "flags":4, "x":200, "y":0 }, - { "matrix":[0, 16], "flags":4, "x":212, "y":0 }, - { "matrix":[0, 17], "flags":4, "x":224, "y":0 }, + { "matrix":[0, 17], "flags":4, "x":0, "y":0 }, + { "matrix":[0, 0], "flags":4, "x":24, "y":0 }, + { "matrix":[0, 1], "flags":4, "x":36, "y":0 }, + { "matrix":[0, 2], "flags":4, "x":48, "y":0 }, + { "matrix":[0, 3], "flags":4, "x":61, "y":0 }, + { "matrix":[0, 4], "flags":4, "x":79, "y":0 }, + { "matrix":[0, 5], "flags":4, "x":91, "y":0 }, + { "matrix":[0, 6], "flags":4, "x":103, "y":0 }, + { "matrix":[0, 7], "flags":4, "x":115, "y":0 }, + { "matrix":[0, 8], "flags":4, "x":133, "y":0 }, + { "matrix":[0, 9], "flags":4, "x":145, "y":0 }, + { "matrix":[0, 10], "flags":4, "x":157, "y":0 }, + { "matrix":[0, 11], "flags":4, "x":170, "y":0 }, + { "matrix":[0, 12], "flags":4, "x":188, "y":0 }, + { "matrix":[0, 14], "flags":4, "x":200, "y":0 }, + { "matrix":[0, 15], "flags":4, "x":212, "y":0 }, + { "matrix":[0, 16], "flags":4, "x":224, "y":0 }, - { "matrix":[1, 0], "flags":4, "x":0, "y":15 }, - { "matrix":[1, 1], "flags":4, "x":12, "y":15 }, - { "matrix":[1, 2], "flags":4, "x":24, "y":15 }, - { "matrix":[1, 3], "flags":4, "x":36, "y":15 }, - { "matrix":[1, 4], "flags":4, "x":48, "y":15 }, - { "matrix":[1, 5], "flags":4, "x":61, "y":15 }, - { "matrix":[1, 6], "flags":4, "x":73, "y":15 }, - { "matrix":[1, 7], "flags":4, "x":85, "y":15 }, - { "matrix":[1, 8], "flags":4, "x":97, "y":15 }, - { "matrix":[1, 9], "flags":4, "x":109, "y":15 }, - { "matrix":[1, 10], "flags":4, "x":121, "y":15 }, - { "matrix":[1, 11], "flags":4, "x":133, "y":15 }, - { "matrix":[1, 12], "flags":4, "x":145, "y":15 }, - { "matrix":[1, 13], "flags":4, "x":163, "y":15 }, - { "matrix":[1, 14], "flags":4, "x":188, "y":15 }, - { "matrix":[1, 15], "flags":4, "x":200, "y":15 }, - { "matrix":[1, 16], "flags":4, "x":212, "y":15 }, - { "matrix":[1, 17], "flags":4, "x":224, "y":15 }, + { "matrix":[1, 17], "flags":4, "x":0, "y":15 }, + { "matrix":[1, 0], "flags":4, "x":12, "y":15 }, + { "matrix":[1, 1], "flags":4, "x":24, "y":15 }, + { "matrix":[1, 2], "flags":4, "x":36, "y":15 }, + { "matrix":[1, 3], "flags":4, "x":48, "y":15 }, + { "matrix":[1, 4], "flags":4, "x":61, "y":15 }, + { "matrix":[1, 5], "flags":4, "x":73, "y":15 }, + { "matrix":[1, 6], "flags":4, "x":85, "y":15 }, + { "matrix":[1, 7], "flags":4, "x":97, "y":15 }, + { "matrix":[1, 8], "flags":4, "x":109, "y":15 }, + { "matrix":[1, 9], "flags":4, "x":121, "y":15 }, + { "matrix":[1, 10], "flags":4, "x":133, "y":15 }, + { "matrix":[1, 11], "flags":4, "x":145, "y":15 }, + { "matrix":[1, 12], "flags":4, "x":163, "y":15 }, + { "matrix":[1, 13], "flags":4, "x":188, "y":15 }, + { "matrix":[1, 14], "flags":4, "x":200, "y":15 }, + { "matrix":[1, 15], "flags":4, "x":212, "y":15 }, + { "matrix":[1, 16], "flags":4, "x":224, "y":15 }, - { "matrix":[2, 0], "flags":4, "x":3, "y":26 }, - { "matrix":[2, 1], "flags":4, "x":18, "y":26 }, - { "matrix":[2, 2], "flags":4, "x":30, "y":26 }, - { "matrix":[2, 3], "flags":4, "x":42, "y":26 }, - { "matrix":[2, 4], "flags":4, "x":54, "y":26 }, - { "matrix":[2, 5], "flags":4, "x":67, "y":26 }, - { "matrix":[2, 6], "flags":4, "x":79, "y":26 }, - { "matrix":[2, 7], "flags":4, "x":91, "y":26 }, - { "matrix":[2, 8], "flags":4, "x":103, "y":26 }, - { "matrix":[2, 9], "flags":4, "x":115, "y":26 }, - { "matrix":[2, 10], "flags":4, "x":127, "y":26 }, - { "matrix":[2, 11], "flags":4, "x":139, "y":26 }, - { "matrix":[2, 12], "flags":4, "x":151, "y":26 }, - { "matrix":[2, 13], "flags":4, "x":166, "y":26 }, - { "matrix":[2, 14], "flags":4, "x":188, "y":26 }, - { "matrix":[2, 15], "flags":4, "x":200, "y":26 }, - { "matrix":[2, 16], "flags":4, "x":212, "y":26 }, - { "matrix":[2, 17], "flags":4, "x":224, "y":32 }, + { "matrix":[2, 17], "flags":4, "x":3, "y":26 }, + { "matrix":[2, 0], "flags":4, "x":18, "y":26 }, + { "matrix":[2, 1], "flags":4, "x":30, "y":26 }, + { "matrix":[2, 2], "flags":4, "x":42, "y":26 }, + { "matrix":[2, 3], "flags":4, "x":54, "y":26 }, + { "matrix":[2, 4], "flags":4, "x":67, "y":26 }, + { "matrix":[2, 5], "flags":4, "x":79, "y":26 }, + { "matrix":[2, 6], "flags":4, "x":91, "y":26 }, + { "matrix":[2, 7], "flags":4, "x":103, "y":26 }, + { "matrix":[2, 8], "flags":4, "x":115, "y":26 }, + { "matrix":[2, 9], "flags":4, "x":127, "y":26 }, + { "matrix":[2, 10], "flags":4, "x":139, "y":26 }, + { "matrix":[2, 11], "flags":4, "x":151, "y":26 }, + { "matrix":[2, 12], "flags":4, "x":166, "y":26 }, + { "matrix":[2, 13], "flags":4, "x":188, "y":26 }, + { "matrix":[2, 14], "flags":4, "x":200, "y":26 }, + { "matrix":[2, 15], "flags":4, "x":212, "y":26 }, + { "matrix":[2, 16], "flags":4, "x":224, "y":32 }, - { "matrix":[3, 0], "flags":4, "x":5, "y":38 }, - { "matrix":[3, 1], "flags":4, "x":21, "y":38 }, - { "matrix":[3, 2], "flags":4, "x":33, "y":38 }, - { "matrix":[3, 3], "flags":4, "x":45, "y":38 }, - { "matrix":[3, 4], "flags":4, "x":58, "y":38 }, - { "matrix":[3, 5], "flags":4, "x":70, "y":38 }, - { "matrix":[3, 6], "flags":4, "x":82, "y":38 }, - { "matrix":[3, 7], "flags":4, "x":94, "y":38 }, - { "matrix":[3, 8], "flags":4, "x":106, "y":38 }, - { "matrix":[3, 9], "flags":4, "x":118, "y":38 }, - { "matrix":[3, 10], "flags":4, "x":130, "y":38 }, - { "matrix":[3, 11], "flags":4, "x":142, "y":38 }, - { "matrix":[3, 13], "flags":4, "x":162, "y":38 }, - { "matrix":[3, 14], "flags":4, "x":188, "y":38 }, - { "matrix":[3, 15], "flags":4, "x":200, "y":38 }, - { "matrix":[3, 16], "flags":4, "x":212, "y":38 }, - { "matrix":[3, 17], "flags":4, "x":224, "y":55 }, + { "matrix":[3, 17], "flags":4, "x":5, "y":38 }, + { "matrix":[3, 0], "flags":4, "x":21, "y":38 }, + { "matrix":[3, 1], "flags":4, "x":33, "y":38 }, + { "matrix":[3, 2], "flags":4, "x":45, "y":38 }, + { "matrix":[3, 3], "flags":4, "x":58, "y":38 }, + { "matrix":[3, 4], "flags":4, "x":70, "y":38 }, + { "matrix":[3, 5], "flags":4, "x":82, "y":38 }, + { "matrix":[3, 6], "flags":4, "x":94, "y":38 }, + { "matrix":[3, 7], "flags":4, "x":106, "y":38 }, + { "matrix":[3, 8], "flags":4, "x":118, "y":38 }, + { "matrix":[3, 9], "flags":4, "x":130, "y":38 }, + { "matrix":[3, 10], "flags":4, "x":142, "y":38 }, + { "matrix":[3, 11], "flags":4, "x":162, "y":38 }, + { "matrix":[3, 13], "flags":4, "x":188, "y":38 }, + { "matrix":[3, 14], "flags":4, "x":200, "y":38 }, + { "matrix":[3, 15], "flags":4, "x":212, "y":38 }, + { "matrix":[3, 16], "flags":4, "x":224, "y":55 }, - { "matrix":[4, 0], "flags":4, "x":8, "y":49 }, - { "matrix":[4, 2], "flags":4, "x":27, "y":49 }, - { "matrix":[4, 3], "flags":4, "x":39, "y":49 }, - { "matrix":[4, 4], "flags":4, "x":51, "y":49 }, - { "matrix":[4, 5], "flags":4, "x":64, "y":49 }, - { "matrix":[4, 6], "flags":4, "x":76, "y":49 }, - { "matrix":[4, 7], "flags":4, "x":88, "y":49 }, - { "matrix":[4, 8], "flags":4, "x":100, "y":49 }, - { "matrix":[4, 9], "flags":4, "x":112, "y":49 }, - { "matrix":[4, 10], "flags":4, "x":124, "y":49 }, - { "matrix":[4, 11], "flags":4, "x":136, "y":49 }, - { "matrix":[4, 13], "flags":4, "x":153, "y":49 }, - { "matrix":[4, 14], "flags":4, "x":188, "y":49 }, - { "matrix":[4, 15], "flags":4, "x":200, "y":49 }, - { "matrix":[4, 16], "flags":4, "x":212, "y":49 }, - { "matrix":[4, 17], "flags":4, "x":212, "y":61 }, + { "matrix":[4, 17], "flags":4, "x":8, "y":49 }, + { "matrix":[4, 0], "flags":4, "x":27, "y":49 }, + { "matrix":[4, 2], "flags":4, "x":39, "y":49 }, + { "matrix":[4, 3], "flags":4, "x":51, "y":49 }, + { "matrix":[4, 4], "flags":4, "x":64, "y":49 }, + { "matrix":[4, 5], "flags":4, "x":76, "y":49 }, + { "matrix":[4, 6], "flags":4, "x":88, "y":49 }, + { "matrix":[4, 7], "flags":4, "x":100, "y":49 }, + { "matrix":[4, 8], "flags":4, "x":112, "y":49 }, + { "matrix":[4, 9], "flags":4, "x":124, "y":49 }, + { "matrix":[4, 10], "flags":4, "x":136, "y":49 }, + { "matrix":[4, 11], "flags":4, "x":153, "y":49 }, + { "matrix":[4, 13], "flags":4, "x":188, "y":49 }, + { "matrix":[4, 14], "flags":4, "x":200, "y":49 }, + { "matrix":[4, 15], "flags":4, "x":212, "y":49 }, + { "matrix":[4, 16], "flags":4, "x":212, "y":61 }, - { "matrix":[5, 0], "flags":4, "x":2, "y":61 }, - { "matrix":[5, 1], "flags":4, "x":17, "y":61 }, - { "matrix":[5, 2], "flags":4, "x":32, "y":61 }, - { "matrix":[5, 6], "flags":4, "x":77, "y":61 }, - { "matrix":[5, 10], "flags":4, "x":121, "y":61 }, - { "matrix":[5, 11], "flags":4, "x":133, "y":61 }, - { "matrix":[5, 12], "flags":4, "x":145, "y":61 }, - { "matrix":[5, 13], "flags":4, "x":173, "y":52 }, - { "matrix":[5, 14], "flags":4, "x":160, "y":64 }, - { "matrix":[5, 15], "flags":4, "x":173, "y":64 }, - { "matrix":[5, 16], "flags":4, "x":185, "y":64 }, - { "matrix":[5, 17], "flags":4, "x":200, "y":61 } + { "matrix":[5, 17], "flags":4, "x":2, "y":61 }, + { "matrix":[5, 0], "flags":4, "x":17, "y":61 }, + { "matrix":[5, 1], "flags":4, "x":32, "y":61 }, + { "matrix":[5, 2], "flags":4, "x":77, "y":61 }, + { "matrix":[5, 6], "flags":4, "x":121, "y":61 }, + { "matrix":[5, 10], "flags":4, "x":133, "y":61 }, + { "matrix":[5, 11], "flags":4, "x":145, "y":61 }, + { "matrix":[5, 12], "flags":4, "x":173, "y":52 }, + { "matrix":[5, 13], "flags":4, "x":160, "y":64 }, + { "matrix":[5, 14], "flags":4, "x":173, "y":64 }, + { "matrix":[5, 15], "flags":4, "x":185, "y":64 }, + { "matrix":[5, 16], "flags":4, "x":200, "y":61 } ], "react_on_keyup": true, "sleep": true diff --git a/keyboards/hator/gravity/tkl/keyboard.json b/keyboards/hator/gravity/tkl/keyboard.json index e10356d2d684..9993f82a8663 100644 --- a/keyboards/hator/gravity/tkl/keyboard.json +++ b/keyboards/hator/gravity/tkl/keyboard.json @@ -54,7 +54,7 @@ "solid_splash": true, "riverflow": true }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ { "matrix": [ 0, 0 ], "flags": 4, "x": 0, "y": 0 }, { "matrix": [ 0, 1 ], "flags": 4, "x": 26, "y": 0 }, diff --git a/keyboards/keychron/c1/rgb/keyboard.json b/keyboards/keychron/c1/rgb/keyboard.json index 26d544d4f063..f7bfef96cb55 100644 --- a/keyboards/keychron/c1/rgb/keyboard.json +++ b/keyboards/keychron/c1/rgb/keyboard.json @@ -134,7 +134,7 @@ } }, "rgb_matrix": { - "driver": "sn32f24xb", + "driver": "sn32f2xx", "animations": { "breathing": true, "band_spiral_val": true, diff --git a/keyboards/keychron/k12/rgb/info.json b/keyboards/keychron/k12/rgb/info.json index 9a1f9ee2fe51..024cf7aa6ccd 100644 --- a/keyboards/keychron/k12/rgb/info.json +++ b/keyboards/keychron/k12/rgb/info.json @@ -45,7 +45,7 @@ "splash": true, "typing_heatmap": true }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "react_on_keyup": true, "sleep": true }, diff --git a/keyboards/keychron/k2/rgb/v2/ansi/info.json b/keyboards/keychron/k2/rgb/v2/ansi/info.json index 230d051ede70..7ed6aebd5af4 100644 --- a/keyboards/keychron/k2/rgb/v2/ansi/info.json +++ b/keyboards/keychron/k2/rgb/v2/ansi/info.json @@ -126,7 +126,7 @@ } }, "rgb_matrix": { - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ { "matrix": [ 0, 0 ], "flags": 4, "x": 0, "y": 0 }, { "matrix": [ 0, 1 ], "flags": 4, "x": 12, "y": 0 }, diff --git a/keyboards/keychron/k2/rgb/v2/iso/info.json b/keyboards/keychron/k2/rgb/v2/iso/info.json index 96aaf3c8cb60..b88294f1b2a0 100644 --- a/keyboards/keychron/k2/rgb/v2/iso/info.json +++ b/keyboards/keychron/k2/rgb/v2/iso/info.json @@ -127,7 +127,7 @@ } }, "rgb_matrix": { - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ { "matrix": [ 0, 0 ], "flags": 4, "x": 7, "y": 0 }, { "matrix": [ 0, 1 ], "flags": 4, "x": 21, "y": 0 }, diff --git a/keyboards/keychron/k4/rgb/v2/ansi/info.json b/keyboards/keychron/k4/rgb/v2/ansi/info.json index b91378ffa913..09ff2fb51bf0 100644 --- a/keyboards/keychron/k4/rgb/v2/ansi/info.json +++ b/keyboards/keychron/k4/rgb/v2/ansi/info.json @@ -139,7 +139,7 @@ }, "rgb_matrix": { - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ { "matrix": [ 0, 0 ], "flags": 4, "x": 0, "y": 0 }, { "matrix": [ 0, 1 ], "flags": 4, "x": 12, "y": 0 }, diff --git a/keyboards/keychron/k4/rgb/v2/iso/info.json b/keyboards/keychron/k4/rgb/v2/iso/info.json index e4272b0ba00f..b3d68c973af5 100644 --- a/keyboards/keychron/k4/rgb/v2/iso/info.json +++ b/keyboards/keychron/k4/rgb/v2/iso/info.json @@ -144,7 +144,7 @@ }, "rgb_matrix": { - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ { "matrix": [ 0, 0 ], "flags": 4, "x": 0, "y": 0 }, { "matrix": [ 0, 1 ], "flags": 4, "x": 12, "y": 0 }, diff --git a/keyboards/keychron/k8/rgb/info.json b/keyboards/keychron/k8/rgb/info.json index b051f56b8038..0bf82dd9f810 100644 --- a/keyboards/keychron/k8/rgb/info.json +++ b/keyboards/keychron/k8/rgb/info.json @@ -63,7 +63,7 @@ "splash" : true, "typing_heatmap" : true, }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "react_on_keyup": true, "sleep": true }, diff --git a/keyboards/ozone/tactical/info.json b/keyboards/ozone/tactical/info.json index bf2a526e99e6..05960975fe77 100644 --- a/keyboards/ozone/tactical/info.json +++ b/keyboards/ozone/tactical/info.json @@ -117,7 +117,7 @@ "animations": { "cycle_left_right" : true, }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ { "matrix": [0, 0], "x": 0, "y": 0, "flags": 4}, { "matrix": [0, 1], "x": 16, "y": 0, "flags": 4}, diff --git a/keyboards/redragon/k552/v2/iso/info.json b/keyboards/redragon/k552/v2/iso/info.json index aa5d8992311d..aa3f06ab717d 100644 --- a/keyboards/redragon/k552/v2/iso/info.json +++ b/keyboards/redragon/k552/v2/iso/info.json @@ -78,7 +78,7 @@ "splash" : true, "typing_heatmap" : true }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ {"matrix": [0, 0], "flags": 4, "x": 0, "y": 0}, diff --git a/keyboards/redragon/k556/info.json b/keyboards/redragon/k556/info.json index 7bb2f0323b26..0c782678e37b 100644 --- a/keyboards/redragon/k556/info.json +++ b/keyboards/redragon/k556/info.json @@ -53,7 +53,7 @@ "splash" : true, "typing_heatmap" : true }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ {"matrix": [0, 0], "flags": 4, "x": 0, "y": 0}, diff --git a/keyboards/redragon/k582/keyboard.json b/keyboards/redragon/k582/keyboard.json index 414b7bf9a59a..57f544002a16 100644 --- a/keyboards/redragon/k582/keyboard.json +++ b/keyboards/redragon/k582/keyboard.json @@ -56,7 +56,7 @@ "solid_splash": true, "riverflow": true }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ {"matrix": [0, 0], "flags": 4, "x": 0, "y": 0}, diff --git a/keyboards/redragon/k630/info.json b/keyboards/redragon/k630/info.json index 1fd22f46dd8d..1dd7e7c63dd4 100644 --- a/keyboards/redragon/k630/info.json +++ b/keyboards/redragon/k630/info.json @@ -52,7 +52,7 @@ "splash" : true, "typing_heatmap" : true, }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ { "matrix":[0, 0], "flags":4, "x":0, "y":0 }, { "matrix":[0, 1], "flags":4, "x":16, "y":0 }, diff --git a/keyboards/royal_kludge/rk61_rgb/info.json b/keyboards/royal_kludge/rk61_rgb/info.json index 153533a1be9c..fa22a76d9bd1 100644 --- a/keyboards/royal_kludge/rk61_rgb/info.json +++ b/keyboards/royal_kludge/rk61_rgb/info.json @@ -48,7 +48,7 @@ "splash" : true, "typing_heatmap" : true }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ { "matrix":[0, 0], "flags":4, "x":0, "y":0 }, { "matrix":[0, 1], "flags":4, "x":16, "y":0 }, diff --git a/keyboards/royal_kludge/rk68_rgb/info.json b/keyboards/royal_kludge/rk68_rgb/info.json index aef19360012a..346edb115ba3 100644 --- a/keyboards/royal_kludge/rk68_rgb/info.json +++ b/keyboards/royal_kludge/rk68_rgb/info.json @@ -49,7 +49,7 @@ "splash" : true, "typing_heatmap" : true }, - "driver": "sn32f24xb", + "driver": "sn32f2xx", "layout": [ { "matrix": [0,0], "x": 0, "y": 0, "flags": 4}, { "matrix": [0,1], "x": 14, "y": 0, "flags": 4}, diff --git a/quantum/matrix.h b/quantum/matrix.h index f14ebd4c5ec5..51f51dd24c99 100644 --- a/quantum/matrix.h +++ b/quantum/matrix.h @@ -20,6 +20,9 @@ along with this program. If not, see . #include #include #include "gpio.h" +#if defined(RGB_MATRIX_ENABLE) +# include "rgb_matrix_drivers.h" +#endif /* diode directions */ #define COL2ROW 0 diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 7f3898fe2a89..1e43fdffec02 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -211,11 +211,11 @@ const rgb_matrix_driver_t rgb_matrix_driver = { .set_color_all = setled_all, }; -#elif defined(RGB_MATRIX_SN32F24XB) +#elif defined(RGB_MATRIX_SN32F2XX) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = sn32f24xb_init, - .flush = sn32f24xb_flush, - .set_color = sn32f24xb_set_color, - .set_color_all = sn32f24xb_set_color_all, + .init = sn32f2xx_init, + .flush = sn32f2xx_flush, + .set_color = sn32f2xx_set_color, + .set_color_all = sn32f2xx_set_color_all, }; #endif diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.h b/quantum/rgb_matrix/rgb_matrix_drivers.h index c739608a43b5..9c96e86c45fc 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.h +++ b/quantum/rgb_matrix/rgb_matrix_drivers.h @@ -35,8 +35,8 @@ # include "snled27351.h" #elif defined(RGB_MATRIX_WS2812) # include "ws2812.h" -#elif defined(RGB_MATRIX_SN32F24XB) -# include "sn32f24xb.h" +#elif defined(RGB_MATRIX_SN32F2XX) +# include "sn32f2xx.h" #elif defined(RGB_MATRIX_SLED1734X) # include "sled1734x.h" #endif