From 066818f5f9cbee4ade1ea94ee167ee2df7d9e559 Mon Sep 17 00:00:00 2001 From: Erovia Date: Mon, 22 Apr 2019 17:26:41 +0200 Subject: Define RGB colors (#5300) * Define RGB colors Define RGB colors and pass them to the rgblight functions, instead of defining multiple macros. * Add new color definitions support for RGB Matrix * Add/clarify info about new color definitions in Docs * Add deprecation warning banner to rgblight_list.h --- quantum/rgb_matrix.h | 1 + quantum/rgblight_list.h | 240 +++++++++++++++++++++++++++++------------------- 2 files changed, 147 insertions(+), 94 deletions(-) (limited to 'quantum') diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 0a11f2692..f5be49435 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -24,6 +24,7 @@ #include "rgb_matrix_types.h" #include "color.h" #include "quantum.h" +#include "rgblight_list.h" #ifdef IS31FL3731 #include "is31fl3731.h" diff --git a/quantum/rgblight_list.h b/quantum/rgblight_list.h index 407fd8e9d..7b8313380 100644 --- a/quantum/rgblight_list.h +++ b/quantum/rgblight_list.h @@ -13,111 +13,163 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef RGBLIGHT_LIST_H -#define RGBLIGHT_LIST_H +#pragma once + +/* RGB COLORS */ +#define RGB_WHITE 0xFF, 0xFF, 0xFF +#define RGB_RED 0xFF, 0x00, 0x00 +#define RGB_CORAL 0xFF, 0x7C, 0x4D +#define RGB_ORANGE 0xFF, 0x80, 0x00 +#define RGB_GOLDENROD 0xD9, 0xA5, 0x21 +#define RGB_GOLD 0xFF, 0xD9, 0x00 +#define RGB_YELLOW 0xFF, 0xFF, 0x00 +#define RGB_CHARTREUSE 0x80, 0xFF, 0x00 +#define RGB_GREEN 0x00, 0xFF, 0x00 +#define RGB_SPRINGGREEN 0x00, 0xFF, 0x80 +#define RGB_TURQUOISE 0x47, 0x6E, 0x6A +#define RGB_TEAL 0x00, 0x80, 0x80 +#define RGB_CYAN 0x00, 0xFF, 0xFF +#define RGB_AZURE 0x99, 0xf5, 0xFF +#define RGB_BLUE 0x00, 0x00, 0xFF +#define RGB_PURPLE 0x7A, 0x00, 0xFF +#define RGB_MAGENTA 0xFF, 0x00, 0xFF +#define RGB_PINK 0xFF, 0x80, 0xBF + +/* HSV COLORS */ +#define HSV_WHITE 0, 0, 255 +#define HSV_RED 0, 255, 255 +#define HSV_CORAL 16, 176, 255 +#define HSV_ORANGE 39, 255, 255 +#define HSV_GOLDENROD 43, 218, 218 +#define HSV_GOLD 51, 255, 255 +#define HSV_YELLOW 60, 255, 255 +#define HSV_CHARTREUSE 90, 255, 255 +#define HSV_GREEN 120, 255, 255 +#define HSV_SPRINGGREEN 150, 255, 255 +#define HSV_TURQUOISE 174, 90, 112 +#define HSV_TEAL 180, 255, 128 +#define HSV_CYAN 180, 255, 255 +#define HSV_AZURE 186, 102, 255 +#define HSV_BLUE 240, 255, 255 +#define HSV_PURPLE 270, 255, 255 +#define HSV_MAGENTA 300, 255, 255 +#define HSV_PINK 330, 128, 255 + + +/* +######################################################################################## +## ## +## ## +## ## +## The functions below have been deprecated and may be removed in a future release. ## +## ## +## Please use the values above with the RGB functions. ## +## ## +## ## +## ## +######################################################################################## +*/ /* SET RGB List */ -#define rgblight_setrgb_white() rgblight_setrgb (0xFF, 0xFF, 0xFF) -#define rgblight_setrgb_red() rgblight_setrgb (0xFF, 0x00, 0x00) -#define rgblight_setrgb_coral() rgblight_setrgb (0xFF, 0x7C, 0x4D) -#define rgblight_setrgb_orange() rgblight_setrgb (0xFF, 0x80, 0x00) -#define rgblight_setrgb_goldenrod() rgblight_setrgb (0xD9, 0xA5, 0x21) -#define rgblight_setrgb_gold() rgblight_setrgb (0xFF, 0xD9, 0x00) -#define rgblight_setrgb_yellow() rgblight_setrgb (0xFF, 0xFF, 0x00) -#define rgblight_setrgb_chartreuse() rgblight_setrgb (0x80, 0xFF, 0x00) -#define rgblight_setrgb_green() rgblight_setrgb (0x00, 0xFF, 0x00) -#define rgblight_setrgb_springgreen() rgblight_setrgb (0x00, 0xFF, 0x80) -#define rgblight_setrgb_turquoise() rgblight_setrgb (0x47, 0x6E, 0x6A) -#define rgblight_setrgb_teal() rgblight_setrgb (0x00, 0x80, 0x80) -#define rgblight_setrgb_cyan() rgblight_setrgb (0x00, 0xFF, 0xFF) -#define rgblight_setrgb_azure() rgblight_setrgb (0x99, 0xf5, 0xFF) -#define rgblight_setrgb_blue() rgblight_setrgb (0x00, 0x00, 0xFF) -#define rgblight_setrgb_purple() rgblight_setrgb (0x7A, 0x00, 0xFF) -#define rgblight_setrgb_magenta() rgblight_setrgb (0xFF, 0x00, 0xFF) -#define rgblight_setrgb_pink() rgblight_setrgb (0xFF, 0x80, 0xBF) +#define rgblight_setrgb_white() rgblight_setrgb (RGB_WHITE) +#define rgblight_setrgb_red() rgblight_setrgb (RGB_RED) +#define rgblight_setrgb_coral() rgblight_setrgb (RGB_CORAL) +#define rgblight_setrgb_orange() rgblight_setrgb (RGB_ORANGE) +#define rgblight_setrgb_goldenrod() rgblight_setrgb (RGB_GOLDENROD) +#define rgblight_setrgb_gold() rgblight_setrgb (RGB_GOLD) +#define rgblight_setrgb_yellow() rgblight_setrgb (RGB_YEllOW) +#define rgblight_setrgb_chartreuse() rgblight_setrgb (RGB_CHARTREUSE) +#define rgblight_setrgb_green() rgblight_setrgb (RGB_GREEN) +#define rgblight_setrgb_springgreen() rgblight_setrgb (RGB_SPRINGGREEN) +#define rgblight_setrgb_turquoise() rgblight_setrgb (RGB_TURQUOISE) +#define rgblight_setrgb_teal() rgblight_setrgb (RGB_TEAL) +#define rgblight_setrgb_cyan() rgblight_setrgb (RGB_CYAN) +#define rgblight_setrgb_azure() rgblight_setrgb (RGB_AZURE) +#define rgblight_setrgb_blue() rgblight_setrgb (RGB_BLUE) +#define rgblight_setrgb_purple() rgblight_setrgb (RGB_PURPLE) +#define rgblight_setrgb_magenta() rgblight_setrgb (RGB_MAGENTA) +#define rgblight_setrgb_pink() rgblight_setrgb (RGB_PINK) /* SET RGB List */ -#define rgblight_setrgb_white_at(at) rgblight_setrgb_at (0xFF, 0xFF, 0xFF, at) -#define rgblight_setrgb_red_at(at) rgblight_setrgb_at (0xFF, 0x00, 0x00, at) -#define rgblight_setrgb_coral_at(at) rgblight_setrgb_at (0xFF, 0x7C, 0x4D, at) -#define rgblight_setrgb_orange_at(at) rgblight_setrgb_at (0xFF, 0x80, 0x00, at) -#define rgblight_setrgb_goldenrod_at(at) rgblight_setrgb_at (0xD9, 0xA5, 0x21, at) -#define rgblight_setrgb_gold_at(at) rgblight_setrgb_at (0xFF, 0xD9, 0x00, at) -#define rgblight_setrgb_yellow_at(at) rgblight_setrgb_at (0xFF, 0xFF, 0x00, at) -#define rgblight_setrgb_chartreuse_at(at) rgblight_setrgb_at (0x80, 0xFF, 0x00, at) -#define rgblight_setrgb_green_at(at) rgblight_setrgb_at (0x00, 0xFF, 0x00, at) -#define rgblight_setrgb_springgreen_at(at) rgblight_setrgb_at (0x00, 0xFF, 0x80, at) -#define rgblight_setrgb_turquoise_at(at) rgblight_setrgb_at (0x47, 0x6E, 0x6A, at) -#define rgblight_setrgb_teal_at(at) rgblight_setrgb_at (0x00, 0x80, 0x80, at) -#define rgblight_setrgb_cyan_at(at) rgblight_setrgb_at (0x00, 0xFF, 0xFF, at) -#define rgblight_setrgb_azure_at(at) rgblight_setrgb_at (0x99, 0xf5, 0xFF, at) -#define rgblight_setrgb_blue_at(at) rgblight_setrgb_at (0x00, 0x00, 0xFF, at) -#define rgblight_setrgb_purple_at(at) rgblight_setrgb_at (0x7A, 0x00, 0xFF, at) -#define rgblight_setrgb_magenta_at(at) rgblight_setrgb_at (0xFF, 0x00, 0xFF, at) -#define rgblight_setrgb_pink_at(at) rgblight_setrgb_at (0xFF, 0x80, 0xBF, at) +#define rgblight_setrgb_white_at(at) rgblight_setrgb_at (RGB_WHITE, at) +#define rgblight_setrgb_red_at(at) rgblight_setrgb_at (RGB_RED, at) +#define rgblight_setrgb_coral_at(at) rgblight_setrgb_at (RGB_CORAL, at) +#define rgblight_setrgb_orange_at(at) rgblight_setrgb_at (RGB_ORANGE at) +#define rgblight_setrgb_goldenrod_at(at) rgblight_setrgb_at (RGB_GOLDENROD, at) +#define rgblight_setrgb_gold_at(at) rgblight_setrgb_at (RGB_GOLD, at) +#define rgblight_setrgb_yellow_at(at) rgblight_setrgb_at (RGB_YELLOW, at) +#define rgblight_setrgb_chartreuse_at(at) rgblight_setrgb_at (RGB_CHARTREUSE, at) +#define rgblight_setrgb_green_at(at) rgblight_setrgb_at (RGB_GREEN, at) +#define rgblight_setrgb_springgreen_at(at) rgblight_setrgb_at (RGB_SPRINGGREEN, at) +#define rgblight_setrgb_turquoise_at(at) rgblight_setrgb_at (RGB_TURQUOISE, at) +#define rgblight_setrgb_teal_at(at) rgblight_setrgb_at (RGB_TEAL, at) +#define rgblight_setrgb_cyan_at(at) rgblight_setrgb_at (RGB_CYAN, at) +#define rgblight_setrgb_azure_at(at) rgblight_setrgb_at (RGB_AZURE, at) +#define rgblight_setrgb_blue_at(at) rgblight_setrgb_at (RGB_BLUE, at) +#define rgblight_setrgb_purple_at(at) rgblight_setrgb_at (RGB_PURPLE, at) +#define rgblight_setrgb_magenta_at(at) rgblight_setrgb_at (RGB_MAGENTA, at) +#define rgblight_setrgb_pink_at(at) rgblight_setrgb_at (RGB_PINK, at) /* SET HSV List */ -#define rgblight_sethsv_white() rgblight_sethsv ( 0, 0, 255) -#define rgblight_sethsv_red() rgblight_sethsv ( 0, 255, 255) -#define rgblight_sethsv_coral() rgblight_sethsv ( 16, 176, 255) -#define rgblight_sethsv_orange() rgblight_sethsv ( 39, 255, 255) -#define rgblight_sethsv_goldenrod() rgblight_sethsv ( 43, 218, 218) -#define rgblight_sethsv_gold() rgblight_sethsv ( 51, 255, 255) -#define rgblight_sethsv_yellow() rgblight_sethsv ( 60, 255, 255) -#define rgblight_sethsv_chartreuse() rgblight_sethsv ( 90, 255, 255) -#define rgblight_sethsv_green() rgblight_sethsv (120, 255, 255) -#define rgblight_sethsv_springgreen() rgblight_sethsv (150, 255, 255) -#define rgblight_sethsv_turquoise() rgblight_sethsv (174, 90, 112) -#define rgblight_sethsv_teal() rgblight_sethsv (180, 255, 128) -#define rgblight_sethsv_cyan() rgblight_sethsv (180, 255, 255) -#define rgblight_sethsv_azure() rgblight_sethsv (186, 102, 255) -#define rgblight_sethsv_blue() rgblight_sethsv (240, 255, 255) -#define rgblight_sethsv_purple() rgblight_sethsv (270, 255, 255) -#define rgblight_sethsv_magenta() rgblight_sethsv (300, 255, 255) -#define rgblight_sethsv_pink() rgblight_sethsv (330, 128, 255) +#define rgblight_sethsv_white() rgblight_sethsv (HSV_WHITE) +#define rgblight_sethsv_red() rgblight_sethsv (HSV_RED) +#define rgblight_sethsv_coral() rgblight_sethsv (HSV_CORAL) +#define rgblight_sethsv_orange() rgblight_sethsv (HSV_ORANGE) +#define rgblight_sethsv_goldenrod() rgblight_sethsv (HSV_GOLDENROD) +#define rgblight_sethsv_gold() rgblight_sethsv (HSV_GOLD) +#define rgblight_sethsv_yellow() rgblight_sethsv (HSV_YELLOW) +#define rgblight_sethsv_chartreuse() rgblight_sethsv (HSV_CHARTREUSE) +#define rgblight_sethsv_green() rgblight_sethsv (HSV_GREEN) +#define rgblight_sethsv_springgreen() rgblight_sethsv (HSV_SPRINGGREEN) +#define rgblight_sethsv_turquoise() rgblight_sethsv (HSV_TURQUOISE) +#define rgblight_sethsv_teal() rgblight_sethsv (HSV_TEAL) +#define rgblight_sethsv_cyan() rgblight_sethsv (HSV_CYAN) +#define rgblight_sethsv_azure() rgblight_sethsv (HSV_AZURE) +#define rgblight_sethsv_blue() rgblight_sethsv (HSV_BLUE) +#define rgblight_sethsv_purple() rgblight_sethsv (HSV_PURPLE) +#define rgblight_sethsv_magenta() rgblight_sethsv (HSV_MAGENTA) +#define rgblight_sethsv_pink() rgblight_sethsv (HSV_PINK) /* SET HSV List */ /* If you're doing layer indication, this is best, as it won't */ /* write to the eeprom, since it's limited (very high value). */ /* If you want to use modes with this (since you can), then you */ /* want to use rgblight_mode_noeeprom(x) instead. */ -#define rgblight_sethsv_noeeprom_white() rgblight_sethsv_noeeprom ( 0, 0, 255) -#define rgblight_sethsv_noeeprom_red() rgblight_sethsv_noeeprom ( 0, 255, 255) -#define rgblight_sethsv_noeeprom_coral() rgblight_sethsv_noeeprom ( 16, 176, 255) -#define rgblight_sethsv_noeeprom_orange() rgblight_sethsv_noeeprom ( 39, 255, 255) -#define rgblight_sethsv_noeeprom_goldenrod() rgblight_sethsv_noeeprom ( 43, 218, 218) -#define rgblight_sethsv_noeeprom_gold() rgblight_sethsv_noeeprom ( 51, 255, 255) -#define rgblight_sethsv_noeeprom_yellow() rgblight_sethsv_noeeprom ( 60, 255, 255) -#define rgblight_sethsv_noeeprom_chartreuse() rgblight_sethsv_noeeprom ( 90, 255, 255) -#define rgblight_sethsv_noeeprom_green() rgblight_sethsv_noeeprom (120, 255, 255) -#define rgblight_sethsv_noeeprom_springgreen() rgblight_sethsv_noeeprom (150, 255, 255) -#define rgblight_sethsv_noeeprom_turquoise() rgblight_sethsv_noeeprom (174, 90, 112) -#define rgblight_sethsv_noeeprom_teal() rgblight_sethsv_noeeprom (180, 255, 128) -#define rgblight_sethsv_noeeprom_cyan() rgblight_sethsv_noeeprom (180, 255, 255) -#define rgblight_sethsv_noeeprom_azure() rgblight_sethsv_noeeprom (186, 102, 255) -#define rgblight_sethsv_noeeprom_blue() rgblight_sethsv_noeeprom (240, 255, 255) -#define rgblight_sethsv_noeeprom_purple() rgblight_sethsv_noeeprom (270, 255, 255) -#define rgblight_sethsv_noeeprom_magenta() rgblight_sethsv_noeeprom (300, 255, 255) -#define rgblight_sethsv_noeeprom_pink() rgblight_sethsv_noeeprom (330, 128, 255) +#define rgblight_sethsv_noeeprom_white() rgblight_sethsv_noeeprom (HSV_WHITE) +#define rgblight_sethsv_noeeprom_red() rgblight_sethsv_noeeprom (HSV_RED) +#define rgblight_sethsv_noeeprom_coral() rgblight_sethsv_noeeprom (HSV_CORAL) +#define rgblight_sethsv_noeeprom_orange() rgblight_sethsv_noeeprom (HSV_ORANGE) +#define rgblight_sethsv_noeeprom_goldenrod() rgblight_sethsv_noeeprom (HSV_GOLDENROD) +#define rgblight_sethsv_noeeprom_gold() rgblight_sethsv_noeeprom (HSV_GOLD) +#define rgblight_sethsv_noeeprom_yellow() rgblight_sethsv_noeeprom (HSV_YELLOW) +#define rgblight_sethsv_noeeprom_chartreuse() rgblight_sethsv_noeeprom (HSV_CHARTREUSE) +#define rgblight_sethsv_noeeprom_green() rgblight_sethsv_noeeprom (HSV_GREEN) +#define rgblight_sethsv_noeeprom_springgreen() rgblight_sethsv_noeeprom (HSV_SPRINGGREEN) +#define rgblight_sethsv_noeeprom_turquoise() rgblight_sethsv_noeeprom (HSV_TURQUOISE) +#define rgblight_sethsv_noeeprom_teal() rgblight_sethsv_noeeprom (HSV_TEAL) +#define rgblight_sethsv_noeeprom_cyan() rgblight_sethsv_noeeprom (HSV_CYAN) +#define rgblight_sethsv_noeeprom_azure() rgblight_sethsv_noeeprom (HSV_AZURE) +#define rgblight_sethsv_noeeprom_blue() rgblight_sethsv_noeeprom (HSV_BLUE) +#define rgblight_sethsv_noeeprom_purple() rgblight_sethsv_noeeprom (HSV_PURPLE) +#define rgblight_sethsv_noeeprom_magenta() rgblight_sethsv_noeeprom (HSV_MAGENTA) +#define rgblight_sethsv_noeeprom_pink() rgblight_sethsv_noeeprom (HSV_PINK) /* SET HSV List */ -#define rgblight_sethsv_white_at(at) rgblight_sethsv_at ( 0, 0, 255, at) -#define rgblight_sethsv_red_at(at) rgblight_sethsv_at ( 0, 255, 255, at) -#define rgblight_sethsv_coral_at(at) rgblight_sethsv_at ( 16, 176, 255, at) -#define rgblight_sethsv_orange_at(at) rgblight_sethsv_at ( 39, 255, 255, at) -#define rgblight_sethsv_goldenrod_at(at) rgblight_sethsv_at ( 43, 218, 218, at) -#define rgblight_sethsv_gold_at(at) rgblight_sethsv_at ( 51, 255, 255, at) -#define rgblight_sethsv_yellow_at(at) rgblight_sethsv_at ( 60, 255, 255, at) -#define rgblight_sethsv_chartreuse_at(at) rgblight_sethsv_at ( 90, 255, 255, at) -#define rgblight_sethsv_green_at(at) rgblight_sethsv_at (120, 255, 255, at) -#define rgblight_sethsv_springgreen_at(at) rgblight_sethsv_at (150, 255, 255, at) -#define rgblight_sethsv_turquoise_at(at) rgblight_sethsv_at (174, 90, 112, at) -#define rgblight_sethsv_teal_at(at) rgblight_sethsv_at (180, 255, 128, at) -#define rgblight_sethsv_cyan_at(at) rgblight_sethsv_at (180, 255, 255, at) -#define rgblight_sethsv_azure_at(at) rgblight_sethsv_at (186, 102, 255, at) -#define rgblight_sethsv_blue_at(at) rgblight_sethsv_at (240, 255, 255, at) -#define rgblight_sethsv_purple_at(at) rgblight_sethsv_at (270, 255, 255, at) -#define rgblight_sethsv_magenta_at(at) rgblight_sethsv_at (300, 255, 255, at) -#define rgblight_sethsv_pink_at(at) rgblight_sethsv_at (330, 128, 255, at) - -#endif +#define rgblight_sethsv_white_at(at) rgblight_sethsv_at (HSV_WHITE, at) +#define rgblight_sethsv_red_at(at) rgblight_sethsv_at (HSV_RED, at) +#define rgblight_sethsv_coral_at(at) rgblight_sethsv_at (HSV_CORAL, at) +#define rgblight_sethsv_orange_at(at) rgblight_sethsv_at (HSV_ORANGE, at) +#define rgblight_sethsv_goldenrod_at(at) rgblight_sethsv_at (HSV_GOLDENROD, at) +#define rgblight_sethsv_gold_at(at) rgblight_sethsv_at (HSV_GOLD, at) +#define rgblight_sethsv_yellow_at(at) rgblight_sethsv_at (HSV_YELLOW, at) +#define rgblight_sethsv_chartreuse_at(at) rgblight_sethsv_at (HSV_CHARTREUSE, at) +#define rgblight_sethsv_green_at(at) rgblight_sethsv_at (HSV_GREEN, at) +#define rgblight_sethsv_springgreen_at(at) rgblight_sethsv_at (HSV_SPRINGGREEN, at) +#define rgblight_sethsv_turquoise_at(at) rgblight_sethsv_at (HSV_TURQUOISE, at) +#define rgblight_sethsv_teal_at(at) rgblight_sethsv_at (HSV_TEAL, at) +#define rgblight_sethsv_cyan_at(at) rgblight_sethsv_at (HSV_CYAN, at) +#define rgblight_sethsv_azure_at(at) rgblight_sethsv_at (HSV_AZURE, at) +#define rgblight_sethsv_blue_at(at) rgblight_sethsv_at (HSV_BLUE, at) +#define rgblight_sethsv_purple_at(at) rgblight_sethsv_at (HSV_PURPLE, at) +#define rgblight_sethsv_magenta_at(at) rgblight_sethsv_at (HSV_MAGENTA, at) +#define rgblight_sethsv_pink_at(at) rgblight_sethsv_at (HSV_PINK, at) -- cgit v1.2.3-70-g09d2 From b61baf4281bde34bfe28aaa1109bd5d5c6471116 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Mon, 22 Apr 2019 11:34:13 -0400 Subject: Fix #3566 use an hardware timer for software PWM stability (#3615) With my XD60, I noticed that when typing the backlight was flickering. The XD60 doesn't have the backlight wired to a hardware PWM pin. I assumed it was a timing issue in the matrix scan that made the PWM lit the LED a bit too longer. I verified it because the more keys that were pressed, the more lighting I observed. This patch makes the software PWM be called during CPU interruptions. It works almost like the hardware PWM, except instead of using the CPU waveform generation, the CPU will fire interruption when the LEDs need be turned on or off. Using the same timer system as for hardware PWM, when the counter will reach OCRxx (the current backlight level), an Output Compare match interrupt will be fired and we'll turn the LEDs off. When the counter reaches its maximum value, an overflow interrupt will be triggered in which we turn the LEDs on. This way we replicate the hardware backlight PWM duty cycle. This gives a better time stability of the PWM computation than pure software PWM, leading to a flicker free backlight. Since this is reusing the hardware PWM code, software PWM also supports backlight breathing. Note that if timer1 is used for audio, backlight will use timer3, and if timer3 is used for audio backlight will use timer1. If both timers are used for audio, then this feature is disabled and we revert to the matrix scan based PWM computation. Signed-off-by: Brice Figureau --- docs/feature_backlight.md | 52 +++++++++- quantum/quantum.c | 256 ++++++++++++++++++++++++++++++++++++++-------- quantum/quantum.h | 4 + 3 files changed, 267 insertions(+), 45 deletions(-) (limited to 'quantum') diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md index c7a1f131e..048d75390 100644 --- a/docs/feature_backlight.md +++ b/docs/feature_backlight.md @@ -30,7 +30,31 @@ You should then be able to use the keycodes below to change the backlight level. This feature is distinct from both the [RGB underglow](feature_rgblight.md) and [RGB matrix](feature_rgb_matrix.md) features as it usually allows for only a single colour per switch, though you can obviously use multiple different coloured LEDs on a keyboard. -Hardware PWM is only supported on certain pins of the MCU, so if the backlighting is not connected to one of them, a software implementation will be used, and backlight breathing will not be available. Currently the supported pins are `B5`, `B6`, `B7`, and `C6`. +Hardware PWM is only supported on certain pins of the MCU, so if the backlighting is not connected to one of them, a software PWM implementation triggered by hardware timer interrupts will be used. + +Hardware PWM is supported according to the following table: + +| Backlight Pin | Hardware timer | +|---------------|----------------| +|`B5` | Timer 1 | +|`B6` | Timer 1 | +|`B7` | Timer 1 | +|`C6` | Timer 3 | +| other | Software PWM | + +The [audio feature](feature_audio.md) also uses hardware timers. Please refer to the following table to know what hardware timer the software PWM will use depending on the audio configuration: + +| Audio Pin(s) | Audio Timer | Software PWM Timer | +|--------------|-------------|--------------------| +| `C4` | Timer 3 | Timer 1 | +| `C5` | Timer 3 | Timer 1 | +| `C6` | Timer 3 | Timer 1 | +| `B5` | Timer 1 | Timer 3 | +| `B6` | Timer 1 | Timer 3 | +| `B7` | Timer 1 | Timer 3 | +| `Bx` & `Cx` | Timer 1 & 3 | None | + +When all timers are in use for [audio](feature_audio.md), the backlight software PWM will not use a hardware timer, but instead will be triggered during the matrix scan. In this case the backlight doesn't support breathing and might show lighting artifacts (for instance flickering), because the PWM computation might not be called with enough timing precision. ## Configuration @@ -39,11 +63,26 @@ To change the behaviour of the backlighting, `#define` these in your `config.h`: |Define |Default |Description | |---------------------|-------------|-------------------------------------------------------------------------------------------------------------| |`BACKLIGHT_PIN` |`B7` |The pin that controls the LEDs. Unless you are designing your own keyboard, you shouldn't need to change this| +|`BACKLIGHT_PINS` |*Not defined*|experimental: see below for more information| |`BACKLIGHT_LEVELS` |`3` |The number of brightness levels (maximum 15 excluding off) | |`BACKLIGHT_CAPS_LOCK`|*Not defined*|Enable Caps Lock indicator using backlight (for keyboards without dedicated LED) | -|`BACKLIGHT_BREATHING`|*Not defined*|Enable backlight breathing, if hardware PWM is used | +|`BACKLIGHT_BREATHING`|*Not defined*|Enable backlight breathing, if supported | |`BREATHING_PERIOD` |`6` |The length of one backlight "breath" in seconds | +## Multiple backlight pins + +Most keyboards have only one backlight pin which control all backlight LEDs (especially if the backlight is connected to an hardware PWM pin). +In software PWM, it is possible to define multiple backlight pins. All those pins will be turned on and off at the same time during the PWM duty cycle. +This feature allows to set for instance the Caps Lock LED (or any other controllable LED) brightness at the same level as the other LEDs of the backlight. This is useful if you have mapped LCTRL in place of Caps Lock and you need the Caps Lock LED to be part of the backlight instead of being activated when Caps Lock is on. + +To activate multiple backlight pins, you need to add something like this to your user `config.h`: + +~~~c +#define BACKLIGHT_LED_COUNT 2 +#undef BACKLIGHT_PIN +#define BACKLIGHT_PINS { F5, B2 } +~~~ + ## Hardware PWM Implementation When using the supported pins for backlighting, QMK will use a hardware timer configured to output a PWM signal. This timer will count up to `ICRx` (by default `0xFFFF`) before resetting to 0. @@ -53,6 +92,15 @@ In this way `OCRxx` essentially controls the duty cycle of the LEDs, and thus th The breathing effect is achieved by registering an interrupt handler for `TIMER1_OVF_vect` that is called whenever the counter resets, roughly 244 times per second. In this handler, the value of an incrementing counter is mapped onto a precomputed brightness curve. To turn off breathing, the interrupt handler is simply disabled, and the brightness reset to the level stored in EEPROM. +## Software PWM Implementation + +When `BACKLIGHT_PIN` is not set to a hardware backlight pin, QMK will use a hardware timer configured to trigger software interrupts. This time will count up to `ICRx` (by default `0xFFFF`) before resetting to 0. +When resetting to 0, the CPU will fire an OVF (overflow) interrupt that will turn the LEDs on, starting the duty cycle. +The desired brightness is calculated and stored in the `OCRxx` register. When the counter reaches this value, the CPU will fire a Compare Output match interrupt, which will turn the LEDs off. +In this way `OCRxx` essentially controls the duty cycle of the LEDs, and thus the brightness, where `0x0000` is completely off and `0xFFFF` is completely on. + +The breathing effect is the same as in the hardware PWM implementation. + ## Backlight Functions |Function |Description | diff --git a/quantum/quantum.c b/quantum/quantum.c index 9aa498dad..0fb798a74 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -1138,30 +1138,38 @@ void matrix_scan_quantum() { matrix_scan_kb(); } -#if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN) +#if defined(BACKLIGHT_ENABLE) && (defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS)) -static const uint8_t backlight_pin = BACKLIGHT_PIN; +// The logic is a bit complex, we support 3 setups: +// 1. hardware PWM when backlight is wired to a PWM pin +// depending on this pin, we use a different output compare unit +// 2. software PWM with hardware timers, but the used timer depends +// on the audio setup (audio wins other backlight) +// 3. full software PWM -// depending on the pin, we use a different output compare unit #if BACKLIGHT_PIN == B7 +# define HARDWARE_PWM # define TCCRxA TCCR1A # define TCCRxB TCCR1B # define COMxx1 COM1C1 # define OCRxx OCR1C # define ICRx ICR1 #elif BACKLIGHT_PIN == B6 +# define HARDWARE_PWM # define TCCRxA TCCR1A # define TCCRxB TCCR1B # define COMxx1 COM1B1 # define OCRxx OCR1B # define ICRx ICR1 #elif BACKLIGHT_PIN == B5 +# define HARDWARE_PWM # define TCCRxA TCCR1A # define TCCRxB TCCR1B # define COMxx1 COM1A1 # define OCRxx OCR1A # define ICRx ICR1 #elif BACKLIGHT_PIN == C6 +# define HARDWARE_PWM # define TCCRxA TCCR3A # define TCCRxB TCCR3B # define COMxx1 COM1A1 @@ -1175,28 +1183,115 @@ static const uint8_t backlight_pin = BACKLIGHT_PIN; # define ICRx ICR1 # define TIMSK1 TIMSK #else -# define NO_HARDWARE_PWM +# if !defined(BACKLIGHT_CUSTOM_DRIVER) +# if !defined(B5_AUDIO) && !defined(B6_AUDIO) && !defined(B7_AUDIO) + // timer 1 is not used by audio , backlight can use it +#pragma message "Using hardware timer 1 with software PWM" +# define HARDWARE_PWM +# define BACKLIGHT_PWM_TIMER +# define TCCRxA TCCR1A +# define TCCRxB TCCR1B +# define OCRxx OCR1A +# define OCRxAH OCR1AH +# define OCRxAL OCR1AL +# define TIMERx_COMPA_vect TIMER1_COMPA_vect +# define TIMERx_OVF_vect TIMER1_OVF_vect +# define OCIExA OCIE1A +# define TOIEx TOIE1 +# define ICRx ICR1 +# ifndef TIMSK +# define TIMSK TIMSK1 +# endif +# elif !defined(C6_AUDIO) && !defined(C5_AUDIO) && !defined(C4_AUDIO) +#pragma message "Using hardware timer 3 with software PWM" +// timer 3 is not used by audio, backlight can use it +# define HARDWARE_PWM +# define BACKLIGHT_PWM_TIMER +# define TCCRxA TCCR3A +# define TCCRxB TCCR3B +# define OCRxx OCR3A +# define OCRxAH OCR3AH +# define OCRxAL OCR3AL +# define TIMERx_COMPA_vect TIMER3_COMPA_vect +# define TIMERx_OVF_vect TIMER3_OVF_vect +# define OCIExA OCIE3A +# define TOIEx TOIE3 +# define ICRx ICR1 +# ifndef TIMSK +# define TIMSK TIMSK3 +# endif +# else +#pragma message "Audio in use - using pure software PWM" +#define NO_HARDWARE_PWM +# endif +# else +#pragma message "Custom driver defined - using pure software PWM" +#define NO_HARDWARE_PWM +# endif #endif #ifndef BACKLIGHT_ON_STATE #define BACKLIGHT_ON_STATE 0 #endif -#ifdef NO_HARDWARE_PWM // pwm through software +void backlight_on(uint8_t backlight_pin) { +#if BACKLIGHT_ON_STATE == 0 + writePinLow(backlight_pin); +#else + writePinHigh(backlight_pin); +#endif +} -__attribute__ ((weak)) +void backlight_off(uint8_t backlight_pin) { +#if BACKLIGHT_ON_STATE == 0 + writePinHigh(backlight_pin); +#else + writePinLow(backlight_pin); +#endif +} + + +#if defined(NO_HARDWARE_PWM) || defined(BACKLIGHT_PWM_TIMER) // pwm through software + +// we support multiple backlight pins +#ifndef BACKLIGHT_LED_COUNT +#define BACKLIGHT_LED_COUNT 1 +#endif + +#if BACKLIGHT_LED_COUNT == 1 +#define BACKLIGHT_PIN_INIT { BACKLIGHT_PIN } +#else +#define BACKLIGHT_PIN_INIT BACKLIGHT_PINS +#endif + +#define FOR_EACH_LED(x) \ + for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) \ + { \ + uint8_t backlight_pin = backlight_pins[i]; \ + { \ + x \ + } \ + } + +static const uint8_t backlight_pins[BACKLIGHT_LED_COUNT] = BACKLIGHT_PIN_INIT; + +#else // full hardware PWM + +// we support only one backlight pin +static const uint8_t backlight_pin = BACKLIGHT_PIN; +#define FOR_EACH_LED(x) x + +#endif + +#ifdef NO_HARDWARE_PWM +__attribute__((weak)) void backlight_init_ports(void) { // Setup backlight pin as output and output to on state. - // DDRx |= n - _SFR_IO8((backlight_pin >> 4) + 1) |= _BV(backlight_pin & 0xF); - #if BACKLIGHT_ON_STATE == 0 - // PORTx &= ~n - _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); - #else - // PORTx |= n - _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); - #endif + FOR_EACH_LED( + setPinOutput(backlight_pin); + backlight_on(backlight_pin); + ) } __attribute__ ((weak)) @@ -1207,21 +1302,14 @@ uint8_t backlight_tick = 0; #ifndef BACKLIGHT_CUSTOM_DRIVER void backlight_task(void) { if ((0xFFFF >> ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) { - #if BACKLIGHT_ON_STATE == 0 - // PORTx &= ~n - _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); - #else - // PORTx |= n - _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); - #endif - } else { - #if BACKLIGHT_ON_STATE == 0 - // PORTx |= n - _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); - #else - // PORTx &= ~n - _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); - #endif + FOR_EACH_LED( + backlight_on(backlight_pin); + ) + } + else { + FOR_EACH_LED( + backlight_off(backlight_pin); + ) } backlight_tick = (backlight_tick + 1) % 16; } @@ -1233,7 +1321,52 @@ void backlight_task(void) { #endif #endif -#else // pwm through timer +#else // hardware pwm through timer + +#ifdef BACKLIGHT_PWM_TIMER + +// The idea of software PWM assisted by hardware timers is the following +// we use the hardware timer in fast PWM mode like for hardware PWM, but +// instead of letting the Output Match Comparator control the led pin +// (which is not possible since the backlight is not wired to PWM pins on the +// CPU), we do the LED on/off by oursleves. +// The timer is setup to count up to 0xFFFF, and we set the Output Compare +// register to the current 16bits backlight level (after CIE correction). +// This means the CPU will trigger a compare match interrupt when the counter +// reaches the backlight level, where we turn off the LEDs, +// but also an overflow interrupt when the counter rolls back to 0, +// in which we're going to turn on the LEDs. +// The LED will then be on for OCRxx/0xFFFF time, adjusted every 244Hz. + +// Triggered when the counter reaches the OCRx value +ISR(TIMERx_COMPA_vect) { + FOR_EACH_LED( + backlight_off(backlight_pin); + ) +} + +// Triggered when the counter reaches the TOP value +// this one triggers at F_CPU/65536 =~ 244 Hz +ISR(TIMERx_OVF_vect) { +#ifdef BACKLIGHT_BREATHING + breathing_task(); +#endif + // for very small values of OCRxx (or backlight level) + // we can't guarantee this whole code won't execute + // at the same time as the compare match interrupt + // which means that we might turn on the leds while + // trying to turn them off, leading to flickering + // artifacts (especially while breathing, because breathing_task + // takes many computation cycles). + // so better not turn them on while the counter TOP is very low. + if (OCRxx > 256) { + FOR_EACH_LED( + backlight_on(backlight_pin); + ) + } +} + +#endif #define TIMER_TOP 0xFFFFU @@ -1265,11 +1398,28 @@ void backlight_set(uint8_t level) { level = BACKLIGHT_LEVELS; if (level == 0) { + #ifdef BACKLIGHT_PWM_TIMER + if (OCRxx) { + TIMSK &= ~(_BV(OCIExA)); + TIMSK &= ~(_BV(TOIEx)); + FOR_EACH_LED( + backlight_off(backlight_pin); + ) + } + #else // Turn off PWM control on backlight pin TCCRxA &= ~(_BV(COMxx1)); + #endif } else { + #ifdef BACKLIGHT_PWM_TIMER + if (!OCRxx) { + TIMSK |= _BV(OCIExA); + TIMSK |= _BV(TOIEx); + } + #else // Turn on PWM control of backlight pin TCCRxA |= _BV(COMxx1); + #endif } // Set the brightness set_pwm(cie_lightness(TIMER_TOP * (uint32_t)level / BACKLIGHT_LEVELS)); @@ -1289,12 +1439,25 @@ static uint8_t breathing_period = BREATHING_PERIOD; static uint8_t breathing_halt = BREATHING_NO_HALT; static uint16_t breathing_counter = 0; +#ifdef BACKLIGHT_PWM_TIMER +static bool breathing = false; + +bool is_breathing(void) { + return breathing; +} + +#define breathing_interrupt_enable() do { breathing = true; } while (0) +#define breathing_interrupt_disable() do { breathing = false; } while (0) +#else + bool is_breathing(void) { return !!(TIMSK1 & _BV(TOIE1)); } #define breathing_interrupt_enable() do {TIMSK1 |= _BV(TOIE1);} while (0) #define breathing_interrupt_disable() do {TIMSK1 &= ~_BV(TOIE1);} while (0) +#endif + #define breathing_min() do {breathing_counter = 0;} while (0) #define breathing_max() do {breathing_counter = breathing_period * 244 / 2;} while (0) @@ -1368,10 +1531,14 @@ static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); } +#ifdef BACKLIGHT_PWM_TIMER +void breathing_task(void) +#else /* Assuming a 16MHz CPU clock and a timer that resets at 64k (ICR1), the following interrupt handler will run * about 244 times per second. */ ISR(TIMER1_OVF_vect) +#endif { uint16_t interval = (uint16_t) breathing_period * 244 / BREATHING_STEPS; // resetting after one period to prevent ugly reset at overflow. @@ -1393,19 +1560,21 @@ __attribute__ ((weak)) void backlight_init_ports(void) { // Setup backlight pin as output and output to on state. - // DDRx |= n - _SFR_IO8((backlight_pin >> 4) + 1) |= _BV(backlight_pin & 0xF); - #if BACKLIGHT_ON_STATE == 0 - // PORTx &= ~n - _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF); - #else - // PORTx |= n - _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF); - #endif + FOR_EACH_LED( + setPinOutput(backlight_pin); + backlight_on(backlight_pin); + ) + // I could write a wall of text here to explain... but TL;DW // Go read the ATmega32u4 datasheet. // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on +#ifdef BACKLIGHT_PWM_TIMER + // TimerX setup, Fast PWM mode count to TOP set in ICRx + TCCRxA = _BV(WGM11); // = 0b00000010; + // clock select clk/1 + TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; +#else // hardware PWM // Pin PB7 = OCR1C (Timer 1, Channel C) // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 // (i.e. start high, go low when counter matches.) @@ -1417,8 +1586,9 @@ void backlight_init_ports(void) "In fast PWM mode, the compare units allow generation of PWM waveforms on the OCnx pins. Setting the COMnx1:0 bits to two will produce a non-inverted PWM [..]." "In fast PWM mode the counter is incremented until the counter value matches either one of the fixed values 0x00FF, 0x01FF, or 0x03FF (WGMn3:0 = 5, 6, or 7), the value in ICRn (WGMn3:0 = 14), or the value in OCRnA (WGMn3:0 = 15)." */ - TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010; + TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010; TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; +#endif // Use full 16-bit resolution. Counter counts to ICR1 before reset to 0. ICRx = TIMER_TOP; @@ -1428,9 +1598,9 @@ void backlight_init_ports(void) #endif } -#endif // NO_HARDWARE_PWM +#endif // hardware backlight -#else // backlight +#else // no backlight __attribute__ ((weak)) void backlight_init_ports(void) {} diff --git a/quantum/quantum.h b/quantum/quantum.h index 987516ded..17cb90274 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -260,8 +260,12 @@ void tap_code16(uint16_t code); #ifdef BACKLIGHT_ENABLE void backlight_init_ports(void); void backlight_task(void); +void backlight_task_internal(void); +void backlight_on(uint8_t backlight_pin); +void backlight_off(uint8_t backlight_pin); #ifdef BACKLIGHT_BREATHING +void breathing_task(void); void breathing_enable(void); void breathing_pulse(void); void breathing_disable(void); -- cgit v1.2.3-70-g09d2 From bb52119a6dfe9c6f0314d1bcd948efda59626a70 Mon Sep 17 00:00:00 2001 From: M-AS Date: Mon, 22 Apr 2019 11:37:40 -0400 Subject: RGB Matrix Animations: Three/six new reactive effects (wide, cross, nexus) (#5602) * added 3 new RGB_Matrix effects * made cross effect behavior smoother * removed dead code * added effect descriptions --- docs/feature_rgb_matrix.md | 54 +++++++++++++--------- quantum/rgb_matrix.c | 33 +++++++++++++ quantum/rgb_matrix.h | 18 ++++++++ .../rgb_matrix_animations/solid_reactive_cross.h | 50 ++++++++++++++++++++ .../rgb_matrix_animations/solid_reactive_nexus.h | 48 +++++++++++++++++++ .../rgb_matrix_animations/solid_reactive_wide.h | 42 +++++++++++++++++ 6 files changed, 224 insertions(+), 21 deletions(-) create mode 100644 quantum/rgb_matrix_animations/solid_reactive_cross.h create mode 100644 quantum/rgb_matrix_animations/solid_reactive_nexus.h create mode 100644 quantum/rgb_matrix_animations/solid_reactive_wide.h (limited to 'quantum') diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index 5309e749c..f2168ab16 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md @@ -189,6 +189,12 @@ enum rgb_matrix_effects { #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) RGB_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit to hue & value then fades value out RGB_MATRIX_SOLID_REACTIVE, // Static single hue, pulses keys hit to shifted hue then fades to current hue + RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out + RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out + RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out + RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out + RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out + RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out RGB_MATRIX_SPLASH, // Full gradient & value pulse away from a single key hit then fades value out RGB_MATRIX_MULTISPLASH, // Full gradient & value pulse away from multiple key hits then fades value out RGB_MATRIX_SOLID_SPLASH, // Hue & value pulse away from a single key hit then fades value out @@ -201,27 +207,33 @@ enum rgb_matrix_effects { You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`: -|Define |Description | -|---------------------------------------------------|--------------------------------------------| -|`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` | -|`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` | -|`#define DISABLE_RGB_MATRIX_BREATHING` |Disables `RGB_MATRIX_BREATHING` | -|`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` | -|`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` | -|`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` | -|`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON`|Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON`| -|`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` | -|`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` | -|`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` | -|`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` | -|`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` | -|`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` | -|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` | -|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLEE`| -|`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` | -|`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` | -|`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` | -|`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` | +|Define |Description | +|-------------------------------------------------------|-----------------------------------------------| +|`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` | +|`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` | +|`#define DISABLE_RGB_MATRIX_BREATHING` |Disables `RGB_MATRIX_BREATHING` | +|`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` | +|`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` | +|`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` | +|`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON` | +|`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` | +|`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` | +|`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` | +|`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` | +|`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` | +|`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` | +|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` | +|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLE` | +|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_WIDE` | +|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` | +|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_CROSS` | +|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTICROSS`| +|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_NEXUS` | +|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS`| +|`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` | +|`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` | +|`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` | +|`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` | ## Custom layer effects diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index a1193d4c0..41ed8983e 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -41,6 +41,9 @@ #include "rgb_matrix_animations/digital_rain_anim.h" #include "rgb_matrix_animations/solid_reactive_simple_anim.h" #include "rgb_matrix_animations/solid_reactive_anim.h" +#include "rgb_matrix_animations/solid_reactive_wide.h" +#include "rgb_matrix_animations/solid_reactive_cross.h" +#include "rgb_matrix_animations/solid_reactive_nexus.h" #include "rgb_matrix_animations/splash_anim.h" #include "rgb_matrix_animations/solid_splash_anim.h" #include "rgb_matrix_animations/breathing_anim.h" @@ -380,6 +383,36 @@ static void rgb_task_render(uint8_t effect) { rendering = rgb_matrix_solid_reactive(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE + case RGB_MATRIX_SOLID_REACTIVE_WIDE: + rendering = rgb_matrix_solid_reactive_wide(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE + case RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE: + rendering = rgb_matrix_solid_reactive_multiwide(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS + case RGB_MATRIX_SOLID_REACTIVE_CROSS: + rendering = rgb_matrix_solid_reactive_cross(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS + case RGB_MATRIX_SOLID_REACTIVE_MULTICROSS: + rendering = rgb_matrix_solid_reactive_multicross(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS + case RGB_MATRIX_SOLID_REACTIVE_NEXUS: + rendering = rgb_matrix_solid_reactive_nexus(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS + case RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS: + rendering = rgb_matrix_solid_reactive_multinexus(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS #ifndef DISABLE_RGB_MATRIX_SPLASH case RGB_MATRIX_SPLASH: rendering = rgb_matrix_splash(&rgb_effect_params); // Max 5ms Avg 3ms diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index f5be49435..5fdc854f0 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -111,6 +111,24 @@ enum rgb_matrix_effects { #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE RGB_MATRIX_SOLID_REACTIVE, #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE + RGB_MATRIX_SOLID_REACTIVE_WIDE, +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE + RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE, +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS + RGB_MATRIX_SOLID_REACTIVE_CROSS, +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS + RGB_MATRIX_SOLID_REACTIVE_MULTICROSS, +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS + RGB_MATRIX_SOLID_REACTIVE_NEXUS, +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS + RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS, +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS #ifndef DISABLE_RGB_MATRIX_SPLASH RGB_MATRIX_SPLASH, #endif // DISABLE_RGB_MATRIX_SPLASH diff --git a/quantum/rgb_matrix_animations/solid_reactive_cross.h b/quantum/rgb_matrix_animations/solid_reactive_cross.h new file mode 100644 index 000000000..af602cba1 --- /dev/null +++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h @@ -0,0 +1,50 @@ +#pragma once +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED +#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) + +extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_config_t rgb_matrix_config; +extern last_hit_t g_last_hit_tracker; + +static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + + HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; + uint8_t count = g_last_hit_tracker.count; + for (uint8_t i = led_min; i < led_max; i++) { + hsv.v = 0; + point_t point = g_rgb_leds[i].point; + for (uint8_t j = start; j < count; j++) { + int16_t dx = point.x - g_last_hit_tracker.x[j]; + int16_t dy = point.y - g_last_hit_tracker.y[j]; + uint8_t dist = sqrt16(dx * dx + dy * dy); + int16_t dist2 = 16; + uint8_t dist3; + uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist; + dx = dx < 0 ? dx * -1 : dx; + dy = dy < 0 ? dy * -1 : dy; + dx = dx * dist2 > 255 ? 255 : dx * dist2; + dy = dy * dist2 > 255 ? 255 : dy * dist2; + dist3 = dx > dy ? dy : dx; + effect += dist3; + if (effect > 255) + effect = 255; + hsv.v = qadd8(hsv.v, 255 - effect); + } + hsv.v = scale8(hsv.v, rgb_matrix_config.val); + RGB rgb = hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + return led_max < DRIVER_LED_TOTAL; +} + +bool rgb_matrix_solid_reactive_multicross(effect_params_t* params) { + return rgb_matrix_solid_reactive_multicross_range(0, params); +} + +bool rgb_matrix_solid_reactive_cross(effect_params_t* params) { + return rgb_matrix_solid_reactive_multicross_range(qsub8(g_last_hit_tracker.count, 1), params); +} + +#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix_animations/solid_reactive_nexus.h b/quantum/rgb_matrix_animations/solid_reactive_nexus.h new file mode 100644 index 000000000..8b4a139dc --- /dev/null +++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h @@ -0,0 +1,48 @@ +#pragma once +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED +#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) + +extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_config_t rgb_matrix_config; +extern last_hit_t g_last_hit_tracker; + +static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + + HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; + uint8_t count = g_last_hit_tracker.count; + for (uint8_t i = led_min; i < led_max; i++) { + hsv.v = 0; + point_t point = g_rgb_leds[i].point; + for (uint8_t j = start; j < count; j++) { + int16_t dx = point.x - g_last_hit_tracker.x[j]; + int16_t dy = point.y - g_last_hit_tracker.y[j]; + uint8_t dist = sqrt16(dx * dx + dy * dy); + int16_t dist2 = 8; + uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; + if (effect > 255) + effect = 255; + if (dist > 72) + effect = 255; + if ((dx > dist2 || dx < -dist2) && (dy > dist2 || dy < -dist2)) + effect = 255; + hsv.v = qadd8(hsv.v, 255 - effect); + hsv.h = rgb_matrix_config.hue + dy / 4; + } + hsv.v = scale8(hsv.v, rgb_matrix_config.val); + RGB rgb = hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + return led_max < DRIVER_LED_TOTAL; +} + +bool rgb_matrix_solid_reactive_multinexus(effect_params_t* params) { + return rgb_matrix_solid_reactive_multinexus_range(0, params); +} + +bool rgb_matrix_solid_reactive_nexus(effect_params_t* params) { + return rgb_matrix_solid_reactive_multinexus_range(qsub8(g_last_hit_tracker.count, 1), params); +} + +#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix_animations/solid_reactive_wide.h b/quantum/rgb_matrix_animations/solid_reactive_wide.h new file mode 100644 index 000000000..abb01892e --- /dev/null +++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h @@ -0,0 +1,42 @@ +#pragma once +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED +#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) + +extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_config_t rgb_matrix_config; +extern last_hit_t g_last_hit_tracker; + +static bool rgb_matrix_solid_reactive_multiwide_range(uint8_t start, effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + + HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; + uint8_t count = g_last_hit_tracker.count; + for (uint8_t i = led_min; i < led_max; i++) { + hsv.v = 0; + point_t point = g_rgb_leds[i].point; + for (uint8_t j = start; j < count; j++) { + int16_t dx = point.x - g_last_hit_tracker.x[j]; + int16_t dy = point.y - g_last_hit_tracker.y[j]; + uint8_t dist = sqrt16(dx * dx + dy * dy); + uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist * 5; + if (effect > 255) + effect = 255; + hsv.v = qadd8(hsv.v, 255 - effect); + } + hsv.v = scale8(hsv.v, rgb_matrix_config.val); + RGB rgb = hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + return led_max < DRIVER_LED_TOTAL; +} + +bool rgb_matrix_solid_reactive_multiwide(effect_params_t* params) { + return rgb_matrix_solid_reactive_multiwide_range(0, params); +} + +bool rgb_matrix_solid_reactive_wide(effect_params_t* params) { + return rgb_matrix_solid_reactive_multiwide_range(qsub8(g_last_hit_tracker.count, 1), params); +} + +#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED -- cgit v1.2.3-70-g09d2 From 479baf98e093b83339c9c1a628d9d25d3d0ab034 Mon Sep 17 00:00:00 2001 From: Rockman18 Date: Wed, 24 Apr 2019 04:27:29 +0200 Subject: [FIX] Misspelled RGB_YELLOW (#5692) --- quantum/rgblight_list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/rgblight_list.h b/quantum/rgblight_list.h index 7b8313380..e024364f0 100644 --- a/quantum/rgblight_list.h +++ b/quantum/rgblight_list.h @@ -77,7 +77,7 @@ #define rgblight_setrgb_orange() rgblight_setrgb (RGB_ORANGE) #define rgblight_setrgb_goldenrod() rgblight_setrgb (RGB_GOLDENROD) #define rgblight_setrgb_gold() rgblight_setrgb (RGB_GOLD) -#define rgblight_setrgb_yellow() rgblight_setrgb (RGB_YEllOW) +#define rgblight_setrgb_yellow() rgblight_setrgb (RGB_YELLOW) #define rgblight_setrgb_chartreuse() rgblight_setrgb (RGB_CHARTREUSE) #define rgblight_setrgb_green() rgblight_setrgb (RGB_GREEN) #define rgblight_setrgb_springgreen() rgblight_setrgb (RGB_SPRINGGREEN) -- cgit v1.2.3-70-g09d2 From 5312131d35ee389231bfc596625ac5915264cc16 Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Wed, 24 Apr 2019 02:38:54 +0900 Subject: add RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; to eeconfig_update_rgblight_default() --- quantum/rgblight.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 5ec11bc07..0b90b79ea 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -38,11 +38,13 @@ /* for split keyboard */ #define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE #define RGBLIGHT_SPLIT_SET_CHANGE_HSVS rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_HSVS + #define RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS rgblight_status.change_flags |= (RGBLIGHT_STATUS_CHANGE_MODE|RGBLIGHT_STATUS_CHANGE_HSVS) #define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_TIMER #define RGBLIGHT_SPLIT_ANIMATION_TICK rgblight_status.change_flags |= RGBLIGHT_STATUS_ANIMATION_TICK #else #define RGBLIGHT_SPLIT_SET_CHANGE_MODE #define RGBLIGHT_SPLIT_SET_CHANGE_HSVS + #define RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS #define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE #define RGBLIGHT_SPLIT_ANIMATION_TICK #endif @@ -221,6 +223,7 @@ void eeconfig_update_rgblight_default(void) { rgblight_config.sat = 255; rgblight_config.val = RGBLIGHT_LIMIT_VAL; rgblight_config.speed = 0; + RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; eeconfig_update_rgblight(rgblight_config.raw); } @@ -249,7 +252,7 @@ void rgblight_init(void) { eeconfig_update_rgblight_default(); } rgblight_config.raw = eeconfig_read_rgblight(); - RGBLIGHT_SPLIT_SET_CHANGE_HSVS; + RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; if (!rgblight_config.mode) { dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n"); eeconfig_update_rgblight_default(); -- cgit v1.2.3-70-g09d2 From 9f8c8c53a51ec6bb8acd55683b1d024558b071ab Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Wed, 24 Apr 2019 02:43:44 +0900 Subject: add RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; to rgblight_update_dword() --- quantum/rgblight.c | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 0b90b79ea..2f23768ed 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -279,6 +279,7 @@ uint32_t rgblight_read_dword(void) { } void rgblight_update_dword(uint32_t dword) { + RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; rgblight_config.raw = dword; if (rgblight_config.enable) rgblight_mode_noeeprom(rgblight_config.mode); -- cgit v1.2.3-70-g09d2 From c3be0520c4c6d4799670ab3639a3de561b4c6c1d Mon Sep 17 00:00:00 2001 From: fauxpark Date: Sun, 28 Apr 2019 04:04:28 +1000 Subject: Fix sendstring "#" producing "£" instead (#5724) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quantum/keymap_extras/sendstring_uk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/keymap_extras/sendstring_uk.h b/quantum/keymap_extras/sendstring_uk.h index 3c71f9764..2824e5d44 100644 --- a/quantum/keymap_extras/sendstring_uk.h +++ b/quantum/keymap_extras/sendstring_uk.h @@ -25,7 +25,7 @@ const bool ascii_to_shift_lut[0x80] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, @@ -45,7 +45,7 @@ const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KC_ESC, 0, 0, 0, 0, - KC_SPC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_7, KC_QUOT, + KC_SPC, KC_1, KC_2, KC_NUHS, KC_4, KC_5, KC_7, KC_QUOT, KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH, -- cgit v1.2.3-70-g09d2 From 1d784f0f9575b70e35c9c8338b0ff80dc7316d7e Mon Sep 17 00:00:00 2001 From: Daniel Prilik Date: Mon, 29 Apr 2019 17:48:41 -0400 Subject: RGB Matrix: Custom effects on a kb/user level (#5338) * Revamped custom effects approach See docs for example usage * push-up RGB Matrix default mode Override default effect using RGB_MATRIX_STARTUP_MODE. Useful on boards without EEPROM support (*cough* Massdrop ALT/CTRL *cough*) * update docs --- common_features.mk | 8 +++++++ docs/feature_rgb_matrix.md | 57 ++++++++++++++++++++++++++++++++++++++++------ quantum/rgb_matrix.c | 43 +++++++++++++++++++++++++++++----- quantum/rgb_matrix.h | 12 ++++++++++ 4 files changed, 107 insertions(+), 13 deletions(-) (limited to 'quantum') diff --git a/common_features.mk b/common_features.mk index fbfbc3ebc..8e9bcf0b9 100644 --- a/common_features.mk +++ b/common_features.mk @@ -178,6 +178,14 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), WS2812) SRC += ws2812.c endif +ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes) + OPT_DEFS += -DRGB_MATRIX_CUSTOM_KB +endif + +ifeq ($(strip $(RGB_MATRIX_CUSTOM_USER)), yes) + OPT_DEFS += -DRGB_MATRIX_CUSTOM_USER +endif + ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) OPT_DEFS += -DTAP_DANCE_ENABLE SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index f2168ab16..4ce9d15f0 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md @@ -177,7 +177,7 @@ enum rgb_matrix_effects { RGB_MATRIX_GRADIENT_UP_DOWN, // Static gradient top to bottom, speed controls how much gradient changes RGB_MATRIX_BREATHING, // Single hue brightness cycling animation RGB_MATRIX_CYCLE_ALL, // Full keyboard solid hue cycling through full gradient - RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right + RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right RGB_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom RGB_MATRIX_RAINBOW_MOVING_CHEVRON, // Full gradent Chevron shapped scrolling left to right RGB_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard @@ -203,7 +203,7 @@ enum rgb_matrix_effects { RGB_MATRIX_EFFECT_MAX }; ``` - + You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`: @@ -236,17 +236,60 @@ You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `con |`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` | -## Custom layer effects +## Custom RGB Matrix Effects + +By setting `RGB_MATRIX_CUSTOM_USER` (and/or `RGB_MATRIX_CUSTOM_KB`) in `rule.mk`, new effects can be defined directly from userspace, without having to edit any QMK core files. + +To declare new effects, create a new `rgb_matrix_user/kb.inc` that looks something like this: -Custom layer effects can be done by defining this in your `.c`: +`rgb_matrix_user.inc` should go in the root of the keymap directory. +`rgb_matrix_kb.inc` should go in the root of the keyboard directory. ```C -void rgb_matrix_indicators_kb(void) { - rgb_matrix_set_color(index, red, green, blue); +// !!! DO NOT ADD #pragma once !!! // + +// Step 1. +// Declare custom effects using the RGB_MATRIX_EFFECT macro +// (note the lack of semicolon after the macro!) +RGB_MATRIX_EFFECT(my_cool_effect) +RGB_MATRIX_EFFECT(my_cool_effect2) + +// Step 2. +// Define effects inside the `RGB_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block +#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS + +// e.g: A simple effect, self-contained within a single method +static bool my_cool_effect(effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + for (uint8_t i = led_min; i < led_max; i++) { + rgb_matrix_set_color(i, 0xff, 0xff, 0x00); + } + return led_max < DRIVER_LED_TOTAL; +} + +// e.g: A more complex effect, relying on external methods and state, with +// dedicated init and run methods +static uint8_t some_global_state; +static void my_cool_effect2_complex_init(effect_params_t* params) { + some_global_state = 1; } +static bool my_cool_effect2_complex_run(effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + for (uint8_t i = led_min; i < led_max; i++) { + rgb_matrix_set_color(i, 0xff, some_global_state++, 0xff); + } + + return led_max < DRIVER_LED_TOTAL; +} +static bool my_cool_effect2(effect_params_t* params) { + if (params->init) my_cool_effect2_complex_init(params); + return my_cool_effect2_complex_run(params); +} + +#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS ``` -A similar function works in the keymap as `rgb_matrix_indicators_user`. +For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix_animation/` ## Colors diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 41ed8983e..5ca9b87a6 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -48,6 +48,19 @@ #include "rgb_matrix_animations/solid_splash_anim.h" #include "rgb_matrix_animations/breathing_anim.h" +#if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) + #define RGB_MATRIX_CUSTOM_EFFECT_IMPLS + #define RGB_MATRIX_EFFECT(name, ...) + #ifdef RGB_MATRIX_CUSTOM_KB + #include "rgb_matrix_kb.inc" + #endif + #ifdef RGB_MATRIX_CUSTOM_USER + #include "rgb_matrix_user.inc" + #endif + #undef RGB_MATRIX_EFFECT + #undef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif + #ifndef RGB_DISABLE_AFTER_TIMEOUT #define RGB_DISABLE_AFTER_TIMEOUT 0 #endif @@ -81,6 +94,15 @@ #define RGB_MATRIX_SPD_STEP 16 #endif +#if !defined(RGB_MATRIX_STARTUP_MODE) + #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL + #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT + #else + // fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace + #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR + #endif +#endif + bool g_suspend_state = false; rgb_config_t rgb_matrix_config; @@ -104,12 +126,7 @@ void eeconfig_update_rgb_matrix(uint32_t val) { void eeconfig_update_rgb_matrix_default(void) { dprintf("eeconfig_update_rgb_matrix_default\n"); rgb_matrix_config.enable = 1; -#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT - rgb_matrix_config.mode = RGB_MATRIX_CYCLE_LEFT_RIGHT; -#else - // fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace - rgb_matrix_config.mode = RGB_MATRIX_SOLID_COLOR; -#endif + rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE; rgb_matrix_config.hue = 0; rgb_matrix_config.sat = UINT8_MAX; rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS; @@ -435,6 +452,20 @@ static void rgb_task_render(uint8_t effect) { #endif // DISABLE_RGB_MATRIX_SOLID_MULTISPLASH #endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) + #define RGB_MATRIX_EFFECT(name, ...) \ + case RGB_MATRIX_CUSTOM_##name: \ + rendering = name(&rgb_effect_params); \ + break; + #ifdef RGB_MATRIX_CUSTOM_KB + #include "rgb_matrix_kb.inc" + #endif + #ifdef RGB_MATRIX_CUSTOM_USER + #include "rgb_matrix_user.inc" + #endif + #undef RGB_MATRIX_EFFECT +#endif + // Factory default magic value case UINT8_MAX: { rgb_matrix_test(); diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 5fdc854f0..775cbeac0 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -142,6 +142,18 @@ enum rgb_matrix_effects { RGB_MATRIX_SOLID_MULTISPLASH, #endif // DISABLE_RGB_MATRIX_SOLID_MULTISPLASH #endif // RGB_MATRIX_KEYREACTIVE_ENABLED + +#if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) + #define RGB_MATRIX_EFFECT(name, ...) RGB_MATRIX_CUSTOM_##name, + #ifdef RGB_MATRIX_CUSTOM_KB + #include "rgb_matrix_kb.inc" + #endif + #ifdef RGB_MATRIX_CUSTOM_USER + #include "rgb_matrix_user.inc" + #endif + #undef RGB_MATRIX_EFFECT +#endif + RGB_MATRIX_EFFECT_MAX }; -- cgit v1.2.3-70-g09d2 From a7113c8ed090d0ac647f30ee9b8ef41252e568ed Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 30 Apr 2019 00:18:50 +0200 Subject: Updated rgb_led struct field modifier to flags (#5619) Updated effects to test led flags Updated massdrop to use new flags field for led toggle --- docs/feature_rgb_matrix.md | 20 +- keyboards/boston_meetup/2019/2019.c | 14 +- keyboards/crkbd/rev1/rev1.c | 88 ++--- keyboards/doro67/rgb/rgb.c | 100 +++--- keyboards/dztech/dz40rgb/dz40rgb.c | 84 ++--- keyboards/dztech/dz40rgb/keymaps/default/keymap.c | 6 +- .../dztech/dz40rgb/keymaps/split_space/keymap.c | 6 +- keyboards/dztech/dz60rgb/dz60rgb.c | 361 +++++++++++---------- keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c | 6 +- keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c | 6 +- keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c | 6 +- keyboards/dztech/dz60rgb/keymaps/iso/keymap.c | 6 +- keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c | 8 +- keyboards/ergodox_ez/ergodox_ez.c | 96 +++--- keyboards/exclusive/e6_rgb/e6_rgb.c | 100 +++--- keyboards/hadron/ver3/ver3.c | 22 +- keyboards/hs60/v1/v1.c | 206 ++++++------ keyboards/massdrop/alt/config.h | 1 - keyboards/massdrop/alt/config_led.c | 210 ++++++------ keyboards/massdrop/alt/keymaps/abishalom/keymap.c | 26 ++ keyboards/massdrop/alt/keymaps/default/keymap.c | 26 ++ keyboards/massdrop/alt/keymaps/mac/keymap.c | 26 ++ keyboards/massdrop/ctrl/config.h | 1 - keyboards/massdrop/ctrl/config_led.c | 236 +++++++------- keyboards/massdrop/ctrl/keymaps/default/keymap.c | 26 ++ keyboards/massdrop/ctrl/keymaps/mac/keymap.c | 26 ++ keyboards/model01/leds.c | 110 +++---- keyboards/planck/ez/ez.c | 66 ++-- keyboards/planck/keymaps/tom/keymap.c | 4 +- keyboards/planck/light/light.c | 70 ++-- keyboards/sol/rev1/rev1.c | 82 ++--- layouts/community/ergodox/drashna/keymap.c | 6 +- layouts/community/ortho_4x12/drashna/keymap.c | 6 +- quantum/rgb_matrix.c | 45 ++- quantum/rgb_matrix.h | 6 +- quantum/rgb_matrix_animations/alpha_mods_anim.h | 5 +- quantum/rgb_matrix_animations/breathing_anim.h | 1 + quantum/rgb_matrix_animations/cycle_all_anim.h | 6 +- .../rgb_matrix_animations/cycle_left_right_anim.h | 3 +- quantum/rgb_matrix_animations/cycle_up_down_anim.h | 3 +- quantum/rgb_matrix_animations/dual_beacon_anim.h | 3 +- .../rgb_matrix_animations/gradient_up_down_anim.h | 3 +- .../jellybean_raindrops_anim.h | 9 +- .../rgb_matrix_animations/rainbow_beacon_anim.h | 3 +- .../rainbow_moving_chevron_anim.h | 3 +- .../rgb_matrix_animations/rainbow_pinwheels_anim.h | 3 +- quantum/rgb_matrix_animations/raindrops_anim.h | 7 +- quantum/rgb_matrix_animations/solid_color_anim.h | 1 + .../rgb_matrix_animations/solid_reactive_anim.h | 1 + .../rgb_matrix_animations/solid_reactive_cross.h | 3 +- .../rgb_matrix_animations/solid_reactive_nexus.h | 3 +- .../solid_reactive_simple_anim.h | 1 + .../rgb_matrix_animations/solid_reactive_wide.h | 3 +- quantum/rgb_matrix_animations/solid_splash_anim.h | 3 +- quantum/rgb_matrix_animations/splash_anim.h | 3 +- quantum/rgb_matrix_types.h | 22 +- tmk_core/protocol/arm_atsam/led_matrix.c | 4 +- 57 files changed, 1173 insertions(+), 1028 deletions(-) (limited to 'quantum') diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index 4ce9d15f0..91ec77ace 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md @@ -127,13 +127,13 @@ Configure the hardware via your `config.h`: From this point forward the configuration is the same for all the drivers. The struct rgb_led array tells the system for each led, what key electrical matrix it represents, what the physical position is on the board, and if the led is for a modifier key or not. Here is a brief example: ```C -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { /* {row | col << 4} * | {x=0..224, y=0..64} - * | | modifier + * | | flags * | | | */ {{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, - {{0|(1<<4)}, {20.36*1, 21.33*0}, 1}, + {{0|(1<<4)}, {20.36*1, 21.33*0}, 4}, .... } ``` @@ -147,7 +147,19 @@ y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based on the physical layout of your keyboard, not the electrical layout. -`modifier` is a boolean, whether or not a certain key is considered a modifier (used in some effects). +`flags` is a bitmask, whether or not a certain LEDs is of a certain type. It is recommended that LEDs are set to only 1 type. + +## Flags + +|Define |Description | +|------------------------------------|-------------------------------------------| +|`#define HAS_FLAGS(bits, flags)` |Returns true if `bits` has all `flags` set.| +|`#define HAS_ANY_FLAGS(bits, flags)`|Returns true if `bits` has any `flags` set.| +|`#define LED_FLAG_NONE 0x00` |If thes LED has no flags. | +|`#define LED_FLAG_ALL 0xFF` |If thes LED has all flags. | +|`#define LED_FLAG_MODIFIER 0x01` |If the Key for this LED is a modifier. | +|`#define LED_FLAG_UNDERGLOW 0x02` |If the LED is for underglow. | +|`#define LED_FLAG_KEYLIGHT 0x04` |If the LED is for key backlight. | ## Keycodes diff --git a/keyboards/boston_meetup/2019/2019.c b/keyboards/boston_meetup/2019/2019.c index 9baed223b..45c185549 100644 --- a/keyboards/boston_meetup/2019/2019.c +++ b/keyboards/boston_meetup/2019/2019.c @@ -21,17 +21,17 @@ #ifdef RGB_MATRIX_ENABLE #include "rgblight.h" -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { /*{row | col << 4} | {x=0..224, y=0..64} | | modifier | | | */ - {{1|(3<<4)}, {188, 16}, 0}, - {{3|(3<<4)}, {187, 48}, 0}, - {{4|(2<<4)}, {149, 64}, 0}, - {{4|(1<<4)}, {112, 64}, 0}, - {{3|(0<<4)}, {37, 48}, 0}, - {{1|(0<<4)}, {38, 16}, 0} + {{1|(3<<4)}, {188, 16}, 4}, + {{3|(3<<4)}, {187, 48}, 4}, + {{4|(2<<4)}, {149, 64}, 4}, + {{4|(1<<4)}, {112, 64}, 4}, + {{3|(0<<4)}, {37, 48}, 4}, + {{1|(0<<4)}, {38, 16}, 4} }; #endif diff --git a/keyboards/crkbd/rev1/rev1.c b/keyboards/crkbd/rev1/rev1.c index 0104adf15..2345028d2 100644 --- a/keyboards/crkbd/rev1/rev1.c +++ b/keyboards/crkbd/rev1/rev1.c @@ -56,70 +56,70 @@ void led_set_kb(uint8_t usb_led) { * | | | modifier * | | | */ #define RGB_MATRIX_LEFT_LEDS \ - { { 0xFF }, { 85, 16 }, 0 }, /* 1 */ \ - { { 0xFF }, { 50, 13 }, 0 }, /* 2 */ \ - { { 0xFF }, { 16, 20 }, 0 }, /* 3 */ \ - { { 0xFF }, { 16, 38 }, 0 }, /* 4 */ \ - { { 0xFF }, { 50, 48 }, 0 }, /* 5 */ \ - { { 0xFF }, { 85, 52 }, 0 }, /* 6 */ \ + { { 0xFF }, { 85, 16 }, 2 }, /* 1 */ \ + { { 0xFF }, { 50, 13 }, 2 }, /* 2 */ \ + { { 0xFF }, { 16, 20 }, 2 }, /* 3 */ \ + { { 0xFF }, { 16, 38 }, 2 }, /* 4 */ \ + { { 0xFF }, { 50, 48 }, 2 }, /* 5 */ \ + { { 0xFF }, { 85, 52 }, 2 }, /* 6 */ \ { { 3 | ( 5 << 4 ) }, { 95, 63 }, 1 }, /* 7 */ \ - { { 2 | ( 5 << 4 ) }, { 85, 39 }, 0 }, /* 8 */ \ - { { 1 | ( 5 << 4 ) }, { 85, 21 }, 0 }, /* 9 */ \ - { { 0 | ( 5 << 4 ) }, { 85, 4 }, 0 }, /* 10 */ \ - { { 0 | ( 4 << 4 ) }, { 68, 02 }, 0 }, /* 11 */ \ - { { 1 | ( 4 << 4 ) }, { 68, 19 }, 0 }, /* 12 */ \ - { { 2 | ( 4 << 4 ) }, { 68, 37 }, 0 }, /* 13 */ \ + { { 2 | ( 5 << 4 ) }, { 85, 39 }, 4 }, /* 8 */ \ + { { 1 | ( 5 << 4 ) }, { 85, 21 }, 4 }, /* 9 */ \ + { { 0 | ( 5 << 4 ) }, { 85, 4 }, 4 }, /* 10 */ \ + { { 0 | ( 4 << 4 ) }, { 68, 02 }, 4 }, /* 11 */ \ + { { 1 | ( 4 << 4 ) }, { 68, 19 }, 4 }, /* 12 */ \ + { { 2 | ( 4 << 4 ) }, { 68, 37 }, 4 }, /* 13 */ \ { { 3 | ( 4 << 4 ) }, { 80, 58 }, 1 }, /* 14 */ \ { { 3 | ( 3 << 4 ) }, { 60, 55 }, 1 }, /* 15 */ \ - { { 2 | ( 3 << 4 ) }, { 50, 35 }, 0 }, /* 16 */ \ - { { 1 | ( 3 << 4 ) }, { 50, 13 }, 0 }, /* 17 */ \ - { { 0 | ( 3 << 4 ) }, { 50, 0 }, 0 }, /* 18 */ \ - { { 0 | ( 2 << 4 ) }, { 33, 3 }, 0 }, /* 19 */ \ - { { 1 | ( 2 << 4 ) }, { 33, 20 }, 0 }, /* 20 */ \ - { { 2 | ( 2 << 4 ) }, { 33, 37 }, 0 }, /* 21 */ \ - { { 2 | ( 1 << 4 ) }, { 16, 42 }, 0 }, /* 22 */ \ - { { 1 | ( 1 << 4 ) }, { 16, 24 }, 0 }, /* 23 */ \ - { { 0 | ( 1 << 4 ) }, { 16, 7 }, 0 }, /* 24 */ \ + { { 2 | ( 3 << 4 ) }, { 50, 35 }, 4 }, /* 16 */ \ + { { 1 | ( 3 << 4 ) }, { 50, 13 }, 4 }, /* 17 */ \ + { { 0 | ( 3 << 4 ) }, { 50, 0 }, 4 }, /* 18 */ \ + { { 0 | ( 2 << 4 ) }, { 33, 3 }, 4 }, /* 19 */ \ + { { 1 | ( 2 << 4 ) }, { 33, 20 }, 4 }, /* 20 */ \ + { { 2 | ( 2 << 4 ) }, { 33, 37 }, 4 }, /* 21 */ \ + { { 2 | ( 1 << 4 ) }, { 16, 42 }, 4 }, /* 22 */ \ + { { 1 | ( 1 << 4 ) }, { 16, 24 }, 4 }, /* 23 */ \ + { { 0 | ( 1 << 4 ) }, { 16, 7 }, 4 }, /* 24 */ \ { { 0 | ( 0 << 4 ) }, { 0, 7 }, 1 }, /* 25 */ \ { { 1 | ( 0 << 4 ) }, { 0, 24 }, 1 }, /* 26 */ \ { { 2 | ( 0 << 4 ) }, { 0, 41 }, 1 }, /* 27 */ #define RGB_MATRIX_RIGHT_LEDS \ - { { 0xFF }, { 139, 16 }, 0 }, /* 1 */ \ - { { 0xFF }, { 174, 13 }, 0 }, /* 2 */ \ - { { 0xFF }, { 208, 20 }, 0 }, /* 3 */ \ - { { 0xFF }, { 208, 38 }, 0 }, /* 4 */ \ - { { 0xFF }, { 174, 48 }, 0 }, /* 5 */ \ - { { 0xFF }, { 139, 52 }, 0 }, /* 6 */ \ + { { 0xFF }, { 139, 16 }, 2 }, /* 1 */ \ + { { 0xFF }, { 174, 13 }, 2 }, /* 2 */ \ + { { 0xFF }, { 208, 20 }, 2 }, /* 3 */ \ + { { 0xFF }, { 208, 38 }, 2 }, /* 4 */ \ + { { 0xFF }, { 174, 48 }, 2 }, /* 5 */ \ + { { 0xFF }, { 139, 52 }, 2 }, /* 6 */ \ { { 7 | ( 5 << 4 ) }, { 129, 63 }, 1 }, /* 7 */ \ - { { 6 | ( 5 << 4 ) }, { 139, 39 }, 0 }, /* 8 */ \ - { { 5 | ( 5 << 4 ) }, { 139, 21 }, 0 }, /* 9 */ \ - { { 4 | ( 5 << 4 ) }, { 139, 4 }, 0 }, /* 10 */ \ - { { 4 | ( 4 << 4 ) }, { 156, 02 }, 0 }, /* 11 */ \ - { { 5 | ( 4 << 4 ) }, { 156, 19 }, 0 }, /* 12 */ \ - { { 6 | ( 4 << 4 ) }, { 156, 37 }, 0 }, /* 13 */ \ + { { 6 | ( 5 << 4 ) }, { 139, 39 }, 4 }, /* 8 */ \ + { { 5 | ( 5 << 4 ) }, { 139, 21 }, 4 }, /* 9 */ \ + { { 4 | ( 5 << 4 ) }, { 139, 4 }, 4 }, /* 10 */ \ + { { 4 | ( 4 << 4 ) }, { 156, 02 }, 4 }, /* 11 */ \ + { { 5 | ( 4 << 4 ) }, { 156, 19 }, 4 }, /* 12 */ \ + { { 6 | ( 4 << 4 ) }, { 156, 37 }, 4 }, /* 13 */ \ { { 7 | ( 4 << 4 ) }, { 144, 58 }, 1 }, /* 14 */ \ { { 7 | ( 3 << 4 ) }, { 164, 55 }, 1 }, /* 15 */ \ - { { 6 | ( 3 << 4 ) }, { 174, 35 }, 0 }, /* 16 */ \ - { { 5 | ( 3 << 4 ) }, { 174, 13 }, 0 }, /* 17 */ \ - { { 4 | ( 3 << 4 ) }, { 174, 0 }, 0 }, /* 18 */ \ - { { 4 | ( 2 << 4 ) }, { 191, 3 }, 0 }, /* 19 */ \ - { { 5 | ( 2 << 4 ) }, { 191, 20 }, 0 }, /* 20 */ \ - { { 6 | ( 2 << 4 ) }, { 191, 37 }, 0 }, /* 21 */ \ - { { 6 | ( 1 << 4 ) }, { 208, 42 }, 0 }, /* 22 */ \ - { { 5 | ( 1 << 4 ) }, { 208, 24 }, 0 }, /* 23 */ \ - { { 4 | ( 1 << 4 ) }, { 208, 7 }, 0 }, /* 24 */ \ + { { 6 | ( 3 << 4 ) }, { 174, 35 }, 4 }, /* 16 */ \ + { { 5 | ( 3 << 4 ) }, { 174, 13 }, 4 }, /* 17 */ \ + { { 4 | ( 3 << 4 ) }, { 174, 0 }, 4 }, /* 18 */ \ + { { 4 | ( 2 << 4 ) }, { 191, 3 }, 4 }, /* 19 */ \ + { { 5 | ( 2 << 4 ) }, { 191, 20 }, 4 }, /* 20 */ \ + { { 6 | ( 2 << 4 ) }, { 191, 37 }, 4 }, /* 21 */ \ + { { 6 | ( 1 << 4 ) }, { 208, 42 }, 4 }, /* 22 */ \ + { { 5 | ( 1 << 4 ) }, { 208, 24 }, 4 }, /* 23 */ \ + { { 4 | ( 1 << 4 ) }, { 208, 7 }, 4 }, /* 24 */ \ { { 4 | ( 0 << 4 ) }, { 224, 7 }, 1 }, /* 25 */ \ { { 5 | ( 0 << 4 ) }, { 224, 24 }, 1 }, /* 26 */ \ { { 6 | ( 0 << 4 ) }, { 224, 41 }, 1 }, /* 27 */ #ifdef RGB_MATRIX_SPLIT_RIGHT -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { RGB_MATRIX_RIGHT_LEDS RGB_MATRIX_LEFT_LEDS }; #else -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { RGB_MATRIX_LEFT_LEDS RGB_MATRIX_RIGHT_LEDS }; diff --git a/keyboards/doro67/rgb/rgb.c b/keyboards/doro67/rgb/rgb.c index 6f39e00c6..8aaf6ef4a 100644 --- a/keyboards/doro67/rgb/rgb.c +++ b/keyboards/doro67/rgb/rgb.c @@ -52,73 +52,73 @@ void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); } -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{0|(0<<4)}, {15*0, 0}, 0}, // Esc - {{0|(1<<4)}, {15*1, 0}, 0}, // 1 - {{0|(2<<4)}, {15*2, 0}, 0}, // 2 - {{0|(3<<4)}, {15*3, 0}, 0}, // 3 - {{0|(4<<4)}, {15*4, 0}, 0}, // 4 - {{0|(5<<4)}, {15*5, 0}, 0}, // 5 - {{0|(6<<4)}, {15*6, 0}, 0}, // 6 - {{0|(7<<4)}, {15*7, 0}, 0}, // 7 - {{0|(8<<4)}, {15*8, 0}, 0}, // 8 - {{0|(9<<4)}, {15*9, 0}, 0}, // 9 - {{0|(10<<4)}, {15*10, 0}, 0}, // 0 - {{0|(11<<4)}, {15*11, 0}, 0}, // - - {{0|(12<<4)}, {15*12, 0}, 0}, // = +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + {{0|(0<<4)}, {15*0, 0}, 4}, // Esc + {{0|(1<<4)}, {15*1, 0}, 4}, // 1 + {{0|(2<<4)}, {15*2, 0}, 4}, // 2 + {{0|(3<<4)}, {15*3, 0}, 4}, // 3 + {{0|(4<<4)}, {15*4, 0}, 4}, // 4 + {{0|(5<<4)}, {15*5, 0}, 4}, // 5 + {{0|(6<<4)}, {15*6, 0}, 4}, // 6 + {{0|(7<<4)}, {15*7, 0}, 4}, // 7 + {{0|(8<<4)}, {15*8, 0}, 4}, // 8 + {{0|(9<<4)}, {15*9, 0}, 4}, // 9 + {{0|(10<<4)}, {15*10, 0}, 4}, // 0 + {{0|(11<<4)}, {15*11, 0}, 4}, // - + {{0|(12<<4)}, {15*12, 0}, 4}, // = {{0|(13<<4)}, {15*13.5, 0}, 1}, // Backspace {{0|(14<<4)}, {15*15, 0}, 1}, // Ins {{1|(0<<4)}, {15*0.5, 16}, 1}, // Tab - {{1|(1<<4)}, {15*1.5, 16}, 0}, // Q - {{1|(2<<4)}, {15*2.5, 16}, 0}, // W - {{1|(3<<4)}, {15*3.5, 16}, 0}, // E - {{1|(4<<4)}, {15*4.5, 16}, 0}, // R - {{1|(5<<4)}, {15*5.5, 16}, 0}, // T - {{1|(6<<4)}, {15*6.5, 16}, 0}, // Y - {{1|(7<<4)}, {15*7.5, 16}, 0}, // U - {{1|(8<<4)}, {15*8.5, 16}, 0}, // I - {{1|(9<<4)}, {15*9.5, 16}, 0}, // O - {{1|(10<<4)}, {15*10.5, 16}, 0}, // P - {{1|(11<<4)}, {15*11.5, 16}, 0}, // [ - {{1|(12<<4)}, {15*12.5, 16}, 0}, // ] - {{1|(13<<4)}, {15*13.75, 16}, 1}, // + {{1|(1<<4)}, {15*1.5, 16}, 4}, // Q + {{1|(2<<4)}, {15*2.5, 16}, 4}, // W + {{1|(3<<4)}, {15*3.5, 16}, 4}, // E + {{1|(4<<4)}, {15*4.5, 16}, 4}, // R + {{1|(5<<4)}, {15*5.5, 16}, 4}, // T + {{1|(6<<4)}, {15*6.5, 16}, 4}, // Y + {{1|(7<<4)}, {15*7.5, 16}, 4}, // U + {{1|(8<<4)}, {15*8.5, 16}, 4}, // I + {{1|(9<<4)}, {15*9.5, 16}, 4}, // O + {{1|(10<<4)}, {15*10.5, 16}, 4}, // P + {{1|(11<<4)}, {15*11.5, 16}, 4}, // [ + {{1|(12<<4)}, {15*12.5, 16}, 4}, // ] + {{1|(13<<4)}, {15*13.75, 16}, 1}, // {{1|(14<<4)}, {15*15, 16}, 1}, // Del {{2|(0<<4)}, {15*0.75, 32}, 1}, // Capslock - {{2|(1<<4)}, {15*1.75, 32}, 0}, // A - {{2|(2<<4)}, {15*2.75, 32}, 0}, // S - {{2|(3<<4)}, {15*3.75, 32}, 0}, // D - {{2|(4<<4)}, {15*4.75, 32}, 0}, // F - {{2|(5<<4)}, {15*5.75, 32}, 0}, // G - {{2|(6<<4)}, {15*6.75, 32}, 0}, // H - {{2|(7<<4)}, {15*7.75, 32}, 0}, // J - {{2|(8<<4)}, {15*8.75, 32}, 0}, // K - {{2|(9<<4)}, {15*9.75, 32}, 0}, // L - {{2|(10<<4)}, {15*10.75, 32}, 0}, // ; - {{2|(11<<4)}, {15*11.75, 32}, 0}, // ' + {{2|(1<<4)}, {15*1.75, 32}, 4}, // A + {{2|(2<<4)}, {15*2.75, 32}, 4}, // S + {{2|(3<<4)}, {15*3.75, 32}, 4}, // D + {{2|(4<<4)}, {15*4.75, 32}, 4}, // F + {{2|(5<<4)}, {15*5.75, 32}, 4}, // G + {{2|(6<<4)}, {15*6.75, 32}, 4}, // H + {{2|(7<<4)}, {15*7.75, 32}, 4}, // J + {{2|(8<<4)}, {15*8.75, 32}, 4}, // K + {{2|(9<<4)}, {15*9.75, 32}, 4}, // L + {{2|(10<<4)}, {15*10.75, 32}, 4}, // ; + {{2|(11<<4)}, {15*11.75, 32}, 4}, // ' {{2|(13<<4)}, {15*13.25, 32}, 1}, // Enter {{2|(14<<4)}, {15*15, 32}, 1}, // Pgup {{3|(0<<4)}, {15*1.25, 48}, 1}, // LShift - {{3|(2<<4)}, {15*2, 48}, 0}, // Z - {{3|(3<<4)}, {15*3, 48}, 0}, // X - {{3|(4<<4)}, {15*4, 48}, 0}, // C - {{3|(5<<4)}, {15*5, 48}, 0}, // V - {{3|(6<<4)}, {15*6, 48}, 0}, // B - {{3|(7<<4)}, {15*7, 48}, 0}, // N - {{3|(8<<4)}, {15*8, 48}, 0}, // M - {{3|(9<<4)}, {15*9, 48}, 0}, // , - {{3|(10<<4)}, {15*10, 48}, 0}, // . - {{3|(11<<4)}, {15*11, 48}, 0}, // / + {{3|(2<<4)}, {15*2, 48}, 4}, // Z + {{3|(3<<4)}, {15*3, 48}, 4}, // X + {{3|(4<<4)}, {15*4, 48}, 4}, // C + {{3|(5<<4)}, {15*5, 48}, 4}, // V + {{3|(6<<4)}, {15*6, 48}, 4}, // B + {{3|(7<<4)}, {15*7, 48}, 4}, // N + {{3|(8<<4)}, {15*8, 48}, 4}, // M + {{3|(9<<4)}, {15*9, 48}, 4}, // , + {{3|(10<<4)}, {15*10, 48}, 4}, // . + {{3|(11<<4)}, {15*11, 48}, 4}, // / {{3|(12<<4)}, {15*12.75, 48}, 1}, // Shift {{3|(13<<4)}, {15*14, 48}, 1}, // Up {{3|(14<<4)}, {15*15, 48}, 1}, // Pgdn - + {{4|(0<<4)}, {15*0.25, 64}, 1}, // Ctrl {{4|(1<<4)}, {15*1.5, 64}, 1}, // GUI {{4|(2<<4)}, {15*2.25, 64}, 1}, // Alt - {{4|(3<<4)}, {15*6.75, 64}, 0}, // Space + {{4|(3<<4)}, {15*6.75, 64}, 4}, // Space {{4|(9<<4)}, {15*9, 64}, 1}, // RAlt {{4|(10<<4)}, {15*10.25, 64}, 1}, // FN {{4|(12<<4)}, {15*13, 64}, 1}, // Left diff --git a/keyboards/dztech/dz40rgb/dz40rgb.c b/keyboards/dztech/dz40rgb/dz40rgb.c index b1a03760f..34bfc4366 100644 --- a/keyboards/dztech/dz40rgb/dz40rgb.c +++ b/keyboards/dztech/dz40rgb/dz40rgb.c @@ -71,7 +71,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(11<<4)}, {20.36*11, 0}, 1}, {{0|(10<<4)}, {20.36*10, 0}, 1}, @@ -90,32 +90,32 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(13<<4)}, {20.36*0,21.33*0.5}, 1}, {{1|(11<<4)}, {20.36*11, 21.33}, 1}, - {{1|(10<<4)}, {20.36*10, 21.33}, 0}, - {{1|(9<<4)}, {20.36*9, 21.33}, 0}, - {{1|(8<<4)}, {20.36*8, 21.33}, 0}, - {{1|(7<<4)}, {20.36*7, 21.33}, 0}, - {{1|(6<<4)}, { 20.36*6, 21.33}, 0}, - {{1|(5<<4)}, { 20.36*5, 21.33}, 0}, - {{1|(4<<4)}, { 20.36*4, 21.33}, 0}, - {{1|(3<<4)}, { 20.36*3, 21.33}, 0}, - {{1|(2<<4)}, { 20.36*2, 21.33}, 0}, - {{1|(1<<4)}, { 20.36*1, 21.33}, 0}, + {{1|(10<<4)}, {20.36*10, 21.33}, 4}, + {{1|(9<<4)}, {20.36*9, 21.33}, 4}, + {{1|(8<<4)}, {20.36*8, 21.33}, 4}, + {{1|(7<<4)}, {20.36*7, 21.33}, 4}, + {{1|(6<<4)}, { 20.36*6, 21.33}, 4}, + {{1|(5<<4)}, { 20.36*5, 21.33}, 4}, + {{1|(4<<4)}, { 20.36*4, 21.33}, 4}, + {{1|(3<<4)}, { 20.36*3, 21.33}, 4}, + {{1|(2<<4)}, { 20.36*2, 21.33}, 4}, + {{1|(1<<4)}, { 20.36*1, 21.33}, 4}, {{1|(0<<4)}, { 20.36*0, 21.33}, 1}, {{1|(12<<4)}, {20.36*11, 21.33*1.5}, 1}, {{1|(13<<4)}, {20.36*0,21.33*1.5}, 1}, {{2|(11<<4)}, {20.36*11, 21.33*2}, 1}, - {{2|(10<<4)}, {20.36*10, 21.33*2}, 0}, - {{2|(9<<4)}, {20.36*9, 21.33*2}, 0}, - {{2|(8<<4)}, {20.36*8, 21.33*2}, 0}, - {{2|(7<<4)}, {20.36*7, 21.33*2}, 0}, - {{2|(6<<4)}, { 20.36*6, 21.33*2}, 0}, - {{2|(5<<4)}, { 20.36*5, 21.33*2}, 0}, - {{2|(4<<4)}, { 20.36*4, 21.33*2}, 0}, - {{2|(3<<4)}, { 20.36*3, 21.33*2}, 0}, - {{2|(2<<4)}, { 20.36*2, 21.33*2}, 0}, - {{2|(1<<4)}, { 20.36*1, 21.33*2}, 0}, + {{2|(10<<4)}, {20.36*10, 21.33*2}, 4}, + {{2|(9<<4)}, {20.36*9, 21.33*2}, 4}, + {{2|(8<<4)}, {20.36*8, 21.33*2}, 4}, + {{2|(7<<4)}, {20.36*7, 21.33*2}, 4}, + {{2|(6<<4)}, { 20.36*6, 21.33*2}, 4}, + {{2|(5<<4)}, { 20.36*5, 21.33*2}, 4}, + {{2|(4<<4)}, { 20.36*4, 21.33*2}, 4}, + {{2|(3<<4)}, { 20.36*3, 21.33*2}, 4}, + {{2|(2<<4)}, { 20.36*2, 21.33*2}, 4}, + {{2|(1<<4)}, { 20.36*1, 21.33*2}, 4}, {{2|(0<<4)}, { 20.36*0, 21.33*2}, 1}, {{2|(12<<4)}, {20.36*11, 21.33*2.5}, 1}, @@ -205,7 +205,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(11<<4)}, {20.36*11, 0}, 1}, {{0|(10<<4)}, {20.36*10, 0}, 1}, @@ -224,32 +224,32 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(13<<4)}, {20.36*0,21.33*0.5}, 1}, {{1|(11<<4)}, {20.36*11, 21.33}, 1}, - {{1|(10<<4)}, {20.36*10, 21.33}, 0}, - {{1|(9<<4)}, {20.36*9, 21.33}, 0}, - {{1|(8<<4)}, {20.36*8, 21.33}, 0}, - {{1|(7<<4)}, {20.36*7, 21.33}, 0}, - {{1|(6<<4)}, { 20.36*6, 21.33}, 0}, - {{1|(5<<4)}, { 20.36*5, 21.33}, 0}, - {{1|(4<<4)}, { 20.36*4, 21.33}, 0}, - {{1|(3<<4)}, { 20.36*3, 21.33}, 0}, - {{1|(2<<4)}, { 20.36*2, 21.33}, 0}, - {{1|(1<<4)}, { 20.36*1, 21.33}, 0}, + {{1|(10<<4)}, {20.36*10, 21.33}, 4}, + {{1|(9<<4)}, {20.36*9, 21.33}, 4}, + {{1|(8<<4)}, {20.36*8, 21.33}, 4}, + {{1|(7<<4)}, {20.36*7, 21.33}, 4}, + {{1|(6<<4)}, { 20.36*6, 21.33}, 4}, + {{1|(5<<4)}, { 20.36*5, 21.33}, 4}, + {{1|(4<<4)}, { 20.36*4, 21.33}, 4}, + {{1|(3<<4)}, { 20.36*3, 21.33}, 4}, + {{1|(2<<4)}, { 20.36*2, 21.33}, 4}, + {{1|(1<<4)}, { 20.36*1, 21.33}, 4}, {{1|(0<<4)}, { 20.36*0, 21.33}, 1}, {{1|(12<<4)}, {20.36*11, 21.33*1.5}, 1}, {{1|(13<<4)}, {20.36*0,21.33*1.5}, 1}, {{2|(11<<4)}, {20.36*11, 21.33*2}, 1}, - {{2|(10<<4)}, {20.36*10, 21.33*2}, 0}, - {{2|(9<<4)}, {20.36*9, 21.33*2}, 0}, - {{2|(8<<4)}, {20.36*8, 21.33*2}, 0}, - {{2|(7<<4)}, {20.36*7, 21.33*2}, 0}, - {{2|(6<<4)}, { 20.36*6, 21.33*2}, 0}, - {{2|(5<<4)}, { 20.36*5, 21.33*2}, 0}, - {{2|(4<<4)}, { 20.36*4, 21.33*2}, 0}, - {{2|(3<<4)}, { 20.36*3, 21.33*2}, 0}, - {{2|(2<<4)}, { 20.36*2, 21.33*2}, 0}, - {{2|(1<<4)}, { 20.36*1, 21.33*2}, 0}, + {{2|(10<<4)}, {20.36*10, 21.33*2}, 4}, + {{2|(9<<4)}, {20.36*9, 21.33*2}, 4}, + {{2|(8<<4)}, {20.36*8, 21.33*2}, 4}, + {{2|(7<<4)}, {20.36*7, 21.33*2}, 4}, + {{2|(6<<4)}, { 20.36*6, 21.33*2}, 4}, + {{2|(5<<4)}, { 20.36*5, 21.33*2}, 4}, + {{2|(4<<4)}, { 20.36*4, 21.33*2}, 4}, + {{2|(3<<4)}, { 20.36*3, 21.33*2}, 4}, + {{2|(2<<4)}, { 20.36*2, 21.33*2}, 4}, + {{2|(1<<4)}, { 20.36*1, 21.33*2}, 4}, {{2|(0<<4)}, { 20.36*0, 21.33*2}, 1}, {{2|(12<<4)}, {20.36*11, 21.33*2.5}, 1}, diff --git a/keyboards/dztech/dz40rgb/keymaps/default/keymap.c b/keyboards/dztech/dz40rgb/keymaps/default/keymap.c index 6ea7421c9..59b917121 100644 --- a/keyboards/dztech/dz40rgb/keymaps/default/keymap.c +++ b/keyboards/dztech/dz40rgb/keymaps/default/keymap.c @@ -35,10 +35,8 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool def rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if (led.matrix_co.raw < 0xFF) { - if (led.modifier) { - rgb_matrix_set_color( i, red, green, blue ); - } + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); } } } diff --git a/keyboards/dztech/dz40rgb/keymaps/split_space/keymap.c b/keyboards/dztech/dz40rgb/keymaps/split_space/keymap.c index bbbe5a8f0..5613e3500 100644 --- a/keyboards/dztech/dz40rgb/keymaps/split_space/keymap.c +++ b/keyboards/dztech/dz40rgb/keymaps/split_space/keymap.c @@ -58,10 +58,8 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool def rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if (led.matrix_co.raw < 0xFF) { - if (led.modifier) { - rgb_matrix_set_color( i, red, green, blue ); - } + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); } } } diff --git a/keyboards/dztech/dz60rgb/dz60rgb.c b/keyboards/dztech/dz60rgb/dz60rgb.c index a6825e750..10b2ea7a8 100644 --- a/keyboards/dztech/dz60rgb/dz60rgb.c +++ b/keyboards/dztech/dz60rgb/dz60rgb.c @@ -64,7 +64,8 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, H_16, G_16, I_16}, {0, K_16, J_16, L_16}, }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(13<<4)}, {16*13.5, 0}, 1}, {{0|(12<<4)}, {16*12, 0}, 1}, {{0|(11<<4)}, {16*11, 0}, 1}, @@ -80,49 +81,49 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(1<<4)}, {16*1, 0}, 1}, {{0|(0<<4)}, {16*0, 0}, 1}, {{2|(13<<4)}, {16*13.75, 24}, 1}, - {{1|(12<<4)}, {16*12.5, 16}, 0}, - {{1|(11<<4)}, {16*11.5, 16}, 0}, - {{1|(10<<4)}, {16*10.5, 16}, 0}, - {{1|(9<<4)}, { 16*9.5, 16}, 0}, - {{1|(8<<4)}, { 16*8.5, 16}, 0}, - {{1|(7<<4)}, { 16*7.5, 16}, 0}, - {{1|(6<<4)}, { 16*6.5, 16}, 0}, - {{1|(5<<4)}, { 16*5.5, 16}, 0}, - {{1|(4<<4)}, { 16*4.5, 16}, 0}, - {{1|(3<<4)}, { 16*3.5, 16}, 0}, - {{1|(2<<4)}, { 16*2.5, 16}, 0}, - {{1|(1<<4)}, { 16*1.5, 16}, 0}, + {{1|(12<<4)}, {16*12.5, 16}, 4}, + {{1|(11<<4)}, {16*11.5, 16}, 4}, + {{1|(10<<4)}, {16*10.5, 16}, 4}, + {{1|(9<<4)}, { 16*9.5, 16}, 4}, + {{1|(8<<4)}, { 16*8.5, 16}, 4}, + {{1|(7<<4)}, { 16*7.5, 16}, 4}, + {{1|(6<<4)}, { 16*6.5, 16}, 4}, + {{1|(5<<4)}, { 16*5.5, 16}, 4}, + {{1|(4<<4)}, { 16*4.5, 16}, 4}, + {{1|(3<<4)}, { 16*3.5, 16}, 4}, + {{1|(2<<4)}, { 16*2.5, 16}, 4}, + {{1|(1<<4)}, { 16*1.5, 16}, 4}, {{1|(0<<4)}, { 16*0.25, 16}, 1}, {{1|(13<<4)}, {16*12.75, 32}, 1}, - {{2|(11<<4)}, {16*11.75, 32}, 0}, - {{2|(10<<4)}, {16*10.75, 32}, 0}, - {{2|(9<<4)}, {16*9.75, 32}, 0}, - {{2|(8<<4)}, {16*8.75, 32}, 0}, - {{2|(7<<4)}, {16*7.75, 32}, 0}, - {{2|(6<<4)}, { 16*6.75, 32}, 0}, - {{2|(5<<4)}, { 16*5.75, 32}, 0}, - {{2|(4<<4)}, { 16*4.75, 32}, 0}, - {{2|(3<<4)}, { 16*3.75, 32}, 0}, - {{2|(2<<4)}, { 16*2.75, 32}, 0}, - {{2|(1<<4)}, { 16*1.75, 32}, 0}, + {{2|(11<<4)}, {16*11.75, 32}, 4}, + {{2|(10<<4)}, {16*10.75, 32}, 4}, + {{2|(9<<4)}, {16*9.75, 32}, 4}, + {{2|(8<<4)}, {16*8.75, 32}, 4}, + {{2|(7<<4)}, {16*7.75, 32}, 4}, + {{2|(6<<4)}, { 16*6.75, 32}, 4}, + {{2|(5<<4)}, { 16*5.75, 32}, 4}, + {{2|(4<<4)}, { 16*4.75, 32}, 4}, + {{2|(3<<4)}, { 16*3.75, 32}, 4}, + {{2|(2<<4)}, { 16*2.75, 32}, 4}, + {{2|(1<<4)}, { 16*1.75, 32}, 4}, {{2|(0<<4)}, { 16*0.375, 32}, 1}, {{3|(11<<4)}, {16*13.125, 48}, 1}, - {{3|(10<<4)}, {16*11.25, 48}, 0}, - {{3|(9<<4)}, {16*10.25, 48}, 0}, - {{3|(8<<4)}, {16*9.25, 48}, 0}, - {{3|(7<<4)}, {16*8.25, 48}, 0}, - {{3|(6<<4)}, {16*7.25, 48}, 0}, - {{3|(5<<4)}, {16*6.25, 48}, 0}, - {{3|(4<<4)}, {16*5.25, 48}, 0}, - {{3|(3<<4)}, {16*4.25, 48}, 0}, - {{3|(2<<4)}, {16*3.25, 48}, 0}, - {{3|(1<<4)}, {16*1.25, 48}, 0}, + {{3|(10<<4)}, {16*11.25, 48}, 4}, + {{3|(9<<4)}, {16*10.25, 48}, 4}, + {{3|(8<<4)}, {16*9.25, 48}, 4}, + {{3|(7<<4)}, {16*8.25, 48}, 4}, + {{3|(6<<4)}, {16*7.25, 48}, 4}, + {{3|(5<<4)}, {16*6.25, 48}, 4}, + {{3|(4<<4)}, {16*5.25, 48}, 4}, + {{3|(3<<4)}, {16*4.25, 48}, 4}, + {{3|(2<<4)}, {16*3.25, 48}, 4}, + {{3|(1<<4)}, {16*1.25, 48}, 4}, {{3|(0<<4)}, {16*0.625, 48}, 1}, {{4|(13<<4)}, {16*13.875, 64}, 1}, {{4|(11<<4)}, {16*12.625, 64}, 1}, {{4|(10<<4)}, {16*11.375, 64}, 1}, {{4|(9<<4)}, {16*10.125, 64}, 1}, - {{4|(5<<4)}, { 16*6.375, 64}, 0}, + {{4|(5<<4)}, { 16*6.375, 64}, 4}, {{4|(2<<4)}, { 16*2.625, 64}, 1}, {{4|(1<<4)}, { 16*1.375, 64}, 1}, {{4|(0<<4)}, { 16*0.125, 64}, 1}, @@ -192,7 +193,8 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, H_16, G_16, I_16}, {0, K_16, J_16, L_16}, }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{2|(12<<4)}, {16*14, 0}, 1}, {{0|(13<<4)}, {16*13, 0}, 1}, {{0|(12<<4)}, {16*12, 0}, 1}, @@ -209,49 +211,49 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(1<<4)}, {16*1, 0}, 1}, {{0|(0<<4)}, {16*0, 0}, 1}, {{1|(13<<4)}, {16*13.75, 16}, 1}, - {{1|(12<<4)}, {16*12.5, 16}, 0}, - {{1|(11<<4)}, {16*11.5, 16}, 0}, - {{1|(10<<4)}, {16*10.5, 16}, 0}, - {{1|(9<<4)}, { 16*9.5, 16}, 0}, - {{1|(8<<4)}, { 16*8.5, 16}, 0}, - {{1|(7<<4)}, { 16*7.5, 16}, 0}, - {{1|(6<<4)}, { 16*6.5, 16}, 0}, - {{1|(5<<4)}, { 16*5.5, 16}, 0}, - {{1|(4<<4)}, { 16*4.5, 16}, 0}, - {{1|(3<<4)}, { 16*3.5, 16}, 0}, - {{1|(2<<4)}, { 16*2.5, 16}, 0}, - {{1|(1<<4)}, { 16*1.5, 16}, 0}, + {{1|(12<<4)}, {16*12.5, 16}, 4}, + {{1|(11<<4)}, {16*11.5, 16}, 4}, + {{1|(10<<4)}, {16*10.5, 16}, 4}, + {{1|(9<<4)}, { 16*9.5, 16}, 4}, + {{1|(8<<4)}, { 16*8.5, 16}, 4}, + {{1|(7<<4)}, { 16*7.5, 16}, 4}, + {{1|(6<<4)}, { 16*6.5, 16}, 4}, + {{1|(5<<4)}, { 16*5.5, 16}, 4}, + {{1|(4<<4)}, { 16*4.5, 16}, 4}, + {{1|(3<<4)}, { 16*3.5, 16}, 4}, + {{1|(2<<4)}, { 16*2.5, 16}, 4}, + {{1|(1<<4)}, { 16*1.5, 16}, 4}, {{1|(0<<4)}, { 16*0.25, 16}, 1}, {{2|(13<<4)}, {16*12.75, 32}, 1}, - {{2|(11<<4)}, {16*11.75, 32}, 0}, - {{2|(10<<4)}, {16*10.75, 32}, 0}, - {{2|(9<<4)}, {16*9.75, 32}, 0}, - {{2|(8<<4)}, {16*8.75, 32}, 0}, - {{2|(7<<4)}, {16*7.75, 32}, 0}, - {{2|(6<<4)}, { 16*6.75, 32}, 0}, - {{2|(5<<4)}, { 16*5.75, 32}, 0}, - {{2|(4<<4)}, { 16*4.75, 32}, 0}, - {{2|(3<<4)}, { 16*3.75, 32}, 0}, - {{2|(2<<4)}, { 16*2.75, 32}, 0}, - {{2|(1<<4)}, { 16*1.75, 32}, 0}, + {{2|(11<<4)}, {16*11.75, 32}, 4}, + {{2|(10<<4)}, {16*10.75, 32}, 4}, + {{2|(9<<4)}, {16*9.75, 32}, 4}, + {{2|(8<<4)}, {16*8.75, 32}, 4}, + {{2|(7<<4)}, {16*7.75, 32}, 4}, + {{2|(6<<4)}, { 16*6.75, 32}, 4}, + {{2|(5<<4)}, { 16*5.75, 32}, 4}, + {{2|(4<<4)}, { 16*4.75, 32}, 4}, + {{2|(3<<4)}, { 16*3.75, 32}, 4}, + {{2|(2<<4)}, { 16*2.75, 32}, 4}, + {{2|(1<<4)}, { 16*1.75, 32}, 4}, {{2|(0<<4)}, { 16*0.375, 32}, 1}, {{3|(13<<4)}, {16*14, 48}, 1}, - {{3|(11<<4)}, {16*12.625, 48}, 0}, - {{3|(10<<4)}, {16*11.25, 48}, 0}, - {{3|(9<<4)}, {16*10.25, 48}, 0}, - {{3|(8<<4)}, {16*9.25, 48}, 0}, - {{3|(7<<4)}, {16*8.25, 48}, 0}, - {{3|(6<<4)}, {16*7.25, 48}, 0}, - {{3|(5<<4)}, {16*6.25, 48}, 0}, - {{3|(4<<4)}, {16*5.25, 48}, 0}, - {{3|(3<<4)}, {16*4.25, 48}, 0}, - {{3|(2<<4)}, {16*3.25, 48}, 0}, - {{3|(1<<4)}, {16*1.25, 48}, 0}, + {{3|(11<<4)}, {16*12.625, 48}, 4}, + {{3|(10<<4)}, {16*11.25, 48}, 4}, + {{3|(9<<4)}, {16*10.25, 48}, 4}, + {{3|(8<<4)}, {16*9.25, 48}, 4}, + {{3|(7<<4)}, {16*8.25, 48}, 4}, + {{3|(6<<4)}, {16*7.25, 48}, 4}, + {{3|(5<<4)}, {16*6.25, 48}, 4}, + {{3|(4<<4)}, {16*5.25, 48}, 4}, + {{3|(3<<4)}, {16*4.25, 48}, 4}, + {{3|(2<<4)}, {16*3.25, 48}, 4}, + {{3|(1<<4)}, {16*1.25, 48}, 4}, {{3|(0<<4)}, {16*0.625, 48}, 1}, {{4|(13<<4)}, {16*13.625, 64}, 1}, {{4|(11<<4)}, {16*12.375, 64}, 1}, {{4|(10<<4)}, {16*11.125, 64}, 1}, - {{4|(5<<4)}, { 16*7, 64}, 0}, + {{4|(5<<4)}, { 16*7, 64}, 4}, {{4|(2<<4)}, { 16*2.875, 64}, 1}, {{4|(1<<4)}, { 16*1.625, 64}, 1}, {{4|(0<<4)}, { 16*0.375, 64}, 1}, @@ -321,7 +323,8 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, H_16, G_16, I_16}, {0, K_16, J_16, L_16}, }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{2|(12<<4)}, {16*14, 0}, 1}, {{0|(13<<4)}, {16*13, 0}, 1}, {{0|(12<<4)}, {16*12, 0}, 1}, @@ -338,49 +341,49 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(1<<4)}, {16*1, 0}, 1}, {{0|(0<<4)}, {16*0, 0}, 1}, {{2|(13<<4)}, {16*13.75, 24}, 1}, - {{1|(12<<4)}, {16*12.5, 16}, 0}, - {{1|(11<<4)}, {16*11.5, 16}, 0}, - {{1|(10<<4)}, {16*10.5, 16}, 0}, - {{1|(9<<4)}, { 16*9.5, 16}, 0}, - {{1|(8<<4)}, { 16*8.5, 16}, 0}, - {{1|(7<<4)}, { 16*7.5, 16}, 0}, - {{1|(6<<4)}, { 16*6.5, 16}, 0}, - {{1|(5<<4)}, { 16*5.5, 16}, 0}, - {{1|(4<<4)}, { 16*4.5, 16}, 0}, - {{1|(3<<4)}, { 16*3.5, 16}, 0}, - {{1|(2<<4)}, { 16*2.5, 16}, 0}, - {{1|(1<<4)}, { 16*1.5, 16}, 0}, + {{1|(12<<4)}, {16*12.5, 16}, 4}, + {{1|(11<<4)}, {16*11.5, 16}, 4}, + {{1|(10<<4)}, {16*10.5, 16}, 4}, + {{1|(9<<4)}, { 16*9.5, 16}, 4}, + {{1|(8<<4)}, { 16*8.5, 16}, 4}, + {{1|(7<<4)}, { 16*7.5, 16}, 4}, + {{1|(6<<4)}, { 16*6.5, 16}, 4}, + {{1|(5<<4)}, { 16*5.5, 16}, 4}, + {{1|(4<<4)}, { 16*4.5, 16}, 4}, + {{1|(3<<4)}, { 16*3.5, 16}, 4}, + {{1|(2<<4)}, { 16*2.5, 16}, 4}, + {{1|(1<<4)}, { 16*1.5, 16}, 4}, {{1|(0<<4)}, { 16*0.25, 16}, 1}, {{1|(13<<4)}, {16*12.75, 32}, 1}, - {{2|(11<<4)}, {16*11.75, 32}, 0}, - {{2|(10<<4)}, {16*10.75, 32}, 0}, - {{2|(9<<4)}, {16*9.75, 32}, 0}, - {{2|(8<<4)}, {16*8.75, 32}, 0}, - {{2|(7<<4)}, {16*7.75, 32}, 0}, - {{2|(6<<4)}, { 16*6.75, 32}, 0}, - {{2|(5<<4)}, { 16*5.75, 32}, 0}, - {{2|(4<<4)}, { 16*4.75, 32}, 0}, - {{2|(3<<4)}, { 16*3.75, 32}, 0}, - {{2|(2<<4)}, { 16*2.75, 32}, 0}, - {{2|(1<<4)}, { 16*1.75, 32}, 0}, + {{2|(11<<4)}, {16*11.75, 32}, 4}, + {{2|(10<<4)}, {16*10.75, 32}, 4}, + {{2|(9<<4)}, {16*9.75, 32}, 4}, + {{2|(8<<4)}, {16*8.75, 32}, 4}, + {{2|(7<<4)}, {16*7.75, 32}, 4}, + {{2|(6<<4)}, { 16*6.75, 32}, 4}, + {{2|(5<<4)}, { 16*5.75, 32}, 4}, + {{2|(4<<4)}, { 16*4.75, 32}, 4}, + {{2|(3<<4)}, { 16*3.75, 32}, 4}, + {{2|(2<<4)}, { 16*2.75, 32}, 4}, + {{2|(1<<4)}, { 16*1.75, 32}, 4}, {{2|(0<<4)}, { 16*0.375, 32}, 1}, {{3|(13<<4)}, {16*14, 48}, 1}, - {{3|(11<<4)}, {16*12.625, 48}, 0}, - {{3|(10<<4)}, {16*11.25, 48}, 0}, - {{3|(9<<4)}, {16*10.25, 48}, 0}, - {{3|(8<<4)}, {16*9.25, 48}, 0}, - {{3|(7<<4)}, {16*8.25, 48}, 0}, - {{3|(6<<4)}, {16*7.25, 48}, 0}, - {{3|(5<<4)}, {16*6.25, 48}, 0}, - {{3|(4<<4)}, {16*5.25, 48}, 0}, - {{3|(3<<4)}, {16*4.25, 48}, 0}, - {{3|(2<<4)}, {16*3.25, 48}, 0}, - {{3|(1<<4)}, {16*1.25, 48}, 0}, + {{3|(11<<4)}, {16*12.625, 48}, 4}, + {{3|(10<<4)}, {16*11.25, 48}, 4}, + {{3|(9<<4)}, {16*10.25, 48}, 4}, + {{3|(8<<4)}, {16*9.25, 48}, 4}, + {{3|(7<<4)}, {16*8.25, 48}, 4}, + {{3|(6<<4)}, {16*7.25, 48}, 4}, + {{3|(5<<4)}, {16*6.25, 48}, 4}, + {{3|(4<<4)}, {16*5.25, 48}, 4}, + {{3|(3<<4)}, {16*4.25, 48}, 4}, + {{3|(2<<4)}, {16*3.25, 48}, 4}, + {{3|(1<<4)}, {16*1.25, 48}, 4}, {{3|(0<<4)}, {16*0.625, 48}, 1}, {{4|(13<<4)}, {16*13.625, 64}, 1}, {{4|(11<<4)}, {16*12.375, 64}, 1}, {{4|(10<<4)}, {16*11.125, 64}, 1}, - {{4|(5<<4)}, { 16*7, 64}, 0}, + {{4|(5<<4)}, { 16*7, 64}, 4}, {{4|(2<<4)}, { 16*2.875, 64}, 1}, {{4|(1<<4)}, { 16*1.625, 64}, 1}, {{4|(0<<4)}, { 16*0.375, 64}, 1}, @@ -449,7 +452,8 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, H_16, G_16, I_16}, {0, K_16, J_16, L_16}, }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(13<<4)}, {16*13.5, 0}, 1}, {{0|(12<<4)}, {16*12, 0}, 1}, {{0|(11<<4)}, {16*11, 0}, 1}, @@ -465,49 +469,49 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(1<<4)}, {16*1, 0}, 1}, {{0|(0<<4)}, {16*0, 0}, 1}, {{1|(13<<4)}, {16*13.75, 16}, 1}, - {{1|(12<<4)}, {16*12.5, 16}, 0}, - {{1|(11<<4)}, {16*11.5, 16}, 0}, - {{1|(10<<4)}, {16*10.5, 16}, 0}, - {{1|(9<<4)}, { 16*9.5, 16}, 0}, - {{1|(8<<4)}, { 16*8.5, 16}, 0}, - {{1|(7<<4)}, { 16*7.5, 16}, 0}, - {{1|(6<<4)}, { 16*6.5, 16}, 0}, - {{1|(5<<4)}, { 16*5.5, 16}, 0}, - {{1|(4<<4)}, { 16*4.5, 16}, 0}, - {{1|(3<<4)}, { 16*3.5, 16}, 0}, - {{1|(2<<4)}, { 16*2.5, 16}, 0}, - {{1|(1<<4)}, { 16*1.5, 16}, 0}, + {{1|(12<<4)}, {16*12.5, 16}, 4}, + {{1|(11<<4)}, {16*11.5, 16}, 4}, + {{1|(10<<4)}, {16*10.5, 16}, 4}, + {{1|(9<<4)}, { 16*9.5, 16}, 4}, + {{1|(8<<4)}, { 16*8.5, 16}, 4}, + {{1|(7<<4)}, { 16*7.5, 16}, 4}, + {{1|(6<<4)}, { 16*6.5, 16}, 4}, + {{1|(5<<4)}, { 16*5.5, 16}, 4}, + {{1|(4<<4)}, { 16*4.5, 16}, 4}, + {{1|(3<<4)}, { 16*3.5, 16}, 4}, + {{1|(2<<4)}, { 16*2.5, 16}, 4}, + {{1|(1<<4)}, { 16*1.5, 16}, 4}, {{1|(0<<4)}, { 16*0.25, 16}, 1}, {{2|(13<<4)}, {16*13.375, 24}, 1}, - {{2|(11<<4)}, {16*11.75, 32}, 0}, - {{2|(10<<4)}, {16*10.75, 32}, 0}, - {{2|(9<<4)}, {16*9.75, 32}, 0}, - {{2|(8<<4)}, {16*8.75, 32}, 0}, - {{2|(7<<4)}, {16*7.75, 32}, 0}, - {{2|(6<<4)}, { 16*6.75, 32}, 0}, - {{2|(5<<4)}, { 16*5.75, 32}, 0}, - {{2|(4<<4)}, { 16*4.75, 32}, 0}, - {{2|(3<<4)}, { 16*3.75, 32}, 0}, - {{2|(2<<4)}, { 16*2.75, 32}, 0}, - {{2|(1<<4)}, { 16*1.75, 32}, 0}, + {{2|(11<<4)}, {16*11.75, 32}, 4}, + {{2|(10<<4)}, {16*10.75, 32}, 4}, + {{2|(9<<4)}, {16*9.75, 32}, 4}, + {{2|(8<<4)}, {16*8.75, 32}, 4}, + {{2|(7<<4)}, {16*7.75, 32}, 4}, + {{2|(6<<4)}, { 16*6.75, 32}, 4}, + {{2|(5<<4)}, { 16*5.75, 32}, 4}, + {{2|(4<<4)}, { 16*4.75, 32}, 4}, + {{2|(3<<4)}, { 16*3.75, 32}, 4}, + {{2|(2<<4)}, { 16*2.75, 32}, 4}, + {{2|(1<<4)}, { 16*1.75, 32}, 4}, {{2|(0<<4)}, { 16*0.375, 32}, 1}, {{3|(11<<4)}, {16*13.125, 48}, 1}, - {{3|(10<<4)}, {16*11.25, 48}, 0}, - {{3|(9<<4)}, {16*10.25, 48}, 0}, - {{3|(8<<4)}, {16*9.25, 48}, 0}, - {{3|(7<<4)}, {16*8.25, 48}, 0}, - {{3|(6<<4)}, {16*7.25, 48}, 0}, - {{3|(5<<4)}, {16*6.25, 48}, 0}, - {{3|(4<<4)}, {16*5.25, 48}, 0}, - {{3|(3<<4)}, {16*4.25, 48}, 0}, - {{3|(2<<4)}, {16*3.25, 48}, 0}, - {{3|(1<<4)}, {16*1.25, 48}, 0}, + {{3|(10<<4)}, {16*11.25, 48}, 4}, + {{3|(9<<4)}, {16*10.25, 48}, 4}, + {{3|(8<<4)}, {16*9.25, 48}, 4}, + {{3|(7<<4)}, {16*8.25, 48}, 4}, + {{3|(6<<4)}, {16*7.25, 48}, 4}, + {{3|(5<<4)}, {16*6.25, 48}, 4}, + {{3|(4<<4)}, {16*5.25, 48}, 4}, + {{3|(3<<4)}, {16*4.25, 48}, 4}, + {{3|(2<<4)}, {16*3.25, 48}, 4}, + {{3|(1<<4)}, {16*1.25, 48}, 4}, {{3|(0<<4)}, {16*0.625, 48}, 1}, {{4|(13<<4)}, {16*13.875, 64}, 1}, {{4|(11<<4)}, {16*12.625, 64}, 1}, {{4|(10<<4)}, {16*11.375, 64}, 1}, {{4|(9<<4)}, {16*10.125, 64}, 1}, - {{4|(5<<4)}, { 16*6.375, 64}, 0}, + {{4|(5<<4)}, { 16*6.375, 64}, 4}, {{4|(2<<4)}, { 16*2.625, 64}, 1}, {{4|(1<<4)}, { 16*1.375, 64}, 1}, {{4|(0<<4)}, { 16*0.125, 64}, 1}, @@ -578,7 +582,8 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, H_16, G_16, I_16}, {0, K_16, J_16, L_16}, }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(13<<4)}, {17.23*13, 0}, 1}, {{0|(12<<4)}, {17.23*12, 0}, 1}, {{0|(11<<4)}, {17.23*11, 0}, 1}, @@ -594,51 +599,51 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0|(1<<4)}, { 17.23*1, 0}, 1}, {{0|(0<<4)}, { 17.23*0, 0}, 1}, {{1|(13<<4)}, {17.23*13, 16}, 1}, - {{1|(12<<4)}, {17.23*12, 16}, 0}, - {{1|(11<<4)}, {17.23*11, 16}, 0}, - {{1|(10<<4)}, {17.23*10, 16}, 0}, - {{1|(9<<4)}, {17.23*9, 16}, 0}, - {{1|(8<<4)}, {17.23*8, 16}, 0}, - {{1|(7<<4)}, {17.23*7, 16}, 0}, - {{1|(6<<4)}, { 17.23*6, 16}, 0}, - {{1|(5<<4)}, { 17.23*5, 16}, 0}, - {{1|(4<<4)}, { 17.23*4, 16}, 0}, - {{1|(3<<4)}, { 17.23*3, 16}, 0}, - {{1|(2<<4)}, { 17.23*2, 16}, 0}, - {{1|(1<<4)}, { 17.23*1, 16}, 0}, + {{1|(12<<4)}, {17.23*12, 16}, 4}, + {{1|(11<<4)}, {17.23*11, 16}, 4}, + {{1|(10<<4)}, {17.23*10, 16}, 4}, + {{1|(9<<4)}, {17.23*9, 16}, 4}, + {{1|(8<<4)}, {17.23*8, 16}, 4}, + {{1|(7<<4)}, {17.23*7, 16}, 4}, + {{1|(6<<4)}, { 17.23*6, 16}, 4}, + {{1|(5<<4)}, { 17.23*5, 16}, 4}, + {{1|(4<<4)}, { 17.23*4, 16}, 4}, + {{1|(3<<4)}, { 17.23*3, 16}, 4}, + {{1|(2<<4)}, { 17.23*2, 16}, 4}, + {{1|(1<<4)}, { 17.23*1, 16}, 4}, {{1|(0<<4)}, { 17.23*0, 16}, 1}, {{2|(13<<4)}, {17.23*13, 32}, 1}, - {{2|(11<<4)}, {17.23*11, 32}, 0}, - {{2|(10<<4)}, {17.23*10, 32}, 0}, - {{2|(9<<4)}, {17.23*9, 32}, 0}, - {{2|(8<<4)}, {17.23*8, 32}, 0}, - {{2|(7<<4)}, {17.23*7, 32}, 0}, - {{2|(6<<4)}, { 17.23*6, 32}, 0}, - {{2|(5<<4)}, { 17.23*5, 32}, 0}, - {{2|(4<<4)}, { 17.23*4, 32}, 0}, - {{2|(3<<4)}, { 17.23*3, 32}, 0}, - {{2|(2<<4)}, { 17.23*2, 32}, 0}, - {{2|(1<<4)}, { 17.23*1, 32}, 0}, + {{2|(11<<4)}, {17.23*11, 32}, 4}, + {{2|(10<<4)}, {17.23*10, 32}, 4}, + {{2|(9<<4)}, {17.23*9, 32}, 4}, + {{2|(8<<4)}, {17.23*8, 32}, 4}, + {{2|(7<<4)}, {17.23*7, 32}, 4}, + {{2|(6<<4)}, { 17.23*6, 32}, 4}, + {{2|(5<<4)}, { 17.23*5, 32}, 4}, + {{2|(4<<4)}, { 17.23*4, 32}, 4}, + {{2|(3<<4)}, { 17.23*3, 32}, 4}, + {{2|(2<<4)}, { 17.23*2, 32}, 4}, + {{2|(1<<4)}, { 17.23*1, 32}, 4}, {{2|(0<<4)}, { 17.23*0, 32}, 1}, {{3|(13<<4)}, {17.23*13, 48}, 1}, - {{3|(11<<4)}, {17.23*11, 48}, 0}, - {{3|(10<<4)}, {17.23*10, 48}, 0}, - {{3|(9<<4)}, {17.23*9, 48}, 0}, - {{3|(8<<4)}, {17.23*8, 48}, 0}, - {{3|(7<<4)}, {17.23*7, 48}, 0}, - {{3|(6<<4)}, { 17.23*6, 48}, 0}, - {{3|(5<<4)}, { 17.23*5, 48}, 0}, - {{3|(4<<4)}, { 17.23*4, 48}, 0}, - {{3|(3<<4)}, { 17.23*3, 48}, 0}, - {{3|(2<<4)}, { 17.23*2, 48}, 0}, - {{3|(1<<4)}, { 17.23*1, 48}, 0}, + {{3|(11<<4)}, {17.23*11, 48}, 4}, + {{3|(10<<4)}, {17.23*10, 48}, 4}, + {{3|(9<<4)}, {17.23*9, 48}, 4}, + {{3|(8<<4)}, {17.23*8, 48}, 4}, + {{3|(7<<4)}, {17.23*7, 48}, 4}, + {{3|(6<<4)}, { 17.23*6, 48}, 4}, + {{3|(5<<4)}, { 17.23*5, 48}, 4}, + {{3|(4<<4)}, { 17.23*4, 48}, 4}, + {{3|(3<<4)}, { 17.23*3, 48}, 4}, + {{3|(2<<4)}, { 17.23*2, 48}, 4}, + {{3|(1<<4)}, { 17.23*1, 48}, 4}, {{3|(0<<4)}, { 17.23*0, 48}, 1}, {{4|(13<<4)}, {17.23*13, 64}, 1}, {{4|(11<<4)}, {17.23*11, 64}, 1}, {{4|(10<<4)}, {17.23*10, 64}, 1}, {{4|(9<<4)}, {17.23*9, 64}, 1}, {{4|(8<<4)}, {17.23*8, 64}, 1}, - {{4|(5<<4)}, { 17.23*5, 64}, 0}, + {{4|(5<<4)}, { 17.23*5, 64}, 4}, {{4|(2<<4)}, { 17.23*2, 64}, 1}, {{4|(1<<4)}, { 17.23*1, 64}, 1}, {{4|(0<<4)}, { 17.23*0, 64}, 1}, diff --git a/keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c b/keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c index fcdf29e4e..741fc55fb 100644 --- a/keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c @@ -42,10 +42,8 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool def rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if (led.matrix_co.raw < 0xFF) { - if (led.modifier) { - rgb_matrix_set_color( i, red, green, blue ); - } + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); } } } diff --git a/keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c b/keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c index 6ba3ac7e6..1f3807c3b 100644 --- a/keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c @@ -43,10 +43,8 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool def rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if (led.matrix_co.raw < 0xFF) { - if (led.modifier) { - rgb_matrix_set_color( i, red, green, blue ); - } + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); } } } diff --git a/keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c b/keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c index 772eddf07..4575eb19d 100644 --- a/keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c @@ -43,10 +43,8 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool def rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if (led.matrix_co.raw < 0xFF) { - if (led.modifier) { - rgb_matrix_set_color( i, red, green, blue ); - } + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); } } } diff --git a/keyboards/dztech/dz60rgb/keymaps/iso/keymap.c b/keyboards/dztech/dz60rgb/keymaps/iso/keymap.c index a78e23703..5e3884803 100644 --- a/keyboards/dztech/dz60rgb/keymaps/iso/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/iso/keymap.c @@ -42,10 +42,8 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool def rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if (led.matrix_co.raw < 0xFF) { - if (led.modifier) { - rgb_matrix_set_color( i, red, green, blue ); - } + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); } } } diff --git a/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c b/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c index 2784f6fa6..3dfa78374 100644 --- a/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c @@ -56,11 +56,9 @@ void rgb_matrix_layer_helper(uint8_t red, uint8_t green, uint8_t blue, bool defa for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - - if (led.matrix_co.raw < 0xFF) { - if (led.modifier) { - rgb_matrix_set_color(i, red, green, blue); - } + + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); } } } diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c index 6f4ae9fed..13ea84302 100644 --- a/keyboards/ergodox_ez/ergodox_ez.c +++ b/keyboards/ergodox_ez/ergodox_ez.c @@ -269,64 +269,64 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { /*{row | col << 4} | {x=0..224, y=0..64} - | | modifier + | | flags | | | */ - {{ 8|(0<<4)}, {17.2* 8, 12.8*0}, 0}, // LED 1 on right > Key 6 - {{ 9|(0<<4)}, {17.2* 9, 12.8*0}, 0}, // LED 2 > Key 7 - {{10|(0<<4)}, {17.2*10, 12.8*0}, 0}, // LED 3 > Key 8 - {{11|(0<<4)}, {17.2*11, 12.8*0}, 0}, // LED 4 > Key 9 - {{12|(0<<4)}, {17.2*12, 12.8*0}, 0}, // LED 5 > Key 0 - - {{ 8|(1<<4)}, {17.2* 8, 12.8*1}, 0}, // LED 6 - {{ 9|(1<<4)}, {17.2* 9, 12.8*1}, 0}, // LED 7 - {{10|(1<<4)}, {17.2*10, 12.8*1}, 0}, // LED 8 - {{11|(1<<4)}, {17.2*11, 12.8*1}, 0}, // LED 9 - {{12|(1<<4)}, {17.2*12, 12.8*1}, 0}, // LED 10 - - {{ 8|(2<<4)}, {17.2* 8, 12.8*2}, 0}, // LED 11 - {{ 9|(2<<4)}, {17.2* 9, 12.8*2}, 0}, // LED 12 - {{10|(2<<4)}, {17.2*10, 12.8*2}, 0}, // LED 13 - {{11|(2<<4)}, {17.2*11, 12.8*2}, 0}, // LED 14 - {{12|(2<<4)}, {17.2*12, 12.8*2}, 0}, // LED 15 - - {{ 8|(3<<4)}, {17.2* 8, 12.8*3}, 0}, // LED 16 - {{ 9|(3<<4)}, {17.2* 9, 12.8*3}, 0}, // LED 17 - {{10|(3<<4)}, {17.2*10, 12.8*3}, 0}, // LED 18 - {{11|(3<<4)}, {17.2*11, 12.8*3}, 0}, // LED 19 - {{12|(3<<4)}, {17.2*12, 12.8*3}, 0}, // LED 20 + {{ 8|(0<<4)}, {17.2* 8, 12.8*0}, 4}, // LED 1 on right > Key 6 + {{ 9|(0<<4)}, {17.2* 9, 12.8*0}, 4}, // LED 2 > Key 7 + {{10|(0<<4)}, {17.2*10, 12.8*0}, 4}, // LED 3 > Key 8 + {{11|(0<<4)}, {17.2*11, 12.8*0}, 4}, // LED 4 > Key 9 + {{12|(0<<4)}, {17.2*12, 12.8*0}, 4}, // LED 5 > Key 0 + + {{ 8|(1<<4)}, {17.2* 8, 12.8*1}, 4}, // LED 6 + {{ 9|(1<<4)}, {17.2* 9, 12.8*1}, 4}, // LED 7 + {{10|(1<<4)}, {17.2*10, 12.8*1}, 4}, // LED 8 + {{11|(1<<4)}, {17.2*11, 12.8*1}, 4}, // LED 9 + {{12|(1<<4)}, {17.2*12, 12.8*1}, 4}, // LED 10 + + {{ 8|(2<<4)}, {17.2* 8, 12.8*2}, 4}, // LED 11 + {{ 9|(2<<4)}, {17.2* 9, 12.8*2}, 4}, // LED 12 + {{10|(2<<4)}, {17.2*10, 12.8*2}, 4}, // LED 13 + {{11|(2<<4)}, {17.2*11, 12.8*2}, 4}, // LED 14 + {{12|(2<<4)}, {17.2*12, 12.8*2}, 4}, // LED 15 + + {{ 8|(3<<4)}, {17.2* 8, 12.8*3}, 4}, // LED 16 + {{ 9|(3<<4)}, {17.2* 9, 12.8*3}, 4}, // LED 17 + {{10|(3<<4)}, {17.2*10, 12.8*3}, 4}, // LED 18 + {{11|(3<<4)}, {17.2*11, 12.8*3}, 4}, // LED 19 + {{12|(3<<4)}, {17.2*12, 12.8*3}, 4}, // LED 20 {{ 9|(4<<4)}, {17.2* 9, 12.8*4}, 1}, // LED 21 {{10|(4<<4)}, {17.2*10, 12.8*4}, 1}, // LED 22 {{11|(4<<4)}, {17.2*11, 12.8*4}, 1}, // LED 23 {{12|(4<<4)}, {17.2*12, 12.8*4}, 1}, // LED 24 - {{ 5|(0<<4)}, {17.2* 5, 12.8*0}, 0}, // LED 1 on left > Key 5 - {{ 4|(0<<4)}, {17.2* 4, 12.8*0}, 0}, // LED 2 > Key 4 - {{ 3|(0<<4)}, {17.2* 3, 12.8*0}, 0}, // LED 3 > Key 3 - {{ 2|(0<<4)}, {17.2* 2, 12.8*0}, 0}, // LED 4 > Key 2 - {{ 1|(0<<4)}, {17.2* 1, 12.8*0}, 0}, // LED 5 > Key 1 - - {{ 5|(1<<4)}, {17.2* 5, 12.8*1}, 0}, // LED 6 - {{ 4|(1<<4)}, {17.2* 4, 12.8*1}, 0}, // LED 7 - {{ 3|(1<<4)}, {17.2* 3, 12.8*1}, 0}, // LED 8 - {{ 2|(1<<4)}, {17.2* 2, 12.8*1}, 0}, // LED 9 - {{ 1|(1<<4)}, {17.2* 1, 12.8*1}, 0}, // LED 10 - - {{ 5|(2<<4)}, {17.2* 5, 12.8*2}, 0}, // LED 11 - {{ 4|(2<<4)}, {17.2* 4, 12.8*2}, 0}, // LED 12 - {{ 3|(2<<4)}, {17.2* 3, 12.8*2}, 0}, // LED 13 - {{ 2|(2<<4)}, {17.2* 2, 12.8*2}, 0}, // LED 14 - {{ 1|(2<<4)}, {17.2* 1, 12.8*2}, 0}, // LED 15 - - {{ 5|(3<<4)}, {17.2* 5, 12.8*3}, 0}, // LED 16 - {{ 4|(3<<4)}, {17.2* 4, 12.8*3}, 0}, // LED 17 - {{ 3|(3<<4)}, {17.2* 3, 12.8*3}, 0}, // LED 18 - {{ 2|(3<<4)}, {17.2* 2, 12.8*3}, 0}, // LED 19 - {{ 1|(3<<4)}, {17.2* 1, 12.8*3}, 0}, // LED 20 + {{ 5|(0<<4)}, {17.2* 5, 12.8*0}, 4}, // LED 1 on left > Key 5 + {{ 4|(0<<4)}, {17.2* 4, 12.8*0}, 4}, // LED 2 > Key 4 + {{ 3|(0<<4)}, {17.2* 3, 12.8*0}, 4}, // LED 3 > Key 3 + {{ 2|(0<<4)}, {17.2* 2, 12.8*0}, 4}, // LED 4 > Key 2 + {{ 1|(0<<4)}, {17.2* 1, 12.8*0}, 4}, // LED 5 > Key 1 + + {{ 5|(1<<4)}, {17.2* 5, 12.8*1}, 4}, // LED 6 + {{ 4|(1<<4)}, {17.2* 4, 12.8*1}, 4}, // LED 7 + {{ 3|(1<<4)}, {17.2* 3, 12.8*1}, 4}, // LED 8 + {{ 2|(1<<4)}, {17.2* 2, 12.8*1}, 4}, // LED 9 + {{ 1|(1<<4)}, {17.2* 1, 12.8*1}, 4}, // LED 10 + + {{ 5|(2<<4)}, {17.2* 5, 12.8*2}, 4}, // LED 11 + {{ 4|(2<<4)}, {17.2* 4, 12.8*2}, 4}, // LED 12 + {{ 3|(2<<4)}, {17.2* 3, 12.8*2}, 4}, // LED 13 + {{ 2|(2<<4)}, {17.2* 2, 12.8*2}, 4}, // LED 14 + {{ 1|(2<<4)}, {17.2* 1, 12.8*2}, 4}, // LED 15 + + {{ 5|(3<<4)}, {17.2* 5, 12.8*3}, 4}, // LED 16 + {{ 4|(3<<4)}, {17.2* 4, 12.8*3}, 4}, // LED 17 + {{ 3|(3<<4)}, {17.2* 3, 12.8*3}, 4}, // LED 18 + {{ 2|(3<<4)}, {17.2* 2, 12.8*3}, 4}, // LED 19 + {{ 1|(3<<4)}, {17.2* 1, 12.8*3}, 4}, // LED 20 {{ 4|(4<<4)}, {17.2* 4, 12.8*4}, 1}, // LED 21 {{ 3|(4<<4)}, {17.2* 3, 12.8*4}, 1}, // LED 22 diff --git a/keyboards/exclusive/e6_rgb/e6_rgb.c b/keyboards/exclusive/e6_rgb/e6_rgb.c index d50af86b5..42f879990 100644 --- a/keyboards/exclusive/e6_rgb/e6_rgb.c +++ b/keyboards/exclusive/e6_rgb/e6_rgb.c @@ -114,80 +114,80 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, E_16, D_16, F_16}, {0, B_16, A_16, C_16}, }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { /* {row | col << 4} * | {x=0..224, y=0..64} - * | | modifier + * | | flags * | | | */ //cs1 {{0|(0<<4)}, { 0, 0}, 1}, - {{0|(1<<4)}, { 17, 0}, 0}, + {{0|(1<<4)}, { 17, 0}, 4}, {{1|(0<<4)}, { 0, 16}, 1}, {{2|(0<<4)}, { 0, 32}, 1}, //cs2 - {{0|(2<<4)}, { 34, 0}, 0}, - {{0|(3<<4)}, { 51, 0}, 0}, - {{1|(1<<4)}, { 17, 16}, 0}, - {{1|(2<<4)}, { 34, 16}, 0}, + {{0|(2<<4)}, { 34, 0}, 4}, + {{0|(3<<4)}, { 51, 0}, 4}, + {{1|(1<<4)}, { 17, 16}, 4}, + {{1|(2<<4)}, { 34, 16}, 4}, //cs3 - {{2|(1<<4)}, { 17, 32}, 0}, - {{2|(2<<4)}, { 34, 32}, 0}, - {{3|(1<<4)}, { 17, 48}, 0}, - {{3|(2<<4)}, { 34, 48}, 0}, + {{2|(1<<4)}, { 17, 32}, 4}, + {{2|(2<<4)}, { 34, 32}, 4}, + {{3|(1<<4)}, { 17, 48}, 4}, + {{3|(2<<4)}, { 34, 48}, 4}, //cs4 - {{0|(4<<4)}, { 68, 0}, 0}, - {{0|(5<<4)}, { 85, 0}, 0}, - {{1|(3<<4)}, { 51, 16}, 0}, - {{1|(4<<4)}, { 68, 16}, 0}, + {{0|(4<<4)}, { 68, 0}, 4}, + {{0|(5<<4)}, { 85, 0}, 4}, + {{1|(3<<4)}, { 51, 16}, 4}, + {{1|(4<<4)}, { 68, 16}, 4}, //cs5 - {{0|(11<<4)}, {187, 0}, 0}, - {{0|(12<<4)}, {204, 0}, 0}, - {{1|(11<<4)}, {187, 16}, 0}, - {{1|(12<<4)}, {204, 16}, 0}, + {{0|(11<<4)}, {187, 0}, 4}, + {{0|(12<<4)}, {204, 0}, 4}, + {{1|(11<<4)}, {187, 16}, 4}, + {{1|(12<<4)}, {204, 16}, 4}, //cs6 - {{0|(7<<4)}, {119, 0}, 0}, - {{0|(8<<4)}, {136, 0}, 0}, - {{1|(7<<4)}, {119, 16}, 0}, - {{1|(8<<4)}, {136, 16}, 0}, + {{0|(7<<4)}, {119, 0}, 4}, + {{0|(8<<4)}, {136, 0}, 4}, + {{1|(7<<4)}, {119, 16}, 4}, + {{1|(8<<4)}, {136, 16}, 4}, //cs7 - {{0|(9<<4)}, {153, 0}, 0}, - {{0|(10<<4)}, {170, 0}, 0}, - {{1|(9<<4)}, {153, 16}, 0}, - {{1|(10<<4)}, {170, 16}, 0}, + {{0|(9<<4)}, {153, 0}, 4}, + {{0|(10<<4)}, {170, 0}, 4}, + {{1|(9<<4)}, {153, 16}, 4}, + {{1|(10<<4)}, {170, 16}, 4}, //cs8 - {{0|(13<<4)}, {221, 0}, 0}, - {{0|(14<<4)}, {221, 0}, 0}, + {{0|(13<<4)}, {221, 0}, 4}, + {{0|(14<<4)}, {221, 0}, 4}, {{1|(13<<4)}, {221, 32}, 1}, {{2|(12<<4)}, {221, 16}, 1}, //cs9 - {{2|(3<<4)}, { 51, 32}, 0}, - {{2|(4<<4)}, { 68, 32}, 0}, - {{3|(3<<4)}, { 51, 48}, 0}, - {{3|(4<<4)}, { 68, 48}, 0}, + {{2|(3<<4)}, { 51, 32}, 4}, + {{2|(4<<4)}, { 68, 32}, 4}, + {{3|(3<<4)}, { 51, 48}, 4}, + {{3|(4<<4)}, { 68, 48}, 4}, //cs10 - {{0|(6<<4)}, {102, 0}, 0}, - {{1|(5<<4)}, { 85, 16}, 0}, - {{1|(6<<4)}, {102, 16}, 0}, - {{2|(5<<4)}, { 85, 32}, 0}, + {{0|(6<<4)}, {102, 0}, 4}, + {{1|(5<<4)}, { 85, 16}, 4}, + {{1|(6<<4)}, {102, 16}, 4}, + {{2|(5<<4)}, { 85, 32}, 4}, //cs11 - {{2|(6<<4)}, {102, 32}, 0}, - {{3|(5<<4)}, { 85, 48}, 0}, - {{3|(6<<4)}, {102, 48}, 0}, - {{4|(5<<4)}, {102, 64}, 0}, + {{2|(6<<4)}, {102, 32}, 4}, + {{3|(5<<4)}, { 85, 48}, 4}, + {{3|(6<<4)}, {102, 48}, 4}, + {{4|(5<<4)}, {102, 64}, 4}, //cs12 - {{2|(7<<4)}, {119, 32}, 0}, - {{2|(8<<4)}, {136, 32}, 0}, - {{3|(7<<4)}, {119, 48}, 0}, - {{3|(8<<4)}, {136, 48}, 0}, + {{2|(7<<4)}, {119, 32}, 4}, + {{2|(8<<4)}, {136, 32}, 4}, + {{3|(7<<4)}, {119, 48}, 4}, + {{3|(8<<4)}, {136, 48}, 4}, //cs13 - {{2|(9<<4)}, {153, 32}, 0}, - {{2|(10<<4)}, {170, 32}, 0}, - {{3|(9<<4)}, {153, 48}, 0}, + {{2|(9<<4)}, {153, 32}, 4}, + {{2|(10<<4)}, {170, 32}, 4}, + {{3|(9<<4)}, {153, 48}, 4}, {{4|(6<<4)}, {136, 48}, 1}, //cs14 - {{2|(11<<4)}, {187, 32}, 0}, - {{3|(10<<4)}, {170, 48}, 0}, + {{2|(11<<4)}, {187, 32}, 4}, + {{3|(10<<4)}, {170, 48}, 4}, {{3|(11<<4)}, {187, 48}, 1}, {{4|(7<<4)}, {153, 48}, 1}, //cs15 diff --git a/keyboards/hadron/ver3/ver3.c b/keyboards/hadron/ver3/ver3.c index e99ed11a7..5827b42e2 100644 --- a/keyboards/hadron/ver3/ver3.c +++ b/keyboards/hadron/ver3/ver3.c @@ -21,21 +21,21 @@ #ifdef RGB_MATRIX_ENABLE #include "rgblight.h" -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { /*{row | col << 4} | {x=0..224, y=0..64} | | modifier | | | */ - {{1|(13<<4)}, {195, 3}, 0}, - {{4|(13<<4)}, {195, 16}, 0}, - {{4|(10<<4)}, {150, 16}, 0}, - {{4|(7<<4)}, {105, 16}, 0}, - {{4|(4<<4)}, {60, 16}, 0}, - {{4|(1<<4)}, {15, 16}, 0}, - {{1|(1<<4)}, {15, 3}, 0}, - {{1|(4<<4)}, {60, 3}, 0}, - {{1|(7<<4)}, {105, 3}, 0}, - {{1|(10<<4)}, {150, 3}, 0} + {{1|(13<<4)}, {195, 3}, 4}, + {{4|(13<<4)}, {195, 16}, 4}, + {{4|(10<<4)}, {150, 16}, 4}, + {{4|(7<<4)}, {105, 16}, 4}, + {{4|(4<<4)}, {60, 16}, 4}, + {{4|(1<<4)}, {15, 16}, 4}, + {{1|(1<<4)}, {15, 3}, 4}, + {{1|(4<<4)}, {60, 3}, 4}, + {{1|(7<<4)}, {105, 3}, 4}, + {{1|(10<<4)}, {150, 3}, 4} }; #endif diff --git a/keyboards/hs60/v1/v1.c b/keyboards/hs60/v1/v1.c index 882611030..bd6dd19b2 100644 --- a/keyboards/hs60/v1/v1.c +++ b/keyboards/hs60/v1/v1.c @@ -165,7 +165,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {1, C9_16, C7_15, C6_15} //D16 }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { // // C7, C6, C5, C4, C3, C2, C1, A7, A6, A5, A4, A3, A2, A1, // C8, C9, C10, C11, C12, C13, C14, A8, A9, A10, A11, A12, A13, A15, @@ -174,70 +174,70 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { // D16, D15, D14, ---, ---, ---, D13, ---, ---, ---, B14, B13, B12, B11 /* {row | col << 4} * | {x=0..224, y=0..64} - * | | modifier + * | | flags * | | | */ {{0|(13<<4)}, {224, 0}, 1}, //A1-A16 - {{0|(12<<4)}, {204, 0}, 0}, - {{0|(11<<4)}, {187, 0}, 0}, - {{0|(10<<4)}, {170, 0}, 0}, - {{0|(9<<4)}, {153, 0}, 0}, - {{0|(8<<4)}, {136, 0}, 0}, - {{0|(7<<4)}, {119, 0}, 0}, - {{1|(7<<4)}, {119, 16}, 0}, - {{1|(8<<4)}, {136, 16}, 0}, - {{1|(9<<4)}, {153, 16}, 0}, - {{1|(10<<4)}, {170, 16}, 0}, - {{1|(11<<4)}, {187, 16}, 0}, - {{1|(12<<4)}, {204, 16}, 0}, + {{0|(12<<4)}, {204, 0}, 4}, + {{0|(11<<4)}, {187, 0}, 4}, + {{0|(10<<4)}, {170, 0}, 4}, + {{0|(9<<4)}, {153, 0}, 4}, + {{0|(8<<4)}, {136, 0}, 4}, + {{0|(7<<4)}, {119, 0}, 4}, + {{1|(7<<4)}, {119, 16}, 4}, + {{1|(8<<4)}, {136, 16}, 4}, + {{1|(9<<4)}, {153, 16}, 4}, + {{1|(10<<4)}, {170, 16}, 4}, + {{1|(11<<4)}, {187, 16}, 4}, + {{1|(12<<4)}, {204, 16}, 4}, {{2|(13<<4)}, {224, 32}, 1}, - {{2|(12<<4)}, {224, 16}, 0}, - {{2|(11<<4)}, {197, 32}, 0}, - - {{3|(10<<4)}, {170, 48}, 0}, //B1-B14 - {{3|(9<<4)}, {153, 48}, 0}, - {{3|(8<<4)}, {136, 48}, 0}, - {{3|(7<<4)}, {119, 48}, 0}, - {{2|(7<<4)}, {119, 32}, 0}, - {{2|(8<<4)}, {136, 32}, 0}, - {{2|(9<<4)}, {153, 32}, 0}, - {{2|(10<<4)}, {170, 32}, 0}, - {{3|(11<<4)}, {187, 48}, 0}, + {{2|(12<<4)}, {224, 16}, 4}, + {{2|(11<<4)}, {197, 32}, 4}, + + {{3|(10<<4)}, {170, 48}, 4}, //B1-B14 + {{3|(9<<4)}, {153, 48}, 4}, + {{3|(8<<4)}, {136, 48}, 4}, + {{3|(7<<4)}, {119, 48}, 4}, + {{2|(7<<4)}, {119, 32}, 4}, + {{2|(8<<4)}, {136, 32}, 4}, + {{2|(9<<4)}, {153, 32}, 4}, + {{2|(10<<4)}, {170, 32}, 4}, + {{3|(11<<4)}, {187, 48}, 4}, {{3|(13<<4)}, {214, 48}, 1}, {{4|(13<<4)}, {224, 64}, 1}, {{4|(12<<4)}, {204, 64}, 1}, {{4|(11<<4)}, {187, 64}, 1}, {{4|(10<<4)}, {170, 64}, 1}, - {{0|(6<<4)}, {102, 0}, 0}, //C1-C16 - {{0|(5<<4)}, { 85, 0}, 0}, - {{0|(4<<4)}, { 68, 0}, 0}, - {{0|(3<<4)}, { 51, 0}, 0}, - {{0|(2<<4)}, { 34, 0}, 0}, - {{0|(1<<4)}, { 17, 0}, 0}, + {{0|(6<<4)}, {102, 0}, 4}, //C1-C16 + {{0|(5<<4)}, { 85, 0}, 4}, + {{0|(4<<4)}, { 68, 0}, 4}, + {{0|(3<<4)}, { 51, 0}, 4}, + {{0|(2<<4)}, { 34, 0}, 4}, + {{0|(1<<4)}, { 17, 0}, 4}, {{0|(0<<4)}, { 0, 0}, 1}, {{1|(0<<4)}, { 0, 16}, 1}, - {{1|(1<<4)}, { 17, 16}, 0}, - {{1|(2<<4)}, { 34, 16}, 0}, - {{1|(3<<4)}, { 51, 16}, 0}, - {{1|(4<<4)}, { 68, 16}, 0}, - {{1|(5<<4)}, { 85, 16}, 0}, - {{1|(6<<4)}, {102, 16}, 0}, - {{2|(6<<4)}, {102, 32}, 0}, - {{2|(5<<4)}, { 85, 32}, 0}, - - {{3|(2<<4)}, { 32, 48}, 0}, //D1-D16 + {{1|(1<<4)}, { 17, 16}, 4}, + {{1|(2<<4)}, { 34, 16}, 4}, + {{1|(3<<4)}, { 51, 16}, 4}, + {{1|(4<<4)}, { 68, 16}, 4}, + {{1|(5<<4)}, { 85, 16}, 4}, + {{1|(6<<4)}, {102, 16}, 4}, + {{2|(6<<4)}, {102, 32}, 4}, + {{2|(5<<4)}, { 85, 32}, 4}, + + {{3|(2<<4)}, { 32, 48}, 4}, //D1-D16 //D2 {{3|(0<<4)}, { 10, 48}, 1}, {{2|(0<<4)}, { 0, 32}, 1}, - {{2|(1<<4)}, { 17, 32}, 0}, - {{2|(2<<4)}, { 34, 32}, 0}, - {{2|(3<<4)}, { 51, 32}, 0}, - {{2|(4<<4)}, { 68, 32}, 0}, - {{3|(3<<4)}, { 51, 48}, 0}, - {{3|(4<<4)}, { 68, 48}, 0}, - {{3|(5<<4)}, { 85, 48}, 0}, - {{3|(6<<4)}, {102, 48}, 0}, - {{4|(3<<4)}, {102, 64}, 0}, + {{2|(1<<4)}, { 17, 32}, 4}, + {{2|(2<<4)}, { 34, 32}, 4}, + {{2|(3<<4)}, { 51, 32}, 4}, + {{2|(4<<4)}, { 68, 32}, 4}, + {{3|(3<<4)}, { 51, 48}, 4}, + {{3|(4<<4)}, { 68, 48}, 4}, + {{3|(5<<4)}, { 85, 48}, 4}, + {{3|(6<<4)}, {102, 48}, 4}, + {{4|(3<<4)}, {102, 64}, 4}, {{4|(2<<4)}, { 34, 68}, 1}, {{4|(1<<4)}, { 17, 68}, 1}, {{4|(0<<4)}, { 0, 68}, 1} @@ -319,7 +319,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {1, C9_16, C7_15, C6_15} //D16 }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { // // C7, C6, C5, C4, C3, C2, C1, A7, A6, A5, A4, A3, A2, A1, // C8, C9, C10, C11, C12, C13, C14, A8, A9, A10, A11, A12, A13, ---, @@ -328,70 +328,70 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { // D16, D15, D14, ---, ---, ---, D13, ---, ---, ---, B14, B13, B12, B11 /* {row | col << 4} * | {x=0..224, y=0..64} - * | | modifier + * | | flags * | | | */ {{0|(13<<4)}, {224, 0}, 1}, //A1-A16 - {{0|(12<<4)}, {204, 0}, 0}, - {{0|(11<<4)}, {187, 0}, 0}, - {{0|(10<<4)}, {170, 0}, 0}, - {{0|(9<<4)}, {153, 0}, 0}, - {{0|(8<<4)}, {136, 0}, 0}, - {{0|(7<<4)}, {119, 0}, 0}, - {{1|(7<<4)}, {119, 16}, 0}, - {{1|(8<<4)}, {136, 16}, 0}, - {{1|(9<<4)}, {153, 16}, 0}, - {{1|(10<<4)}, {170, 16}, 0}, - {{1|(11<<4)}, {187, 16}, 0}, - {{1|(12<<4)}, {204, 16}, 0}, + {{0|(12<<4)}, {204, 0}, 4}, + {{0|(11<<4)}, {187, 0}, 4}, + {{0|(10<<4)}, {170, 0}, 4}, + {{0|(9<<4)}, {153, 0}, 4}, + {{0|(8<<4)}, {136, 0}, 4}, + {{0|(7<<4)}, {119, 0}, 4}, + {{1|(7<<4)}, {119, 16}, 4}, + {{1|(8<<4)}, {136, 16}, 4}, + {{1|(9<<4)}, {153, 16}, 4}, + {{1|(10<<4)}, {170, 16}, 4}, + {{1|(11<<4)}, {187, 16}, 4}, + {{1|(12<<4)}, {204, 16}, 4}, {{2|(13<<4)}, {224, 8}, 1}, - {{2|(12<<4)}, {204, 32}, 0}, - {{2|(11<<4)}, {187, 32}, 0}, - - {{3|(10<<4)}, {170, 48}, 0}, //B1-B14 - {{3|(9<<4)}, {153, 48}, 0}, - {{3|(8<<4)}, {136, 48}, 0}, - {{3|(7<<4)}, {119, 48}, 0}, - {{2|(7<<4)}, {119, 32}, 0}, - {{2|(8<<4)}, {136, 32}, 0}, - {{2|(9<<4)}, {153, 32}, 0}, - {{2|(10<<4)}, {170, 32}, 0}, - {{3|(11<<4)}, {187, 48}, 0}, + {{2|(12<<4)}, {204, 32}, 4}, + {{2|(11<<4)}, {187, 32}, 4}, + + {{3|(10<<4)}, {170, 48}, 4}, //B1-B14 + {{3|(9<<4)}, {153, 48}, 4}, + {{3|(8<<4)}, {136, 48}, 4}, + {{3|(7<<4)}, {119, 48}, 4}, + {{2|(7<<4)}, {119, 32}, 4}, + {{2|(8<<4)}, {136, 32}, 4}, + {{2|(9<<4)}, {153, 32}, 4}, + {{2|(10<<4)}, {170, 32}, 4}, + {{3|(11<<4)}, {187, 48}, 4}, {{3|(13<<4)}, {214, 48}, 1}, {{4|(13<<4)}, {224, 64}, 1}, {{4|(12<<4)}, {204, 64}, 1}, {{4|(11<<4)}, {187, 64}, 1}, {{4|(10<<4)}, {170, 64}, 1}, - {{0|(6<<4)}, {102, 0}, 0}, //C1-C16 - {{0|(5<<4)}, { 85, 0}, 0}, - {{0|(4<<4)}, { 68, 0}, 0}, - {{0|(3<<4)}, { 51, 0}, 0}, - {{0|(2<<4)}, { 34, 0}, 0}, - {{0|(1<<4)}, { 17, 0}, 0}, + {{0|(6<<4)}, {102, 0}, 4}, //C1-C16 + {{0|(5<<4)}, { 85, 0}, 4}, + {{0|(4<<4)}, { 68, 0}, 4}, + {{0|(3<<4)}, { 51, 0}, 4}, + {{0|(2<<4)}, { 34, 0}, 4}, + {{0|(1<<4)}, { 17, 0}, 4}, {{0|(0<<4)}, { 0, 0}, 1}, {{1|(0<<4)}, { 0, 16}, 1}, - {{1|(1<<4)}, { 17, 16}, 0}, - {{1|(2<<4)}, { 34, 16}, 0}, - {{1|(3<<4)}, { 51, 16}, 0}, - {{1|(4<<4)}, { 68, 16}, 0}, - {{1|(5<<4)}, { 85, 16}, 0}, - {{1|(6<<4)}, {102, 16}, 0}, - {{2|(6<<4)}, {102, 32}, 0}, - {{2|(5<<4)}, { 85, 32}, 0}, - - {{3|(2<<4)}, { 32, 48}, 0}, //D1-D16 - {{3|(1<<4)}, { 17, 48}, 0}, + {{1|(1<<4)}, { 17, 16}, 4}, + {{1|(2<<4)}, { 34, 16}, 4}, + {{1|(3<<4)}, { 51, 16}, 4}, + {{1|(4<<4)}, { 68, 16}, 4}, + {{1|(5<<4)}, { 85, 16}, 4}, + {{1|(6<<4)}, {102, 16}, 4}, + {{2|(6<<4)}, {102, 32}, 4}, + {{2|(5<<4)}, { 85, 32}, 4}, + + {{3|(2<<4)}, { 32, 48}, 4}, //D1-D16 + {{3|(1<<4)}, { 17, 48}, 4}, {{3|(0<<4)}, { 0, 48}, 1}, {{2|(0<<4)}, { 0, 32}, 1}, - {{2|(1<<4)}, { 17, 32}, 0}, - {{2|(2<<4)}, { 34, 32}, 0}, - {{2|(3<<4)}, { 51, 32}, 0}, - {{2|(4<<4)}, { 68, 32}, 0}, - {{3|(3<<4)}, { 51, 48}, 0}, - {{3|(4<<4)}, { 68, 48}, 0}, - {{3|(5<<4)}, { 85, 48}, 0}, - {{3|(6<<4)}, {102, 48}, 0}, - {{4|(3<<4)}, {102, 64}, 0}, + {{2|(1<<4)}, { 17, 32}, 4}, + {{2|(2<<4)}, { 34, 32}, 4}, + {{2|(3<<4)}, { 51, 32}, 4}, + {{2|(4<<4)}, { 68, 32}, 4}, + {{3|(3<<4)}, { 51, 48}, 4}, + {{3|(4<<4)}, { 68, 48}, 4}, + {{3|(5<<4)}, { 85, 48}, 4}, + {{3|(6<<4)}, {102, 48}, 4}, + {{4|(3<<4)}, {102, 64}, 4}, {{4|(2<<4)}, { 34, 68}, 1}, {{4|(1<<4)}, { 17, 68}, 1}, {{4|(0<<4)}, { 0, 68}, 1} diff --git a/keyboards/massdrop/alt/config.h b/keyboards/massdrop/alt/config.h index f63c38bf6..59e66e133 100644 --- a/keyboards/massdrop/alt/config.h +++ b/keyboards/massdrop/alt/config.h @@ -123,6 +123,5 @@ along with this program. If not, see . #define RGB_MATRIX_KEYPRESSES #define RGB_MATRIX_LED_PROCESS_LIMIT 15 #define RGB_MATRIX_LED_FLUSH_LIMIT 10 -#define RGB_MATRIX_EXTRA_TOG #include "config_led.h" diff --git a/keyboards/massdrop/alt/config_led.c b/keyboards/massdrop/alt/config_led.c index 7d98e47c9..1a9a539a0 100644 --- a/keyboards/massdrop/alt/config_led.c +++ b/keyboards/massdrop/alt/config_led.c @@ -20,122 +20,122 @@ // // There is a quick-and-dirty implementation of this under ledvis.html -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - /* 0 */ { { (0)|(0 << 4) }, { 8, 56 }, 0 }, // KC_ESC - /* 1 */ { { (0)|(1 << 4) }, { 22, 56 }, 0 }, // KC_1 - /* 2 */ { { (0)|(2 << 4) }, { 35, 56 }, 0 }, // KC_2 - /* 3 */ { { (0)|(3 << 4) }, { 49, 56 }, 0 }, // KC_3 - /* 4 */ { { (0)|(4 << 4) }, { 63, 56 }, 0 }, // KC_4 - /* 5 */ { { (0)|(5 << 4) }, { 77, 56 }, 0 }, // KC_5 - /* 6 */ { { (0)|(6 << 4) }, { 91, 56 }, 0 }, // KC_6 - /* 7 */ { { (0)|(7 << 4) }, { 105, 56 }, 0 }, // KC_7 - /* 8 */ { { (0)|(8 << 4) }, { 118, 56 }, 0 }, // KC_8 - /* 9 */ { { (0)|(9 << 4) }, { 132, 56 }, 0 }, // KC_9 - /* 10 */ { { (0)|(10 << 4) }, { 146, 56 }, 0 }, // KC_0 - /* 11 */ { { (0)|(11 << 4) }, { 160, 56 }, 0 }, // KC_MINS - /* 12 */ { { (0)|(12 << 4) }, { 174, 56 }, 0 }, // KC_EQL - /* 13 */ { { (0)|(13 << 4) }, { 195, 56 }, 0 }, // KC_BSPC - /* 14 */ { { (0)|(14 << 4) }, { 215, 56 }, 0 }, // KC_DEL - /* 15 */ { { (1)|(0 << 4) }, { 11, 44 }, 0 }, // KC_TAB - /* 16 */ { { (1)|(1 << 4) }, { 28, 44 }, 0 }, // KC_Q - /* 17 */ { { (1)|(2 << 4) }, { 42, 44 }, 0 }, // KC_W - /* 18 */ { { (1)|(3 << 4) }, { 56, 44 }, 0 }, // KC_E - /* 19 */ { { (1)|(4 << 4) }, { 70, 44 }, 0 }, // KC_R - /* 20 */ { { (1)|(5 << 4) }, { 84, 44 }, 0 }, // KC_T - /* 21 */ { { (1)|(6 << 4) }, { 98, 44 }, 0 }, // KC_Y - /* 22 */ { { (1)|(7 << 4) }, { 112, 44 }, 0 }, // KC_U - /* 23 */ { { (1)|(8 << 4) }, { 125, 44 }, 0 }, // KC_I - /* 24 */ { { (1)|(9 << 4) }, { 139, 44 }, 0 }, // KC_O - /* 25 */ { { (1)|(10 << 4) }, { 153, 44 }, 0 }, // KC_P - /* 26 */ { { (1)|(11 << 4) }, { 167, 44 }, 0 }, // KC_LBRC - /* 27 */ { { (1)|(12 << 4) }, { 181, 44 }, 0 }, // KC_RBRC - /* 28 */ { { (1)|(13 << 4) }, { 198, 44 }, 0 }, // KC_BSLS - /* 29 */ { { (1)|(14 << 4) }, { 215, 44 }, 0 }, // KC_HOME +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + /* 0 */ { { (0)|(0 << 4) }, { 8, 56 }, 4 }, // KC_ESC + /* 1 */ { { (0)|(1 << 4) }, { 22, 56 }, 4 }, // KC_1 + /* 2 */ { { (0)|(2 << 4) }, { 35, 56 }, 4 }, // KC_2 + /* 3 */ { { (0)|(3 << 4) }, { 49, 56 }, 4 }, // KC_3 + /* 4 */ { { (0)|(4 << 4) }, { 63, 56 }, 4 }, // KC_4 + /* 5 */ { { (0)|(5 << 4) }, { 77, 56 }, 4 }, // KC_5 + /* 6 */ { { (0)|(6 << 4) }, { 91, 56 }, 4 }, // KC_6 + /* 7 */ { { (0)|(7 << 4) }, { 105, 56 }, 4 }, // KC_7 + /* 8 */ { { (0)|(8 << 4) }, { 118, 56 }, 4 }, // KC_8 + /* 9 */ { { (0)|(9 << 4) }, { 132, 56 }, 4 }, // KC_9 + /* 10 */ { { (0)|(10 << 4) }, { 146, 56 }, 4 }, // KC_0 + /* 11 */ { { (0)|(11 << 4) }, { 160, 56 }, 4 }, // KC_MINS + /* 12 */ { { (0)|(12 << 4) }, { 174, 56 }, 4 }, // KC_EQL + /* 13 */ { { (0)|(13 << 4) }, { 195, 56 }, 4 }, // KC_BSPC + /* 14 */ { { (0)|(14 << 4) }, { 215, 56 }, 4 }, // KC_DEL + /* 15 */ { { (1)|(0 << 4) }, { 11, 44 }, 4 }, // KC_TAB + /* 16 */ { { (1)|(1 << 4) }, { 28, 44 }, 4 }, // KC_Q + /* 17 */ { { (1)|(2 << 4) }, { 42, 44 }, 4 }, // KC_W + /* 18 */ { { (1)|(3 << 4) }, { 56, 44 }, 4 }, // KC_E + /* 19 */ { { (1)|(4 << 4) }, { 70, 44 }, 4 }, // KC_R + /* 20 */ { { (1)|(5 << 4) }, { 84, 44 }, 4 }, // KC_T + /* 21 */ { { (1)|(6 << 4) }, { 98, 44 }, 4 }, // KC_Y + /* 22 */ { { (1)|(7 << 4) }, { 112, 44 }, 4 }, // KC_U + /* 23 */ { { (1)|(8 << 4) }, { 125, 44 }, 4 }, // KC_I + /* 24 */ { { (1)|(9 << 4) }, { 139, 44 }, 4 }, // KC_O + /* 25 */ { { (1)|(10 << 4) }, { 153, 44 }, 4 }, // KC_P + /* 26 */ { { (1)|(11 << 4) }, { 167, 44 }, 4 }, // KC_LBRC + /* 27 */ { { (1)|(12 << 4) }, { 181, 44 }, 4 }, // KC_RBRC + /* 28 */ { { (1)|(13 << 4) }, { 198, 44 }, 4 }, // KC_BSLS + /* 29 */ { { (1)|(14 << 4) }, { 215, 44 }, 4 }, // KC_HOME /* 30 */ { { (2)|(0 << 4) }, { 13, 32 }, 1 }, // KC_CAPS - /* 31 */ { { (2)|(1 << 4) }, { 32, 32 }, 0 }, // KC_A - /* 32 */ { { (2)|(2 << 4) }, { 46, 32 }, 0 }, // KC_S - /* 33 */ { { (2)|(3 << 4) }, { 60, 32 }, 0 }, // KC_D - /* 34 */ { { (2)|(4 << 4) }, { 73, 32 }, 0 }, // KC_F - /* 35 */ { { (2)|(5 << 4) }, { 87, 32 }, 0 }, // KC_G - /* 36 */ { { (2)|(6 << 4) }, { 101, 32 }, 0 }, // KC_H - /* 37 */ { { (2)|(7 << 4) }, { 115, 32 }, 0 }, // KC_J - /* 38 */ { { (2)|(8 << 4) }, { 129, 32 }, 0 }, // KC_K - /* 39 */ { { (2)|(9 << 4) }, { 143, 32 }, 0 }, // KC_L - /* 40 */ { { (2)|(10 << 4) }, { 156, 32 }, 0 }, // KC_SCLN - /* 41 */ { { (2)|(11 << 4) }, { 170, 32 }, 0 }, // KC_QUOT + /* 31 */ { { (2)|(1 << 4) }, { 32, 32 }, 4 }, // KC_A + /* 32 */ { { (2)|(2 << 4) }, { 46, 32 }, 4 }, // KC_S + /* 33 */ { { (2)|(3 << 4) }, { 60, 32 }, 4 }, // KC_D + /* 34 */ { { (2)|(4 << 4) }, { 73, 32 }, 4 }, // KC_F + /* 35 */ { { (2)|(5 << 4) }, { 87, 32 }, 4 }, // KC_G + /* 36 */ { { (2)|(6 << 4) }, { 101, 32 }, 4 }, // KC_H + /* 37 */ { { (2)|(7 << 4) }, { 115, 32 }, 4 }, // KC_J + /* 38 */ { { (2)|(8 << 4) }, { 129, 32 }, 4 }, // KC_K + /* 39 */ { { (2)|(9 << 4) }, { 143, 32 }, 4 }, // KC_L + /* 40 */ { { (2)|(10 << 4) }, { 156, 32 }, 4 }, // KC_SCLN + /* 41 */ { { (2)|(11 << 4) }, { 170, 32 }, 4 }, // KC_QUOT /* _________________________________________ */ // ____ - /* 42 */ { { (2)|(13 << 4) }, { 193, 32 }, 0 }, // KC_ENT - /* 43 */ { { (2)|(14 << 4) }, { 215, 32 }, 0 }, // KC_PGUP - /* 44 */ { { (3)|(0 << 4) }, { 16, 19 }, 0 }, // KC_LSFT - /* 45 */ { { (3)|(2 << 4) }, { 39, 19 }, 0 }, // KC_Z - /* 46 */ { { (3)|(3 << 4) }, { 53, 19 }, 0 }, // KC_X - /* 47 */ { { (3)|(4 << 4) }, { 67, 19 }, 0 }, // KC_C - /* 48 */ { { (3)|(5 << 4) }, { 80, 19 }, 0 }, // KC_V - /* 49 */ { { (3)|(6 << 4) }, { 94, 19 }, 0 }, // KC_B - /* 50 */ { { (3)|(7 << 4) }, { 108, 19 }, 0 }, // KC_N - /* 51 */ { { (3)|(8 << 4) }, { 122, 19 }, 0 }, // KC_M - /* 52 */ { { (3)|(9 << 4) }, { 136, 19 }, 0 }, // KC_COMM - /* 53 */ { { (3)|(10 << 4) }, { 150, 19 }, 0 }, // KC_DOT - /* 54 */ { { (3)|(11 << 4) }, { 163, 19 }, 0 }, // KC_SLSH - /* 55 */ { { (3)|(12 << 4) }, { 182, 19 }, 0 }, // KC_RSFT + /* 42 */ { { (2)|(13 << 4) }, { 193, 32 }, 4 }, // KC_ENT + /* 43 */ { { (2)|(14 << 4) }, { 215, 32 }, 4 }, // KC_PGUP + /* 44 */ { { (3)|(0 << 4) }, { 16, 19 }, 4 }, // KC_LSFT + /* 45 */ { { (3)|(2 << 4) }, { 39, 19 }, 4 }, // KC_Z + /* 46 */ { { (3)|(3 << 4) }, { 53, 19 }, 4 }, // KC_X + /* 47 */ { { (3)|(4 << 4) }, { 67, 19 }, 4 }, // KC_C + /* 48 */ { { (3)|(5 << 4) }, { 80, 19 }, 4 }, // KC_V + /* 49 */ { { (3)|(6 << 4) }, { 94, 19 }, 4 }, // KC_B + /* 50 */ { { (3)|(7 << 4) }, { 108, 19 }, 4 }, // KC_N + /* 51 */ { { (3)|(8 << 4) }, { 122, 19 }, 4 }, // KC_M + /* 52 */ { { (3)|(9 << 4) }, { 136, 19 }, 4 }, // KC_COMM + /* 53 */ { { (3)|(10 << 4) }, { 150, 19 }, 4 }, // KC_DOT + /* 54 */ { { (3)|(11 << 4) }, { 163, 19 }, 4 }, // KC_SLSH + /* 55 */ { { (3)|(12 << 4) }, { 182, 19 }, 4 }, // KC_RSFT /* _________________________________________ */ // ____ - /* 56 */ { { (3)|(13 << 4) }, { 201, 19 }, 0 }, // KC_UP - /* 57 */ { { (3)|(14 << 4) }, { 215, 19 }, 0 }, // KC_PGDN - /* 58 */ { { (4)|(0 << 4) }, { 9, 7 }, 0 }, // KC_LCTL - /* 59 */ { { (4)|(1 << 4) }, { 27, 7 }, 0 }, // KC_LGUI - /* 60 */ { { (4)|(2 << 4) }, { 44, 7 }, 0 }, // KC_LALT + /* 56 */ { { (3)|(13 << 4) }, { 201, 19 }, 4 }, // KC_UP + /* 57 */ { { (3)|(14 << 4) }, { 215, 19 }, 4 }, // KC_PGDN + /* 58 */ { { (4)|(0 << 4) }, { 9, 7 }, 4 }, // KC_LCTL + /* 59 */ { { (4)|(1 << 4) }, { 27, 7 }, 4 }, // KC_LGUI + /* 60 */ { { (4)|(2 << 4) }, { 44, 7 }, 4 }, // KC_LALT /* _________________________________________ */ // ____ /* _________________________________________ */ // ____ /* _________________________________________ */ // ____ - /* 61 */ { { (4)|(6 << 4) }, { 96, 7 }, 0 }, // KC_SPC + /* 61 */ { { (4)|(6 << 4) }, { 96, 7 }, 4 }, // KC_SPC /* _________________________________________ */ // ____ /* _________________________________________ */ // ____ /* _________________________________________ */ // ____ - /* 62 */ { { (4)|(10 << 4) }, { 148, 7 }, 0 }, // KC_RALT - /* 63 */ { { (4)|(11 << 4) }, { 165, 7 }, 0 }, // MO(1) - /* 64 */ { { (4)|(12 << 4) }, { 188, 7 }, 0 }, // KC_LEFT - /* 65 */ { { (4)|(13 << 4) }, { 201, 7 }, 0 }, // KC_DOWN - /* 66 */ { { (4)|(14 << 4) }, { 215, 7 }, 0 }, // KC_RGHT + /* 62 */ { { (4)|(10 << 4) }, { 148, 7 }, 4 }, // KC_RALT + /* 63 */ { { (4)|(11 << 4) }, { 165, 7 }, 4 }, // MO(1) + /* 64 */ { { (4)|(12 << 4) }, { 188, 7 }, 4 }, // KC_LEFT + /* 65 */ { { (4)|(13 << 4) }, { 201, 7 }, 4 }, // KC_DOWN + /* 66 */ { { (4)|(14 << 4) }, { 215, 7 }, 4 }, // KC_RGHT // Underglow LEDs - { { 255 }, { 1, 1 }, 0 }, - { { 255 }, { 15, 0 }, 0 }, - { { 255 }, { 31, 0 }, 0 }, - { { 255 }, { 47, 0 }, 0 }, - { { 255 }, { 63, 0 }, 0 }, - { { 255 }, { 79, 0 }, 0 }, - { { 255 }, { 95, 0 }, 0 }, - { { 255 }, { 112, 0 }, 0 }, - { { 255 }, { 128, 0 }, 0 }, - { { 255 }, { 144, 0 }, 0 }, - { { 255 }, { 160, 0 }, 0 }, - { { 255 }, { 176, 0 }, 0 }, - { { 255 }, { 192, 0 }, 0 }, - { { 255 }, { 208, 0 }, 0 }, - { { 255 }, { 222, 1 }, 0 }, - { { 255 }, { 224, 13 }, 0 }, - { { 255 }, { 224, 25 }, 0 }, - { { 255 }, { 224, 38 }, 0 }, - { { 255 }, { 224, 50 }, 0 }, - { { 255 }, { 222, 62 }, 0 }, - { { 255 }, { 191, 64 }, 0 }, - { { 255 }, { 179, 64 }, 0 }, - { { 255 }, { 167, 64 }, 0 }, - { { 255 }, { 153, 64 }, 0 }, - { { 255 }, { 139, 64 }, 0 }, - { { 255 }, { 125, 64 }, 0 }, - { { 255 }, { 112, 64 }, 0 }, - { { 255 }, { 98, 64 }, 0 }, - { { 255 }, { 84, 64 }, 0 }, - { { 255 }, { 70, 64 }, 0 }, - { { 255 }, { 56, 64 }, 0 }, - { { 255 }, { 42, 64 }, 0 }, - { { 255 }, { 28, 64 }, 0 }, - { { 255 }, { 1, 62 }, 0 }, - { { 255 }, { 0, 50 }, 0 }, - { { 255 }, { 0, 38 }, 0 }, - { { 255 }, { 0, 25 }, 0 }, - { { 255 }, { 0, 13 }, 0 }, + { { 255 }, { 1, 1 }, 2 }, + { { 255 }, { 15, 0 }, 2 }, + { { 255 }, { 31, 0 }, 2 }, + { { 255 }, { 47, 0 }, 2 }, + { { 255 }, { 63, 0 }, 2 }, + { { 255 }, { 79, 0 }, 2 }, + { { 255 }, { 95, 0 }, 2 }, + { { 255 }, { 112, 0 }, 2 }, + { { 255 }, { 128, 0 }, 2 }, + { { 255 }, { 144, 0 }, 2 }, + { { 255 }, { 160, 0 }, 2 }, + { { 255 }, { 176, 0 }, 2 }, + { { 255 }, { 192, 0 }, 2 }, + { { 255 }, { 208, 0 }, 2 }, + { { 255 }, { 222, 1 }, 2 }, + { { 255 }, { 224, 13 }, 2 }, + { { 255 }, { 224, 25 }, 2 }, + { { 255 }, { 224, 38 }, 2 }, + { { 255 }, { 224, 50 }, 2 }, + { { 255 }, { 222, 62 }, 2 }, + { { 255 }, { 191, 64 }, 2 }, + { { 255 }, { 179, 64 }, 2 }, + { { 255 }, { 167, 64 }, 2 }, + { { 255 }, { 153, 64 }, 2 }, + { { 255 }, { 139, 64 }, 2 }, + { { 255 }, { 125, 64 }, 2 }, + { { 255 }, { 112, 64 }, 2 }, + { { 255 }, { 98, 64 }, 2 }, + { { 255 }, { 84, 64 }, 2 }, + { { 255 }, { 70, 64 }, 2 }, + { { 255 }, { 56, 64 }, 2 }, + { { 255 }, { 42, 64 }, 2 }, + { { 255 }, { 28, 64 }, 2 }, + { { 255 }, { 1, 62 }, 2 }, + { { 255 }, { 0, 50 }, 2 }, + { { 255 }, { 0, 38 }, 2 }, + { { 255 }, { 0, 25 }, 2 }, + { { 255 }, { 0, 13 }, 2 }, }; #ifdef USB_LED_INDICATOR_ENABLE diff --git a/keyboards/massdrop/alt/keymaps/abishalom/keymap.c b/keyboards/massdrop/alt/keymaps/abishalom/keymap.c index a4519d404..f6f79ad91 100644 --- a/keyboards/massdrop/alt/keymaps/abishalom/keymap.c +++ b/keyboards/massdrop/alt/keymaps/abishalom/keymap.c @@ -95,6 +95,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } } return false; + case RGB_TOG: + if (record->event.pressed) { + switch (rgb_matrix_get_flags()) { + case LED_FLAG_ALL: { + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_KEYLIGHT: { + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_UNDERGLOW: { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_disable_noeeprom(); + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + } + break; + } + } + return false; default: return true; //Process all other keycodes normally } diff --git a/keyboards/massdrop/alt/keymaps/default/keymap.c b/keyboards/massdrop/alt/keymaps/default/keymap.c index a4519d404..f6f79ad91 100644 --- a/keyboards/massdrop/alt/keymaps/default/keymap.c +++ b/keyboards/massdrop/alt/keymaps/default/keymap.c @@ -95,6 +95,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } } return false; + case RGB_TOG: + if (record->event.pressed) { + switch (rgb_matrix_get_flags()) { + case LED_FLAG_ALL: { + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_KEYLIGHT: { + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_UNDERGLOW: { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_disable_noeeprom(); + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + } + break; + } + } + return false; default: return true; //Process all other keycodes normally } diff --git a/keyboards/massdrop/alt/keymaps/mac/keymap.c b/keyboards/massdrop/alt/keymaps/mac/keymap.c index 26a1c6d01..222d7e2c5 100644 --- a/keyboards/massdrop/alt/keymaps/mac/keymap.c +++ b/keyboards/massdrop/alt/keymaps/mac/keymap.c @@ -95,6 +95,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } } return false; + case RGB_TOG: + if (record->event.pressed) { + switch (rgb_matrix_get_flags()) { + case LED_FLAG_ALL: { + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_KEYLIGHT: { + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_UNDERGLOW: { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_disable_noeeprom(); + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + } + break; + } + } + return false; default: return true; //Process all other keycodes normally } diff --git a/keyboards/massdrop/ctrl/config.h b/keyboards/massdrop/ctrl/config.h index df2e50921..9b9f98f5f 100644 --- a/keyboards/massdrop/ctrl/config.h +++ b/keyboards/massdrop/ctrl/config.h @@ -123,6 +123,5 @@ along with this program. If not, see . #define RGB_MATRIX_KEYPRESSES #define RGB_MATRIX_LED_PROCESS_LIMIT 15 #define RGB_MATRIX_LED_FLUSH_LIMIT 10 -#define RGB_MATRIX_EXTRA_TOG #include "config_led.h" diff --git a/keyboards/massdrop/ctrl/config_led.c b/keyboards/massdrop/ctrl/config_led.c index afdbf3a22..20d9c649e 100644 --- a/keyboards/massdrop/ctrl/config_led.c +++ b/keyboards/massdrop/ctrl/config_led.c @@ -5,133 +5,133 @@ #include "rgb_matrix.h" #include "config_led.h" -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { // KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_PAUS - { { 0|(0<<4) }, { 7, 5 }, 0 }, - { { 0|(1<<4) }, { 31, 5 }, 0 }, - { { 0|(2<<4) }, { 43, 5 }, 0 }, - { { 0|(3<<4) }, { 55, 5 }, 0 }, - { { 0|(4<<4) }, { 67, 5 }, 0 }, - { { 0|(5<<4) }, { 85, 5 }, 0 }, - { { 0|(6<<4) }, { 97, 5 }, 0 }, - { { 0|(7<<4) }, { 109, 5 }, 0 }, - { { 6|(0<<4) }, { 121, 5 }, 0 }, - { { 6|(1<<4) }, { 139, 5 }, 0 }, - { { 6|(2<<4) }, { 151, 5 }, 0 }, - { { 6|(3<<4) }, { 163, 5 }, 0 }, - { { 6|(4<<4) }, { 175, 5 }, 0 }, - { { 6|(5<<4) }, { 193, 5 }, 0 }, + { { 0|(0<<4) }, { 7, 5 }, 4 }, + { { 0|(1<<4) }, { 31, 5 }, 4 }, + { { 0|(2<<4) }, { 43, 5 }, 4 }, + { { 0|(3<<4) }, { 55, 5 }, 4 }, + { { 0|(4<<4) }, { 67, 5 }, 4 }, + { { 0|(5<<4) }, { 85, 5 }, 4 }, + { { 0|(6<<4) }, { 97, 5 }, 4 }, + { { 0|(7<<4) }, { 109, 5 }, 4 }, + { { 6|(0<<4) }, { 121, 5 }, 4 }, + { { 6|(1<<4) }, { 139, 5 }, 4 }, + { { 6|(2<<4) }, { 151, 5 }, 4 }, + { { 6|(3<<4) }, { 163, 5 }, 4 }, + { { 6|(4<<4) }, { 175, 5 }, 4 }, + { { 6|(5<<4) }, { 193, 5 }, 4 }, { { 6|(6<<4) }, { 205, 5 }, 1 }, - { { 6|(7<<4) }, { 217, 5 }, 0 }, + { { 6|(7<<4) }, { 217, 5 }, 4 }, // KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP - { { 1|(0<<4) }, { 7, 20 }, 0 }, - { { 1|(1<<4) }, { 19, 20 }, 0 }, - { { 1|(2<<4) }, { 31, 20 }, 0 }, - { { 1|(3<<4) }, { 43, 20 }, 0 }, - { { 1|(4<<4) }, { 55, 20 }, 0 }, - { { 1|(5<<4) }, { 67, 20 }, 0 }, - { { 1|(6<<4) }, { 79, 20 }, 0 }, - { { 1|(7<<4) }, { 91, 20 }, 0 }, - { { 7|(0<<4) }, { 103, 20 }, 0 }, - { { 7|(1<<4) }, { 115, 20 }, 0 }, - { { 7|(2<<4) }, { 127, 20 }, 0 }, - { { 7|(3<<4) }, { 139, 20 }, 0 }, - { { 7|(4<<4) }, { 151, 20 }, 0 }, - { { 7|(5<<4) }, { 169, 20 }, 0 }, - { { 7|(6<<4) }, { 193, 20 }, 0 }, - { { 7|(7<<4) }, { 205, 20 }, 0 }, - { { 9|(7<<4) }, { 217, 20 }, 0 }, + { { 1|(0<<4) }, { 7, 20 }, 4 }, + { { 1|(1<<4) }, { 19, 20 }, 4 }, + { { 1|(2<<4) }, { 31, 20 }, 4 }, + { { 1|(3<<4) }, { 43, 20 }, 4 }, + { { 1|(4<<4) }, { 55, 20 }, 4 }, + { { 1|(5<<4) }, { 67, 20 }, 4 }, + { { 1|(6<<4) }, { 79, 20 }, 4 }, + { { 1|(7<<4) }, { 91, 20 }, 4 }, + { { 7|(0<<4) }, { 103, 20 }, 4 }, + { { 7|(1<<4) }, { 115, 20 }, 4 }, + { { 7|(2<<4) }, { 127, 20 }, 4 }, + { { 7|(3<<4) }, { 139, 20 }, 4 }, + { { 7|(4<<4) }, { 151, 20 }, 4 }, + { { 7|(5<<4) }, { 169, 20 }, 4 }, + { { 7|(6<<4) }, { 193, 20 }, 4 }, + { { 7|(7<<4) }, { 205, 20 }, 4 }, + { { 9|(7<<4) }, { 217, 20 }, 4 }, // KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN - { { 2|(0<<4) }, { 10, 30 }, 0 }, - { { 2|(1<<4) }, { 25, 30 }, 0 }, - { { 2|(2<<4) }, { 37, 30 }, 0 }, - { { 2|(3<<4) }, { 49, 30 }, 0 }, - { { 2|(4<<4) }, { 61, 30 }, 0 }, - { { 2|(5<<4) }, { 73, 30 }, 0 }, - { { 2|(6<<4) }, { 85, 30 }, 0 }, - { { 2|(7<<4) }, { 97, 30 }, 0 }, - { { 8|(0<<4) }, { 109, 30 }, 0 }, - { { 8|(1<<4) }, { 121, 30 }, 0 }, - { { 8|(2<<4) }, { 133, 30 }, 0 }, - { { 8|(3<<4) }, { 145, 30 }, 0 }, - { { 8|(4<<4) }, { 157, 30 }, 0 }, - { { 8|(5<<4) }, { 172, 30 }, 0 }, - { { 8|(6<<4) }, { 193, 30 }, 0 }, - { { 8|(7<<4) }, { 205, 30 }, 0 }, - { { 9|(6<<4) }, { 217, 30 }, 0 }, + { { 2|(0<<4) }, { 10, 30 }, 4 }, + { { 2|(1<<4) }, { 25, 30 }, 4 }, + { { 2|(2<<4) }, { 37, 30 }, 4 }, + { { 2|(3<<4) }, { 49, 30 }, 4 }, + { { 2|(4<<4) }, { 61, 30 }, 4 }, + { { 2|(5<<4) }, { 73, 30 }, 4 }, + { { 2|(6<<4) }, { 85, 30 }, 4 }, + { { 2|(7<<4) }, { 97, 30 }, 4 }, + { { 8|(0<<4) }, { 109, 30 }, 4 }, + { { 8|(1<<4) }, { 121, 30 }, 4 }, + { { 8|(2<<4) }, { 133, 30 }, 4 }, + { { 8|(3<<4) }, { 145, 30 }, 4 }, + { { 8|(4<<4) }, { 157, 30 }, 4 }, + { { 8|(5<<4) }, { 172, 30 }, 4 }, + { { 8|(6<<4) }, { 193, 30 }, 4 }, + { { 8|(7<<4) }, { 205, 30 }, 4 }, + { { 9|(6<<4) }, { 217, 30 }, 4 }, // KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT { { 3|(0<<4) }, { 11, 39 }, 1 }, - { { 3|(1<<4) }, { 28, 39 }, 0 }, - { { 3|(2<<4) }, { 40, 39 }, 0 }, - { { 3|(3<<4) }, { 52, 39 }, 0 }, - { { 3|(4<<4) }, { 64, 39 }, 0 }, - { { 3|(5<<4) }, { 76, 39 }, 0 }, - { { 3|(6<<4) }, { 88, 39 }, 0 }, - { { 3|(7<<4) }, { 100, 39 }, 0 }, - { { 9|(0<<4) }, { 112, 39 }, 0 }, - { { 9|(1<<4) }, { 124, 39 }, 0 }, - { { 9|(2<<4) }, { 136, 39 }, 0 }, - { { 9|(3<<4) }, { 148, 39 }, 0 }, - { { 9|(4<<4) }, { 168, 39 }, 0 }, + { { 3|(1<<4) }, { 28, 39 }, 4 }, + { { 3|(2<<4) }, { 40, 39 }, 4 }, + { { 3|(3<<4) }, { 52, 39 }, 4 }, + { { 3|(4<<4) }, { 64, 39 }, 4 }, + { { 3|(5<<4) }, { 76, 39 }, 4 }, + { { 3|(6<<4) }, { 88, 39 }, 4 }, + { { 3|(7<<4) }, { 100, 39 }, 4 }, + { { 9|(0<<4) }, { 112, 39 }, 4 }, + { { 9|(1<<4) }, { 124, 39 }, 4 }, + { { 9|(2<<4) }, { 136, 39 }, 4 }, + { { 9|(3<<4) }, { 148, 39 }, 4 }, + { { 9|(4<<4) }, { 168, 39 }, 4 }, // KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP - { { 4|(0<<4) }, { 14, 49 }, 0 }, - { { 4|(1<<4) }, { 34, 49 }, 0 }, - { { 4|(2<<4) }, { 46, 49 }, 0 }, - { { 4|(3<<4) }, { 58, 49 }, 0 }, - { { 4|(4<<4) }, { 70, 49 }, 0 }, - { { 4|(5<<4) }, { 82, 49 }, 0 }, - { { 4|(6<<4) }, { 94, 49 }, 0 }, - { { 4|(7<<4) }, { 106, 49 }, 0 }, - { { 10|(0<<4) }, { 118, 49 }, 0 }, - { { 10|(1<<4) }, { 130, 49 }, 0 }, - { { 10|(2<<4) }, { 142, 49 }, 0 }, - { { 10|(3<<4) }, { 165, 49 }, 0 }, - { { 9|(5<<4) }, { 205, 49 }, 0 }, + { { 4|(0<<4) }, { 14, 49 }, 4 }, + { { 4|(1<<4) }, { 34, 49 }, 4 }, + { { 4|(2<<4) }, { 46, 49 }, 4 }, + { { 4|(3<<4) }, { 58, 49 }, 4 }, + { { 4|(4<<4) }, { 70, 49 }, 4 }, + { { 4|(5<<4) }, { 82, 49 }, 4 }, + { { 4|(6<<4) }, { 94, 49 }, 4 }, + { { 4|(7<<4) }, { 106, 49 }, 4 }, + { { 10|(0<<4) }, { 118, 49 }, 4 }, + { { 10|(1<<4) }, { 130, 49 }, 4 }, + { { 10|(2<<4) }, { 142, 49 }, 4 }, + { { 10|(3<<4) }, { 165, 49 }, 4 }, + { { 9|(5<<4) }, { 205, 49 }, 4 }, // KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT - { { 5|(0<<4) }, { 8, 59 }, 0 }, - { { 5|(1<<4) }, { 23, 59 }, 0 }, - { { 5|(2<<4) }, { 38, 59 }, 0 }, - { { 5|(3<<4) }, { 83, 59 }, 0 }, - { { 5|(4<<4) }, { 129, 59 }, 0 }, - { { 5|(5<<4) }, { 144, 59 }, 0 }, - { { 5|(6<<4) }, { 159, 59 }, 0 }, - { { 5|(7<<4) }, { 174, 59 }, 0 }, - { { 10|(4<<4) }, { 193, 59 }, 0 }, - { { 10|(5<<4) }, { 205, 59 }, 0 }, - { { 10|(6<<4) }, { 217, 59 }, 0 }, + { { 5|(0<<4) }, { 8, 59 }, 4 }, + { { 5|(1<<4) }, { 23, 59 }, 4 }, + { { 5|(2<<4) }, { 38, 59 }, 4 }, + { { 5|(3<<4) }, { 83, 59 }, 4 }, + { { 5|(4<<4) }, { 129, 59 }, 4 }, + { { 5|(5<<4) }, { 144, 59 }, 4 }, + { { 5|(6<<4) }, { 159, 59 }, 4 }, + { { 5|(7<<4) }, { 174, 59 }, 4 }, + { { 10|(4<<4) }, { 193, 59 }, 4 }, + { { 10|(5<<4) }, { 205, 59 }, 4 }, + { { 10|(6<<4) }, { 217, 59 }, 4 }, // Underglow / Border - { { 0xFF }, { 222, 64 }, 0 }, - { { 0xFF }, { 204, 64 }, 0 }, - { { 0xFF }, { 186, 64 }, 0 }, - { { 0xFF }, { 167, 64 }, 0 }, - { { 0xFF }, { 149, 64 }, 0 }, - { { 0xFF }, { 130, 64 }, 0 }, - { { 0xFF }, { 112, 64 }, 0 }, - { { 0xFF }, { 94, 64 }, 0 }, - { { 0xFF }, { 75, 64 }, 0 }, - { { 0xFF }, { 57, 64 }, 0 }, - { { 0xFF }, { 38, 64 }, 0 }, - { { 0xFF }, { 20, 64 }, 0 }, - { { 0xFF }, { 0, 64 }, 0 }, - { { 0xFF }, { 0, 47 }, 0 }, - { { 0xFF }, { 0, 32 }, 0 }, - { { 0xFF }, { 0, 17 }, 0 }, - { { 0xFF }, { 0, 0 }, 0 }, - { { 0xFF }, { 20, 0 }, 0 }, - { { 0xFF }, { 38, 0 }, 0 }, - { { 0xFF }, { 57, 0 }, 0 }, - { { 0xFF }, { 75, 0 }, 0 }, - { { 0xFF }, { 94, 0 }, 0 }, - { { 0xFF }, { 112, 0 }, 0 }, - { { 0xFF }, { 130, 0 }, 0 }, - { { 0xFF }, { 149, 0 }, 0 }, - { { 0xFF }, { 167, 0 }, 0 }, - { { 0xFF }, { 186, 0 }, 0 }, - { { 0xFF }, { 204, 0 }, 0 }, - { { 0xFF }, { 222, 1 }, 0 }, - { { 0xFF }, { 224, 17 }, 0 }, - { { 0xFF }, { 224, 32 }, 0 }, - { { 0xFF }, { 224, 47 }, 0 }, + { { 0xFF }, { 222, 64 }, 2 }, + { { 0xFF }, { 204, 64 }, 2 }, + { { 0xFF }, { 186, 64 }, 2 }, + { { 0xFF }, { 167, 64 }, 2 }, + { { 0xFF }, { 149, 64 }, 2 }, + { { 0xFF }, { 130, 64 }, 2 }, + { { 0xFF }, { 112, 64 }, 2 }, + { { 0xFF }, { 94, 64 }, 2 }, + { { 0xFF }, { 75, 64 }, 2 }, + { { 0xFF }, { 57, 64 }, 2 }, + { { 0xFF }, { 38, 64 }, 2 }, + { { 0xFF }, { 20, 64 }, 2 }, + { { 0xFF }, { 0, 64 }, 2 }, + { { 0xFF }, { 0, 47 }, 2 }, + { { 0xFF }, { 0, 32 }, 2 }, + { { 0xFF }, { 0, 17 }, 2 }, + { { 0xFF }, { 0, 0 }, 2 }, + { { 0xFF }, { 20, 0 }, 2 }, + { { 0xFF }, { 38, 0 }, 2 }, + { { 0xFF }, { 57, 0 }, 2 }, + { { 0xFF }, { 75, 0 }, 2 }, + { { 0xFF }, { 94, 0 }, 2 }, + { { 0xFF }, { 112, 0 }, 2 }, + { { 0xFF }, { 130, 0 }, 2 }, + { { 0xFF }, { 149, 0 }, 2 }, + { { 0xFF }, { 167, 0 }, 2 }, + { { 0xFF }, { 186, 0 }, 2 }, + { { 0xFF }, { 204, 0 }, 2 }, + { { 0xFF }, { 222, 1 }, 2 }, + { { 0xFF }, { 224, 17 }, 2 }, + { { 0xFF }, { 224, 32 }, 2 }, + { { 0xFF }, { 224, 47 }, 2 }, }; #ifdef USB_LED_INDICATOR_ENABLE diff --git a/keyboards/massdrop/ctrl/keymaps/default/keymap.c b/keyboards/massdrop/ctrl/keymaps/default/keymap.c index 182abbbad..53c96d95d 100644 --- a/keyboards/massdrop/ctrl/keymaps/default/keymap.c +++ b/keyboards/massdrop/ctrl/keymaps/default/keymap.c @@ -98,6 +98,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } } return false; + case RGB_TOG: + if (record->event.pressed) { + switch (rgb_matrix_get_flags()) { + case LED_FLAG_ALL: { + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_KEYLIGHT: { + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_UNDERGLOW: { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_disable_noeeprom(); + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + } + break; + } + } + return false; default: return true; //Process all other keycodes normally } diff --git a/keyboards/massdrop/ctrl/keymaps/mac/keymap.c b/keyboards/massdrop/ctrl/keymaps/mac/keymap.c index 41cf82757..79fe7388a 100644 --- a/keyboards/massdrop/ctrl/keymaps/mac/keymap.c +++ b/keyboards/massdrop/ctrl/keymaps/mac/keymap.c @@ -98,6 +98,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } } return false; + case RGB_TOG: + if (record->event.pressed) { + switch (rgb_matrix_get_flags()) { + case LED_FLAG_ALL: { + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_KEYLIGHT: { + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + } + break; + case LED_FLAG_UNDERGLOW: { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_disable_noeeprom(); + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + } + break; + } + } + return false; default: return true; //Process all other keycodes normally } diff --git a/keyboards/model01/leds.c b/keyboards/model01/leds.c index 7a62c7424..0abc1f0da 100644 --- a/keyboards/model01/leds.c +++ b/keyboards/model01/leds.c @@ -46,34 +46,34 @@ void set_led_to(int led, uint8_t r, uint8_t g, uint8_t b) { #ifdef RGB_MATRIX_ENABLE __attribute__ ((weak)) -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{0x73}, { 3, 35}, 0}, - {{0x72}, { 0, 26}, 0}, - {{0x71}, { 0, 17}, 0}, - {{0x70}, { 0, 6}, 0}, - {{0x60}, { 14, 5}, 0}, - {{0x61}, { 15, 16}, 0}, - {{0x62}, { 16, 25}, 0}, - {{0x63}, { 17, 34}, 0}, - {{0x53}, { 31, 29}, 0}, - {{0x52}, { 31, 19}, 0}, - {{0x51}, { 30, 11}, 0}, - {{0x50}, { 30, 1}, 0}, - {{0x40}, { 45, 0}, 0}, - {{0x41}, { 45, 8}, 0}, - {{0x42}, { 46, 17}, 0}, - {{0x43}, { 46, 27}, 0}, - {{0x33}, { 60, 27}, 0}, - {{0x32}, { 60, 18}, 0}, - {{0x31}, { 60, 9}, 0}, - {{0x30}, { 60, 0}, 0}, - {{0x20}, { 74, 2}, 0}, - {{0x21}, { 74, 11}, 0}, - {{0x22}, { 75, 20}, 0}, - {{0x23}, { 74, 28}, 0}, - {{0x12}, { 89, 30}, 0}, - {{0x11}, { 89, 19}, 0}, - {{0x10}, { 89, 7}, 0}, +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + {{0x73}, { 3, 35}, 4}, + {{0x72}, { 0, 26}, 4}, + {{0x71}, { 0, 17}, 4}, + {{0x70}, { 0, 6}, 4}, + {{0x60}, { 14, 5}, 4}, + {{0x61}, { 15, 16}, 4}, + {{0x62}, { 16, 25}, 4}, + {{0x63}, { 17, 34}, 4}, + {{0x53}, { 31, 29}, 4}, + {{0x52}, { 31, 19}, 4}, + {{0x51}, { 30, 11}, 4}, + {{0x50}, { 30, 1}, 4}, + {{0x40}, { 45, 0}, 4}, + {{0x41}, { 45, 8}, 4}, + {{0x42}, { 46, 17}, 4}, + {{0x43}, { 46, 27}, 4}, + {{0x33}, { 60, 27}, 4}, + {{0x32}, { 60, 18}, 4}, + {{0x31}, { 60, 9}, 4}, + {{0x30}, { 60, 0}, 4}, + {{0x20}, { 74, 2}, 4}, + {{0x21}, { 74, 11}, 4}, + {{0x22}, { 75, 20}, 4}, + {{0x23}, { 74, 28}, 4}, + {{0x12}, { 89, 30}, 4}, + {{0x11}, { 89, 19}, 4}, + {{0x10}, { 89, 7}, 4}, {{0x00}, { 70, 38}, 1}, {{0x01}, { 82, 41}, 1}, {{0x02}, { 93, 45}, 1}, @@ -84,33 +84,33 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{0x76}, {130, 45}, 1}, {{0x75}, {141, 41}, 1}, {{0x74}, {153, 38}, 1}, - {{0x64}, {134, 7}, 0}, - {{0x65}, {134, 19}, 0}, - {{0x66}, {134, 30}, 0}, - {{0x57}, {149, 28}, 0}, - {{0x56}, {148, 20}, 0}, - {{0x55}, {149, 11}, 0}, - {{0x54}, {149, 2}, 0}, - {{0x44}, {163, 0}, 0}, - {{0x45}, {163, 9}, 0}, - {{0x46}, {163, 18}, 0}, - {{0x47}, {163, 27}, 0}, - {{0x37}, {177, 27}, 0}, - {{0x36}, {177, 17}, 0}, - {{0x35}, {178, 8}, 0}, - {{0x34}, {178, 0}, 0}, - {{0x24}, {193, 1}, 0}, - {{0x25}, {193, 11}, 0}, - {{0x26}, {192, 19}, 0}, - {{0x27}, {192, 29}, 0}, - {{0x17}, {206, 34}, 0}, - {{0x16}, {207, 25}, 0}, - {{0x15}, {208, 16}, 0}, - {{0x14}, {209, 5}, 0}, - {{0x04}, {224, 6}, 0}, - {{0x05}, {223, 17}, 0}, - {{0x06}, {223, 26}, 0}, - {{0x07}, {220, 35}, 0}, + {{0x64}, {134, 7}, 4}, + {{0x65}, {134, 19}, 4}, + {{0x66}, {134, 30}, 4}, + {{0x57}, {149, 28}, 4}, + {{0x56}, {148, 20}, 4}, + {{0x55}, {149, 11}, 4}, + {{0x54}, {149, 2}, 4}, + {{0x44}, {163, 0}, 4}, + {{0x45}, {163, 9}, 4}, + {{0x46}, {163, 18}, 4}, + {{0x47}, {163, 27}, 4}, + {{0x37}, {177, 27}, 4}, + {{0x36}, {177, 17}, 4}, + {{0x35}, {178, 8}, 4}, + {{0x34}, {178, 0}, 4}, + {{0x24}, {193, 1}, 4}, + {{0x25}, {193, 11}, 4}, + {{0x26}, {192, 19}, 4}, + {{0x27}, {192, 29}, 4}, + {{0x17}, {206, 34}, 4}, + {{0x16}, {207, 25}, 4}, + {{0x15}, {208, 16}, 4}, + {{0x14}, {209, 5}, 4}, + {{0x04}, {224, 6}, 4}, + {{0x05}, {223, 17}, 4}, + {{0x06}, {223, 26}, 4}, + {{0x07}, {220, 35}, 4}, }; static struct { diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c index c3b7e2617..94f507189 100644 --- a/keyboards/planck/ez/ez.c +++ b/keyboards/planck/ez/ez.c @@ -79,49 +79,49 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { /*{row | col << 4} | {x=0..224, y=0..64} - | | modifier + | | flags | | | */ {{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, - {{0|(1<<4)}, {20.36*1, 21.33*0}, 0}, - {{0|(2<<4)}, {20.36*2, 21.33*0}, 0}, - {{0|(3<<4)}, {20.36*3, 21.33*0}, 0}, - {{0|(4<<4)}, {20.36*4, 21.33*0}, 0}, - {{0|(5<<4)}, {20.36*5, 21.33*0}, 0}, - {{4|(0<<4)}, {20.36*6, 21.33*0}, 0}, - {{4|(1<<4)}, {20.36*7, 21.33*0}, 0}, - {{4|(2<<4)}, {20.36*8, 21.33*0}, 0}, - {{4|(3<<4)}, {20.36*9, 21.33*0}, 0}, - {{4|(4<<4)}, {20.36*10,21.33*0}, 0}, + {{0|(1<<4)}, {20.36*1, 21.33*0}, 4}, + {{0|(2<<4)}, {20.36*2, 21.33*0}, 4}, + {{0|(3<<4)}, {20.36*3, 21.33*0}, 4}, + {{0|(4<<4)}, {20.36*4, 21.33*0}, 4}, + {{0|(5<<4)}, {20.36*5, 21.33*0}, 4}, + {{4|(0<<4)}, {20.36*6, 21.33*0}, 4}, + {{4|(1<<4)}, {20.36*7, 21.33*0}, 4}, + {{4|(2<<4)}, {20.36*8, 21.33*0}, 4}, + {{4|(3<<4)}, {20.36*9, 21.33*0}, 4}, + {{4|(4<<4)}, {20.36*10,21.33*0}, 4}, {{4|(5<<4)}, {20.36*11,21.33*0}, 1}, {{1|(0<<4)}, {20.36*0, 21.33*1}, 1}, - {{1|(1<<4)}, {20.36*1, 21.33*1}, 0}, - {{1|(2<<4)}, {20.36*2, 21.33*1}, 0}, - {{1|(3<<4)}, {20.36*3, 21.33*1}, 0}, - {{1|(4<<4)}, {20.36*4, 21.33*1}, 0}, - {{1|(5<<4)}, {20.36*5, 21.33*1}, 0}, - {{5|(0<<4)}, {20.36*6, 21.33*1}, 0}, - {{5|(1<<4)}, {20.36*7, 21.33*1}, 0}, - {{5|(2<<4)}, {20.36*8, 21.33*1}, 0}, - {{5|(3<<4)}, {20.36*9, 21.33*1}, 0}, - {{5|(4<<4)}, {20.36*10,21.33*1}, 0}, + {{1|(1<<4)}, {20.36*1, 21.33*1}, 4}, + {{1|(2<<4)}, {20.36*2, 21.33*1}, 4}, + {{1|(3<<4)}, {20.36*3, 21.33*1}, 4}, + {{1|(4<<4)}, {20.36*4, 21.33*1}, 4}, + {{1|(5<<4)}, {20.36*5, 21.33*1}, 4}, + {{5|(0<<4)}, {20.36*6, 21.33*1}, 4}, + {{5|(1<<4)}, {20.36*7, 21.33*1}, 4}, + {{5|(2<<4)}, {20.36*8, 21.33*1}, 4}, + {{5|(3<<4)}, {20.36*9, 21.33*1}, 4}, + {{5|(4<<4)}, {20.36*10,21.33*1}, 4}, {{5|(5<<4)}, {20.36*11,21.33*1}, 1}, {{2|(0<<4)}, {20.36*0, 21.33*2}, 1}, - {{2|(1<<4)}, {20.36*1, 21.33*2}, 0}, - {{2|(2<<4)}, {20.36*2, 21.33*2}, 0}, - {{2|(3<<4)}, {20.36*3, 21.33*2}, 0}, - {{2|(4<<4)}, {20.36*4, 21.33*2}, 0}, - {{2|(5<<4)}, {20.36*5, 21.33*2}, 0}, - {{6|(0<<4)}, {20.36*6, 21.33*2}, 0}, - {{6|(1<<4)}, {20.36*7, 21.33*2}, 0}, - {{6|(2<<4)}, {20.36*8, 21.33*2}, 0}, - {{6|(3<<4)}, {20.36*9, 21.33*2}, 0}, - {{6|(4<<4)}, {20.36*10,21.33*2}, 0}, + {{2|(1<<4)}, {20.36*1, 21.33*2}, 4}, + {{2|(2<<4)}, {20.36*2, 21.33*2}, 4}, + {{2|(3<<4)}, {20.36*3, 21.33*2}, 4}, + {{2|(4<<4)}, {20.36*4, 21.33*2}, 4}, + {{2|(5<<4)}, {20.36*5, 21.33*2}, 4}, + {{6|(0<<4)}, {20.36*6, 21.33*2}, 4}, + {{6|(1<<4)}, {20.36*7, 21.33*2}, 4}, + {{6|(2<<4)}, {20.36*8, 21.33*2}, 4}, + {{6|(3<<4)}, {20.36*9, 21.33*2}, 4}, + {{6|(4<<4)}, {20.36*10,21.33*2}, 4}, {{6|(5<<4)}, {20.36*11,21.33*2}, 1}, {{3|(0<<4)}, {20.36*0, 21.33*3}, 1}, @@ -129,7 +129,7 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{3|(2<<4)}, {20.36*2, 21.33*3}, 1}, {{7|(3<<4)}, {20.36*3, 21.33*3}, 1}, {{7|(4<<4)}, {20.36*4, 21.33*3}, 1}, - {{7|(5<<4)}, {20.36*5.5,21.33*3}, 0}, + {{7|(5<<4)}, {20.36*5.5,21.33*3}, 4}, {{7|(0<<4)}, {20.36*7, 21.33*3}, 1}, {{7|(1<<4)}, {20.36*8, 21.33*3}, 1}, {{7|(2<<4)}, {20.36*9, 21.33*3}, 1}, diff --git a/keyboards/planck/keymaps/tom/keymap.c b/keyboards/planck/keymaps/tom/keymap.c index 6e3b08938..5b7177c6c 100644 --- a/keyboards/planck/keymaps/tom/keymap.c +++ b/keyboards/planck/keymaps/tom/keymap.c @@ -231,7 +231,7 @@ void rgb_matrix_indicators_user(void) { case _RAISE: for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if ( led.modifier ) { + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { rgb_matrix_set_color(i, 0x6B, 0x00, 0x80); } else { rgb_matrix_set_color(i, 0x00, 0xFF, 0x00); @@ -242,7 +242,7 @@ void rgb_matrix_indicators_user(void) { case _LOWER: for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if ( led.modifier ) { + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { rgb_matrix_set_color(i, 0xFF, 0xA5, 0x00); } else { rgb_matrix_set_color(i, 0x00, 0x67, 0xC7); diff --git a/keyboards/planck/light/light.c b/keyboards/planck/light/light.c index f463090dd..178d28274 100644 --- a/keyboards/planck/light/light.c +++ b/keyboards/planck/light/light.c @@ -77,49 +77,49 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {1, C9_14, C8_14, C7_14} }; -const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { /*{row | col << 4} | {x=0..224, y=0..64} - | | modifier + | | flags | | | */ {{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, - {{0|(1<<4)}, {20.36*1, 21.33*0}, 0}, - {{0|(2<<4)}, {20.36*2, 21.33*0}, 0}, - {{0|(3<<4)}, {20.36*3, 21.33*0}, 0}, - {{0|(4<<4)}, {20.36*4, 21.33*0}, 0}, - {{0|(5<<4)}, {20.36*5, 21.33*0}, 0}, - {{0|(6<<4)}, {20.36*6, 21.33*0}, 0}, - {{0|(7<<4)}, {20.36*7, 21.33*0}, 0}, - {{0|(8<<4)}, {20.36*8, 21.33*0}, 0}, - {{0|(9<<4)}, {20.36*9, 21.33*0}, 0}, - {{0|(10<<4)}, {20.36*10,21.33*0}, 0}, + {{0|(1<<4)}, {20.36*1, 21.33*0}, 4}, + {{0|(2<<4)}, {20.36*2, 21.33*0}, 4}, + {{0|(3<<4)}, {20.36*3, 21.33*0}, 4}, + {{0|(4<<4)}, {20.36*4, 21.33*0}, 4}, + {{0|(5<<4)}, {20.36*5, 21.33*0}, 4}, + {{0|(6<<4)}, {20.36*6, 21.33*0}, 4}, + {{0|(7<<4)}, {20.36*7, 21.33*0}, 4}, + {{0|(8<<4)}, {20.36*8, 21.33*0}, 4}, + {{0|(9<<4)}, {20.36*9, 21.33*0}, 4}, + {{0|(10<<4)}, {20.36*10,21.33*0}, 4}, {{0|(11<<4)}, {20.36*11,21.33*0}, 1}, {{1|(0<<4)}, {20.36*0, 21.33*1}, 1}, - {{1|(1<<4)}, {20.36*1, 21.33*1}, 0}, - {{1|(2<<4)}, {20.36*2, 21.33*1}, 0}, - {{1|(3<<4)}, {20.36*3, 21.33*1}, 0}, - {{1|(4<<4)}, {20.36*4, 21.33*1}, 0}, - {{1|(5<<4)}, {20.36*5, 21.33*1}, 0}, - {{1|(6<<4)}, {20.36*6, 21.33*1}, 0}, - {{1|(7<<4)}, {20.36*7, 21.33*1}, 0}, - {{1|(8<<4)}, {20.36*8, 21.33*1}, 0}, - {{1|(9<<4)}, {20.36*9, 21.33*1}, 0}, - {{1|(10<<4)}, {20.36*10,21.33*1}, 0}, + {{1|(1<<4)}, {20.36*1, 21.33*1}, 4}, + {{1|(2<<4)}, {20.36*2, 21.33*1}, 4}, + {{1|(3<<4)}, {20.36*3, 21.33*1}, 4}, + {{1|(4<<4)}, {20.36*4, 21.33*1}, 4}, + {{1|(5<<4)}, {20.36*5, 21.33*1}, 4}, + {{1|(6<<4)}, {20.36*6, 21.33*1}, 4}, + {{1|(7<<4)}, {20.36*7, 21.33*1}, 4}, + {{1|(8<<4)}, {20.36*8, 21.33*1}, 4}, + {{1|(9<<4)}, {20.36*9, 21.33*1}, 4}, + {{1|(10<<4)}, {20.36*10,21.33*1}, 4}, {{1|(11<<4)}, {20.36*11,21.33*1}, 1}, {{2|(0<<4)}, {20.36*0, 21.33*2}, 1}, - {{2|(1<<4)}, {20.36*1, 21.33*2}, 0}, - {{2|(2<<4)}, {20.36*2, 21.33*2}, 0}, - {{2|(3<<4)}, {20.36*3, 21.33*2}, 0}, - {{2|(4<<4)}, {20.36*4, 21.33*2}, 0}, - {{2|(5<<4)}, {20.36*5, 21.33*2}, 0}, - {{2|(6<<4)}, {20.36*6, 21.33*2}, 0}, - {{2|(7<<4)}, {20.36*7, 21.33*2}, 0}, - {{2|(8<<4)}, {20.36*8, 21.33*2}, 0}, - {{2|(9<<4)}, {20.36*9, 21.33*2}, 0}, - {{2|(10<<4)}, {20.36*10,21.33*2}, 0}, + {{2|(1<<4)}, {20.36*1, 21.33*2}, 4}, + {{2|(2<<4)}, {20.36*2, 21.33*2}, 4}, + {{2|(3<<4)}, {20.36*3, 21.33*2}, 4}, + {{2|(4<<4)}, {20.36*4, 21.33*2}, 4}, + {{2|(5<<4)}, {20.36*5, 21.33*2}, 4}, + {{2|(6<<4)}, {20.36*6, 21.33*2}, 4}, + {{2|(7<<4)}, {20.36*7, 21.33*2}, 4}, + {{2|(8<<4)}, {20.36*8, 21.33*2}, 4}, + {{2|(9<<4)}, {20.36*9, 21.33*2}, 4}, + {{2|(10<<4)}, {20.36*10,21.33*2}, 4}, {{2|(11<<4)}, {20.36*11,21.33*2}, 1}, {{3|(0<<4)}, {20.36*0, 21.33*3}, 1}, @@ -127,9 +127,9 @@ const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { {{3|(2<<4)}, {20.36*2, 21.33*3}, 1}, {{3|(3<<4)}, {20.36*3, 21.33*3}, 1}, {{3|(4<<4)}, {20.36*4, 21.33*3}, 1}, - {{3|(5<<4)}, {20.36*5, 21.33*3}, 0}, - {{3|(5<<4)}, {20.36*5.5,21.33*3}, 0}, - {{3|(6<<4)}, {20.36*6, 21.33*3}, 0}, + {{3|(5<<4)}, {20.36*5, 21.33*3}, 4}, + {{3|(5<<4)}, {20.36*5.5,21.33*3}, 4}, + {{3|(6<<4)}, {20.36*6, 21.33*3}, 4}, {{3|(7<<4)}, {20.36*7, 21.33*3}, 1}, {{3|(8<<4)}, {20.36*8, 21.33*3}, 1}, {{3|(9<<4)}, {20.36*9, 21.33*3}, 1}, diff --git a/keyboards/sol/rev1/rev1.c b/keyboards/sol/rev1/rev1.c index 049b5c218..b668b02e9 100644 --- a/keyboards/sol/rev1/rev1.c +++ b/keyboards/sol/rev1/rev1.c @@ -1,35 +1,35 @@ #include "sol.h" #ifdef RGB_MATRIX_ENABLE - const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { // Left Hand Mapped Left to Right { { 0 | (0 << 4) }, { 0, 0 }, 1}, - { { 0 | (1 << 4) }, { 22, 0 }, 0}, - { { 0 | (2 << 4) }, { 37, 0 }, 0}, - { { 0 | (3 << 4) }, { 37, 0 }, 0}, - { { 0 | (4 << 4) }, { 67, 0 }, 0}, - { { 0 | (5 << 4) }, { 82, 0 }, 0}, + { { 0 | (1 << 4) }, { 22, 0 }, 4}, + { { 0 | (2 << 4) }, { 37, 0 }, 4}, + { { 0 | (3 << 4) }, { 37, 0 }, 4}, + { { 0 | (4 << 4) }, { 67, 0 }, 4}, + { { 0 | (5 << 4) }, { 82, 0 }, 4}, { { 0 | (6 << 4) }, { 104, 0 }, 1}, { { 1 | (0 << 4) }, { 0, 16 }, 1}, - { { 1 | (1 << 4) }, { 22, 16 }, 0}, - { { 1 | (2 << 4) }, { 37, 16 }, 0}, - { { 1 | (3 << 4) }, { 37, 16 }, 0}, - { { 1 | (4 << 4) }, { 67, 16 }, 0}, - { { 1 | (5 << 4) }, { 82, 16 }, 0}, + { { 1 | (1 << 4) }, { 22, 16 }, 4}, + { { 1 | (2 << 4) }, { 37, 16 }, 4}, + { { 1 | (3 << 4) }, { 37, 16 }, 4}, + { { 1 | (4 << 4) }, { 67, 16 }, 4}, + { { 1 | (5 << 4) }, { 82, 16 }, 4}, { { 1 | (6 << 4) }, { 104, 16 }, 1}, { { 2 | (0 << 4) }, { 0, 32 }, 1}, - { { 2 | (1 << 4) }, { 22, 32 }, 0}, - { { 2 | (2 << 4) }, { 37, 32 }, 0}, - { { 2 | (3 << 4) }, { 37, 32 }, 0}, - { { 2 | (4 << 4) }, { 67, 32 }, 0}, - { { 2 | (5 << 4) }, { 82, 32 }, 0}, + { { 2 | (1 << 4) }, { 22, 32 }, 4}, + { { 2 | (2 << 4) }, { 37, 32 }, 4}, + { { 2 | (3 << 4) }, { 37, 32 }, 4}, + { { 2 | (4 << 4) }, { 67, 32 }, 4}, + { { 2 | (5 << 4) }, { 82, 32 }, 4}, { { 2 | (6 << 4) }, { 104, 32 }, 1}, { { 3 | (0 << 4) }, { 0, 48 }, 1}, - { { 3 | (1 << 4) }, { 22, 48 }, 0}, - { { 3 | (2 << 4) }, { 37, 48 }, 0}, - { { 3 | (3 << 4) }, { 37, 48 }, 0}, - { { 3 | (4 << 4) }, { 67, 48 }, 0}, - { { 3 | (5 << 4) }, { 82, 48 }, 0}, + { { 3 | (1 << 4) }, { 22, 48 }, 4}, + { { 3 | (2 << 4) }, { 37, 48 }, 4}, + { { 3 | (3 << 4) }, { 37, 48 }, 4}, + { { 3 | (4 << 4) }, { 67, 48 }, 4}, + { { 3 | (5 << 4) }, { 82, 48 }, 4}, { { 3 | (6 << 4) }, { 104, 48 }, 1}, { { 4 | (0 << 4) }, { 0, 64 }, 1}, { { 4 | (1 << 4) }, { 22, 64 }, 1}, @@ -42,32 +42,32 @@ { { 5 | (6 << 4) }, { 97, 55 }, 1}, // Left Hand Mapped Right to Left { { 6 | (0 << 4) }, { 224, 0 }, 1}, - { { 6 | (1 << 4) }, { 202, 0 }, 0}, - { { 6 | (2 << 4) }, { 187, 0 }, 0}, - { { 6 | (3 << 4) }, { 172, 0 }, 0}, - { { 6 | (4 << 4) }, { 157, 0 }, 0}, - { { 6 | (5 << 4) }, { 142, 0 }, 0}, + { { 6 | (1 << 4) }, { 202, 0 }, 4}, + { { 6 | (2 << 4) }, { 187, 0 }, 4}, + { { 6 | (3 << 4) }, { 172, 0 }, 4}, + { { 6 | (4 << 4) }, { 157, 0 }, 4}, + { { 6 | (5 << 4) }, { 142, 0 }, 4}, { { 6 | (6 << 4) }, { 120, 0 }, 1}, { { 7 | (0 << 4) }, { 224, 16 }, 1}, - { { 7 | (1 << 4) }, { 202, 16 }, 0}, - { { 7 | (2 << 4) }, { 187, 16 }, 0}, - { { 7 | (3 << 4) }, { 172, 16 }, 0}, - { { 7 | (4 << 4) }, { 157, 16 }, 0}, - { { 7 | (5 << 4) }, { 142, 16 }, 0}, + { { 7 | (1 << 4) }, { 202, 16 }, 4}, + { { 7 | (2 << 4) }, { 187, 16 }, 4}, + { { 7 | (3 << 4) }, { 172, 16 }, 4}, + { { 7 | (4 << 4) }, { 157, 16 }, 4}, + { { 7 | (5 << 4) }, { 142, 16 }, 4}, { { 7 | (6 << 4) }, { 120, 16 }, 1}, { { 8 | (0 << 4) }, { 224, 32 }, 1}, - { { 8 | (1 << 4) }, { 202, 32 }, 0}, - { { 8 | (2 << 4) }, { 187, 32 }, 0}, - { { 8 | (3 << 4) }, { 172, 32 }, 0}, - { { 8 | (4 << 4) }, { 157, 32 }, 0}, - { { 8 | (5 << 4) }, { 142, 32 }, 0}, + { { 8 | (1 << 4) }, { 202, 32 }, 4}, + { { 8 | (2 << 4) }, { 187, 32 }, 4}, + { { 8 | (3 << 4) }, { 172, 32 }, 4}, + { { 8 | (4 << 4) }, { 157, 32 }, 4}, + { { 8 | (5 << 4) }, { 142, 32 }, 4}, { { 8 | (6 << 4) }, { 120, 32 }, 1}, { { 9 | (0 << 4) }, { 224, 48 }, 1}, - { { 9 | (1 << 4) }, { 202, 48 }, 0}, - { { 9 | (2 << 4) }, { 187, 48 }, 0}, - { { 9 | (3 << 4) }, { 172, 48 }, 0}, - { { 9 | (4 << 4) }, { 157, 48 }, 0}, - { { 9 | (5 << 4) }, { 142, 48 }, 0}, + { { 9 | (1 << 4) }, { 202, 48 }, 4}, + { { 9 | (2 << 4) }, { 187, 48 }, 4}, + { { 9 | (3 << 4) }, { 172, 48 }, 4}, + { { 9 | (4 << 4) }, { 157, 48 }, 4}, + { { 9 | (5 << 4) }, { 142, 48 }, 4}, { { 9 | (6 << 4) }, { 120, 48 }, 1}, { { 10 | (0 << 4) }, { 224, 64 }, 1}, { { 10 | (1 << 4) }, { 202, 64 }, 1}, diff --git a/layouts/community/ergodox/drashna/keymap.c b/layouts/community/ergodox/drashna/keymap.c index e7f43ad66..26c2e3304 100644 --- a/layouts/community/ergodox/drashna/keymap.c +++ b/layouts/community/ergodox/drashna/keymap.c @@ -405,10 +405,8 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) { rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if (led.matrix_co.raw < 0xFF) { - if (led.modifier) { - rgb_matrix_set_color( i, red, green, blue ); - } + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); } } } diff --git a/layouts/community/ortho_4x12/drashna/keymap.c b/layouts/community/ortho_4x12/drashna/keymap.c index 16defede9..f82b4e7da 100644 --- a/layouts/community/ortho_4x12/drashna/keymap.c +++ b/layouts/community/ortho_4x12/drashna/keymap.c @@ -179,10 +179,8 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool def rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; - if (led.matrix_co.raw < 0xFF) { - if (led.modifier) { - rgb_matrix_set_color( i, red, green, blue ); - } + if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); } } } diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 5ca9b87a6..8c16c7790 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -162,28 +162,11 @@ void rgb_matrix_update_pwm_buffers(void) { } void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { -#ifdef RGB_MATRIX_EXTRA_TOG - const bool is_key = g_rgb_leds[index].matrix_co.raw != 0xff; - if ( - (rgb_matrix_config.enable == RGB_ZONE_KEYS && !is_key) || - (rgb_matrix_config.enable == RGB_ZONE_UNDER && is_key) - ) { - rgb_matrix_driver.set_color(index, 0, 0, 0); - return; - } -#endif - rgb_matrix_driver.set_color(index, red, green, blue); } void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { -#ifdef RGB_MATRIX_EXTRA_TOG - for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - rgb_matrix_set_color(i, red, green, blue); - } -#else rgb_matrix_driver.set_color_all(red, green, blue); -#endif } bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { @@ -262,7 +245,7 @@ static bool rgb_matrix_none(effect_params_t* params) { static uint8_t rgb_last_enable = UINT8_MAX; static uint8_t rgb_last_effect = UINT8_MAX; -static effect_params_t rgb_effect_params = { 0, 0 }; +static effect_params_t rgb_effect_params = { 0, 0xFF }; static rgb_task_states rgb_task_state = SYNCING; static void rgb_task_timers(void) { @@ -575,29 +558,31 @@ void rgb_matrix_set_suspend_state(bool state) { } void rgb_matrix_toggle(void) { - rgb_matrix_config.enable++; - if (!rgb_matrix_config.enable) { - rgb_task_state = STARTING; - } + rgb_matrix_config.enable ^= 1; + rgb_task_state = STARTING; eeconfig_update_rgb_matrix(rgb_matrix_config.raw); } void rgb_matrix_enable(void) { - rgb_matrix_config.enable = 1; + rgb_matrix_enable_noeeprom(); eeconfig_update_rgb_matrix(rgb_matrix_config.raw); } void rgb_matrix_enable_noeeprom(void) { - rgb_matrix_config.enable = 1; + if (!rgb_matrix_config.enable) + rgb_task_state = STARTING; + rgb_matrix_config.enable = 1; } void rgb_matrix_disable(void) { - rgb_matrix_config.enable = 0; + rgb_matrix_disable_noeeprom(); eeconfig_update_rgb_matrix(rgb_matrix_config.raw); } void rgb_matrix_disable_noeeprom(void) { - rgb_matrix_config.enable = 0; + if (rgb_matrix_config.enable) + rgb_task_state = STARTING; + rgb_matrix_config.enable = 0; } void rgb_matrix_step(void) { @@ -658,6 +643,14 @@ void rgb_matrix_decrease_speed(void) { eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this } +led_flags_t rgb_matrix_get_flags(void) { + return rgb_effect_params.flags; +} + +void rgb_matrix_set_flags(led_flags_t flags) { + rgb_effect_params.flags = flags; +} + void rgb_matrix_mode(uint8_t mode) { rgb_matrix_config.mode = mode; rgb_task_state = STARTING; diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 775cbeac0..33665ffff 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -54,7 +54,9 @@ uint8_t max = DRIVER_LED_TOTAL; #endif -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +#define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) continue + +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; typedef struct { @@ -209,6 +211,8 @@ void rgb_matrix_increase_val(void); void rgb_matrix_decrease_val(void); void rgb_matrix_increase_speed(void); void rgb_matrix_decrease_speed(void); +led_flags_t rgb_matrix_get_flags(void); +void rgb_matrix_set_flags(led_flags_t flags); void rgb_matrix_mode(uint8_t mode); void rgb_matrix_mode_noeeprom(uint8_t mode); uint8_t rgb_matrix_get_mode(void); diff --git a/quantum/rgb_matrix_animations/alpha_mods_anim.h b/quantum/rgb_matrix_animations/alpha_mods_anim.h index cc1914d7f..4bd01c4fc 100644 --- a/quantum/rgb_matrix_animations/alpha_mods_anim.h +++ b/quantum/rgb_matrix_animations/alpha_mods_anim.h @@ -1,7 +1,7 @@ #pragma once #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; // alphas = color1, mods = color2 @@ -14,7 +14,8 @@ bool rgb_matrix_alphas_mods(effect_params_t* params) { RGB rgb2 = hsv_to_rgb(hsv); for (uint8_t i = led_min; i < led_max; i++) { - if (g_rgb_leds[i].modifier) { + RGB_MATRIX_TEST_LED_FLAGS(); + if (HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_MODIFIER)) { rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b); } else { rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); diff --git a/quantum/rgb_matrix_animations/breathing_anim.h b/quantum/rgb_matrix_animations/breathing_anim.h index 4a9a1dcdb..54d60f927 100644 --- a/quantum/rgb_matrix_animations/breathing_anim.h +++ b/quantum/rgb_matrix_animations/breathing_anim.h @@ -12,6 +12,7 @@ bool rgb_matrix_breathing(effect_params_t* params) { HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, val }; RGB rgb = hsv_to_rgb(hsv); for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } return led_max < DRIVER_LED_TOTAL; diff --git a/quantum/rgb_matrix_animations/cycle_all_anim.h b/quantum/rgb_matrix_animations/cycle_all_anim.h index 5c18cfa0c..513dff128 100644 --- a/quantum/rgb_matrix_animations/cycle_all_anim.h +++ b/quantum/rgb_matrix_animations/cycle_all_anim.h @@ -2,16 +2,16 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL extern rgb_counters_t g_rgb_counters; -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_cycle_all(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; - uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); + hsv.h = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); for (uint8_t i = led_min; i < led_max; i++) { - hsv.h = time; + RGB_MATRIX_TEST_LED_FLAGS(); RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/cycle_left_right_anim.h b/quantum/rgb_matrix_animations/cycle_left_right_anim.h index f519aeb47..428adea22 100644 --- a/quantum/rgb_matrix_animations/cycle_left_right_anim.h +++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT extern rgb_counters_t g_rgb_counters; -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_cycle_left_right(effect_params_t* params) { @@ -11,6 +11,7 @@ bool rgb_matrix_cycle_left_right(effect_params_t* params) { HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); point_t point = g_rgb_leds[i].point; hsv.h = point.x - time; RGB rgb = hsv_to_rgb(hsv); diff --git a/quantum/rgb_matrix_animations/cycle_up_down_anim.h b/quantum/rgb_matrix_animations/cycle_up_down_anim.h index 8b91d890d..ea63095d2 100644 --- a/quantum/rgb_matrix_animations/cycle_up_down_anim.h +++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN extern rgb_counters_t g_rgb_counters; -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_cycle_up_down(effect_params_t* params) { @@ -11,6 +11,7 @@ bool rgb_matrix_cycle_up_down(effect_params_t* params) { HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); point_t point = g_rgb_leds[i].point; hsv.h = point.y - time; RGB rgb = hsv_to_rgb(hsv); diff --git a/quantum/rgb_matrix_animations/dual_beacon_anim.h b/quantum/rgb_matrix_animations/dual_beacon_anim.h index dda315780..00f6e5088 100644 --- a/quantum/rgb_matrix_animations/dual_beacon_anim.h +++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON extern rgb_counters_t g_rgb_counters; -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_dual_beacon(effect_params_t* params) { @@ -13,6 +13,7 @@ bool rgb_matrix_dual_beacon(effect_params_t* params) { int8_t cos_value = cos8(time) - 128; int8_t sin_value = sin8(time) - 128; for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); point_t point = g_rgb_leds[i].point; hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue; RGB rgb = hsv_to_rgb(hsv); diff --git a/quantum/rgb_matrix_animations/gradient_up_down_anim.h b/quantum/rgb_matrix_animations/gradient_up_down_anim.h index 11498e22f..05117540a 100644 --- a/quantum/rgb_matrix_animations/gradient_up_down_anim.h +++ b/quantum/rgb_matrix_animations/gradient_up_down_anim.h @@ -1,7 +1,7 @@ #pragma once #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_gradient_up_down(effect_params_t* params) { @@ -10,6 +10,7 @@ bool rgb_matrix_gradient_up_down(effect_params_t* params) { HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; uint8_t scale = scale8(64, rgb_matrix_config.speed); for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); point_t point = g_rgb_leds[i].point; // The y range will be 0..64, map this to 0..4 // Relies on hue being 8-bit and wrapping diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h index 01ff5c230..dffa53264 100644 --- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h @@ -2,10 +2,11 @@ #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS extern rgb_counters_t g_rgb_counters; -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; -static void jellybean_raindrops_set_color(int i) { +static void jellybean_raindrops_set_color(int i, effect_params_t* params) { + if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) return; HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val }; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); @@ -15,14 +16,14 @@ bool rgb_matrix_jellybean_raindrops(effect_params_t* params) { if (!params->init) { // Change one LED every tick, make sure speed is not 0 if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) { - jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL); + jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL, params); } return false; } RGB_MATRIX_USE_LIMITS(led_min, led_max); for (int i = led_min; i < led_max; i++) { - jellybean_raindrops_set_color(i); + jellybean_raindrops_set_color(i, params); } return led_max < DRIVER_LED_TOTAL; } diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h index 3c15e64ab..89f6965c3 100644 --- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON extern rgb_counters_t g_rgb_counters; -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_rainbow_beacon(effect_params_t* params) { @@ -13,6 +13,7 @@ bool rgb_matrix_rainbow_beacon(effect_params_t* params) { int16_t cos_value = 2 * (cos8(time) - 128); int16_t sin_value = 2 * (sin8(time) - 128); for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); point_t point = g_rgb_leds[i].point; hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue; RGB rgb = hsv_to_rgb(hsv); diff --git a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h index 0d11d5280..0d57aef57 100644 --- a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON extern rgb_counters_t g_rgb_counters; -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) { @@ -11,6 +11,7 @@ bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) { HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); point_t point = g_rgb_leds[i].point; hsv.h = abs8(point.y - 32) + (point.x - time) + rgb_matrix_config.hue; RGB rgb = hsv_to_rgb(hsv); diff --git a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h index d7cd42cbe..03652758c 100644 --- a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS extern rgb_counters_t g_rgb_counters; -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) { @@ -13,6 +13,7 @@ bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) { int16_t cos_value = 3 * (cos8(time) - 128); int16_t sin_value = 3 * (sin8(time) - 128); for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); point_t point = g_rgb_leds[i].point; hsv.h = ((point.y - 32) * cos_value + (56 - abs8(point.x - 112)) * sin_value) / 128 + rgb_matrix_config.hue; RGB rgb = hsv_to_rgb(hsv); diff --git a/quantum/rgb_matrix_animations/raindrops_anim.h b/quantum/rgb_matrix_animations/raindrops_anim.h index fc721375b..0e3a87864 100644 --- a/quantum/rgb_matrix_animations/raindrops_anim.h +++ b/quantum/rgb_matrix_animations/raindrops_anim.h @@ -5,7 +5,8 @@ extern rgb_counters_t g_rgb_counters; extern rgb_config_t rgb_matrix_config; -static void raindrops_set_color(int i) { +static void raindrops_set_color(int i, effect_params_t* params) { + if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) return; HSV hsv = { 0 , rgb_matrix_config.sat, rgb_matrix_config.val }; // Take the shortest path between hues @@ -25,14 +26,14 @@ bool rgb_matrix_raindrops(effect_params_t* params) { if (!params->init) { // Change one LED every tick, make sure speed is not 0 if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) { - raindrops_set_color(rand() % DRIVER_LED_TOTAL); + raindrops_set_color(rand() % DRIVER_LED_TOTAL, params); } return false; } RGB_MATRIX_USE_LIMITS(led_min, led_max); for (int i = led_min; i < led_max; i++) { - raindrops_set_color(i); + raindrops_set_color(i, params); } return led_max < DRIVER_LED_TOTAL; } diff --git a/quantum/rgb_matrix_animations/solid_color_anim.h b/quantum/rgb_matrix_animations/solid_color_anim.h index 24a197beb..033c1f933 100644 --- a/quantum/rgb_matrix_animations/solid_color_anim.h +++ b/quantum/rgb_matrix_animations/solid_color_anim.h @@ -8,6 +8,7 @@ bool rgb_matrix_solid_color(effect_params_t* params) { HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val }; RGB rgb = hsv_to_rgb(hsv); for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } return led_max < DRIVER_LED_TOTAL; diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index 220e54233..836409dd6 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -13,6 +13,7 @@ bool rgb_matrix_solid_reactive(effect_params_t* params) { uint16_t max_tick = 65535 / rgb_matrix_config.speed; // Relies on hue being 8-bit and wrapping for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); uint16_t tick = max_tick; for(uint8_t j = 0; j < g_last_hit_tracker.count; j++) { if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) { diff --git a/quantum/rgb_matrix_animations/solid_reactive_cross.h b/quantum/rgb_matrix_animations/solid_reactive_cross.h index af602cba1..1dec1886d 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_cross.h +++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -15,6 +15,7 @@ static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_par hsv.v = 0; point_t point = g_rgb_leds[i].point; for (uint8_t j = start; j < count; j++) { + RGB_MATRIX_TEST_LED_FLAGS(); int16_t dx = point.x - g_last_hit_tracker.x[j]; int16_t dy = point.y - g_last_hit_tracker.y[j]; uint8_t dist = sqrt16(dx * dx + dy * dy); diff --git a/quantum/rgb_matrix_animations/solid_reactive_nexus.h b/quantum/rgb_matrix_animations/solid_reactive_nexus.h index 8b4a139dc..8952a1e2b 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_nexus.h +++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -15,6 +15,7 @@ static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_par hsv.v = 0; point_t point = g_rgb_leds[i].point; for (uint8_t j = start; j < count; j++) { + RGB_MATRIX_TEST_LED_FLAGS(); int16_t dx = point.x - g_last_hit_tracker.x[j]; int16_t dy = point.y - g_last_hit_tracker.y[j]; uint8_t dist = sqrt16(dx * dx + dy * dy); diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h index e84cd6939..d7bdb414e 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h @@ -12,6 +12,7 @@ bool rgb_matrix_solid_reactive_simple(effect_params_t* params) { // Max tick based on speed scale ensures results from scale16by8 with rgb_matrix_config.speed are no greater than 255 uint16_t max_tick = 65535 / rgb_matrix_config.speed; for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); uint16_t tick = max_tick; for(uint8_t j = 0; j < g_last_hit_tracker.count; j++) { if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) { diff --git a/quantum/rgb_matrix_animations/solid_reactive_wide.h b/quantum/rgb_matrix_animations/solid_reactive_wide.h index abb01892e..d86cb1284 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_wide.h +++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -15,6 +15,7 @@ static bool rgb_matrix_solid_reactive_multiwide_range(uint8_t start, effect_para hsv.v = 0; point_t point = g_rgb_leds[i].point; for (uint8_t j = start; j < count; j++) { + RGB_MATRIX_TEST_LED_FLAGS(); int16_t dx = point.x - g_last_hit_tracker.x[j]; int16_t dy = point.y - g_last_hit_tracker.y[j]; uint8_t dist = sqrt16(dx * dx + dy * dy); diff --git a/quantum/rgb_matrix_animations/solid_splash_anim.h b/quantum/rgb_matrix_animations/solid_splash_anim.h index 82ac055b8..14312f33d 100644 --- a/quantum/rgb_matrix_animations/solid_splash_anim.h +++ b/quantum/rgb_matrix_animations/solid_splash_anim.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH) -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -12,6 +12,7 @@ static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* p HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; uint8_t count = g_last_hit_tracker.count; for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); hsv.v = 0; point_t point = g_rgb_leds[i].point; for (uint8_t j = start; j < count; j++) { diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h index 829d30eef..3c96d451e 100644 --- a/quantum/rgb_matrix_animations/splash_anim.h +++ b/quantum/rgb_matrix_animations/splash_anim.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) -extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -12,6 +12,7 @@ static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params) HSV hsv = { 0, rgb_matrix_config.sat, 0 }; uint8_t count = g_last_hit_tracker.count; for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); hsv.h = rgb_matrix_config.hue; hsv.v = 0; point_t point = g_rgb_leds[i].point; diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h index 908e96da5..7a3bc6714 100644 --- a/quantum/rgb_matrix_types.h +++ b/quantum/rgb_matrix_types.h @@ -67,19 +67,21 @@ typedef union { }; } matrix_co_t; +#define HAS_FLAGS(bits, flags) ((bits & flags) == flags) +#define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00) + +#define LED_FLAG_ALL 0xFF +#define LED_FLAG_NONE 0x00 +#define LED_FLAG_MODIFIER 0x01 +#define LED_FLAG_UNDERGLOW 0x02 +#define LED_FLAG_KEYLIGHT 0x04 + typedef struct PACKED { - matrix_co_t matrix_co; - point_t point; - uint8_t modifier:1; + matrix_co_t matrix_co; + point_t point; + uint8_t flags; } rgb_led; -typedef enum { - RGB_ZONE_OFF = 0, - RGB_ZONE_ALL, - RGB_ZONE_KEYS, - RGB_ZONE_UNDER, -} rgb_zone_t; - typedef union { uint32_t raw; struct PACKED { diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index e29fb6587..a2eab1b56 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.c +++ b/tmk_core/protocol/arm_atsam/led_matrix.c @@ -443,9 +443,9 @@ static void led_matrix_massdrop_config_override(int i) uint8_t highest_active_layer = biton32(layer_state); - if (led_lighting_mode == LED_MODE_KEYS_ONLY && g_rgb_leds[i].matrix_co.raw == 0xff) { + if (led_lighting_mode == LED_MODE_KEYS_ONLY && HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_UNDERGLOW)) { //Do not act on this LED - } else if (led_lighting_mode == LED_MODE_NON_KEYS_ONLY && g_rgb_leds[i].matrix_co.raw != 0xff) { + } else if (led_lighting_mode == LED_MODE_NON_KEYS_ONLY && !HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_UNDERGLOW)) { //Do not act on this LED } else if (led_lighting_mode == LED_MODE_INDICATORS_ONLY) { //Do not act on this LED (Only show indicators) -- cgit v1.2.3-70-g09d2 From c745d9b82e3f2047feb97a7a8937f27c6e989fd7 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Mon, 29 Apr 2019 22:21:46 -0500 Subject: Simple extended space cadet (#5277) * Simplifying and Extending Space Cadet to work on Ctrl and Alt keys * PR Review feedback * Reverting back to keycodes --- common_features.mk | 6 ++ docs/_summary.md | 3 +- docs/feature_space_cadet.md | 59 +++++++++++ docs/feature_space_cadet_shift.md | 37 ------- docs/feature_space_cadet_shift_enter.md | 31 ------ quantum/process_keycode/process_space_cadet.c | 146 ++++++++++++++++++++++++++ quantum/process_keycode/process_space_cadet.h | 21 ++++ quantum/quantum.c | 123 +--------------------- quantum/quantum.h | 4 + quantum/quantum_keycodes.h | 12 +++ 10 files changed, 252 insertions(+), 190 deletions(-) create mode 100644 docs/feature_space_cadet.md delete mode 100644 docs/feature_space_cadet_shift.md delete mode 100644 docs/feature_space_cadet_shift_enter.md create mode 100644 quantum/process_keycode/process_space_cadet.c create mode 100644 quantum/process_keycode/process_space_cadet.h (limited to 'quantum') diff --git a/common_features.mk b/common_features.mk index 8e9bcf0b9..6dffe31ff 100644 --- a/common_features.mk +++ b/common_features.mk @@ -351,3 +351,9 @@ ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes) QUANTUM_LIB_SRC += i2c_master.c SRC += oled_driver.c endif + +SPACE_CADET_ENABLE ?= yes +ifeq ($(strip $(SPACE_CADET_ENABLE)), yes) + SRC += $(QUANTUM_DIR)/process_keycode/process_space_cadet.c + OPT_DEFS += -DSPACE_CADET_ENABLE +endif diff --git a/docs/_summary.md b/docs/_summary.md index c9d6c2bb1..d31087019 100644 --- a/docs/_summary.md +++ b/docs/_summary.md @@ -68,8 +68,7 @@ * [PS/2 Mouse](feature_ps2_mouse.md) * [RGB Lighting](feature_rgblight.md) * [RGB Matrix](feature_rgb_matrix.md) - * [Space Cadet Shift](feature_space_cadet_shift.md) - * [Space Cadet Shift Enter](feature_space_cadet_shift_enter.md) + * [Space Cadet](feature_space_cadet.md) * [Stenography](feature_stenography.md) * [Swap Hands](feature_swap_hands.md) * [Tap Dance](feature_tap_dance.md) diff --git a/docs/feature_space_cadet.md b/docs/feature_space_cadet.md new file mode 100644 index 000000000..3e4665cde --- /dev/null +++ b/docs/feature_space_cadet.md @@ -0,0 +1,59 @@ +# Space Cadet: The Future, Built In + +Steve Losh described the [Space Cadet Shift](http://stevelosh.com/blog/2012/10/a-modern-space-cadet/) quite well. Essentially, when you tap Left Shift on its own, you get an opening parenthesis; tap Right Shift on its own and you get the closing one. When held, the Shift keys function as normal. Yes, it's as cool as it sounds, and now even cooler supporting Control and Alt as well! + +## Usage + +Firstly, in your keymap, do one of the following: +- Replace the Left Shift key with `KC_LSPO` (Left Shift, Parenthesis Open), and Right Shift with `KC_RSPC` (Right Shift, Parenthesis Close). +- Replace the Left Control key with `KC_LCPO` (Left Control, Parenthesis Open), and Right Control with `KC_RCPC` (Right Control, Parenthesis Close). +- Replace the Left Alt key with `KC_LAPO` (Left Alt, Parenthesis Open), and Right Alt with `KC_RAPC` (Right Alt, Parenthesis Close). +- Replace any Shift key in your keymap with `KC_SFTENT` (Right Shift, Enter). + +## Keycodes + +|Keycode |Description | +|-----------|-------------------------------------------| +|`KC_LSPO` |Left Shift when held, `(` when tapped | +|`KC_RSPC` |Right Shift when held, `)` when tapped | +|`KC_LCPO` |Left Control when held, `(` when tapped | +|`KC_RCPC` |Right Control when held, `)` when tapped | +|`KC_LAPO` |Left Alt when held, `(` when tapped | +|`KC_RAPC` |Right Alt when held, `)` when tapped | +|`KC_SFTENT`|Right Shift when held, `Enter` when tapped | + +## Caveats + +Space Cadet's functionality can conflict with the default Command functionality when both Shift keys are held at the same time. See the [Command feature](feature_command.md) for info on how to change it, or make sure that Command is disabled in your `rules.mk` with: + +```make +COMMAND_ENABLE = no +``` + +## Configuration + +By default Space Cadet assumes a US ANSI layout, but if your layout uses different keys for parentheses, you can redefine them in your `config.h`. In addition, you can redefine the modifier to send on tap, or even send no modifier at all. The new configuration defines bundle all options up into a single define of 3 key codes in this order: the `Modifier` when held or when used with other keys, the `Tap Modifer` sent when tapped (no modifier if `KC_TRNS`), finally the `Keycode` sent when tapped. Now keep in mind, mods from other keys will still apply to the `Keycode` if say `KC_RSFT` is held while tapping `KC_LSPO` key with `KC_TRNS` as the `Tap Modifer`. + +|Define |Default |Description | +|----------------|-------------------------------|---------------------------------------------------------------------------------| +|`LSPO_KEYS` |`KC_LSFT, LSPO_MOD, LSPO_KEY` |Send `KC_LSFT` when held, the mod and key defined by `LSPO_MOD` and `LSPO_KEY`. | +|`RSPC_KEYS` |`KC_RSFT, RSPC_MOD, RSPC_KEY` |Send `KC_RSFT` when held, the mod and key defined by `RSPC_MOD` and `RSPC_KEY`. | +|`LCPO_KEYS` |`KC_LCTL, KC_LCTL, KC_9` |Send `KC_LCTL` when held, the mod `KC_LCTL` with the key `KC_9` when tapped. | +|`RCPO_KEYS` |`KC_RCTL, KC_RCTL, KC_0` |Send `KC_RCTL` when held, the mod `KC_RCTL` with the key `KC_0` when tapped. | +|`LAPO_KEYS` |`KC_LALT, KC_LALT, KC_9` |Send `KC_LALT` when held, the mod `KC_LALT` with the key `KC_9` when tapped. | +|`RAPO_KEYS` |`KC_RALT, KC_RALT, KC_0` |Send `KC_RALT` when held, the mod `KC_RALT` with the key `KC_0` when tapped. | +|`SFTENT_KEYS` |`KC_RSFT, KC_TRNS, SFTENT_KEY` |Send `KC_RSFT` when held, no mod with the key `SFTENT_KEY` when tapped. | + + +## Obsolete Configuration + +These defines are used in the above defines internally to support backwards compatibility, so you may continue to use them, however the above defines open up a larger range of flexibility than before. As an example, say you want to not send any modifier when you tap just `KC_LSPO`, with the old defines you had an all or nothing choice of using the `DISABLE_SPACE_CADET_MODIFIER` define. Now you can define that key as: `#define KC_LSPO_KEYS KC_LSFT, KC_TRNS, KC_9`. This tells the system to set Left Shift if held or used with other keys, then on tap send no modifier (transparent) with the `KC_9` + +|Define |Default |Description | +|------------------------------|-------------|------------------------------------------------------------------| +|`LSPO_KEY` |`KC_9` |The keycode to send when Left Shift is tapped | +|`RSPC_KEY` |`KC_0` |The keycode to send when Right Shift is tapped | +|`LSPO_MOD` |`KC_LSFT` |The modifier to apply to `LSPO_KEY` | +|`RSPC_MOD` |`KC_RSFT` |The modifier to apply to `RSPC_KEY` | +|`SFTENT_KEY` |`KC_ENT` |The keycode to send when the Shift key is tapped | +|`DISABLE_SPACE_CADET_MODIFIER`|*Not defined*|If defined, prevent the Space Cadet from applying a modifier | diff --git a/docs/feature_space_cadet_shift.md b/docs/feature_space_cadet_shift.md deleted file mode 100644 index 427d2a581..000000000 --- a/docs/feature_space_cadet_shift.md +++ /dev/null @@ -1,37 +0,0 @@ -# Space Cadet Shift: The Future, Built In - -Steve Losh described the [Space Cadet Shift](http://stevelosh.com/blog/2012/10/a-modern-space-cadet/) quite well. Essentially, when you tap Left Shift on its own, you get an opening parenthesis; tap Right Shift on its own and you get the closing one. When held, the Shift keys function as normal. Yes, it's as cool as it sounds. - -## Usage - -Replace the Left Shift key in your keymap with `KC_LSPO` (Left Shift, Parenthesis Open), and Right Shift with `KC_RSPC` (Right Shift, Parenthesis Close). - -## Keycodes - -|Keycode |Description | -|---------|--------------------------------------| -|`KC_LSPO`|Left Shift when held, `(` when tapped | -|`KC_RSPC`|Right Shift when held, `)` when tapped| - -## Caveats - -Space Cadet's functionality can conflict with the default Command functionality when both Shift keys are held at the same time. Make sure that Command is disabled in your `rules.mk` with: - -```make -COMMAND_ENABLE = no -``` - -## Configuration - -By default Space Cadet assumes a US ANSI layout, but if your layout uses different keys for parentheses, you can redefine them in your `config.h`. -You can also disable the rollover, allowing you to use the opposite Shift key to cancel the Space Cadet state in the event of an erroneous press, instead of emitting a pair of parentheses when the keys are released. -Also, by default, the Space Cadet applies modifiers LSPO_MOD and RSPC_MOD to keys defined by LSPO_KEY and RSPC_KEY. You can override this behavior by redefining those variables in your `config.h`. You can also prevent the Space Cadet to apply a modifier by defining DISABLE_SPACE_CADET_MODIFIER in your `config.h`. - -|Define |Default |Description | -|------------------------------|-------------|--------------------------------------------------------------------------------| -|`LSPO_KEY` |`KC_9` |The keycode to send when Left Shift is tapped | -|`RSPC_KEY` |`KC_0` |The keycode to send when Right Shift is tapped | -|`LSPO_MOD` |`KC_LSFT` |The keycode to send when Left Shift is tapped | -|`RSPC_MOD` |`KC_RSFT` |The keycode to send when Right Shift is tapped | -|`DISABLE_SPACE_CADET_ROLLOVER`|*Not defined*|If defined, use the opposite Shift key to cancel Space Cadet | -|`DISABLE_SPACE_CADET_MODIFIER`|*Not defined*|If defined, prevent the Space Cadet to apply a modifier to LSPO_KEY and RSPC_KEY| diff --git a/docs/feature_space_cadet_shift_enter.md b/docs/feature_space_cadet_shift_enter.md deleted file mode 100644 index 56a569b13..000000000 --- a/docs/feature_space_cadet_shift_enter.md +++ /dev/null @@ -1,31 +0,0 @@ -# Space Cadet Shift Enter - -Based on the [Space Cadet Shift](feature_space_cadet_shift.md) feature. Tap the Shift key on its own, and it behaves like Enter. When held, the Shift functions as normal. - -## Usage - -Replace any Shift key in your keymap with `KC_SFTENT` (Shift, Enter), and you're done. - -## Keycodes - -|Keycode |Description | -|-----------|----------------------------------------| -|`KC_SFTENT`|Right Shift when held, Enter when tapped| - -## Caveats - -As with Space Cadet Shift, this feature may conflict with Command, so it should be disabled in your `rules.mk` with: - -```make -COMMAND_ENABLE = no -``` - -This feature also uses the same timers as Space Cadet Shift, so using them in tandem may produce strange results. - -## Configuration - -By default Space Cadet assumes a US ANSI layout, but if you'd like to use a different key for Enter, you can redefine it in your `config.h`: - -|Define |Default |Description | -|------------|--------|------------------------------------------------| -|`SFTENT_KEY`|`KC_ENT`|The keycode to send when the Shift key is tapped| diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c new file mode 100644 index 000000000..a9c506168 --- /dev/null +++ b/quantum/process_keycode/process_space_cadet.c @@ -0,0 +1,146 @@ +/* Copyright 2019 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 "process_space_cadet.h" + +#ifndef TAPPING_TERM + #define TAPPING_TERM 200 +#endif + +// ********** OBSOLETE DEFINES, STOP USING! (pls?) ********** +// Shift / paren setup +#ifndef LSPO_KEY + #define LSPO_KEY KC_9 +#endif +#ifndef RSPC_KEY + #define RSPC_KEY KC_0 +#endif + +// Shift / Enter setup +#ifndef SFTENT_KEY + #define SFTENT_KEY KC_ENT +#endif + +#ifdef DISABLE_SPACE_CADET_MODIFIER + #ifndef LSPO_MOD + #define LSPO_MOD KC_TRNS + #endif + #ifndef RSPC_MOD + #define RSPC_MOD KC_TRNS + #endif +#else + #ifndef LSPO_MOD + #define LSPO_MOD KC_LSFT + #endif + #ifndef RSPC_MOD + #define RSPC_MOD KC_RSFT + #endif +#endif +// ********************************************************** + +// Shift / paren setup +#ifndef LSPO_KEYS + #define LSPO_KEYS KC_LSFT, LSPO_MOD, LSPO_KEY +#endif +#ifndef RSPC_KEYS + #define RSPC_KEYS KC_RSFT, RSPC_MOD, RSPC_KEY +#endif + +// Control / paren setup +#ifndef LCPO_KEYS + #define LCPO_KEYS KC_LCTL, KC_LCTL, KC_9 +#endif +#ifndef RCPO_KEYS + #define RCPO_KEYS KC_RCTL, KC_RCTL, KC_0 +#endif + +// Alt / paren setup +#ifndef LAPO_KEYS + #define LAPO_KEYS KC_LALT, KC_LALT, KC_9 +#endif +#ifndef RAPO_KEYS + #define RAPO_KEYS KC_RALT, KC_RALT, KC_0 +#endif + +// Shift / Enter setup +#ifndef SFTENT_KEYS + #define SFTENT_KEYS KC_RSFT, KC_TRNS, SFTENT_KEY +#endif + +static uint8_t sc_last = 0; +static uint16_t sc_timer = 0; + +void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod, uint8_t keycode) { + if (record->event.pressed) { + sc_last = normalMod; + sc_timer = timer_read (); + if (IS_MOD(normalMod)) { + register_mods(MOD_BIT(normalMod)); + } + } + else { + if (IS_MOD(normalMod)) { + unregister_mods(MOD_BIT(normalMod)); + } + + if (sc_last == normalMod && timer_elapsed(sc_timer) < TAPPING_TERM) { + if (IS_MOD(tapMod)) { + register_mods(MOD_BIT(tapMod)); + } + tap_code(keycode); + if (IS_MOD(tapMod)) { + unregister_mods(MOD_BIT(tapMod)); + } + } + } +} + +bool process_space_cadet(uint16_t keycode, keyrecord_t *record) { + switch(keycode) { + case KC_LSPO: { + perform_space_cadet(record, LSPO_KEYS); + return false; + } + case KC_RSPC: { + perform_space_cadet(record, RSPC_KEYS); + return false; + } + case KC_LCPO: { + perform_space_cadet(record, LCPO_KEYS); + return false; + } + case KC_RCPC: { + perform_space_cadet(record, RCPO_KEYS); + return false; + } + case KC_LAPO: { + perform_space_cadet(record, LAPO_KEYS); + return false; + } + case KC_RAPC: { + perform_space_cadet(record, RAPO_KEYS); + return false; + } + case KC_SFTENT: { + perform_space_cadet(record, SFTENT_KEYS); + return false; + } + default: { + sc_last = 0; + break; + } + } + return true; +} diff --git a/quantum/process_keycode/process_space_cadet.h b/quantum/process_keycode/process_space_cadet.h new file mode 100644 index 000000000..3f08b8002 --- /dev/null +++ b/quantum/process_keycode/process_space_cadet.h @@ -0,0 +1,21 @@ +/* Copyright 2019 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 "quantum.h" + +void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod, uint8_t keycode); +bool process_space_cadet(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/quantum.c b/quantum/quantum.c index 0fb798a74..fcedf0bc1 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -24,10 +24,6 @@ #include "outputselect.h" #endif -#ifndef TAPPING_TERM -#define TAPPING_TERM 200 -#endif - #ifndef BREATHING_PERIOD #define BREATHING_PERIOD 6 #endif @@ -196,30 +192,6 @@ void reset_keyboard(void) { bootloader_jump(); } -// Shift / paren setup - -#ifndef LSPO_KEY - #define LSPO_KEY KC_9 -#endif -#ifndef RSPC_KEY - #define RSPC_KEY KC_0 -#endif - -#ifndef LSPO_MOD - #define LSPO_MOD KC_LSFT -#endif -#ifndef RSPC_MOD - #define RSPC_MOD KC_RSFT -#endif - -// Shift / Enter setup -#ifndef SFTENT_KEY - #define SFTENT_KEY KC_ENT -#endif - -static bool shift_interrupted[2] = {0, 0}; -static uint16_t scs_timer[2] = {0, 0}; - /* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise. * Used to ensure that the correct keycode is released if the key is released. */ @@ -328,6 +300,9 @@ bool process_record_quantum(keyrecord_t *record) { #endif #ifdef TERMINAL_ENABLE process_terminal(keycode, record) && + #endif + #ifdef SPACE_CADET_ENABLE + process_space_cadet(keycode, record) && #endif true)) { return false; @@ -685,92 +660,6 @@ bool process_record_quantum(keyrecord_t *record) { return false; } break; - case KC_LSPO: { - if (record->event.pressed) { - shift_interrupted[0] = false; - scs_timer[0] = timer_read (); - register_mods(MOD_BIT(KC_LSFT)); - } - else { - #ifdef DISABLE_SPACE_CADET_ROLLOVER - if (get_mods() & MOD_BIT(RSPC_MOD)) { - shift_interrupted[0] = true; - shift_interrupted[1] = true; - } - #endif - if (!shift_interrupted[0] && timer_elapsed(scs_timer[0]) < TAPPING_TERM) { - #ifdef DISABLE_SPACE_CADET_MODIFIER - unregister_mods(MOD_BIT(KC_LSFT)); - #else - if( LSPO_MOD != KC_LSFT ){ - unregister_mods(MOD_BIT(KC_LSFT)); - register_mods(MOD_BIT(LSPO_MOD)); - } - #endif - register_code(LSPO_KEY); - unregister_code(LSPO_KEY); - #ifndef DISABLE_SPACE_CADET_MODIFIER - if( LSPO_MOD != KC_LSFT ){ - unregister_mods(MOD_BIT(LSPO_MOD)); - } - #endif - } - unregister_mods(MOD_BIT(KC_LSFT)); - } - return false; - } - - case KC_RSPC: { - if (record->event.pressed) { - shift_interrupted[1] = false; - scs_timer[1] = timer_read (); - register_mods(MOD_BIT(KC_RSFT)); - } - else { - #ifdef DISABLE_SPACE_CADET_ROLLOVER - if (get_mods() & MOD_BIT(LSPO_MOD)) { - shift_interrupted[0] = true; - shift_interrupted[1] = true; - } - #endif - if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) { - #ifdef DISABLE_SPACE_CADET_MODIFIER - unregister_mods(MOD_BIT(KC_RSFT)); - #else - if( RSPC_MOD != KC_RSFT ){ - unregister_mods(MOD_BIT(KC_RSFT)); - register_mods(MOD_BIT(RSPC_MOD)); - } - #endif - register_code(RSPC_KEY); - unregister_code(RSPC_KEY); - #ifndef DISABLE_SPACE_CADET_MODIFIER - if ( RSPC_MOD != KC_RSFT ){ - unregister_mods(MOD_BIT(RSPC_MOD)); - } - #endif - } - unregister_mods(MOD_BIT(KC_RSFT)); - } - return false; - } - - case KC_SFTENT: { - if (record->event.pressed) { - shift_interrupted[1] = false; - scs_timer[1] = timer_read (); - register_mods(MOD_BIT(KC_RSFT)); - } - else if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) { - unregister_mods(MOD_BIT(KC_RSFT)); - register_code(SFTENT_KEY); - unregister_code(SFTENT_KEY); - } - else { - unregister_mods(MOD_BIT(KC_RSFT)); - } - return false; - } case GRAVE_ESC: { uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT) @@ -825,12 +714,6 @@ bool process_record_quantum(keyrecord_t *record) { return false; } #endif - - default: { - shift_interrupted[0] = true; - shift_interrupted[1] = true; - break; - } } return process_action_kb(record); diff --git a/quantum/quantum.h b/quantum/quantum.h index 17cb90274..208268df6 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -131,6 +131,10 @@ extern uint32_t default_layer_state; #include "process_terminal_nop.h" #endif +#ifdef SPACE_CADET_ENABLE + #include "process_space_cadet.h" +#endif + #ifdef HD44780_ENABLE #include "hd44780.h" #endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index fe2e3510d..19bd7c216 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -475,6 +475,18 @@ enum quantum_keycodes { HPT_DWLI, HPT_DWLD, + // Left control, open paren + KC_LCPO, + + // Right control, close paren + KC_RCPC, + + // Left control, open paren + KC_LAPO, + + // Right control, close paren + KC_RAPC, + // always leave at the end SAFE_RANGE }; -- cgit v1.2.3-70-g09d2 From bb208f3e3b69fb154f4f78d7538ffa28482f232f Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 30 Apr 2019 09:55:53 -0500 Subject: Implement kb function for rgb matrix to led lookup (#5738) --- keyboards/sol/sol.c | 19 +++++++++++++++++++ quantum/rgb_matrix.c | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/keyboards/sol/sol.c b/keyboards/sol/sol.c index 5945cc60a..a65d4c15f 100644 --- a/keyboards/sol/sol.c +++ b/keyboards/sol/sol.c @@ -1 +1,20 @@ #include "sol.h" + +#if defined(RGB_MATRIX_ENABLE) +uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { + if (row == 4 && column == 5) { + led_i[0] = 33; + return 1; + } else if (row == 4 && column == 6) { + led_i[0] = 34; + return 1; + } else if (row == 10 && column == 5) { + led_i[0] = 68; + return 1; + } else if (row == 10 && column == 6) { + led_i[0] = 69; + return 1; + } + return 0; +} +#endif diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 8c16c7790..5528a0834 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -144,9 +144,14 @@ void eeconfig_debug_rgb_matrix(void) { dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed); } +__attribute__ ((weak)) +uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { + return 0; +} + uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { // TODO: This is kinda expensive, fix this soonish - uint8_t led_count = 0; + uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); for (uint8_t i = 0; i < DRIVER_LED_TOTAL && led_count < LED_HITS_TO_REMEMBER; i++) { matrix_co_t matrix_co = g_rgb_leds[i].matrix_co; if (row == matrix_co.row && column == matrix_co.col) { -- cgit v1.2.3-70-g09d2 From 50bc2dbe77e533959c4b8f821a31b489d25c7cb7 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Wed, 1 May 2019 07:48:33 -0500 Subject: Fixing incorrect usage of RGBLED_NUM in ws2812 driver when used with RGB Matrix (#5744) --- drivers/avr/ws2812.c | 2 +- quantum/rgb_matrix_drivers.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/drivers/avr/ws2812.c b/drivers/avr/ws2812.c index b3ed4fd0b..7c3cb5174 100644 --- a/drivers/avr/ws2812.c +++ b/drivers/avr/ws2812.c @@ -158,7 +158,7 @@ void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b) void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b) { - for (int i = 0; i < RGBLED_NUM; i++) { + for (int i = 0; i < sizeof(led)/sizeof(led[0]); i++) { led[i].r = r; led[i].g = g; led[i].b = b; diff --git a/quantum/rgb_matrix_drivers.c b/quantum/rgb_matrix_drivers.c index 3814dd61f..1d64dc909 100644 --- a/quantum/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix_drivers.c @@ -99,12 +99,12 @@ const rgb_matrix_driver_t rgb_matrix_driver = { #elif defined(WS2812) -extern LED_TYPE led[RGBLED_NUM]; +extern LED_TYPE led[DRIVER_LED_TOTAL]; static void flush( void ) { // Assumes use of RGB_DI_PIN - ws2812_setleds(led, RGBLED_NUM); + ws2812_setleds(led, DRIVER_LED_TOTAL); } static void init( void ) -- cgit v1.2.3-70-g09d2 From 22ba36a4d86c06ce1b6049555525646eb16bb57a Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Wed, 1 May 2019 10:02:02 -0500 Subject: rgblight 255 hue (#5547) --- common_features.mk | 1 + docs/feature_rgblight.md | 2 +- .../jc65/v32u4/keymaps/dead_encryption/keymap.c | 2 +- quantum/rgblight.c | 200 ++++++--------------- quantum/rgblight.h | 27 +-- quantum/rgblight_list.h | 32 ++-- 6 files changed, 84 insertions(+), 180 deletions(-) (limited to 'quantum') diff --git a/common_features.mk b/common_features.mk index 6dffe31ff..7c35f07d5 100644 --- a/common_features.mk +++ b/common_features.mk @@ -105,6 +105,7 @@ endif ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) POST_CONFIG_H += $(QUANTUM_DIR)/rgblight_post_config.h OPT_DEFS += -DRGBLIGHT_ENABLE + SRC += $(QUANTUM_DIR)/color.c SRC += $(QUANTUM_DIR)/rgblight.c CIE1931_CURVE = yes LED_BREATHING_TABLE = yes diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index 48277373a..8b0a45cb6 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md @@ -145,7 +145,7 @@ const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; // These control which hues are selected for each of the "Static gradient" modes -const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; +const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64}; ``` ## Functions diff --git a/keyboards/jc65/v32u4/keymaps/dead_encryption/keymap.c b/keyboards/jc65/v32u4/keymaps/dead_encryption/keymap.c index 61386395a..528bde885 100644 --- a/keyboards/jc65/v32u4/keymaps/dead_encryption/keymap.c +++ b/keyboards/jc65/v32u4/keymaps/dead_encryption/keymap.c @@ -15,7 +15,7 @@ const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; // These control which colors are selected for the gradient mode -const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; +const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64}; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT( diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 2f23768ed..98755ff08 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -28,8 +28,10 @@ #include "progmem.h" #include "timer.h" #include "rgblight.h" +#include "color.h" #include "debug.h" #include "led_tables.h" +#include "lib/lib8tion/lib8tion.h" #ifdef VELOCIKEY_ENABLE #include "velocikey.h" #endif @@ -74,16 +76,13 @@ static inline int is_static_effect(uint8_t mode) { return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; } -#define MIN(a,b) (((a)<(b))?(a):(b)) -#define MAX(a,b) (((a)>(b))?(a):(b)) - #ifdef RGBLIGHT_LED_MAP const uint8_t led_map[] PROGMEM = RGBLIGHT_LED_MAP; #endif #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT __attribute__ ((weak)) -const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; +const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64}; #endif rgblight_config_t rgblight_config; @@ -109,59 +108,10 @@ void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds) { } -void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { - uint8_t r = 0, g = 0, b = 0, base, color; - - if (val > RGBLIGHT_LIMIT_VAL) { - val=RGBLIGHT_LIMIT_VAL; // limit the val - } - - if (sat == 0) { // Acromatic color (gray). Hue doesn't mind. - r = val; - g = val; - b = val; - } else { - base = ((255 - sat) * val) >> 8; - color = (val - base) * (hue % 60) / 60; - - switch (hue / 60) { - case 0: - r = val; - g = base + color; - b = base; - break; - case 1: - r = val - color; - g = val; - b = base; - break; - case 2: - r = base; - g = val; - b = base + color; - break; - case 3: - r = base; - g = val - color; - b = val; - break; - case 4: - r = base + color; - g = base; - b = val; - break; - case 5: - r = val; - g = base; - b = val - color; - break; - } - } - r = pgm_read_byte(&CIE1931_CURVE[r]); - g = pgm_read_byte(&CIE1931_CURVE[g]); - b = pgm_read_byte(&CIE1931_CURVE[b]); - - setrgb(r, g, b, led1); +void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { + HSV hsv = { hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val }; + RGB rgb = hsv_to_rgb(hsv); + setrgb(rgb.r, rgb.g, rgb.b, led1); } void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { @@ -180,24 +130,9 @@ void rgblight_check_config(void) { rgblight_config.mode = RGBLIGHT_MODES; } - if (rgblight_config.hue < 0) { - rgblight_config.hue = 0; - } else if (rgblight_config.hue > 360) { - rgblight_config.hue %= 360; - } - - if (rgblight_config.sat < 0) { - rgblight_config.sat = 0; - } else if (rgblight_config.sat > 255) { - rgblight_config.sat = 255; - } - - if (rgblight_config.val < 0) { - rgblight_config.val = 0; - } else if (rgblight_config.val > RGBLIGHT_LIMIT_VAL) { + if (rgblight_config.val > RGBLIGHT_LIMIT_VAL) { rgblight_config.val = RGBLIGHT_LIMIT_VAL; } - } uint32_t eeconfig_read_rgblight(void) { @@ -220,7 +155,7 @@ void eeconfig_update_rgblight_default(void) { rgblight_config.enable = 1; rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT; rgblight_config.hue = 0; - rgblight_config.sat = 255; + rgblight_config.sat = UINT8_MAX; rgblight_config.val = RGBLIGHT_LIMIT_VAL; rgblight_config.speed = 0; RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; @@ -442,23 +377,8 @@ void rgblight_disable_noeeprom(void) { rgblight_set(); } - -// Deals with the messy details of incrementing an integer -static uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { - int16_t new_value = value; - new_value += step; - return MIN( MAX( new_value, min ), max ); -} - -static uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { - int16_t new_value = value; - new_value -= step; - return MIN( MAX( new_value, min ), max ); -} - void rgblight_increase_hue_helper(bool write_to_eeprom) { - uint16_t hue; - hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360; + uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP; rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); } void rgblight_increase_hue_noeeprom(void) { @@ -468,12 +388,7 @@ void rgblight_increase_hue(void) { rgblight_increase_hue_helper(true); } void rgblight_decrease_hue_helper(bool write_to_eeprom) { - uint16_t hue; - if (rgblight_config.hue-RGBLIGHT_HUE_STEP < 0) { - hue = (rgblight_config.hue + 360 - RGBLIGHT_HUE_STEP) % 360; - } else { - hue = (rgblight_config.hue - RGBLIGHT_HUE_STEP) % 360; - } + uint8_t hue = rgblight_config.hue - RGBLIGHT_HUE_STEP; rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); } void rgblight_decrease_hue_noeeprom(void) { @@ -483,12 +398,7 @@ void rgblight_decrease_hue(void) { rgblight_decrease_hue_helper(true); } void rgblight_increase_sat_helper(bool write_to_eeprom) { - uint8_t sat; - if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) { - sat = 255; - } else { - sat = rgblight_config.sat + RGBLIGHT_SAT_STEP; - } + uint8_t sat = qadd8(rgblight_config.sat, RGBLIGHT_SAT_STEP); rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); } void rgblight_increase_sat_noeeprom(void) { @@ -498,12 +408,7 @@ void rgblight_increase_sat(void) { rgblight_increase_sat_helper(true); } void rgblight_decrease_sat_helper(bool write_to_eeprom) { - uint8_t sat; - if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) { - sat = 0; - } else { - sat = rgblight_config.sat - RGBLIGHT_SAT_STEP; - } + uint8_t sat = qsub8(rgblight_config.sat, RGBLIGHT_SAT_STEP); rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); } void rgblight_decrease_sat_noeeprom(void) { @@ -513,12 +418,7 @@ void rgblight_decrease_sat(void) { rgblight_decrease_sat_helper(true); } void rgblight_increase_val_helper(bool write_to_eeprom) { - uint8_t val; - if (rgblight_config.val + RGBLIGHT_VAL_STEP > RGBLIGHT_LIMIT_VAL) { - val = RGBLIGHT_LIMIT_VAL; - } else { - val = rgblight_config.val + RGBLIGHT_VAL_STEP; - } + uint8_t val = qadd8(rgblight_config.val, RGBLIGHT_VAL_STEP); rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); } void rgblight_increase_val_noeeprom(void) { @@ -528,12 +428,7 @@ void rgblight_increase_val(void) { rgblight_increase_val_helper(true); } void rgblight_decrease_val_helper(bool write_to_eeprom) { - uint8_t val; - if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) { - val = 0; - } else { - val = rgblight_config.val - RGBLIGHT_VAL_STEP; - } + uint8_t val = qsub8(rgblight_config.val, RGBLIGHT_VAL_STEP); rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); } void rgblight_decrease_val_noeeprom(void) { @@ -543,18 +438,20 @@ void rgblight_decrease_val(void) { rgblight_decrease_val_helper(true); } void rgblight_increase_speed(void) { - rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 ); + if (rgblight_config.speed < 3) + rgblight_config.speed++; //RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED? eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this } void rgblight_decrease_speed(void) { - rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 ); + if (rgblight_config.speed > 0) + rgblight_config.speed--; //RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?? eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this } -void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) { +void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) { if (rgblight_config.enable) { LED_TYPE tmp_led; sethsv(hue, sat, val, &tmp_led); @@ -563,7 +460,7 @@ void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) { } } -void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { +void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { if (rgblight_config.enable) { rgblight_status.base_mode = mode_base_table[rgblight_config.mode]; if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) { @@ -596,13 +493,22 @@ void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT else if (rgblight_status.base_mode == RGBLIGHT_MODE_STATIC_GRADIENT) { // static gradient - uint16_t _hue; uint8_t delta = rgblight_config.mode - rgblight_status.base_mode; - int8_t direction = (delta % 2) ? -1 : 1; - uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[delta / 2]); + bool direction = (delta % 2) == 0; +#ifdef __AVR__ + // probably due to how pgm_read_word is defined for ARM, but the ARM compiler really hates this line + uint8_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[delta / 2]); +#else + uint8_t range = RGBLED_GRADIENT_RANGES[delta / 2]; +#endif for (uint8_t i = 0; i < RGBLED_NUM; i++) { - _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360; - dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range); + uint8_t _hue = ((uint16_t)i * (uint16_t)range) / RGBLED_NUM; + if (direction) { + _hue = hue + _hue; + } else { + _hue = hue - _hue; + } + dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range); sethsv(_hue, sat, val, (LED_TYPE *)&led[i]); } rgblight_set(); @@ -628,15 +534,15 @@ void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool } } -void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { +void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, true); } -void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { +void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, false); } -uint16_t rgblight_get_hue(void) { +uint8_t rgblight_get_hue(void) { return rgblight_config.hue; } @@ -668,7 +574,7 @@ void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) { rgblight_set(); } -void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) { +void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) { if (!rgblight_config.enable) { return; } LED_TYPE tmp_led; @@ -701,7 +607,7 @@ void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8 wait_ms(1); } -void rgblight_sethsv_range(uint16_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) { +void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) { if (!rgblight_config.enable) { return; } LED_TYPE tmp_led; @@ -717,11 +623,11 @@ void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b) { rgblight_setrgb_range(r, g, b, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM); } -void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val) { +void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_range(hue, sat, val, 0, (uint8_t) RGBLED_NUM/2); } -void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val) { +void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_range(hue, sat, val, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM); } @@ -982,7 +888,7 @@ void rgblight_effect_breathing(animation_status_t *anim) { // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ val = (exp(sin((anim->pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)); rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); - anim->pos = (anim->pos + 1) % 256; + anim->pos = (anim->pos + 1); } #endif @@ -992,36 +898,32 @@ const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30}; void rgblight_effect_rainbow_mood(animation_status_t *anim) { rgblight_sethsv_noeeprom_old(anim->current_hue, rgblight_config.sat, rgblight_config.val); - anim->current_hue = (anim->current_hue + 1) % 360; + anim->current_hue++; } #endif #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL #ifndef RGBLIGHT_RAINBOW_SWIRL_RANGE - #define RGBLIGHT_RAINBOW_SWIRL_RANGE 360 + #define RGBLIGHT_RAINBOW_SWIRL_RANGE 255 #endif __attribute__ ((weak)) const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20}; void rgblight_effect_rainbow_swirl(animation_status_t *anim) { - uint16_t hue; + uint8_t hue; uint8_t i; for (i = 0; i < RGBLED_NUM; i++) { - hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / RGBLED_NUM * i + anim->current_hue) % 360; + hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / RGBLED_NUM * i + anim->current_hue); sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); } rgblight_set(); if (anim->delta % 2) { - anim->current_hue = (anim->current_hue + 1) % 360; + anim->current_hue++; } else { - if (anim->current_hue - 1 < 0) { - anim->current_hue = 359; - } else { - anim->current_hue = anim->current_hue - 1; - } + anim->current_hue--; } } #endif @@ -1146,12 +1048,12 @@ void rgblight_effect_knight(animation_status_t *anim) { #ifdef RGBLIGHT_EFFECT_CHRISTMAS void rgblight_effect_christmas(animation_status_t *anim) { - uint16_t hue; + uint8_t hue; uint8_t i; anim->current_offset = (anim->current_offset + 1) % 2; for (i = 0; i < RGBLED_NUM; i++) { - hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + anim->current_offset) % 2) * 120; + hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + anim->current_offset) % 2) * 85; sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); } rgblight_set(); diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 748d009dc..9ccb3135c 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -113,7 +113,7 @@ enum RGBLIGHT_EFFECT_MODE { #endif #ifndef RGBLIGHT_HUE_STEP -#define RGBLIGHT_HUE_STEP 10 +#define RGBLIGHT_HUE_STEP 8 #endif #ifndef RGBLIGHT_SAT_STEP #define RGBLIGHT_SAT_STEP 17 @@ -151,12 +151,13 @@ extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM; extern const uint16_t RGBLED_RGBTEST_INTERVALS[1] PROGMEM; extern bool is_rgblight_initialized; +// Should stay in sycn with rgb matrix config as we reuse eeprom storage for both (for now) typedef union { uint32_t raw; struct { bool enable :1; - uint8_t mode :6; - uint16_t hue :9; + uint8_t mode :7; + uint8_t hue :8; uint8_t sat :8; uint8_t val :8; uint8_t speed :8;//EECONFIG needs to be increased to support this @@ -211,19 +212,19 @@ void rgblight_increase_val(void); void rgblight_decrease_val(void); void rgblight_increase_speed(void); void rgblight_decrease_speed(void); -void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); -uint16_t rgblight_get_hue(void); +void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val); +uint8_t rgblight_get_hue(void); uint8_t rgblight_get_sat(void); uint8_t rgblight_get_val(void); void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b); void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index); -void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index); +void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index); void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end); -void rgblight_sethsv_range(uint16_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end); +void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end); void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b); void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b); -void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val); -void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val); +void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val); +void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val); void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds); uint32_t eeconfig_read_rgblight(void); @@ -234,10 +235,10 @@ void eeconfig_debug_rgblight(void); void rgb_matrix_increase(void); void rgb_matrix_decrease(void); -void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); +void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); -void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); +void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val); void rgblight_mode_noeeprom(uint8_t mode); void rgblight_toggle_noeeprom(void); void rgblight_enable_noeeprom(void); @@ -251,7 +252,7 @@ void rgblight_decrease_sat_noeeprom(void); void rgblight_increase_val_noeeprom(void); void rgblight_decrease_val_noeeprom(void); -void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); +void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); @@ -274,7 +275,7 @@ typedef struct _animation_status_t { union { uint16_t pos16; uint8_t pos; - int16_t current_hue; + int8_t current_hue; uint16_t current_offset; }; } animation_status_t; diff --git a/quantum/rgblight_list.h b/quantum/rgblight_list.h index e024364f0..702e33e76 100644 --- a/quantum/rgblight_list.h +++ b/quantum/rgblight_list.h @@ -38,22 +38,22 @@ /* HSV COLORS */ #define HSV_WHITE 0, 0, 255 #define HSV_RED 0, 255, 255 -#define HSV_CORAL 16, 176, 255 -#define HSV_ORANGE 39, 255, 255 -#define HSV_GOLDENROD 43, 218, 218 -#define HSV_GOLD 51, 255, 255 -#define HSV_YELLOW 60, 255, 255 -#define HSV_CHARTREUSE 90, 255, 255 -#define HSV_GREEN 120, 255, 255 -#define HSV_SPRINGGREEN 150, 255, 255 -#define HSV_TURQUOISE 174, 90, 112 -#define HSV_TEAL 180, 255, 128 -#define HSV_CYAN 180, 255, 255 -#define HSV_AZURE 186, 102, 255 -#define HSV_BLUE 240, 255, 255 -#define HSV_PURPLE 270, 255, 255 -#define HSV_MAGENTA 300, 255, 255 -#define HSV_PINK 330, 128, 255 +#define HSV_CORAL 11, 176, 255 +#define HSV_ORANGE 28, 255, 255 +#define HSV_GOLDENROD 30, 218, 218 +#define HSV_GOLD 36, 255, 255 +#define HSV_YELLOW 43, 255, 255 +#define HSV_CHARTREUSE 64, 255, 255 +#define HSV_GREEN 85, 255, 255 +#define HSV_SPRINGGREEN 106, 255, 255 +#define HSV_TURQUOISE 123, 90, 112 +#define HSV_TEAL 128, 255, 128 +#define HSV_CYAN 128, 255, 255 +#define HSV_AZURE 132, 102, 255 +#define HSV_BLUE 170, 255, 255 +#define HSV_PURPLE 191, 255, 255 +#define HSV_MAGENTA 213, 255, 255 +#define HSV_PINK 234, 128, 255 /* -- cgit v1.2.3-70-g09d2 From 3235c8527dd292d4a5e5e28302e118f3ef1a043e Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Wed, 1 May 2019 13:36:50 -0500 Subject: Simple fix for selecting which tracked key press to work off of for simple reactive effects (#5745) --- quantum/rgb_matrix_animations/solid_reactive_anim.h | 3 ++- quantum/rgb_matrix_animations/solid_reactive_simple_anim.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index 836409dd6..82483653a 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -15,7 +15,8 @@ bool rgb_matrix_solid_reactive(effect_params_t* params) { for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); uint16_t tick = max_tick; - for(uint8_t j = 0; j < g_last_hit_tracker.count; j++) { + // Reverse search to find most recent key hit + for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) { if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) { tick = g_last_hit_tracker.tick[j]; break; diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h index d7bdb414e..9fc4d527a 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h @@ -14,7 +14,8 @@ bool rgb_matrix_solid_reactive_simple(effect_params_t* params) { for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); uint16_t tick = max_tick; - for(uint8_t j = 0; j < g_last_hit_tracker.count; j++) { + // Reverse search to find most recent key hit + for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) { if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) { tick = g_last_hit_tracker.tick[j]; break; -- cgit v1.2.3-70-g09d2 From 12a07dae33aaa59b8172f13f25af74e0cf3b82cc Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Wed, 1 May 2019 20:59:01 -0500 Subject: Adjusted the linear led table and hsv_to_rgb to better handle 255 hue (#5739) * Adjusted the linear led table and hsv_to_rgb to better handle 255 hue * small math adjustments to better handle specific uint8_t rounding and overflows --- quantum/color.c | 9 +++++---- quantum/led_tables.c | 48 +++++++++++++++++++----------------------------- 2 files changed, 24 insertions(+), 33 deletions(-) (limited to 'quantum') diff --git a/quantum/color.c b/quantum/color.c index c49877592..466e6edac 100644 --- a/quantum/color.c +++ b/quantum/color.c @@ -22,8 +22,8 @@ RGB hsv_to_rgb( HSV hsv ) { RGB rgb; - uint8_t region, p, q, t; - uint16_t h, s, v, remainder; + uint8_t region, remainder, p, q, t; + uint16_t h, s, v; if ( hsv.s == 0 ) { @@ -37,8 +37,8 @@ RGB hsv_to_rgb( HSV hsv ) s = hsv.s; v = hsv.v; - region = h / 43; - remainder = (h - (region * 43)) * 6; + region = h * 6 / 255; + remainder = (h * 2 - region * 85) * 3; p = (v * (255 - s)) >> 8; q = (v * (255 - ((s * remainder) >> 8))) >> 8; @@ -46,6 +46,7 @@ RGB hsv_to_rgb( HSV hsv ) switch ( region ) { + case 6: case 0: rgb.r = v; rgb.g = t; diff --git a/quantum/led_tables.c b/quantum/led_tables.c index b99f26209..0eeb5c44b 100644 --- a/quantum/led_tables.c +++ b/quantum/led_tables.c @@ -19,38 +19,28 @@ along with this program. If not, see . #ifdef USE_CIE1931_CURVE // Lightness curve using the CIE 1931 lightness formula //Generated by the python script provided in http://jared.geek.nz/2013/feb/linear-led-pwm -const uint8_t CIE1931_CURVE[] PROGMEM = { - 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, - 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, - 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, - 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, - 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, - 13, 14, 14, 15, 15, 15, 16, 16, 17, 17, - 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, - 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, - 28, 28, 29, 29, 30, 31, 31, 32, 32, 33, - 34, 34, 35, 36, 37, 37, 38, 39, 39, 40, - 41, 42, 43, 43, 44, 45, 46, 47, 47, 48, - 49, 50, 51, 52, 53, 54, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 70, 71, 72, 73, 74, 75, 76, 77, 79, - 80, 81, 82, 83, 85, 86, 87, 88, 90, 91, - 92, 94, 95, 96, 98, 99, 100, 102, 103, 105, - 106, 108, 109, 110, 112, 113, 115, 116, 118, 120, - 121, 123, 124, 126, 128, 129, 131, 132, 134, 136, - 138, 139, 141, 143, 145, 146, 148, 150, 152, 154, - 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, - 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, - 196, 198, 200, 202, 204, 207, 209, 211, 214, 216, - 218, 220, 223, 225, 228, 230, 232, 235, 237, 240, - 242, 245, 247, 250, 252, 255, - }; +const uint8_t CIE1931_CURVE[256] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, + 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, + 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, + 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, + 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, + 25, 25, 26, 26, 27, 28, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34, + 35, 35, 36, 37, 37, 38, 39, 40, 40, 41, 42, 43, 44, 44, 45, 46, + 47, 48, 49, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, + 79, 80, 82, 83, 84, 85, 87, 88, 89, 90, 92, 93, 94, 96, 97, 99, +100, 101, 103, 104, 106, 107, 108, 110, 111, 113, 114, 116, 118, 119, 121, 122, +124, 125, 127, 129, 130, 132, 134, 135, 137, 139, 141, 142, 144, 146, 148, 149, +151, 153, 155, 157, 159, 161, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, +182, 185, 187, 189, 191, 193, 195, 197, 200, 202, 204, 206, 208, 211, 213, 215, +218, 220, 222, 225, 227, 230, 232, 234, 237, 239, 242, 244, 247, 249, 252, 255 +}; #endif #ifdef USE_LED_BREATHING_TABLE -const uint8_t LED_BREATHING_TABLE[] PROGMEM = { +const uint8_t LED_BREATHING_TABLE[256] PROGMEM = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 9, 10, 11, 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 67, 70, 73, 76, -- cgit v1.2.3-70-g09d2 From 3da8d46a07167fc862e90b6bb232812d5cb64651 Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Thu, 2 May 2019 23:59:29 +0900 Subject: If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin() (#5484) * If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin() * Change rgblight breathing table size to be easily selectable. add RGBLIGHT_BREATHE_TABLE_SIZE macro for customize breathing effect. --- docs/feature_rgblight.md | 2 +- quantum/rgblight.c | 12 ++++ quantum/rgblight.h | 4 +- quantum/rgblight_breathe_table.h | 116 +++++++++++++++++++++++++++++++++++ quantum/template/avr/config.h | 6 ++ util/rgblight_breathing_table_calc.c | 49 +++++++++++++++ 6 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 quantum/rgblight_breathe_table.h create mode 100644 util/rgblight_breathing_table_calc.c (limited to 'quantum') diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index 8b0a45cb6..4572f45b2 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md @@ -114,7 +114,7 @@ The following options can be used to tweak the various animations: |`RGBLIGHT_EFFECT_RGB_TEST` |*Not defined*|If defined, enable RGB test animation mode. | |`RGBLIGHT_EFFECT_ALTERNATING` |*Not defined*|If defined, enable alternating animation mode. | |`RGBLIGHT_ANIMATIONS` |*Not defined*|If defined, enables all additional animation modes | -|`RGBLIGHT_EFFECT_BREATHE_CENTER` |`1.85` |Used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 | +|`RGBLIGHT_EFFECT_BREATHE_CENTER` |*Not defined*|If defined, used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 | |`RGBLIGHT_EFFECT_BREATHE_MAX` |`255` |The maximum brightness for the breathing mode. Valid values are 1 to 255 | |`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation | |`RGBLIGHT_EFFECT_KNIGHT_LENGTH` |`3` |The number of LEDs to light up for the "Knight" animation | diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 98755ff08..77772e292 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -879,6 +879,14 @@ void rgblight_task(void) { // Effects #ifdef RGBLIGHT_EFFECT_BREATHING + +#ifndef RGBLIGHT_EFFECT_BREATHE_CENTER + #ifndef RGBLIGHT_BREATHE_TABLE_SIZE + #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64 + #endif + #include +#endif + __attribute__ ((weak)) const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; @@ -886,7 +894,11 @@ void rgblight_effect_breathing(animation_status_t *anim) { float val; // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ +#ifdef RGBLIGHT_EFFECT_BREATHE_TABLE + val = pgm_read_byte(&rgblight_effect_breathe_table[anim->pos / table_scale]); +#else val = (exp(sin((anim->pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)); +#endif rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); anim->pos = (anim->pos + 1); } diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 9ccb3135c..35d7942ca 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -80,9 +80,7 @@ enum RGBLIGHT_EFFECT_MODE { #define RGBLIGHT_MODES (RGBLIGHT_MODE_last-1) -#ifndef RGBLIGHT_EFFECT_BREATHE_CENTER -#define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1-2.7 -#endif +// sample: #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 #ifndef RGBLIGHT_EFFECT_BREATHE_MAX #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255 diff --git a/quantum/rgblight_breathe_table.h b/quantum/rgblight_breathe_table.h new file mode 100644 index 000000000..7ab8cc947 --- /dev/null +++ b/quantum/rgblight_breathe_table.h @@ -0,0 +1,116 @@ +#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE +#define RGBLIGHT_EFFECT_BREATHE_TABLE + +const uint8_t rgblight_effect_breathe_table[] PROGMEM = { + /* #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 */ + /* #define RGBLIGHT_EFFECT_BREATHE_MAX 255 */ + + #if RGBLIGHT_BREATHE_TABLE_SIZE == 256 + 0x22, 0x23, 0x25, 0x26, 0x28, 0x29, 0x2a, 0x2c, + 0x2d, 0x2f, 0x30, 0x32, 0x33, 0x35, 0x36, 0x38, + 0x3a, 0x3b, 0x3d, 0x3e, 0x40, 0x42, 0x43, 0x45, + 0x47, 0x49, 0x4a, 0x4c, 0x4e, 0x50, 0x51, 0x53, + 0x55, 0x57, 0x59, 0x5a, 0x5c, 0x5e, 0x60, 0x62, + 0x64, 0x66, 0x68, 0x69, 0x6b, 0x6d, 0x6f, 0x71, + 0x73, 0x75, 0x77, 0x79, 0x7b, 0x7d, 0x7f, 0x81, + 0x83, 0x85, 0x87, 0x89, 0x8a, 0x8c, 0x8e, 0x90, + 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, 0x9f, + 0xa1, 0xa3, 0xa5, 0xa7, 0xa8, 0xaa, 0xac, 0xae, + 0xaf, 0xb1, 0xb3, 0xb4, 0xb6, 0xb8, 0xb9, 0xbb, + 0xbc, 0xbe, 0xbf, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6, + 0xc7, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xd0, + 0xd1, 0xd2, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd7, 0xd8, 0xd9, 0xd9, 0xda, 0xda, 0xdb, 0xdb, + 0xdb, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdb, + 0xdb, 0xdb, 0xda, 0xda, 0xd9, 0xd9, 0xd8, 0xd7, + 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd2, 0xd1, + 0xd0, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7, + 0xc6, 0xc5, 0xc3, 0xc2, 0xc1, 0xbf, 0xbe, 0xbc, + 0xbb, 0xb9, 0xb8, 0xb6, 0xb4, 0xb3, 0xb1, 0xaf, + 0xae, 0xac, 0xaa, 0xa8, 0xa7, 0xa5, 0xa3, 0xa1, + 0x9f, 0x9e, 0x9c, 0x9a, 0x98, 0x96, 0x94, 0x92, + 0x90, 0x8e, 0x8c, 0x8a, 0x89, 0x87, 0x85, 0x83, + 0x81, 0x7f, 0x7d, 0x7b, 0x79, 0x77, 0x75, 0x73, + 0x71, 0x6f, 0x6d, 0x6b, 0x69, 0x68, 0x66, 0x64, + 0x62, 0x60, 0x5e, 0x5c, 0x5a, 0x59, 0x57, 0x55, + 0x53, 0x51, 0x50, 0x4e, 0x4c, 0x4a, 0x49, 0x47, + 0x45, 0x43, 0x42, 0x40, 0x3e, 0x3d, 0x3b, 0x3a, + 0x38, 0x36, 0x35, 0x33, 0x32, 0x30, 0x2f, 0x2d, + 0x2c, 0x2a, 0x29, 0x28, 0x26, 0x25, 0x23, 0x22 + #endif /* 256 bytes table */ + + #if RGBLIGHT_BREATHE_TABLE_SIZE == 128 + 0x22, 0x25, 0x28, 0x2a, + 0x2d, 0x30, 0x33, 0x36, + 0x3a, 0x3d, 0x40, 0x43, + 0x47, 0x4a, 0x4e, 0x51, + 0x55, 0x59, 0x5c, 0x60, + 0x64, 0x68, 0x6b, 0x6f, + 0x73, 0x77, 0x7b, 0x7f, + 0x83, 0x87, 0x8a, 0x8e, + 0x92, 0x96, 0x9a, 0x9e, + 0xa1, 0xa5, 0xa8, 0xac, + 0xaf, 0xb3, 0xb6, 0xb9, + 0xbc, 0xbf, 0xc2, 0xc5, + 0xc7, 0xca, 0xcc, 0xce, + 0xd1, 0xd2, 0xd4, 0xd6, + 0xd7, 0xd9, 0xda, 0xdb, + 0xdb, 0xdc, 0xdc, 0xdd, + 0xdd, 0xdc, 0xdc, 0xdc, + 0xdb, 0xda, 0xd9, 0xd8, + 0xd7, 0xd5, 0xd3, 0xd2, + 0xd0, 0xcd, 0xcb, 0xc9, + 0xc6, 0xc3, 0xc1, 0xbe, + 0xbb, 0xb8, 0xb4, 0xb1, + 0xae, 0xaa, 0xa7, 0xa3, + 0x9f, 0x9c, 0x98, 0x94, + 0x90, 0x8c, 0x89, 0x85, + 0x81, 0x7d, 0x79, 0x75, + 0x71, 0x6d, 0x69, 0x66, + 0x62, 0x5e, 0x5a, 0x57, + 0x53, 0x50, 0x4c, 0x49, + 0x45, 0x42, 0x3e, 0x3b, + 0x38, 0x35, 0x32, 0x2f, + 0x2c, 0x29, 0x26, 0x23 + #endif /* 128 bytes table */ + + #if RGBLIGHT_BREATHE_TABLE_SIZE == 64 + 0x22, 0x28, + 0x2d, 0x33, + 0x3a, 0x40, + 0x47, 0x4e, + 0x55, 0x5c, + 0x64, 0x6b, + 0x73, 0x7b, + 0x83, 0x8a, + 0x92, 0x9a, + 0xa1, 0xa8, + 0xaf, 0xb6, + 0xbc, 0xc2, + 0xc7, 0xcc, + 0xd1, 0xd4, + 0xd7, 0xda, + 0xdb, 0xdc, + 0xdd, 0xdc, + 0xdb, 0xd9, + 0xd7, 0xd3, + 0xd0, 0xcb, + 0xc6, 0xc1, + 0xbb, 0xb4, + 0xae, 0xa7, + 0x9f, 0x98, + 0x90, 0x89, + 0x81, 0x79, + 0x71, 0x69, + 0x62, 0x5a, + 0x53, 0x4c, + 0x45, 0x3e, + 0x38, 0x32, + 0x2c, 0x26 + #endif /* 64 bytes table */ +}; + +static const int table_scale = 256/sizeof(rgblight_effect_breathe_table); + +#endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */ diff --git a/quantum/template/avr/config.h b/quantum/template/avr/config.h index a9bb75482..48d7afb14 100644 --- a/quantum/template/avr/config.h +++ b/quantum/template/avr/config.h @@ -77,6 +77,12 @@ along with this program. If not, see . // #define RGBLIGHT_EFFECT_STATIC_GRADIENT // #define RGBLIGHT_EFFECT_RGB_TEST // #define RGBLIGHT_EFFECT_ALTERNATING +// /*== customize breathing effect ==*/ +// /*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/ +// #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64 +// /*==== use exp() and sin() ====*/ +// #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7 +// #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255 // #endif /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ diff --git a/util/rgblight_breathing_table_calc.c b/util/rgblight_breathing_table_calc.c new file mode 100644 index 000000000..fc4d49ea5 --- /dev/null +++ b/util/rgblight_breathing_table_calc.c @@ -0,0 +1,49 @@ +// +// calculate rgblight_effect_breathe_table[] values +// +// this is host program for quantum/rgblight.c:void rgblight_effect_breathing(); +// +// example: +// $ edit util/rgblight_breathing_table_calc.c +// $ cc -o util/rgblight_breathing_table_calc util/rgblight_breathing_table_calc.c +// $ ./util/rgblight_breathing_table_calc > keyboards/KEYBOARD_NAME/keymaps/KEYMAP_NAME/rgblight_breathe_table.h +// +#include +#include +#include + +/// customize breeathing effect part /////////////////////////// +#define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7 +#define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255 +//////////////////////////////////////////////////////////////// + +int main(void) { + int pos, step; + int table[256]; + for (pos = 0; pos < 256; pos ++ ) { + table[pos] = (uint8_t)( + (exp(sin((pos/255.0)*M_PI))- RGBLIGHT_EFFECT_BREATHE_CENTER/M_E) + * (RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)) + ); + } + printf("#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE\n"); + printf("#define RGBLIGHT_EFFECT_BREATHE_TABLE\n\n"); + printf("const uint8_t rgblight_effect_breathe_table[] PROGMEM = {\n"); + printf(" /* #define RGBLIGHT_EFFECT_BREATHE_CENTER %.2f */\n", RGBLIGHT_EFFECT_BREATHE_CENTER); + printf(" /* #define RGBLIGHT_EFFECT_BREATHE_MAX %d */\n", RGBLIGHT_EFFECT_BREATHE_MAX); + + for (int s = 0, step = (1<=256?"":"," ); + if ((pos+step) % 8 == 0) + printf("\n"); + } + printf(" #endif /* %d bytes table */\n", s == 0 ? 256:(s== 1 ? 128: 64)); + } + printf("};\n"); + printf("\nstatic const int table_scale = 256/sizeof(rgblight_effect_breathe_table);\n"); + printf("\n#endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */\n"); + return 0; +} -- cgit v1.2.3-70-g09d2 From 41beecfc1847bd0039c508753a212fa18f207e3f Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 3 May 2019 08:24:22 -0700 Subject: Add DFU Suffix for ARM boards (#5763) * Add DFU Suffix for ARM boards * Blindly flash DFU SUFFIX ARGS for now * Fix commented out check * Fix DFU Suffix Argument check Thank you jack! * Update Travis CI Scripts to include dfu-util So we can get dfu-suffix as well * Manually add dfu-suffix package * Use external repo for newer version of dfu-util One that includes dfu-suffix * Update .travis.yml * Silence unnecessary output from dfu-suffix --- .travis.yml | 4 ++++ keyboards/candybar/rules.mk | 1 + keyboards/clueboard/60/rules.mk | 1 + keyboards/clueboard/66/rev4/rules.mk | 1 + keyboards/clueboard/66_hotswap/gen1/rules.mk | 1 + keyboards/dztech/dz40rgb/rules.mk | 1 + keyboards/dztech/dz60rgb/rules.mk | 1 + keyboards/ergodox_infinity/rules.mk | 1 + keyboards/hs60/v2/keymaps/ansi_via/rules.mk | 1 + keyboards/hs60/v2/keymaps/default_via/rules.mk | 1 + keyboards/hs60/v2/keymaps/goatmaster/rules.mk | 1 + keyboards/hs60/v2/keymaps/hhkb_via/rules.mk | 1 + keyboards/hs60/v2/keymaps/iso_andys8/rules.mk | 1 + keyboards/hs60/v2/keymaps/stanrc85/rules.mk | 1 + keyboards/hs60/v2/keymaps/win_osx_dual/rules.mk | 1 + keyboards/hs60/v2/rules.mk | 1 + keyboards/infinity60/rules.mk | 1 + keyboards/k_type/rules.mk | 1 + keyboards/vinta/rules.mk | 1 + keyboards/whitefox/rules.mk | 1 + quantum/mcu_selection.mk | 1 + quantum/stm32/proton_c.mk | 1 + tmk_core/chibios.mk | 5 +++++ 23 files changed, 30 insertions(+) (limited to 'quantum') diff --git a/.travis.yml b/.travis.yml index a50b205ec..796be6c04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,14 @@ env: - MAKEFLAGS="-j3 --output-sync" before_install: - wget http://ww1.microchip.com/downloads/en/DeviceDoc/avr8-gnu-toolchain-3.5.4.1709-linux.any.x86_64.tar.gz || wget http://qmk.fm/avr8-gnu-toolchain-3.5.4.1709-linux.any.x86_64.tar.gz + # Need DFU > .5 for dfu-suffix + - sudo add-apt-repository --yes ppa:tormodvolden/ppa + - sudo apt-get update -qq install: - tar -zxf avr8-gnu-toolchain-3.5.4.1709-linux.any.x86_64.tar.gz - export PATH="$PATH:$TRAVIS_BUILD_DIR/avr8-gnu-toolchain-linux_x86_64/bin" - npm install -g moxygen + - sudo apt-get -y --force-yes install dfu-util before_script: - avr-gcc --version script: diff --git a/keyboards/candybar/rules.mk b/keyboards/candybar/rules.mk index 6f39ee0e7..0bc9a5b3e 100644 --- a/keyboards/candybar/rules.mk +++ b/keyboards/candybar/rules.mk @@ -31,6 +31,7 @@ OPT_DEFS = # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/clueboard/60/rules.mk b/keyboards/clueboard/60/rules.mk index aada07352..a0927025b 100644 --- a/keyboards/clueboard/60/rules.mk +++ b/keyboards/clueboard/60/rules.mk @@ -35,6 +35,7 @@ OPT_DEFS = # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/clueboard/66/rev4/rules.mk b/keyboards/clueboard/66/rev4/rules.mk index 846b1eee0..4d20ff2e9 100644 --- a/keyboards/clueboard/66/rev4/rules.mk +++ b/keyboards/clueboard/66/rev4/rules.mk @@ -13,6 +13,7 @@ OPT_DEFS = # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/clueboard/66_hotswap/gen1/rules.mk b/keyboards/clueboard/66_hotswap/gen1/rules.mk index 6b1ee92c1..326912a34 100644 --- a/keyboards/clueboard/66_hotswap/gen1/rules.mk +++ b/keyboards/clueboard/66_hotswap/gen1/rules.mk @@ -37,6 +37,7 @@ OPT_DEFS = # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # LED Configuration LED_MATRIX_ENABLE = IS31FL3731 diff --git a/keyboards/dztech/dz40rgb/rules.mk b/keyboards/dztech/dz40rgb/rules.mk index 99cbafb8c..d0ddec838 100644 --- a/keyboards/dztech/dz40rgb/rules.mk +++ b/keyboards/dztech/dz40rgb/rules.mk @@ -40,6 +40,7 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/dztech/dz60rgb/rules.mk b/keyboards/dztech/dz60rgb/rules.mk index 98e95c88d..20ca7f2eb 100644 --- a/keyboards/dztech/dz60rgb/rules.mk +++ b/keyboards/dztech/dz60rgb/rules.mk @@ -35,6 +35,7 @@ OPT_DEFS = # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 BACKLIGHT_ENABLE = no diff --git a/keyboards/ergodox_infinity/rules.mk b/keyboards/ergodox_infinity/rules.mk index 1cc95193c..af8e9ef20 100644 --- a/keyboards/ergodox_infinity/rules.mk +++ b/keyboards/ergodox_infinity/rules.mk @@ -59,6 +59,7 @@ OPT_DEFS += -DCORTEX_VTOR_INIT=0x00002000 # DFU_ARGS = -d 1c11:b007 +DFU_SUFFIX_ARGS = -p b007 -v 1c11 BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = yes # Mouse keys(+4700) diff --git a/keyboards/hs60/v2/keymaps/ansi_via/rules.mk b/keyboards/hs60/v2/keymaps/ansi_via/rules.mk index a2850a830..deb4fc889 100644 --- a/keyboards/hs60/v2/keymaps/ansi_via/rules.mk +++ b/keyboards/hs60/v2/keymaps/ansi_via/rules.mk @@ -45,6 +45,7 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/hs60/v2/keymaps/default_via/rules.mk b/keyboards/hs60/v2/keymaps/default_via/rules.mk index a2850a830..deb4fc889 100644 --- a/keyboards/hs60/v2/keymaps/default_via/rules.mk +++ b/keyboards/hs60/v2/keymaps/default_via/rules.mk @@ -45,6 +45,7 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/hs60/v2/keymaps/goatmaster/rules.mk b/keyboards/hs60/v2/keymaps/goatmaster/rules.mk index a2850a830..deb4fc889 100644 --- a/keyboards/hs60/v2/keymaps/goatmaster/rules.mk +++ b/keyboards/hs60/v2/keymaps/goatmaster/rules.mk @@ -45,6 +45,7 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/hs60/v2/keymaps/hhkb_via/rules.mk b/keyboards/hs60/v2/keymaps/hhkb_via/rules.mk index a2850a830..deb4fc889 100644 --- a/keyboards/hs60/v2/keymaps/hhkb_via/rules.mk +++ b/keyboards/hs60/v2/keymaps/hhkb_via/rules.mk @@ -45,6 +45,7 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/hs60/v2/keymaps/iso_andys8/rules.mk b/keyboards/hs60/v2/keymaps/iso_andys8/rules.mk index a2850a830..deb4fc889 100644 --- a/keyboards/hs60/v2/keymaps/iso_andys8/rules.mk +++ b/keyboards/hs60/v2/keymaps/iso_andys8/rules.mk @@ -45,6 +45,7 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/hs60/v2/keymaps/stanrc85/rules.mk b/keyboards/hs60/v2/keymaps/stanrc85/rules.mk index c46a6b952..817785d7a 100644 --- a/keyboards/hs60/v2/keymaps/stanrc85/rules.mk +++ b/keyboards/hs60/v2/keymaps/stanrc85/rules.mk @@ -45,6 +45,7 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/hs60/v2/keymaps/win_osx_dual/rules.mk b/keyboards/hs60/v2/keymaps/win_osx_dual/rules.mk index c89d90969..05193af4b 100644 --- a/keyboards/hs60/v2/keymaps/win_osx_dual/rules.mk +++ b/keyboards/hs60/v2/keymaps/win_osx_dual/rules.mk @@ -45,6 +45,7 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/hs60/v2/rules.mk b/keyboards/hs60/v2/rules.mk index 5659d28c9..64948c2e9 100644 --- a/keyboards/hs60/v2/rules.mk +++ b/keyboards/hs60/v2/rules.mk @@ -45,6 +45,7 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/infinity60/rules.mk b/keyboards/infinity60/rules.mk index 8cb2b3755..1f02e05c8 100644 --- a/keyboards/infinity60/rules.mk +++ b/keyboards/infinity60/rules.mk @@ -58,6 +58,7 @@ OPT_DEFS = -DCORTEX_VTOR_INIT=0x00001000 # DFU_ARGS = -d 1c11:b007 +DFU_SUFFIX_ARGS = -p b007 -v 1c11 BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration ## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.) diff --git a/keyboards/k_type/rules.mk b/keyboards/k_type/rules.mk index a1c56903b..7762f1868 100644 --- a/keyboards/k_type/rules.mk +++ b/keyboards/k_type/rules.mk @@ -57,6 +57,7 @@ ARMV = 7 OPT_DEFS = DFU_ARGS = -d 1c11:b007 +DFU_SUFFIX_ARGS = -p b007 -v 1c11 # Build Options # comment out to disable the options. diff --git a/keyboards/vinta/rules.mk b/keyboards/vinta/rules.mk index 9d89d9663..3ddb8d5bc 100644 --- a/keyboards/vinta/rules.mk +++ b/keyboards/vinta/rules.mk @@ -33,6 +33,7 @@ OPT_DEFS = # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p DF11 -v 0483 # Build Options # comment out to disable the options. diff --git a/keyboards/whitefox/rules.mk b/keyboards/whitefox/rules.mk index 9f222bf4f..d9aa911c5 100644 --- a/keyboards/whitefox/rules.mk +++ b/keyboards/whitefox/rules.mk @@ -55,6 +55,7 @@ ARMV = 7 OPT_DEFS = DFU_ARGS = -d 1c11:b007 +DFU_SUFFIX_ARGS = -p b007 -v 1c11 # Build Options # comment out to disable the options. diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk index 209b578ea..fa6dc8b53 100644 --- a/quantum/mcu_selection.mk +++ b/quantum/mcu_selection.mk @@ -34,6 +34,7 @@ ifneq ($(findstring STM32F303, $(MCU)),) # Options to pass to dfu-util when flashing DFU_ARGS ?= -d 0483:df11 -a 0 -s 0x08000000:leave + DFU_SUFFIX_ARGS = -p DF11 -v 0483 endif ifneq (,$(filter $(MCU),atmega32u4 at90usb1286)) diff --git a/quantum/stm32/proton_c.mk b/quantum/stm32/proton_c.mk index a0fa01373..a65e283d3 100644 --- a/quantum/stm32/proton_c.mk +++ b/quantum/stm32/proton_c.mk @@ -42,3 +42,4 @@ OPT_DEFS = # Options to pass to dfu-util when flashing DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave +DFU_SUFFIX_ARGS = -p df11 -v 0483 diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk index 01edebfd7..44c00bdd1 100644 --- a/tmk_core/chibios.mk +++ b/tmk_core/chibios.mk @@ -201,6 +201,7 @@ DFU_ARGS ?= ifneq ("$(SERIAL)","") DFU_ARGS += -S $(SERIAL) endif +DFU_SUFFIX_ARGS ?= ST_LINK_ARGS ?= @@ -208,6 +209,7 @@ ST_LINK_ARGS ?= EXTRALIBDIRS = $(RULESPATH)/ld DFU_UTIL ?= dfu-util +DFU_SUFFIX ?= dfu-suffix ST_LINK_CLI ?= st-link_cli # Generate a .qmk for the QMK-FF @@ -259,4 +261,7 @@ st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter $(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst bin: $(BUILD_DIR)/$(TARGET).bin sizeafter + if [ ! -z "$(DFU_SUFFIX_ARGS)" ]; then \ + $(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\ + fi $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin; -- cgit v1.2.3-70-g09d2 From bdc8d89e6b8f49528b716d9bd3343a4f9e9327bd Mon Sep 17 00:00:00 2001 From: Konstantin Đorđević Date: Fri, 3 May 2019 18:33:00 +0200 Subject: New keycode macro (XP) for shifted character pairs using UNICODEMAP + bug fixes and improvements (#4803) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Expose unicode_saved_mods * Add UNICODEMAP shift pair functionality and XS keycode * Add XS to keycode reference documentation * Pick pair index based on both Shift and Caps Lock state * Add XS to Unicode feature docs * Clean up process_unicode* headers * Extract unicode_map index calculation into function * Pick pair index as XOR rather than OR of Shift and Caps states * unicode_input_start() has to be called before the unicode_map index is calculated * Replace unicodemap_input_error() with more generic unicode_input_cancel() * Replace register+tap+unregister with tap_code16(LCTL(LSFT(KC_U))) * UNICODE_OSX_KEY → UNICODE_KEY_OSX, UNICODE_WINC_KEY → UNICODE_KEY_WINC * Make keycode range checks more robust * Fix keycode range checks for different input modes * Add UNICODE_KEY_LNX, update docs * QK_UNICODEMAP_SHIFT → QK_UNICODEMAP_PAIR * XS → XP, update docs * Tweak Unicode docs * Use recently added MOD_MASK_SHIFT and IS_HOST_LED_ON helpers * Update Unicode table in docs/keycodes.md * Update Unicode docs per review comments * Replace references to Mac OS X with macOS in Unicode docs * As of v0.9.0, WinCompose supports all possible code points * Expand descriptions in XP docs * Update keycode table and cycling docs * Further expand cycling docs --- docs/feature_unicode.md | 83 +++++++++++++++--------- docs/keycodes.md | 16 +++-- quantum/process_keycode/process_unicode.c | 6 +- quantum/process_keycode/process_unicode.h | 2 +- quantum/process_keycode/process_unicode_common.c | 38 +++++++---- quantum/process_keycode/process_unicode_common.h | 13 ++-- quantum/process_keycode/process_unicodemap.c | 36 ++++++---- quantum/process_keycode/process_unicodemap.h | 4 +- quantum/quantum_keycodes.h | 7 +- users/konstantin/config.h | 2 +- 10 files changed, 133 insertions(+), 74 deletions(-) (limited to 'quantum') diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 1bc3c89d2..778cdc69c 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -4,11 +4,11 @@ There are three Unicode keymap definition methods available in QMK: ## `UNICODE_ENABLE` -Supports Unicode up to `0x7FFF`. This covers characters for most modern languages, as well as symbols, but it doesn't cover emoji. The keycode function is `UC(c)` in the keymap file, where _c_ is the code point's number (preferably hexadecimal, up to 4 digits long). For example: `UC(0x45B)`, `UC(0x30C4)`. +Supports Unicode up to `0x7FFF`. This covers characters for most modern languages, as well as symbols, but it doesn't cover emoji. The keycode function is `UC(c)` in the keymap, where _c_ is the code point's number (preferably hexadecimal, up to 4 digits long). For example: `UC(0x45B)`, `UC(0x30C4)`. ## `UNICODEMAP_ENABLE` -Supports Unicode up to `0x10FFFF` (all possible code points). You need to maintain a separate mapping table `const uint32_t PROGMEM unicode_map[] = {...}` in your keymap file. The keycode function is `X(i)`, where _i_ is an array index into the mapping table. The table may contain at most 1024 entries. +Supports Unicode up to `0x10FFFF` (all possible code points). You need to maintain a separate mapping table `const uint32_t PROGMEM unicode_map[] = {...}` in your keymap file. The keycode function is `X(i)`, where _i_ is an array index into the mapping table. The table may contain at most 16384 entries. You may want to have an enum to make referencing easier. So, you could add something like this to your keymap file: @@ -26,13 +26,21 @@ const uint32_t PROGMEM unicode_map[] = { }; ``` -Then you can use `X(BANG)` etc. in your keymap. +Then you can use `X(BANG)`, `X(SNEK)` etc. in your keymap. + +### Lower and Upper Case + +Characters often come in lower and upper case pairs, for example: å, Å. To make inputting these characters easier, you can use `XP(i, j)` in your keymap, where _i_ and _j_ are the mapping table indices of the lower and upper case character, respectively. If you're holding down Shift or have Caps Lock turned on when you press the key, the second (upper case) character will be inserted; otherwise, the first (lower case) version will appear. + +This is most useful when creating a keymap for an international layout with special characters. Instead of having to put the lower and upper case versions of a character on separate keys, you can have them both on the same key by using `XP`. This blends Unicode keys in with regular alphas. + +Due to keycode size constraints, _i_ and _j_ can each only refer to one of the first 128 characters in your `unicode_map`. In other words, 0 ≤ _i_ ≤ 127 and 0 ≤ _j_ ≤ 127. This is enough for most use cases, but if you'd like to customize the index calculation, you can override the [`unicodemap_index()`](https://github.com/qmk/qmk_firmware/blob/71f640d47ee12c862c798e1f56392853c7b1c1a8/quantum/process_keycode/process_unicodemap.c#L40) function. This also allows you to, say, check Ctrl instead of Shift/Caps. ## `UCIS_ENABLE` -Supports Unicode up to `0x10FFFF` (all possible code points). As with `UNICODEMAP`, you need to maintain a mapping table in your keymap file. However, there are no built-in keycodes for this feature — you will have to add a keycode or function that calls `qk_ucis_start()`. Once this function's been called, you can type the corresponding mnemonic for your character, then hit Space or Enter to complete it, or Esc to cancel. If the mnemonic matches an entry in your table, the typed text will automatically be erased and the corresponding Unicode character inserted. +Supports Unicode up to `0x10FFFF` (all possible code points). As with `UNICODEMAP`, you need to maintain a mapping table in your keymap file. However, there are no built-in keycodes for this feature — you have to add a keycode or function that calls `qk_ucis_start()`. Once this function has been called, you can type the corresponding mnemonic for your character, then hit Space or Enter to complete it, or Esc to cancel. If the mnemonic matches an entry in your table, the typed text will automatically be erased and the corresponding Unicode character inserted. -For instance, you would define a table like this in your keymap file: +For instance, you could define a table like this in your keymap file: ```c const qk_ucis_symbol_t ucis_symbol_table[] = UCIS_TABLE( @@ -42,7 +50,7 @@ const qk_ucis_symbol_t ucis_symbol_table[] = UCIS_TABLE( ); ``` -You call `qk_ucis_start()`, then type "rofl" and hit Enter. QMK should erase the "rofl" text and input the laughing emoji. +To use it, call `qk_ucis_start()`, then type "rofl" and hit Enter. QMK should erase the "rofl" text and insert the laughing emoji. ### Customization @@ -60,28 +68,29 @@ Unicode input in QMK works by inputting a sequence of characters to the OS, sort The following input modes are available: -* **`UC_OSX`**: Mac OS X built-in Unicode hex input. Supports code points up to `0xFFFF` (`0x10FFFF` with `UNICODEMAP`). +* **`UC_OSX`**: macOS built-in Unicode hex input. Supports code points up to `0xFFFF` (`0x10FFFF` with `UNICODEMAP`). To enable, go to _System Preferences > Keyboard > Input Sources_, add _Unicode Hex Input_ to the list (it's under _Other_), then activate it from the input dropdown in the Menu Bar. - By default, this mode uses the left Option key (`KC_LALT`), but this can be changed by defining [`UNICODE_OSX_KEY`](#input-key-configuration) with another keycode. + By default, this mode uses the left Option key (`KC_LALT`) for Unicode input, but this can be changed by defining [`UNICODE_KEY_OSX`](#input-key-configuration) with another keycode. - **Note:** Using the _Unicode Hex Input_ input source may disable some Option based shortcuts, such as: Option + Left Arrow (`moveWordLeftAndModifySelection`) and Option + Right Arrow (`moveWordRightAndModifySelection`). + !> Using the _Unicode Hex Input_ input source may disable some Option based shortcuts, such as Option + Left Arrow and Option + Right Arrow. * **`UC_LNX`**: Linux built-in IBus Unicode input. Supports code points up to `0x10FFFF` (all possible code points). Enabled by default and works almost anywhere on IBus-enabled distros. Without IBus, this mode works under GTK apps, but rarely anywhere else. + By default, this mode uses Ctrl+Shift+U (`LCTL(LSFT(KC_U))`) to start Unicode input, but this can be changed by defining [`UNICODE_KEY_LNX`](#input-key-configuration) with another keycode. This might be required for IBus versions ≥1.5.15, where Ctrl+Shift+U behavior is consolidated into Ctrl+Shift+E. * **`UC_WIN`**: _(not recommended)_ Windows built-in hex numpad Unicode input. Supports code points up to `0xFFFF`. - To enable, create a registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad` and set its value to `1`. This can be done from the Command Prompt by running `reg add "HKCU\Control Panel\Input Method" -v EnableHexNumpad -t REG_SZ -d 1` with administrator privileges. Afterwards, reboot. + To enable, create a registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad` and set its value to `1`. This can be done from the Command Prompt by running `reg add "HKCU\Control Panel\Input Method" -v EnableHexNumpad -t REG_SZ -d 1` with administrator privileges. Reboot afterwards. This mode is not recommended because of reliability and compatibility issues; use the `UC_WINC` mode instead. * **`UC_BSD`**: _(non implemented)_ Unicode input under BSD. Not implemented at this time. If you're a BSD user and want to help add support for it, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues). -* **`UC_WINC`**: Windows Unicode input using [WinCompose](https://github.com/samhocevar/wincompose). As of v0.8.2, supports code points up to `0xFFFFF` (all currently assigned code points). +* **`UC_WINC`**: Windows Unicode input using [WinCompose](https://github.com/samhocevar/wincompose). As of v0.9.0, supports code points up to `0x10FFFF` (all possible code points). To enable, install the [latest release](https://github.com/samhocevar/wincompose/releases/latest). Once installed, WinCompose will automatically run on startup. Works reliably under all version of Windows supported by the app. - By default, this mode uses the right Alt key (`KC_RALT`), but this can be changed in the WinCompose settings and by defining [`UNICODE_WINC_KEY`](#input-key-configuration) with another keycode. + By default, this mode uses right Alt (`KC_RALT`) as the Compose key, but this can be changed in the WinCompose settings and by defining [`UNICODE_KEY_WINC`](#input-key-configuration) with another keycode. ### Switching Input Modes @@ -89,17 +98,17 @@ There are two ways to set the input mode for Unicode: by keycode or by function. You can switch the input mode at any time by using one of the following keycodes. The easiest way is to add the ones you use to your keymap. -|Keycode |Alias |Input mode |Description | -|-----------------------|---------|-------------|-----------------------------------------| -|`UNICODE_MODE_FORWARD` |`UC_MOD` | |Cycles forwards through the available modes. [(Disabled by default)](#input-method-cycling)| -|`UNICODE_MODE_REVERSE` |`UC_RMOD`| |Cycles forwards through the available modes. [(Disabled by default)](#input-method-cycling)| -|`UNICODE_MODE_OSX` |`UC_M_OS`|`UC_OSX` |Switch to Mac OS X input. | -|`UNICODE_MODE_LNX` |`UC_M_LN`|`UC_LNX` |Switch to Linux input. | -|`UNICODE_MODE_WIN` |`UC_M_WI`|`UC_WIN` |Switch to Windows input. | -|`UNICODE_MODE_BSD` |`UC_M_BS`|`UC_BSD` |Switch to BSD input (not implemented). | -|`UNICODE_MODE_WINC` |`UC_M_WC`|`UC_WINC` |Switch to Windows input using WinCompose.| +|Keycode |Alias |Input Mode |Description | +|----------------------|---------|------------|--------------------------------------------------------------| +|`UNICODE_MODE_FORWARD`|`UC_MOD` |Next in list|[Cycle](#input-mode-cycling) through selected modes | +|`UNICODE_MODE_REVERSE`|`UC_RMOD`|Prev in list|[Cycle](#input-mode-cycling) through selected modes in reverse| +|`UNICODE_MODE_OSX` |`UC_M_OS`|`UC_OSX` |Switch to macOS input | +|`UNICODE_MODE_LNX` |`UC_M_LN`|`UC_LNX` |Switch to Linux input | +|`UNICODE_MODE_WIN` |`UC_M_WI`|`UC_WIN` |Switch to Windows input | +|`UNICODE_MODE_BSD` |`UC_M_BS`|`UC_BSD` |Switch to BSD input (not implemented) | +|`UNICODE_MODE_WINC` |`UC_M_WC`|`UC_WINC` |Switch to Windows input using WinCompose | -You can also switch the input mode by calling `set_unicode_input_mode(x)` in your code, where _x_ is one of the above input mode constants (e.g. `UC_LNX`). Since the function only needs to be called once, it's recommended that you do it in `eeconfig_init_user` (or a similar function). For example: +You can also switch the input mode by calling `set_unicode_input_mode(x)` in your code, where _x_ is one of the above input mode constants (e.g. `UC_LNX`). Since the function only needs to be called once, it's recommended that you do it in `eeconfig_init_user()` (or a similar function). For example: ```c void eeconfig_init_user(void) { @@ -123,35 +132,45 @@ For instance, you can add these definitions to your `config.h` file: ### Additional Customization -Because Unicode is such a large and variable feature, there are a number of options that you can customize to work better on your system. +Because Unicode is a large and versatile feature, there are a number of options you can customize to make it work better on your system. -#### Start and Finish input functions +#### Start and Finish Input Functions The functions for starting and finishing Unicode input on your platform can be overridden locally. Possible uses include customizing input mode behavior if you don't use the default keys, or adding extra visual/audio feedback to Unicode input. -* `void unicode_input_start(void)` – This sends the initial sequence that tells your platform to enter Unicode input mode. For example, it presses Ctrl+Shift+U on Linux and holds the Option key on Mac. +* `void unicode_input_start(void)` – This sends the initial sequence that tells your platform to enter Unicode input mode. For example, it presses Ctrl+Shift+U on Linux and holds the Option key on macOS. * `void unicode_input_finish(void)` – This is called to exit Unicode input mode, for example by pressing Space or releasing the Option key. You can find the default implementations of these functions in [`process_unicode_common.c`](https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_unicode_common.c). - #### Input Key Configuration -Additionally, you can customize the keys used to trigger the unicode input for macOS and WinCompose by adding defines to your `config.h` +You can customize the keys used to trigger Unicode input for macOS, Linux and WinCompose by adding corresponding defines to your `config.h`. The default values match the platforms' default settings, so you shouldn't need to change this unless Unicode input isn't working, or you want to use a different key (e.g. in order to free up left or right Alt). + +|Define |Type |Default |Example | +|------------------|----------|------------------|-------------------------------------------| +|`UNICODE_KEY_OSX` |`uint8_t` |`KC_LALT` |`#define UNICODE_KEY_OSX KC_RALT` | +|`UNICODE_KEY_LNX` |`uint16_t`|`LCTL(LSFT(KC_U))`|`#define UNICODE_KEY_LNX LCTL(LSFT(KC_E))`| +|`UNICODE_KEY_WINC`|`uint8_t` |`KC_RALT` |`#define UNICODE_KEY_WINC KC_RGUI` | + +#### Input Mode Cycling + +You can choose which input modes are available for cycling through. By default, this is disabled. If you want to enable it, limiting it to just the modes you use makes sense. Note that the values in the list are comma-delimited. ```c -#define UNICODE_OSX_KEY KC_LALT -#define UNICODE_WINC_KEY KC_RALT +#define UNICODE_SELECTED_MODES UC_OSX, UC_LNX, UC_WIN, UC_WINC ``` -#### Input Method Cycling +You can cycle through the selected modes by using the `UC_MOD`/`UC_RMOD` keycodes, or by calling `cycle_unicode_input_mode(offset)` in your code (`offset` is how many modes to move forward by, so +1 corresponds to `UC_MOD`). -Also, you can choose which input methods are availble for cycling through. By default, this is disabled. But if you want to enabled it, then limiting it to just those modes makes sense. Note that `UNICODE_SELECTED_MODES` define is comma delimited. +By default, when the keyboard boots, it will initialize the input mode to the last one you used. You can disable this and make it start with the first mode in the list every time by adding the following to your `config.h`: ```c -#define UNICODE_SELECTED_MODES UC_OSX, UC_LNX, UC_WIN, UC_BSD, UC_WINC +#define UNICODE_CYCLE_PERSIST false ``` +!> Using `UNICODE_SELECTED_MODES` means you don't have to initially set the input mode in `matrix_init_user()` (or a similar function); the Unicode system will do that for you on startup. This has the added benefit of avoiding unnecessary writes to EEPROM. + ## `send_unicode_hex_string` To type multiple characters for things like (ノಠ痊ಠ)ノ彡┻━┻, you can use `send_unicode_hex_string()` much like `SEND_STRING()` except you would use hex values separate by spaces. diff --git a/docs/keycodes.md b/docs/keycodes.md index 91578414d..c0e6aa5c6 100644 --- a/docs/keycodes.md +++ b/docs/keycodes.md @@ -450,7 +450,15 @@ This is a reference only. Each group of keys links to the page documenting their ## [Unicode Support](feature_unicode.md) -|Key |Description | -|-------|---------------------------------------------------------------------------| -|`UC(c)`|Send Unicode code point `c` (`UNICODE_ENABLE`) | -|`X(i)` |Send Unicode code point at index `i` in `unicode_map` (`UNICODEMAP_ENABLE`)| +|Key |Aliases |Description | +|----------------------|---------|----------------------------------------------------------------| +|`UC(c)` | |Send Unicode code point `c` | +|`X(i)` | |Send Unicode code point at index `i` in `unicode_map` | +|`XP(i, j)` | |Send Unicode code point at index `i`, or `j` if Shift/Caps is on| +|`UNICODE_MODE_FORWARD`|`UC_MOD` |Cycle through selected input modes | +|`UNICODE_MODE_REVERSE`|`UC_RMOD`|Cycle through selected input modes in reverse | +|`UNICODE_MODE_OSX` |`UC_M_OS`|Switch to macOS input | +|`UNICODE_MODE_LNX` |`UC_M_LN`|Switch to Linux input | +|`UNICODE_MODE_WIN` |`UC_M_WI`|Switch to Windows input | +|`UNICODE_MODE_BSD` |`UC_M_BS`|Switch to BSD input (not implemented) | +|`UNICODE_MODE_WINC` |`UC_M_WC`|Switch to Windows input using WinCompose | diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 19beb8452..2c914013a 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -13,15 +13,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #include "process_unicode.h" #include "action_util.h" #include "eeprom.h" bool process_unicode(uint16_t keycode, keyrecord_t *record) { - if (keycode > QK_UNICODE && record->event.pressed) { - uint16_t unicode = keycode & 0x7FFF; + if (keycode >= QK_UNICODE && keycode <= QK_UNICODE_MAX && record->event.pressed) { unicode_input_start(); - register_hex(unicode); + register_hex(keycode & 0x7FFF); unicode_input_finish(); } return true; diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index 0913e9910..22765ad56 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h @@ -13,9 +13,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #pragma once -#include "quantum.h" #include "process_unicode_common.h" bool process_unicode(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index d0a9cf232..21ac2291d 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -20,6 +20,8 @@ #include unicode_config_t unicode_config; +uint8_t unicode_saved_mods; + #if UNICODE_SELECTED_MODES != -1 static uint8_t selected[] = { UNICODE_SELECTED_MODES }; static uint8_t selected_count = sizeof selected / sizeof *selected; @@ -75,30 +77,24 @@ void persist_unicode_input_mode(void) { eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); } -static uint8_t saved_mods; - __attribute__((weak)) void unicode_input_start(void) { - saved_mods = get_mods(); // Save current mods + unicode_saved_mods = get_mods(); // Save current mods clear_mods(); // Unregister mods to start from a clean state switch (unicode_config.input_mode) { case UC_OSX: - register_code(UNICODE_OSX_KEY); + register_code(UNICODE_KEY_OSX); break; case UC_LNX: - register_code(KC_LCTL); - register_code(KC_LSFT); - tap_code(KC_U); // TODO: Replace with tap_code16(LCTL(LSFT(KC_U))); and test - unregister_code(KC_LSFT); - unregister_code(KC_LCTL); + tap_code16(UNICODE_KEY_LNX); break; case UC_WIN: register_code(KC_LALT); tap_code(KC_PPLS); break; case UC_WINC: - tap_code(UNICODE_WINC_KEY); + tap_code(UNICODE_KEY_WINC); tap_code(KC_U); break; } @@ -110,7 +106,7 @@ __attribute__((weak)) void unicode_input_finish(void) { switch (unicode_config.input_mode) { case UC_OSX: - unregister_code(UNICODE_OSX_KEY); + unregister_code(UNICODE_KEY_OSX); break; case UC_LNX: tap_code(KC_SPC); @@ -123,7 +119,25 @@ void unicode_input_finish(void) { break; } - set_mods(saved_mods); // Reregister previously set mods + set_mods(unicode_saved_mods); // Reregister previously set mods +} + +__attribute__((weak)) +void unicode_input_cancel(void) { + switch (unicode_config.input_mode) { + case UC_OSX: + unregister_code(UNICODE_KEY_OSX); + break; + case UC_LNX: + case UC_WINC: + tap_code(KC_ESC); + break; + case UC_WIN: + unregister_code(KC_LALT); + break; + } + + set_mods(unicode_saved_mods); // Reregister previously set mods } __attribute__((weak)) diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index e608ab76b..7340800e5 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -23,11 +23,14 @@ #endif // Keycodes used for starting Unicode input on different platforms -#ifndef UNICODE_OSX_KEY - #define UNICODE_OSX_KEY KC_LALT +#ifndef UNICODE_KEY_OSX + #define UNICODE_KEY_OSX KC_LALT #endif -#ifndef UNICODE_WINC_KEY - #define UNICODE_WINC_KEY KC_RALT +#ifndef UNICODE_KEY_LNX + #define UNICODE_KEY_LNX LCTL(LSFT(KC_U)) +#endif +#ifndef UNICODE_KEY_WINC + #define UNICODE_KEY_WINC KC_RALT #endif // Comma-delimited, ordered list of input modes selected for use (e.g. in cycle) @@ -63,6 +66,7 @@ typedef union { } unicode_config_t; extern unicode_config_t unicode_config; +extern uint8_t unicode_saved_mods; void unicode_input_mode_init(void); uint8_t get_unicode_input_mode(void); @@ -72,6 +76,7 @@ void persist_unicode_input_mode(void); void unicode_input_start(void); void unicode_input_finish(void); +void unicode_input_cancel(void); void register_hex(uint16_t hex); void send_unicode_hex_string(const char *str); diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index 327402761..b88787986 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c @@ -15,7 +15,6 @@ */ #include "process_unicodemap.h" -#include "process_unicode_common.h" void register_hex32(uint32_t hex) { bool onzerostart = true; @@ -38,28 +37,39 @@ void register_hex32(uint32_t hex) { } __attribute__((weak)) -void unicodemap_input_error() {} +uint16_t unicodemap_index(uint16_t keycode) { + if (keycode >= QK_UNICODEMAP_PAIR) { + // Keycode is a pair: extract index based on Shift / Caps Lock state + uint16_t index = keycode - QK_UNICODEMAP_PAIR; + + bool shift = unicode_saved_mods & MOD_MASK_SHIFT, caps = IS_HOST_LED_ON(USB_LED_CAPS_LOCK); + if (shift ^ caps) { index >>= 7; } + + return index & 0x7F; + } else { + // Keycode is a regular index + return keycode - QK_UNICODEMAP; + } +} bool process_unicodemap(uint16_t keycode, keyrecord_t *record) { - if ((keycode & QK_UNICODEMAP) == QK_UNICODEMAP && record->event.pressed) { - uint16_t index = keycode - QK_UNICODEMAP; - uint32_t code = pgm_read_dword(unicode_map + index); + if (keycode >= QK_UNICODEMAP && keycode <= QK_UNICODEMAP_PAIR_MAX && record->event.pressed) { + unicode_input_start(); + + uint32_t code = pgm_read_dword(unicode_map + unicodemap_index(keycode)); uint8_t input_mode = get_unicode_input_mode(); - if (code > 0xFFFF && code <= 0x10FFFF && input_mode == UC_OSX) { - // Convert to UTF-16 surrogate pair + if (code > 0x10FFFF || (code > 0xFFFF && input_mode == UC_WIN)) { + // Character is out of range supported by the platform + unicode_input_cancel(); + } else if (code > 0xFFFF && input_mode == UC_OSX) { + // Convert to UTF-16 surrogate pair on Mac code -= 0x10000; uint32_t lo = code & 0x3FF, hi = (code & 0xFFC00) >> 10; - - unicode_input_start(); register_hex32(hi + 0xD800); register_hex32(lo + 0xDC00); unicode_input_finish(); - } else if ((code > 0x10FFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { - // Character is out of range supported by the OS - unicodemap_input_error(); } else { - unicode_input_start(); register_hex32(code); unicode_input_finish(); } diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h index fe4f97915..51709c5dc 100644 --- a/quantum/process_keycode/process_unicodemap.h +++ b/quantum/process_keycode/process_unicodemap.h @@ -16,10 +16,10 @@ #pragma once -#include "quantum.h" #include "process_unicode_common.h" extern const uint32_t PROGMEM unicode_map[]; -void unicodemap_input_error(void); +void register_hex32(uint32_t hex); +uint16_t unicodemap_index(uint16_t keycode); bool process_unicodemap(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 19bd7c216..779c355ef 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -87,7 +87,9 @@ enum quantum_keycodes { #endif #ifdef UNICODEMAP_ENABLE QK_UNICODEMAP = 0x8000, - QK_UNICODEMAP_MAX = 0x83FF, + QK_UNICODEMAP_MAX = 0xBFFF, + QK_UNICODEMAP_PAIR = 0xC000, + QK_UNICODEMAP_PAIR_MAX = 0xFFFF, #endif // Loose keycodes - to be used directly @@ -712,7 +714,8 @@ enum quantum_keycodes { #endif #ifdef UNICODEMAP_ENABLE // Allows Unicode input up to 0x10FFFF, requires unicode_map - #define X(i) (QK_UNICODEMAP | (i)) + #define X(i) (QK_UNICODEMAP | (i)) + #define XP(i, j) (QK_UNICODEMAP_PAIR | ((i) & 0x7F) | (((j) & 0x7F) << 7)) // 127 max i and j #endif #define UC_MOD UNICODE_MODE_FORWARD diff --git a/users/konstantin/config.h b/users/konstantin/config.h index f18c4a70e..4ca19f824 100644 --- a/users/konstantin/config.h +++ b/users/konstantin/config.h @@ -19,4 +19,4 @@ #define UNICODE_CYCLE_PERSIST false #define UNICODE_SELECTED_MODES UC_WINC, UC_WIN, UC_LNX -#define UNICODE_WINC_KEY KC_RGUI +#define UNICODE_KEY_WINC KC_RGUI -- cgit v1.2.3-70-g09d2 From 4c14b5832a7598d19a6a1196aaaafd473f7ed920 Mon Sep 17 00:00:00 2001 From: MechMerlin <30334081+mechmerlin@users.noreply.github.com> Date: Fri, 3 May 2019 17:26:29 -0700 Subject: Fix up ps2avrgb templates (#5606) * fix up ps2avrgb templates * set backlight enable to no as per review comments * add back no_uart --- quantum/template/ps2avrgb/readme.md | 2 ++ quantum/template/ps2avrgb/rules.mk | 4 ++-- quantum/template/ps2avrgb/usbconfig.h | 5 +---- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'quantum') diff --git a/quantum/template/ps2avrgb/readme.md b/quantum/template/ps2avrgb/readme.md index ef24deb8f..1449b278c 100644 --- a/quantum/template/ps2avrgb/readme.md +++ b/quantum/template/ps2avrgb/readme.md @@ -16,6 +16,8 @@ Flashing ps2avr(GB) boards use an atmega32a microcontroller and a different bootloader. It is not flashable using the regular QMK methods. +**Reset Key:** Hold down the key located at `K00`, commonly programmed as `Esc` while plugging in the keyboard. + Windows: 1. Download [HIDBootFlash](http://vusb.wikidot.com/project:hidbootflash). 2. Place your keyboard into reset. diff --git a/quantum/template/ps2avrgb/rules.mk b/quantum/template/ps2avrgb/rules.mk index 191a13844..bd0eed052 100644 --- a/quantum/template/ps2avrgb/rules.mk +++ b/quantum/template/ps2avrgb/rules.mk @@ -31,13 +31,13 @@ F_CPU = 12000000 BOOTLOADER = bootloadHID # build options -BOOTMAGIC_ENABLE = full +BOOTMAGIC_ENABLE = no MOUSEKEY_ENABLE = no EXTRAKEY_ENABLE = yes CONSOLE_ENABLE = yes COMMAND_ENABLE = yes BACKLIGHT_ENABLE = no -RGBLIGHT_ENABLE = no +RGBLIGHT_ENABLE = yes RGBLIGHT_CUSTOM_DRIVER = yes OPT_DEFS = -DDEBUG_LEVEL=0 diff --git a/quantum/template/ps2avrgb/usbconfig.h b/quantum/template/ps2avrgb/usbconfig.h index d2d848fcd..54a7d20f1 100644 --- a/quantum/template/ps2avrgb/usbconfig.h +++ b/quantum/template/ps2avrgb/usbconfig.h @@ -8,8 +8,7 @@ * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $ */ -#ifndef __usbconfig_h_included__ -#define __usbconfig_h_included__ +#pragma once #include "config.h" @@ -392,5 +391,3 @@ section at the end of this file). /* #define USB_INTR_PENDING EIFR */ #define USB_INTR_PENDING_BIT INTF1 #define USB_INTR_VECTOR INT1_vect - -#endif /* __usbconfig_h_included__ */ -- cgit v1.2.3-70-g09d2 From e290dc5ad811e9d121e216fba6fe03666772c3a4 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Sun, 5 May 2019 18:27:02 -0500 Subject: Space Cadet: Reducing unnecessary reported keypresses (#5781) * Reducing unnecessary reported keypresses and minor docs / variable name changes * Apply suggestions from code review Co-Authored-By: XScorpion2 --- docs/feature_space_cadet.md | 6 ++--- quantum/process_keycode/process_space_cadet.c | 39 +++++++++++++++------------ quantum/process_keycode/process_space_cadet.h | 2 +- users/xulkal/config.h | 2 +- 4 files changed, 27 insertions(+), 22 deletions(-) (limited to 'quantum') diff --git a/docs/feature_space_cadet.md b/docs/feature_space_cadet.md index 3e4665cde..5c375c518 100644 --- a/docs/feature_space_cadet.md +++ b/docs/feature_space_cadet.md @@ -39,15 +39,15 @@ By default Space Cadet assumes a US ANSI layout, but if your layout uses differe |`LSPO_KEYS` |`KC_LSFT, LSPO_MOD, LSPO_KEY` |Send `KC_LSFT` when held, the mod and key defined by `LSPO_MOD` and `LSPO_KEY`. | |`RSPC_KEYS` |`KC_RSFT, RSPC_MOD, RSPC_KEY` |Send `KC_RSFT` when held, the mod and key defined by `RSPC_MOD` and `RSPC_KEY`. | |`LCPO_KEYS` |`KC_LCTL, KC_LCTL, KC_9` |Send `KC_LCTL` when held, the mod `KC_LCTL` with the key `KC_9` when tapped. | -|`RCPO_KEYS` |`KC_RCTL, KC_RCTL, KC_0` |Send `KC_RCTL` when held, the mod `KC_RCTL` with the key `KC_0` when tapped. | +|`RCPC_KEYS` |`KC_RCTL, KC_RCTL, KC_0` |Send `KC_RCTL` when held, the mod `KC_RCTL` with the key `KC_0` when tapped. | |`LAPO_KEYS` |`KC_LALT, KC_LALT, KC_9` |Send `KC_LALT` when held, the mod `KC_LALT` with the key `KC_9` when tapped. | -|`RAPO_KEYS` |`KC_RALT, KC_RALT, KC_0` |Send `KC_RALT` when held, the mod `KC_RALT` with the key `KC_0` when tapped. | +|`RAPC_KEYS` |`KC_RALT, KC_RALT, KC_0` |Send `KC_RALT` when held, the mod `KC_RALT` with the key `KC_0` when tapped. | |`SFTENT_KEYS` |`KC_RSFT, KC_TRNS, SFTENT_KEY` |Send `KC_RSFT` when held, no mod with the key `SFTENT_KEY` when tapped. | ## Obsolete Configuration -These defines are used in the above defines internally to support backwards compatibility, so you may continue to use them, however the above defines open up a larger range of flexibility than before. As an example, say you want to not send any modifier when you tap just `KC_LSPO`, with the old defines you had an all or nothing choice of using the `DISABLE_SPACE_CADET_MODIFIER` define. Now you can define that key as: `#define KC_LSPO_KEYS KC_LSFT, KC_TRNS, KC_9`. This tells the system to set Left Shift if held or used with other keys, then on tap send no modifier (transparent) with the `KC_9` +These defines are used in the above defines internally to support backwards compatibility, so you may continue to use them, however the above defines open up a larger range of flexibility than before. As an example, say you want to not send any modifier when you tap just `KC_LSPO`, with the old defines you had an all or nothing choice of using the `DISABLE_SPACE_CADET_MODIFIER` define. Now you can define that key as: `#define LSPO_KEYS KC_LSFT, KC_TRNS, KC_9`. This tells the system to set Left Shift if held or used with other keys, then on tap send no modifier (transparent) with the `KC_9`. |Define |Default |Description | |------------------------------|-------------|------------------------------------------------------------------| diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c index a9c506168..ac39df808 100644 --- a/quantum/process_keycode/process_space_cadet.c +++ b/quantum/process_keycode/process_space_cadet.c @@ -62,16 +62,16 @@ #ifndef LCPO_KEYS #define LCPO_KEYS KC_LCTL, KC_LCTL, KC_9 #endif -#ifndef RCPO_KEYS - #define RCPO_KEYS KC_RCTL, KC_RCTL, KC_0 +#ifndef RCPC_KEYS + #define RCPC_KEYS KC_RCTL, KC_RCTL, KC_0 #endif // Alt / paren setup #ifndef LAPO_KEYS #define LAPO_KEYS KC_LALT, KC_LALT, KC_9 #endif -#ifndef RAPO_KEYS - #define RAPO_KEYS KC_RALT, KC_RALT, KC_0 +#ifndef RAPC_KEYS + #define RAPC_KEYS KC_RALT, KC_RALT, KC_0 #endif // Shift / Enter setup @@ -82,27 +82,32 @@ static uint8_t sc_last = 0; static uint16_t sc_timer = 0; -void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod, uint8_t keycode) { +void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) { if (record->event.pressed) { - sc_last = normalMod; + sc_last = holdMod; sc_timer = timer_read (); - if (IS_MOD(normalMod)) { - register_mods(MOD_BIT(normalMod)); + if (IS_MOD(holdMod)) { + register_mods(MOD_BIT(holdMod)); } } else { - if (IS_MOD(normalMod)) { - unregister_mods(MOD_BIT(normalMod)); - } - - if (sc_last == normalMod && timer_elapsed(sc_timer) < TAPPING_TERM) { - if (IS_MOD(tapMod)) { - register_mods(MOD_BIT(tapMod)); + if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) { + if (holdMod != tapMod) { + if (IS_MOD(holdMod)) { + unregister_mods(MOD_BIT(holdMod)); + } + if (IS_MOD(tapMod)) { + register_mods(MOD_BIT(tapMod)); + } } tap_code(keycode); if (IS_MOD(tapMod)) { unregister_mods(MOD_BIT(tapMod)); } + } else { + if (IS_MOD(holdMod)) { + unregister_mods(MOD_BIT(holdMod)); + } } } } @@ -122,7 +127,7 @@ bool process_space_cadet(uint16_t keycode, keyrecord_t *record) { return false; } case KC_RCPC: { - perform_space_cadet(record, RCPO_KEYS); + perform_space_cadet(record, RCPC_KEYS); return false; } case KC_LAPO: { @@ -130,7 +135,7 @@ bool process_space_cadet(uint16_t keycode, keyrecord_t *record) { return false; } case KC_RAPC: { - perform_space_cadet(record, RAPO_KEYS); + perform_space_cadet(record, RAPC_KEYS); return false; } case KC_SFTENT: { diff --git a/quantum/process_keycode/process_space_cadet.h b/quantum/process_keycode/process_space_cadet.h index 3f08b8002..c82314350 100644 --- a/quantum/process_keycode/process_space_cadet.h +++ b/quantum/process_keycode/process_space_cadet.h @@ -17,5 +17,5 @@ #include "quantum.h" -void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod, uint8_t keycode); +void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode); bool process_space_cadet(uint16_t keycode, keyrecord_t *record); diff --git a/users/xulkal/config.h b/users/xulkal/config.h index 6ff4ca49d..2899017b0 100644 --- a/users/xulkal/config.h +++ b/users/xulkal/config.h @@ -10,7 +10,7 @@ #define LSPO_KEYS KC_LSFT, KC_TRNS, KC_LBRC #define RSPC_KEYS KC_RSFT, KC_TRNS, KC_RBRC #define LCPO_KEYS KC_LCTL, KC_TRNS, KC_MINS -#define RCPO_KEYS KC_RCTL, KC_TRNS, KC_EQL +#define RCPC_KEYS KC_RCTL, KC_TRNS, KC_EQL // No need for the single versions when multi performance isn't a problem =D #define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE -- cgit v1.2.3-70-g09d2 From e01b2d518a1a08ce07278ef9a38c7a793c843749 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Mon, 6 May 2019 17:06:43 -0500 Subject: [Keyboard] Sol keyboard conversion to split common (#5773) * Split common conversion * Updated serial and encoder pins * Fixing default folder until r2 * Fixing oled driver on slave split common * Fixing keymap compile errors * Fixing oled inactivity timer on slave split common * Hoisted oled driver task, init, & activity to keyboard.c * Update keyboards/sol/config.h Co-Authored-By: XScorpion2 * Remove TAPPING_FORCE_HOLD --- keyboards/sol/common/knob_v2.c | 71 ------- keyboards/sol/common/knob_v2.h | 28 --- keyboards/sol/config.h | 70 +++++++ keyboards/sol/keymaps/brianweyer/keymap.c | 36 +++- keyboards/sol/keymaps/brianweyer/rules.mk | 6 - keyboards/sol/keymaps/danielhklein/keymap.c | 28 ++- keyboards/sol/keymaps/danielhklein/rules.mk | 6 - keyboards/sol/keymaps/default/keymap.c | 28 ++- keyboards/sol/keymaps/default/rules.mk | 6 - keyboards/sol/keymaps/kageurufu/keymap.c | 26 ++- keyboards/sol/keymaps/kageurufu/rules.mk | 6 - keyboards/sol/keymaps/xulkal/keymap.c | 12 +- keyboards/sol/keymaps/xulkal/rules.mk | 7 +- keyboards/sol/rev1/config.h | 111 +--------- keyboards/sol/rev1/matrix.c | 304 ---------------------------- keyboards/sol/rev1/rev1.c | 6 +- keyboards/sol/rev1/rev1.h | 71 +------ keyboards/sol/rev1/rules.mk | 2 - keyboards/sol/rev1/split_util.c | 54 ----- keyboards/sol/rev1/split_util.h | 15 -- keyboards/sol/rules.mk | 7 +- keyboards/sol/serial.c | 288 -------------------------- keyboards/sol/serial.h | 26 --- keyboards/sol/sol.h | 54 ++++- quantum/quantum.c | 23 +-- quantum/split_common/matrix.c | 2 +- tmk_core/common/keyboard.c | 19 ++ 27 files changed, 250 insertions(+), 1062 deletions(-) delete mode 100644 keyboards/sol/common/knob_v2.c delete mode 100644 keyboards/sol/common/knob_v2.h delete mode 100644 keyboards/sol/rev1/matrix.c delete mode 100644 keyboards/sol/rev1/split_util.c delete mode 100644 keyboards/sol/rev1/split_util.h delete mode 100644 keyboards/sol/serial.c delete mode 100644 keyboards/sol/serial.h (limited to 'quantum') diff --git a/keyboards/sol/common/knob_v2.c b/keyboards/sol/common/knob_v2.c deleted file mode 100644 index f22f7c5d8..000000000 --- a/keyboards/sol/common/knob_v2.c +++ /dev/null @@ -1,71 +0,0 @@ -#include "knob_v2.h" - -bool knob_prev_a = false; -static knob_report_t knob_report = {.dir = 0, .phase = 0}; - -void knob_init(void) { - // I use pins D1 (ISR1) & D4 for a knob. - - // Set pin mode for D4 as input. - DDRD &= ~(0UL << ENCODER_PIN_2); - - // Enable internal pull-up for D4. - // This is done by "writing" 1 to a pin that has its mode set to input. - PORTD |= (1 << ENCODER_PIN_2); - - // Enable interrupt for D1 - // For more info on the below flags see this awesome section 11.1 (pages 89-90) here: - // https://cdn-shop.adafruit.com/datasheets/atmel-7766-8-bit-avr-atmega16u4-32u4_datasheet.pdf - // Set pin mode & pull-up. - DDRD &= ~(0UL << ENCODER_PIN_1); - PORTD |= (1UL << ENCODER_PIN_1); - - // INT: 33221100 - EICRA |= 0b00010000; // 0b01 - any edge - // INT: 6 3210 - EIMSK |= 0b00000100; -} - -ISR(ENCODER_INT) { - bool a = PIND & (1 << ENCODER_PIN_1); - - if (knob_prev_a != a) { - // "A" channel has REALLY changed. - knob_report.phase = a; - knob_prev_a = a; - bool b = PIND & (1 << ENCODER_PIN_2); - if (a == b) { - // Halfway through CCW rotation (A == B) - // - // +---YOU ARE HERE (A=1, B=1) - // | +---OR HERE (A=0, B=0) - // | | - // v v - // A: _____/^^^^^\__ - // B: __/^^^^^\_____ - knob_report.dir++; - } else { - // Halfway through CW rotation (A != B) - // - // +---YOU ARE HERE (A=1, B=0) - // | +---OR HERE (A=0, B=1) - // | | - // v v - // A: _____/^^^^^\_____ - // B: ________/^^^^^\__ - knob_report.dir--; - } - } -} - -knob_report_t knob_report_read(void) { - // Return knob report. - return knob_report; -} - -void knob_report_reset(void) { - // Call this ASAP once you've processed the previous knob report. - // TODO: This should probably be called within `knob_report_read`. - knob_report.dir = 0; - knob_report.phase = 0; -} diff --git a/keyboards/sol/common/knob_v2.h b/keyboards/sol/common/knob_v2.h deleted file mode 100644 index 45196eb1a..000000000 --- a/keyboards/sol/common/knob_v2.h +++ /dev/null @@ -1,28 +0,0 @@ -// Rotary knob implementation - Version 2. -// Uses 2 digital pins - D2 (via interrupt) & D6. -// #include "rev1.h" -#include -#include -#include - -#ifndef ENCODER_PIN_1 - #define ENCODER_PIN_1 PD2 -#endif -#ifndef ENCODER_PIN_2 - #define ENCODER_PIN_2 PD6 -#endif -#ifndef ENCODER_INT - #define ENCODER_INT INT2_vect -#endif - -typedef struct knob_report_t { - int8_t dir; // Contains number of rotations that happened - int8_t phase; // Contains 0 if last rotation happened on 90 degrees, 1 if on 270 -} knob_report_t; - -void knob_init(void); -knob_report_t knob_report_read(void); -void knob_report_reset(void); - -bool knob_prev_a; -int8_t knob_dir; diff --git a/keyboards/sol/config.h b/keyboards/sol/config.h index 93fd2261b..a7317d9d9 100644 --- a/keyboards/sol/config.h +++ b/keyboards/sol/config.h @@ -20,3 +20,73 @@ along with this program. If not, see . #include "config_common.h" +#define TAPPING_TERM 150 + +/* Select hand configuration */ +#define SOFT_SERIAL_PIN D3 +#define EE_HANDS + +/* key matrix size */ +// Rows are doubled-up +#define MATRIX_ROWS 12 +#define MATRIX_ROW_PINS { C6, B6, B5, B4, D7, E6} + +// wiring of each half +#define MATRIX_COLS 7 +#define MATRIX_COL_PINS { F0, F1, F4, F5, F6, F7, C7 } + +// Encoder support +#define NUMBER_OF_ENCODERS 1 +#define ENCODERS_PAD_A { D2 } +#define ENCODERS_PAD_B { D6 } + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCING_DELAY 5 + +/* ws2812 RGB LED */ +#define RGB_DI_PIN B3 + +#ifdef IOS_DEVICE_ENABLE + #define RGBLIGHT_LIMIT_VAL 40 +#elif RGBLIGHT_FULL_POWER + #define RGBLIGHT_LIMIT_VAL 255 +#else + #define RGBLIGHT_LIMIT_VAL 120 +#endif +#define RGB_MATRIX_MAXIMUM_BRIGHTNESS RGBLIGHT_LIMIT_VAL + +#define LED_HITS_TO_REMEMBER 5 + +#define RGBLIGHT_ANIMATIONS + +#if defined(RGBLIGHT_ENABLE) && !defined(IOS_DEVICE_ENABLE) +// USB_MAX_POWER_CONSUMPTION value for Helix keyboard +// 120 RGBoff, OLEDoff +// 120 OLED +// 330 RGB 6 +// 300 RGB 32 +// 310 OLED & RGB 32 + #define USB_MAX_POWER_CONSUMPTION 500 +#else + // fix iPhone and iPad power adapter issue + // iOS device need lessthan 100 + #define USB_MAX_POWER_CONSUMPTION 100 +#endif + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +// #define NO_DEBUG + +/* disable print */ +// #define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION diff --git a/keyboards/sol/keymaps/brianweyer/keymap.c b/keyboards/sol/keymaps/brianweyer/keymap.c index 87d603d81..3ba52081d 100755 --- a/keyboards/sol/keymaps/brianweyer/keymap.c +++ b/keyboards/sol/keymaps/brianweyer/keymap.c @@ -11,8 +11,6 @@ extern keymap_config_t keymap_config; extern rgblight_config_t rgblight_config; #endif -extern uint8_t is_master; - // Each layer gets a name for readability, which is then used in the keymap matrix below. // The underscores don't mean anything - you can have a layer called STUFF or any other name. // Layer names don't all need to be of the same length, obviously, and you can also skip them @@ -59,8 +57,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| LCTL, LALT, FN, LGUI, RGB_MOD, SPC, DEL, BSPC, SPC, ADJ, LGUI, FN, LALT, LCTL, //|--------+--------+--------+--------+--------+--+--------+--------| |--------+--+--------+--------+--------+--------+--------+--------| - VOLD, VOLU, SPC, ENT, ENT, SPC, DOWN, UP - // Rotary Left |--------+--------| |--------+-----------+ Rotary Right + SPC, ENT, ENT, SPC + // |--------+--------| |--------+-----------+ ), /* FN @@ -90,8 +88,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, //|--------+--------+--------+--------+--------+--+--------+--------| |--------+--+--------+--------+--------+--------+--------+--------| - VOLD, VOLU, _______, _______, _______, _______, UP, DOWN - // Rotary Left |--------+--------| |--------+-----------+ Rotary Right + _______, _______, _______, _______ + // |--------+--------| |--------+-----------+ ), /* ADJ @@ -122,8 +120,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ //|--------+--------+--------+--------+--------+--+--------+--------| |--------+--------+--+--------+--------+--------+--------+--------| - _______, _______, _______, _______, _______, _______, _______, _______ \ - // Rotary Left |--------+--------| |--------+--------+ Rotary Right + _______, _______, _______, _______ \ + // |--------+--------| |--------+--------+ ) }; @@ -132,6 +130,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { bool TOG_STATUS = false; int RGB_current_mode; +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } else if (index == 1) { /* Second encoder*/ + if (clockwise) { + tap_code(KC_UP); + } else { + tap_code(KC_DOWN); + } + } +} +#endif + bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { @@ -182,7 +198,7 @@ void matrix_init_user(void) { #ifdef OLED_DRIVER_ENABLE oled_rotation_t oled_init_user(oled_rotation_t rotation) { - if (!has_usb()) + if (!is_keyboard_master()) return OLED_ROTATION_180; // flip 180 for offhand return rotation; } @@ -244,7 +260,7 @@ static void render_status(void) { } void oled_task_user(void) { - if (is_master) + if (is_keyboard_master()) render_status(); else render_logo(); diff --git a/keyboards/sol/keymaps/brianweyer/rules.mk b/keyboards/sol/keymaps/brianweyer/rules.mk index 15b0c8fd2..12c877946 100755 --- a/keyboards/sol/keymaps/brianweyer/rules.mk +++ b/keyboards/sol/keymaps/brianweyer/rules.mk @@ -17,18 +17,12 @@ RGB_MATRIX_KEYPRESSES = no # Enable reactive per-key effects. Can be very laggy RGBLIGHT_FULL_POWER = no # Allow maximum RGB brightness. Otherwise, limited to a safe level for a normal USB-A port UNICODE_ENABLE = no # Unicode SWAP_HANDS_ENABLE = no # Enable one-hand typing -ENCODER_ENABLE_CUSTOM = yes # Enable rotary encoder (+90) OLED_DRIVER_ENABLE = yes # Enable the OLED Driver (+5000) IOS_DEVICE_ENABLE = no # Limit max brightness to connect to IOS device (iPad,iPhone) # Do not edit past here -ifeq ($(strip $(ENCODER_ENABLE_CUSTOM)), yes) - OPT_DEFS += -DENCODER_ENABLE_CUSTOM - SRC += common/knob_v2.c -endif - ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) OPT_DEFS += -DIOS_DEVICE_ENABLE else ifeq ($(strip $(RGBLIGHT_FULL_POWER)), yes) diff --git a/keyboards/sol/keymaps/danielhklein/keymap.c b/keyboards/sol/keymaps/danielhklein/keymap.c index 9bcc5761a..860361e81 100644 --- a/keyboards/sol/keymaps/danielhklein/keymap.c +++ b/keyboards/sol/keymaps/danielhklein/keymap.c @@ -11,8 +11,6 @@ extern keymap_config_t keymap_config; extern rgblight_config_t rgblight_config; #endif -extern uint8_t is_master; - // Each layer gets a name for readability, which is then used in the keymap matrix below. // The underscores don't mean anything - you can have a layer called STUFF or any other name. // Layer names don't all need to be of the same length, obviously, and you can also skip them @@ -64,7 +62,7 @@ LAYOUT( \ KC_CAPS, _10, _11, _12, _13, _14, KC_LCBR, KC_RCBR, _15, _16, _17, _18, _19, KC_QUOT, \ KC_LSFT, _20, _21, _22, _23, _24, KC_GRV, KC_BSLS, _25, _26, _27, _28, _29, KC_RSFT, \ KC_LEFT, KC_DOWN, KC_LCTRL, KC_LALT, KC_LGUI, KC_BSPC, FN, ADJ, KC_SPC, KC_RGUI, KC_RALT, KC_RCTRL, KC_UP, KC_RIGHT, \ - KC_VOLU, KC_VOLD, KC_BSPC, FN, ADJ, KC_SPC, KC_VOLU, KC_VOLD \ + KC_BSPC, FN, ADJ, KC_SPC \ ) const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -132,7 +130,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, KC_INS, KC_END, \ _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MPLY, KC_MUTE, KC_VOLD, KC_VOLU, KC_MRWD, KC_MFFD, \ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ - XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX \ + XXXXXXX, _______, XXXXXXX, XXXXXXX \ ), /* ADJ @@ -157,7 +155,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { XXXXXXX, RGB_SAD, RGB_VAI, RGB_SAI, XXXXXXX, XXXXXXX, COLEMAK, XXXXXXX, KC_P4, KC_P5, KC_P6, KC_PENT, XXXXXXX, XXXXXXX, \ XXXXXXX, RGB_HUD, RGB_VAD, RGB_HUI, XXXXXXX, XXXXXXX, QWERTY, XXXXXXX, KC_P1, KC_P2, KC_P3, KC_SPC, XXXXXXX, XXXXXXX, \ XXXXXXX, RGBRST, RGB_TOG, RGB_MOD, RGB_RMOD, XXXXXXX, XXXXXXX, _______, XXXXXXX, KC_P0, KC_PDOT, KC_BSPC, XXXXXXX, XXXXXXX, \ - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX \ + XXXXXXX, XXXXXXX, _______, XXXXXXX \ ) }; @@ -165,6 +163,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { bool TOG_STATUS = false; int RGB_current_mode; +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } else if (index == 1) { /* Second encoder*/ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } +} +#endif + // Setting ADJ layer RGB back to default void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { @@ -308,7 +324,7 @@ static void render_status(void) { } void oled_task_user(void) { - if (is_master) + if (is_keyboard_master()) render_status(); else render_logo(); diff --git a/keyboards/sol/keymaps/danielhklein/rules.mk b/keyboards/sol/keymaps/danielhklein/rules.mk index 526b72fe7..09b0e201d 100644 --- a/keyboards/sol/keymaps/danielhklein/rules.mk +++ b/keyboards/sol/keymaps/danielhklein/rules.mk @@ -17,18 +17,12 @@ RGB_MATRIX_KEYPRESSES = no # Enable reactive per-key effects. Can be very laggy RGBLIGHT_FULL_POWER = no # Allow maximum RGB brightness. Otherwise, limited to a safe level for a normal USB-A port UNICODE_ENABLE = no # Unicode SWAP_HANDS_ENABLE = no # Enable one-hand typing -ENCODER_ENABLE_CUSTOM = yes # Enable rotary encoder (+90) OLED_DRIVER_ENABLE = no # Enable the OLED Driver (+5000) IOS_DEVICE_ENABLE = no # Limit max brightness to connect to IOS device (iPad,iPhone) # Do not edit past here -ifeq ($(strip $(ENCODER_ENABLE_CUSTOM)), yes) - OPT_DEFS += -DENCODER_ENABLE_CUSTOM - SRC += common/knob_v2.c -endif - ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) OPT_DEFS += -DIOS_DEVICE_ENABLE else ifeq ($(strip $(RGBLIGHT_FULL_POWER)), yes) diff --git a/keyboards/sol/keymaps/default/keymap.c b/keyboards/sol/keymaps/default/keymap.c index a40bc40b7..c101a9bd8 100644 --- a/keyboards/sol/keymaps/default/keymap.c +++ b/keyboards/sol/keymaps/default/keymap.c @@ -12,8 +12,6 @@ extern keymap_config_t keymap_config; extern rgblight_config_t rgblight_config; #endif -extern uint8_t is_master; - // Each layer gets a name for readability, which is then used in the keymap matrix below. // The underscores don't mean anything - you can have a layer called STUFF or any other name. // Layer names don't all need to be of the same length, obviously, and you can also skip them @@ -70,7 +68,7 @@ LAYOUT( \ FN_CAPS, _10, _11, _12, _13, _14, KC_LPRN, KC_RPRN, _15, _16, _17, _18, _19, KC_QUOT, \ KC_LSFT, _20, _21, _22, _23, _24, KC_LCBR, KC_RCBR, _25, _26, _27, _28, _29, KC_ENT, \ KC_LCTL, KC_LGUI, KC_LALT, RGB_TOG, ADJ, KC_SPC, KC_DEL, KC_ENT, KC_SPC, FN, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, \ - KC_VOLU, KC_VOLD, KC_SPC, KC_DEL, KC_ENT, KC_SPC, KC_VOLU, KC_VOLD \ + KC_SPC, KC_DEL, KC_ENT, KC_SPC \ ) const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -138,7 +136,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, KC_INS, KC_END, \ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ _______, _______, _______, RGB_MOD, _______, _______, _______, _______, _______, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, \ - KC_VOLU, KC_VOLD, _______, _______, _______, _______, KC_VOLU, KC_VOLD \ + _______, _______, _______, _______ \ ), /* ADJ @@ -163,7 +161,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, RGB_HUD, RGB_VAD, RGB_HUI, RGBRST, _______, _______, _______, _______, QWERTY, COLEMAK, _______, _______, _______, \ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \ _______, _______, _______, RGB_MOD, _______, _______, _______, _______, _______, _______, RGB_RMOD,RGB_HUD, RGB_SAD, RGB_VAD, \ - KC_VOLU, KC_VOLD, _______, _______, _______, _______, KC_VOLU, KC_VOLD \ + _______, _______, _______, _______ \ ) }; @@ -173,6 +171,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { bool TOG_STATUS = false; int RGB_current_mode; +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } else if (index == 1) { /* Second encoder*/ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } +} +#endif + // Setting ADJ layer RGB back to default void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { @@ -316,7 +332,7 @@ static void render_status(void) { } void oled_task_user(void) { - if (is_master) + if (is_keyboard_master()) render_status(); else render_logo(); diff --git a/keyboards/sol/keymaps/default/rules.mk b/keyboards/sol/keymaps/default/rules.mk index 526b72fe7..09b0e201d 100644 --- a/keyboards/sol/keymaps/default/rules.mk +++ b/keyboards/sol/keymaps/default/rules.mk @@ -17,18 +17,12 @@ RGB_MATRIX_KEYPRESSES = no # Enable reactive per-key effects. Can be very laggy RGBLIGHT_FULL_POWER = no # Allow maximum RGB brightness. Otherwise, limited to a safe level for a normal USB-A port UNICODE_ENABLE = no # Unicode SWAP_HANDS_ENABLE = no # Enable one-hand typing -ENCODER_ENABLE_CUSTOM = yes # Enable rotary encoder (+90) OLED_DRIVER_ENABLE = no # Enable the OLED Driver (+5000) IOS_DEVICE_ENABLE = no # Limit max brightness to connect to IOS device (iPad,iPhone) # Do not edit past here -ifeq ($(strip $(ENCODER_ENABLE_CUSTOM)), yes) - OPT_DEFS += -DENCODER_ENABLE_CUSTOM - SRC += common/knob_v2.c -endif - ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) OPT_DEFS += -DIOS_DEVICE_ENABLE else ifeq ($(strip $(RGBLIGHT_FULL_POWER)), yes) diff --git a/keyboards/sol/keymaps/kageurufu/keymap.c b/keyboards/sol/keymaps/kageurufu/keymap.c index 9ea89db05..b587ef2b3 100644 --- a/keyboards/sol/keymaps/kageurufu/keymap.c +++ b/keyboards/sol/keymaps/kageurufu/keymap.c @@ -35,7 +35,7 @@ EXPAND_LAYOUT( \ FN_ESC, _10, _11, _12, _13, _14, RGB_SAI, RGB_VAI, _15, _16, _17, _18, _19, KC_QUOT, \ KC_LSPO, _20, _21, _22, _23, _24, RGB_SAD, RGB_VAD, _25, _26, _27, _28, _29, KC_RSPC, \ KC_LCTL, KC_LGUI, KC_LGUI, KC_LALT, FN, KC_SPC, FN, FN, KC_SPC, KC_MINS, KC_EQL, KC_DOWN, KC_PGUP, KC_PGDN, \ - KC_VOLD, KC_VOLU, KC_SPC, KC_BSPC, KC_ENT, KC_SPC, KC_VOLD, KC_VOLU \ + KC_SPC, KC_BSPC, KC_ENT, KC_SPC \ ) #define BASE_LAYOUT(...) _BASE_LAYOUT(__VA_ARGS__) @@ -65,15 +65,33 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ________________FUNCTION_L3________________, _______, _______, ________________FUNCTION_R3________________, \ ________________FUNCTION_L4________________, _______, _______, ________________FUNCTION_R4________________, \ ________________FUNCTION_L5________________, ADJ, ADJ, ________________FUNCTION_R5________________, \ - KC_VOLD, KC_VOLU, _______, KC_DEL, _______, _______, KC_VOLD, KC_VOLU \ + _______, KC_DEL, _______, _______ \ ), - [_ADJ] = EXPAND_LAYOUT( \ + [_ADJ] = EXPAND_LAYOUT( \ _________________ADJUST_L1_________________, _______, _______, _________________ADJUST_R1_________________, \ _________________ADJUST_L2_________________, _______, _______, _________________ADJUST_R2_________________, \ _________________ADJUST_L3_________________, _______, _______, _________________ADJUST_R3_________________, \ _________________ADJUST_L4_________________, _______, _______, _________________ADJUST_R4_________________, \ _________________ADJUST_L5_________________, _______, _______, _________________ADJUST_R5_________________, \ - KC_VOLD, KC_VOLU, _______, _______, _______, _______, KC_VOLD, KC_VOLU \ + _______, _______, _______, _______ \ ) }; + +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } else if (index == 1) { /* Second encoder*/ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } +} +#endif diff --git a/keyboards/sol/keymaps/kageurufu/rules.mk b/keyboards/sol/keymaps/kageurufu/rules.mk index 82816f960..21dca0b11 100644 --- a/keyboards/sol/keymaps/kageurufu/rules.mk +++ b/keyboards/sol/keymaps/kageurufu/rules.mk @@ -17,18 +17,12 @@ RGB_MATRIX_KEYPRESSES = no # Enable reactive per-key effects. Can be very laggy RGBLIGHT_FULL_POWER = no # Allow maximum RGB brightness. Otherwise, limited to a safe level for a normal USB-A port UNICODE_ENABLE = no # Unicode SWAP_HANDS_ENABLE = no # Enable one-hand typing -ENCODER_ENABLE_CUSTOM = yes # Enable rotary encoder (+90) OLED_DRIVER_ENABLE = no # Enable the OLED Driver (+5000) IOS_DEVICE_ENABLE = no # Limit max brightness to connect to IOS device (iPad,iPhone) # Do not edit past here -ifeq ($(strip $(ENCODER_ENABLE_CUSTOM)), yes) - OPT_DEFS += -DENCODER_ENABLE_CUSTOM - SRC += common/knob_v2.c -endif - ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) OPT_DEFS += -DIOS_DEVICE_ENABLE else ifeq ($(strip $(RGBLIGHT_FULL_POWER)), yes) diff --git a/keyboards/sol/keymaps/xulkal/keymap.c b/keyboards/sol/keymaps/xulkal/keymap.c index 4591034d2..111e8aa32 100644 --- a/keyboards/sol/keymaps/xulkal/keymap.c +++ b/keyboards/sol/keymaps/xulkal/keymap.c @@ -36,7 +36,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _________________QWERTY_L3_________________, KC_GRV, KC_QUOT, _________________QWERTY_R3_________________, \ _________________QWERTY_L4_________________, RGB_TOG, RGBRST, _________________QWERTY_R4_________________, \ _________________QWERTY_L5_________________, RGB_RMOD, RGB_MOD, _________________QWERTY_R5_________________, \ - KC_VOLU, KC_VOLD, KC_SPC, KC_DEL, KC_ENT, KC_SPC, KC_VOLU, KC_VOLD \ + KC_SPC, KC_DEL, KC_ENT, KC_SPC \ ), #ifndef GAMELAYER_DISABLE @@ -46,7 +46,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ___________________GAME_L3_________________, KC_GRV, KC_QUOT, ___________________GAME_R3_________________, \ ___________________GAME_L4_________________, RGB_TOG, RGBRST, ___________________GAME_R4_________________, \ ___________________GAME_L5_________________, RGB_RMOD, RGB_MOD, ___________________GAME_R5_________________, \ - KC_VOLU, KC_VOLD, KC_SPC, KC_DEL, KC_ENT, KC_SPC, KC_VOLU, KC_VOLD \ + KC_SPC, KC_DEL, KC_ENT, KC_SPC \ ), #endif @@ -56,7 +56,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { __________________LOWER_L3_________________, _______, _______, __________________LOWER_R3_________________, \ __________________LOWER_L4_________________, _______, _______, __________________LOWER_R4_________________, \ __________________LOWER_L5_________________, _______, _______, __________________LOWER_R5_________________, \ - _______, _______, _______, _______, _______, _______, _______, _______ \ + _______, _______, _______, _______ \ ), [_RAISE] = EXPAND_LAYOUT( \ @@ -65,7 +65,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { __________________RAISE_L3_________________, _______, _______, __________________RAISE_R3_________________, \ __________________RAISE_L4_________________, _______, _______, __________________RAISE_R4_________________, \ __________________RAISE_L5_________________, _______, _______, __________________RAISE_R5_________________, \ - _______, _______, _______, _______, _______, _______, _______, _______ \ + _______, _______, _______, _______ \ ), #ifdef TRILAYER_ENABLED @@ -75,7 +75,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _________________ADJUST_L3_________________, _______, _______, _________________ADJUST_R3_________________, \ _________________ADJUST_L4_________________, _______, _______, _________________ADJUST_R4_________________, \ _________________ADJUST_L5_________________, _______, _______, _________________ADJUST_R5_________________, \ - _______, _______, _______, _______, _______, _______, _______, _______ \ + _______, _______, _______, _______ \ ), #endif }; @@ -158,7 +158,7 @@ static void render_status(void) { } void oled_task_user(void) { - if (has_usb()) { + if (is_keyboard_master()) { render_status(); } else { render_logo(); diff --git a/keyboards/sol/keymaps/xulkal/rules.mk b/keyboards/sol/keymaps/xulkal/rules.mk index 685b8ced9..c3ed98edb 100644 --- a/keyboards/sol/keymaps/xulkal/rules.mk +++ b/keyboards/sol/keymaps/xulkal/rules.mk @@ -16,17 +16,12 @@ RGB_MATRIX_KEYPRESSES = yes # Enable reactive per-key effects. Can be very l RGBLIGHT_FULL_POWER = no # Allow maximum RGB brightness. Otherwise, limited to a safe level for a normal USB-A port UNICODE_ENABLE = no # Unicode SWAP_HANDS_ENABLE = no # Enable one-hand typing -ENCODER_ENABLE_CUSTOM = no # Enable rotary encoder (+90) OLED_DRIVER_ENABLE = yes # Enable the OLED Driver (+5000) +ENCODER_ENABLE = no # Enable rotary encoder (+90) IOS_DEVICE_ENABLE = no # Limit max brightness to connect to IOS device (iPad,iPhone) # Do not edit past here -ifeq ($(strip $(ENCODER_ENABLE_CUSTOM)), yes) - OPT_DEFS += -DENCODER_ENABLE_CUSTOM - SRC += common/knob_v2.c -endif - ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) OPT_DEFS += -DIOS_DEVICE_ENABLE else ifeq ($(strip $(RGBLIGHT_FULL_POWER)), yes) diff --git a/keyboards/sol/rev1/config.h b/keyboards/sol/rev1/config.h index 1d8391f64..056869daa 100644 --- a/keyboards/sol/rev1/config.h +++ b/keyboards/sol/rev1/config.h @@ -16,8 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef REV1_CONFIG_H -#define REV1_CONFIG_H +#pragma once /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED @@ -27,117 +26,9 @@ along with this program. If not, see . #define PRODUCT Sol #define DESCRIPTION "An RGB, split, ortho-esque keyboard" -#define PREVENT_STUCK_MODIFIERS -#define TAPPING_FORCE_HOLD -#define TAPPING_TERM 150 - -#define USE_I2C -#define USE_SERIAL -#define USE_SERIAL_PD3 - -/* Select hand configuration */ -#define MASTER_LEFT -// #define MASTER_RIGHT -// #define EE_HANDS - -/* Select rows configuration */ -// Rows are 4 or 5 -// #define HELIX_ROWS 5 see ./rules.mk - -/* key matrix size */ -// Rows are doubled-up -#define MATRIX_ROWS 12 -#define MATRIX_ROW_PINS { C6, B6, B5, B4, D7, E6} - -// wiring of each half -#define MATRIX_COLS 7 -#define MATRIX_COL_PINS { F0, F1, F4, F5, F6, F7, C7 } -// #define MATRIX_COL_PINS { B2, B3, B1, F7, F6, F5, F4 } //uncomment this line and comment line above if you need to reverse left-to-right key order - -/* define if matrix has ghost */ -//#define MATRIX_HAS_GHOST - -/* number of backlight levels */ -// #define BACKLIGHT_LEVELS 3 - -/* Set 0 if debouncing isn't needed */ -#define DEBOUNCING_DELAY 5 - -/* 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 - -/* ws2812 RGB LED */ -#define RGB_DI_PIN B3 -#define RGBLIGHT_TIMER -//#define RGBLED_NUM 12 // Number of LEDs. see ./keymaps/default/config.h -#define ws2812_PORTREG PORTD -#define ws2812_DDRREG DDRD - -#define DRIVER_COUNT 1 -// #define RGB_MATRIX_KEYPRESSES -#define BACKLIGHT_PIN B7 -#define BACKLIGHT_LEVELS 5 - #ifdef LED_MIRRORED #define RGBLED_NUM 35 #else #define RGBLED_NUM 70 #endif #define DRIVER_LED_TOTAL RGBLED_NUM - -#define RGBLIGHT_RAINBOW_SWIRL_RANGE 1950 - -#ifdef IOS_DEVICE_ENABLE - #define RGBLIGHT_LIMIT_VAL 40 - #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 40 -#elif RGBLIGHT_FULL_POWER - #define RGBLIGHT_LIMIT_VAL 255 - #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 -#else - #define RGBLIGHT_LIMIT_VAL 120 - #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120 -#endif - -#define RGBLIGHT_VAL_STEP (RGBLIGHT_LIMIT_VAL / 10) -#define RGBLIGHT_HUE_STEP 10 -#define RGBLIGHT_SAT_STEP 17 - -#define RGBLIGHT_ANIMATIONS - -#define LED_HITS_TO_REMEMBER 5 - -#if defined(RGBLIGHT_ENABLE) && !defined(IOS_DEVICE_ENABLE) -// USB_MAX_POWER_CONSUMPTION value for Helix keyboard -// 120 RGBoff, OLEDoff -// 120 OLED -// 330 RGB 6 -// 300 RGB 32 -// 310 OLED & RGB 32 - #define USB_MAX_POWER_CONSUMPTION 500 -#else - // fix iPhone and iPad power adapter issue - // iOS device need lessthan 100 - #define USB_MAX_POWER_CONSUMPTION 100 -#endif - -/* - * Feature disable options - * These options are also useful to firmware size reduction. - */ - -/* disable debug print */ -// #define NO_DEBUG - -/* disable print */ -// #define NO_PRINT - -/* disable action features */ -//#define NO_ACTION_LAYER -//#define NO_ACTION_TAPPING -//#define NO_ACTION_ONESHOT -//#define NO_ACTION_MACRO -//#define NO_ACTION_FUNCTION - -#endif diff --git a/keyboards/sol/rev1/matrix.c b/keyboards/sol/rev1/matrix.c deleted file mode 100644 index 804d8b980..000000000 --- a/keyboards/sol/rev1/matrix.c +++ /dev/null @@ -1,304 +0,0 @@ -/* -Copyright 2012 Jun Wako - -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 . -*/ - -/* - * scan matrix - */ -#include -#include -#include -#include -#include -#include -#include "print.h" -#include "debug.h" -#include "util.h" -#include "matrix.h" -#include "split_util.h" -#include - -#include "serial.h" - -#ifndef DEBOUNCE -# define DEBOUNCE 5 -#endif - -#ifdef ENCODER_ENABLE_CUSTOM - #include "common/knob_v2.h" -#endif - -#define ERROR_DISCONNECT_COUNT 5 - -static uint8_t debouncing = DEBOUNCE; -static const int ROWS_PER_HAND = MATRIX_ROWS/2; -static uint8_t error_count = 0; -uint8_t is_master = 0 ; - -static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; -static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; - -/* matrix state(1:on, 0:off) */ -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -static matrix_row_t read_cols(void); -static void init_cols(void); -static void unselect_rows(void); -static void select_row(uint8_t row); -static uint8_t matrix_master_scan(void); - - -__attribute__ ((weak)) -void matrix_init_kb(void) { - matrix_init_user(); -} - -__attribute__ ((weak)) -void matrix_scan_kb(void) { - matrix_scan_user(); -} - -__attribute__ ((weak)) -void matrix_init_user(void) { -} - -__attribute__ ((weak)) -void matrix_scan_user(void) { -} - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} - -void matrix_init(void) -{ - debug_enable = true; - debug_matrix = true; - debug_mouse = true; - // initialize row and col - unselect_rows(); - init_cols(); - - TX_RX_LED_INIT; - - // initialize matrix state: all keys off - for (uint8_t i=0; i < MATRIX_ROWS; i++) { - matrix[i] = 0; - matrix_debouncing[i] = 0; - } - - is_master = has_usb(); - - #ifdef ENCODER_ENABLE_CUSTOM - knob_init(); //FOR ENCODER - #endif - matrix_init_quantum(); -} - -uint8_t _matrix_scan(void) -{ - // Right hand is stored after the left in the matirx so, we need to offset it - int offset = isLeftHand ? 0 : (ROWS_PER_HAND); - - for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { - select_row(i); - _delay_us(30); // without this wait read unstable value. - matrix_row_t cols = read_cols(); - if (matrix_debouncing[i+offset] != cols) { - matrix_debouncing[i+offset] = cols; - debouncing = DEBOUNCE; - } - unselect_rows(); - } - - if (debouncing) { - if (--debouncing) { - _delay_ms(1); - } else { - for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { - matrix[i+offset] = matrix_debouncing[i+offset]; - } - } - } - - #ifdef ENCODER_ENABLE_CUSTOM - knob_report_t knob_report = knob_report_read(); - - knob_report_reset(); - - matrix[5 + offset] &= 0b11111100; - if (knob_report.phase) { // I check for phase to avoid handling the rotation twice (on 90 and 270 degrees). - if (knob_report.dir > 0) { - matrix[5 + offset] |= 0b00000001; - } else if (knob_report.dir < 0) { - matrix[5 + offset] |= 0b00000010; - } - } - #endif - - return 1; -} - -int serial_transaction(void) { - int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; - int ret=serial_update_buffers(); - if (ret ) { - return 1; - } - - for (int i = 0; i < ROWS_PER_HAND; ++i) { - matrix[slaveOffset+i] = serial_slave_buffer[i]; - } - return 0; -} - -uint8_t matrix_scan(void) -{ - if (is_master) { - matrix_master_scan(); - }else{ - matrix_slave_scan(); - - int offset = (isLeftHand) ? ROWS_PER_HAND : 0; - - for (int i = 0; i < ROWS_PER_HAND; ++i) { - matrix[offset+i] = serial_master_buffer[i]; - } - - matrix_scan_quantum(); - } - return 1; -} - - -uint8_t matrix_master_scan(void) { - - int ret = _matrix_scan(); - - int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; - - for (int i = 0; i < ROWS_PER_HAND; ++i) { - serial_master_buffer[i] = matrix[offset+i]; - } - - if( serial_transaction() ) { - // turn on the indicator led when halves are disconnected - TXLED1; - - error_count++; - - if (error_count > ERROR_DISCONNECT_COUNT) { - // reset other half if disconnected - int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; - for (int i = 0; i < ROWS_PER_HAND; ++i) { - matrix[slaveOffset+i] = 0; - } - } - } else { - // turn off the indicator led on no error - TXLED0; - error_count = 0; - } - matrix_scan_quantum(); - return ret; -} - -void matrix_slave_scan(void) { - _matrix_scan(); - - int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; - - for (int i = 0; i < ROWS_PER_HAND; ++i) { - serial_slave_buffer[i] = matrix[offset+i]; - } -} - -bool matrix_is_modified(void) -{ - if (debouncing) return false; - return true; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & ((matrix_row_t)1<> 4) + 1) &= ~_BV(col_pins[x] & 0xF); - _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF); - } -} - -static matrix_row_t read_cols(void) -{ - matrix_row_t result = 0; - for(int x = 0; x < MATRIX_COLS; x++) { - result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x); - } - return result; -} - -static void unselect_rows(void) -{ - for(int x = 0; x < ROWS_PER_HAND; x++) { - _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF); - _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF); - } -} - -static void select_row(uint8_t row) -{ - _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF); - _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF); -} diff --git a/keyboards/sol/rev1/rev1.c b/keyboards/sol/rev1/rev1.c index b668b02e9..23896860e 100644 --- a/keyboards/sol/rev1/rev1.c +++ b/keyboards/sol/rev1/rev1.c @@ -1,4 +1,4 @@ -#include "sol.h" +#include "quantum.h" #ifdef RGB_MATRIX_ENABLE rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { @@ -81,7 +81,3 @@ }; #endif -void matrix_init_kb(void) { - matrix_init_user(); -}; - diff --git a/keyboards/sol/rev1/rev1.h b/keyboards/sol/rev1/rev1.h index 27b5ac896..6f70f09be 100644 --- a/keyboards/sol/rev1/rev1.h +++ b/keyboards/sol/rev1/rev1.h @@ -1,70 +1 @@ -#ifndef REV1_H -#define REV1_H - -#include "sol.h" - -//void promicro_bootloader_jmp(bool program); -#include "quantum.h" - -#ifdef RGBLIGHT_ENABLE -//rgb led driver -#include "ws2812.h" -#endif - -#ifdef USE_I2C -#include -#ifdef __AVR__ - #include - #include -#endif -#endif - -//void promicro_bootloader_jmp(bool program); -// LEL/LER/REL/RER are -// LeftEncoderLeft, LeftEncoderRight, RightEncoderLeft, and RightEncoderRight - -#define LAYOUT( \ - L00, L01, L02, L03, L04, L05, L06, R06, R00, R01, R02, R03, R04, R05, \ - L10, L11, L12, L13, L14, L15, L16, R16, R10, R11, R12, R13, R14, R15, \ - L20, L21, L22, L23, L24, L25, L26, R26, R20, R21, R22, R23, R24, R25, \ - L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35, \ - L40, L41, L42, L43, L44, L45, L46, R46, R40, R41, R42, R43, R44, R45, \ - LEL, LER, L55, L56, R56, R50, REL, RER \ - ) \ - { \ - { L00, L01, L02, L03, L04, L05, L06 }, \ - { L10, L11, L12, L13, L14, L15, L16 }, \ - { L20, L21, L22, L23, L24, L25, L26 }, \ - { L30, L31, L32, L33, L34, L35, L36 }, \ - { L40, L41, L42, L43, L44, L45, L46 }, \ - { LEL, LER, KC_NO, KC_NO, KC_NO, L55, L56 }, \ - { R05, R04, R03, R02, R01, R00, R06 }, \ - { R15, R14, R13, R12, R11, R10, R16 }, \ - { R25, R24, R23, R22, R21, R20, R26 }, \ - { R35, R34, R33, R32, R31, R30, R36 }, \ - { R45, R44, R43, R42, R41, R40, R46 }, \ - { REL, RER, KC_NO, KC_NO, KC_NO, R50, R56 } \ - } - -#define KC________ KC_TRNS -#define KC_RGB_MOD RGB_MOD -#define KC_FN FN -#define KC_ADJ ADJ -#define LAYOUT_kc( \ - L00, L01, L02, L03, L04, L05, L06, R06, R00, R01, R02, R03, R04, R05, \ - L10, L11, L12, L13, L14, L15, L16, R16, R10, R11, R12, R13, R14, R15, \ - L20, L21, L22, L23, L24, L25, L26, R26, R20, R21, R22, R23, R24, R25, \ - L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35, \ - L40, L41, L42, L43, L44, L45, L46, R46, R40, R41, R42, R43, R44, R45, \ - LEL, LER, L55, L56, R56, R50, REL, RER \ - ) \ - LAYOUT( \ - KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##L06, KC_##R06, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \ - KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##L16, KC_##R16, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ - KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##L26, KC_##R26, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ - KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##L34, KC_##L35, KC_##L36, KC_##R36, KC_##R30, KC_##R31, KC_##R32, KC_##R33, KC_##R34, KC_##R35, \ - KC_##L40, KC_##L41, KC_##L42, KC_##L43, KC_##L44, KC_##L45, KC_##L46, KC_##R46, KC_##R40, KC_##R41, KC_##R42, KC_##R43, KC_##R44, KC_##R45, \ - KC_##LEL, KC_##LER, KC_##L55, KC_##L56, KC_##R56, KC_##R50, KC_##REL, KC_##RER \ - ) - -#endif +#pragma once diff --git a/keyboards/sol/rev1/rules.mk b/keyboards/sol/rev1/rules.mk index 99f4dd896..e69de29bb 100644 --- a/keyboards/sol/rev1/rules.mk +++ b/keyboards/sol/rev1/rules.mk @@ -1,2 +0,0 @@ -SRC += rev1/matrix.c \ - rev1/split_util.c diff --git a/keyboards/sol/rev1/split_util.c b/keyboards/sol/rev1/split_util.c deleted file mode 100644 index c645bbdfe..000000000 --- a/keyboards/sol/rev1/split_util.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "split_util.h" -#include "matrix.h" -#include "keyboard.h" -#include "serial.h" - -volatile bool isLeftHand = true; - -static void setup_handedness(void) { - #ifdef EE_HANDS - isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS); - #else - #if defined(MASTER_RIGHT) - isLeftHand = !has_usb(); - #else - isLeftHand = has_usb(); - #endif - #endif -} - -static void keyboard_master_setup(void) { - serial_master_init(); -} - -static void keyboard_slave_setup(void) { - serial_slave_init(); -} - -bool has_usb(void) { - USBCON |= (1 << OTGPADE); //enables VBUS pad - _delay_us(5); - return (USBSTA & (1< -#include "eeconfig.h" - -extern volatile bool isLeftHand; - -// slave version of matix scan, defined in matrix.c -void matrix_slave_scan(void); - -void split_keyboard_setup(void); -bool has_usb(void); - -#endif diff --git a/keyboards/sol/rules.mk b/keyboards/sol/rules.mk index bafdd9c52..b7d689c03 100644 --- a/keyboards/sol/rules.mk +++ b/keyboards/sol/rules.mk @@ -1,5 +1,3 @@ -SRC += serial.c - # MCU name #MCU = at90usb1287 MCU = atmega32u4 @@ -48,6 +46,9 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT # Custom local font file OPT_DEFS += -DOLED_FONT_H=\"common/glcdfont.c\" +SPLIT_KEYBOARD = yes +ENCODER_ENABLE = yes + # Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically @@ -62,6 +63,4 @@ UNICODE_ENABLE = no # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. -CUSTOM_MATRIX = yes - DEFAULT_FOLDER = sol/rev1 diff --git a/keyboards/sol/serial.c b/keyboards/sol/serial.c deleted file mode 100644 index 169b4b176..000000000 --- a/keyboards/sol/serial.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * WARNING: be careful changing this code, it is very timing dependent - */ - -#ifndef F_CPU -#define F_CPU 16000000 -#endif - -#include -#include -#include -#include -#include "serial.h" - -#ifdef USE_SERIAL - -#define _delay_sub_us(x) __builtin_avr_delay_cycles(x) - -// Serial pulse period in microseconds. -#define SELECT_SERIAL_SPEED 1 -#if SELECT_SERIAL_SPEED == 0 - // Very High speed - #define SERIAL_DELAY 4 // micro sec - #define READ_WRITE_START_ADJUST 30 // cycles - #define READ_WRITE_WIDTH_ADJUST 10 // cycles -#elif SELECT_SERIAL_SPEED == 1 - // High speed - #define SERIAL_DELAY 6 // micro sec - #define READ_WRITE_START_ADJUST 23 // cycles - #define READ_WRITE_WIDTH_ADJUST 10 // cycles -#elif SELECT_SERIAL_SPEED == 2 - // Middle speed - #define SERIAL_DELAY 12 // micro sec - #define READ_WRITE_START_ADJUST 25 // cycles - #define READ_WRITE_WIDTH_ADJUST 10 // cycles -#elif SELECT_SERIAL_SPEED == 3 - // Low speed - #define SERIAL_DELAY 24 // micro sec - #define READ_WRITE_START_ADJUST 25 // cycles - #define READ_WRITE_WIDTH_ADJUST 10 // cycles -#elif SELECT_SERIAL_SPEED == 4 - // Very Low speed - #define SERIAL_DELAY 50 // micro sec - #define READ_WRITE_START_ADJUST 25 // cycles - #define READ_WRITE_WIDTH_ADJUST 10 // cycles -#else -#error Illegal Serial Speed -#endif - - -#define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2) -#define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2) - -#define SLAVE_INT_WIDTH 1 -#define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY - -uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; -uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; - -#define SLAVE_DATA_CORRUPT (1<<0) -volatile uint8_t status = 0; - -inline static -void serial_delay(void) { - _delay_us(SERIAL_DELAY); -} - -inline static -void serial_delay_half1(void) { - _delay_us(SERIAL_DELAY_HALF1); -} - -inline static -void serial_delay_half2(void) { - _delay_us(SERIAL_DELAY_HALF2); -} - -inline static -void serial_output(void) { - SERIAL_PIN_DDR |= SERIAL_PIN_MASK; -} - -// make the serial pin an input with pull-up resistor -inline static -void serial_input_with_pullup(void) { - SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK; - SERIAL_PIN_PORT |= SERIAL_PIN_MASK; -} - -inline static -uint8_t serial_read_pin(void) { - return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK); -} - -inline static -void serial_low(void) { - SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; -} - -inline static -void serial_high(void) { - SERIAL_PIN_PORT |= SERIAL_PIN_MASK; -} - -void serial_master_init(void) { - serial_output(); - serial_high(); -} - -void serial_slave_init(void) { - serial_input_with_pullup(); - - -// Enable INT3 -EIMSK |= _BV(INT3); -// Trigger on falling edge of INT3 -EICRA &= ~(_BV(ISC30) | _BV(ISC31)); - -} - -// Used by the sender to synchronize timing with the reciver. -static -void sync_recv(void) { - for (int i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) { - } - // This shouldn't hang if the slave disconnects because the - // serial line will float to high if the slave does disconnect. - while (!serial_read_pin()); -} - -// Used by the reciver to send a synchronization signal to the sender. -static -void sync_send(void) { - serial_low(); - serial_delay(); - serial_high(); -} - -// Reads a byte from the serial line -static -uint8_t serial_read_byte(void) { - uint8_t byte = 0; - _delay_sub_us(READ_WRITE_START_ADJUST); - for ( uint8_t i = 0; i < 8; ++i) { - serial_delay_half1(); // read the middle of pulses - byte = (byte << 1) | serial_read_pin(); - _delay_sub_us(READ_WRITE_WIDTH_ADJUST); - serial_delay_half2(); - } - return byte; -} - -// Sends a byte with MSB ordering -static -void serial_write_byte(uint8_t data) { - uint8_t b = 1<<7; - while( b ) { - if(data & b) { - serial_high(); - } else { - serial_low(); - } - b >>= 1; - serial_delay(); - } - serial_low(); // sync_send() / senc_recv() need raise edge -} - -// interrupt handle to be used by the slave device -ISR(SERIAL_PIN_INTERRUPT) { - serial_output(); - - // slave send phase - uint8_t checksum = 0; - for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) { - sync_send(); - serial_write_byte(serial_slave_buffer[i]); - checksum += serial_slave_buffer[i]; - } - sync_send(); - serial_write_byte(checksum); - - // slave switch to input - sync_send(); //0 - serial_delay_half1(); //1 - serial_low(); //2 - serial_input_with_pullup(); //2 - serial_delay_half1(); //3 - - // slave recive phase - uint8_t checksum_computed = 0; - for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) { - sync_recv(); - serial_master_buffer[i] = serial_read_byte(); - checksum_computed += serial_master_buffer[i]; - } - sync_recv(); - uint8_t checksum_received = serial_read_byte(); - - if ( checksum_computed != checksum_received ) { - status |= SLAVE_DATA_CORRUPT; - } else { - status &= ~SLAVE_DATA_CORRUPT; - } - - sync_recv(); //weit master output to high -} - -inline -bool serial_slave_DATA_CORRUPT(void) { - return status & SLAVE_DATA_CORRUPT; -} - -// Copies the serial_slave_buffer to the master and sends the -// serial_master_buffer to the slave. -// -// Returns: -// 0 => no error -// 1 => slave did not respond -// 2 => checksum error -int serial_update_buffers(void) { - // this code is very time dependent, so we need to disable interrupts - cli(); - - // signal to the slave that we want to start a transaction - serial_output(); - serial_low(); - _delay_us(SLAVE_INT_WIDTH); - - // wait for the slaves response - serial_input_with_pullup(); - _delay_us(SLAVE_INT_RESPONSE_TIME); - - // check if the slave is present - if (serial_read_pin()) { - // slave failed to pull the line low, assume not present - serial_output(); - serial_high(); - sei(); - return 1; - } - - // master recive phase - // if the slave is present syncronize with it - - uint8_t checksum_computed = 0; - // receive data from the slave - for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) { - sync_recv(); - serial_slave_buffer[i] = serial_read_byte(); - checksum_computed += serial_slave_buffer[i]; - } - sync_recv(); - uint8_t checksum_received = serial_read_byte(); - - if (checksum_computed != checksum_received) { - serial_output(); - serial_high(); - sei(); - return 2; - } - - // master switch to output - sync_recv(); //0 - serial_delay(); //1 - serial_low(); //3 - serial_output(); // 3 - serial_delay_half1(); //4 - - // master send phase - uint8_t checksum = 0; - - for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) { - sync_send(); - serial_write_byte(serial_master_buffer[i]); - checksum += serial_master_buffer[i]; - } - sync_send(); - serial_write_byte(checksum); - - // always, release the line when not in use - sync_send(); - - sei(); - return 0; -} - -#endif diff --git a/keyboards/sol/serial.h b/keyboards/sol/serial.h deleted file mode 100644 index cd6bcc76b..000000000 --- a/keyboards/sol/serial.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MY_SERIAL_H -#define MY_SERIAL_H - -#include - -/* TODO: some defines for interrupt setup */ -#define SERIAL_PIN_DDR DDRD -#define SERIAL_PIN_PORT PORTD -#define SERIAL_PIN_INPUT PIND -#define SERIAL_PIN_MASK _BV(PD3) //SErial pin goes here, D0-D3 -#define SERIAL_PIN_INTERRUPT INT3_vect //"INT#" of your serial pin - - -#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 -#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2 - -// Buffers for master - slave communication -extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; -extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; - -void serial_master_init(void); -void serial_slave_init(void); -int serial_update_buffers(void); -bool serial_slave_data_corrupt(void); - -#endif diff --git a/keyboards/sol/sol.h b/keyboards/sol/sol.h index 8f451ce56..8a41702df 100644 --- a/keyboards/sol/sol.h +++ b/keyboards/sol/sol.h @@ -1,7 +1,53 @@ -#ifndef SOL_H -#define SOL_H +#pragma once -#include "rev1.h" #include "quantum.h" - +#ifdef KEYBOARD_sol_rev1 +#include "rev1.h" +#elif KEYBOARD_sol_rev2 +#include "rev2.h" #endif + + +#define LAYOUT( \ + L00, L01, L02, L03, L04, L05, L06, R06, R00, R01, R02, R03, R04, R05, \ + L10, L11, L12, L13, L14, L15, L16, R16, R10, R11, R12, R13, R14, R15, \ + L20, L21, L22, L23, L24, L25, L26, R26, R20, R21, R22, R23, R24, R25, \ + L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35, \ + L40, L41, L42, L43, L44, L45, L46, R46, R40, R41, R42, R43, R44, R45, \ + L55, L56, R56, R50 \ + ) \ + { \ + { L00, L01, L02, L03, L04, L05, L06 }, \ + { L10, L11, L12, L13, L14, L15, L16 }, \ + { L20, L21, L22, L23, L24, L25, L26 }, \ + { L30, L31, L32, L33, L34, L35, L36 }, \ + { L40, L41, L42, L43, L44, L45, L46 }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, L55, L56 }, \ + { R05, R04, R03, R02, R01, R00, R06 }, \ + { R15, R14, R13, R12, R11, R10, R16 }, \ + { R25, R24, R23, R22, R21, R20, R26 }, \ + { R35, R34, R33, R32, R31, R30, R36 }, \ + { R45, R44, R43, R42, R41, R40, R46 }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, R50, R56 } \ + } + +#define KC________ KC_TRNS +#define KC_RGB_MOD RGB_MOD +#define KC_FN FN +#define KC_ADJ ADJ +#define LAYOUT_kc( \ + L00, L01, L02, L03, L04, L05, L06, R06, R00, R01, R02, R03, R04, R05, \ + L10, L11, L12, L13, L14, L15, L16, R16, R10, R11, R12, R13, R14, R15, \ + L20, L21, L22, L23, L24, L25, L26, R26, R20, R21, R22, R23, R24, R25, \ + L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35, \ + L40, L41, L42, L43, L44, L45, L46, R46, R40, R41, R42, R43, R44, R45, \ + L55, L56, R56, R50 \ + ) \ + LAYOUT( \ + KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##L06, KC_##R06, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \ + KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##L16, KC_##R16, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ + KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##L26, KC_##R26, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ + KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##L34, KC_##L35, KC_##L36, KC_##R36, KC_##R30, KC_##R31, KC_##R32, KC_##R33, KC_##R34, KC_##R35, \ + KC_##L40, KC_##L41, KC_##L42, KC_##L43, KC_##L44, KC_##L45, KC_##L46, KC_##R46, KC_##R40, KC_##R41, KC_##R42, KC_##R43, KC_##R44, KC_##R45, \ + KC_##L55, KC_##L56, KC_##R56, KC_##R50 \ + ) diff --git a/quantum/quantum.c b/quantum/quantum.c index fcedf0bc1..d4fa7f2ef 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -247,12 +247,6 @@ bool process_record_quantum(keyrecord_t *record) { preprocess_tap_dance(keycode, record); #endif - #if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) - // Wake up oled if user is using those fabulous keys! - if (record->event.pressed) - oled_on(); - #endif - if (!( #if defined(KEY_LOCK_ENABLE) // Must run first to be able to mask key_up events. @@ -976,9 +970,6 @@ void matrix_init_quantum() { #ifdef OUTPUT_AUTO_ENABLE set_output(OUTPUT_AUTO); #endif - #ifdef OLED_DRIVER_ENABLE - oled_init(OLED_ROTATION_0); - #endif matrix_init_kb(); } @@ -1015,10 +1006,6 @@ void matrix_scan_quantum() { haptic_task(); #endif - #ifdef OLED_DRIVER_ENABLE - oled_task(); - #endif - matrix_scan_kb(); } #if defined(BACKLIGHT_ENABLE) && (defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS)) @@ -1214,10 +1201,10 @@ void backlight_task(void) { // (which is not possible since the backlight is not wired to PWM pins on the // CPU), we do the LED on/off by oursleves. // The timer is setup to count up to 0xFFFF, and we set the Output Compare -// register to the current 16bits backlight level (after CIE correction). -// This means the CPU will trigger a compare match interrupt when the counter -// reaches the backlight level, where we turn off the LEDs, -// but also an overflow interrupt when the counter rolls back to 0, +// register to the current 16bits backlight level (after CIE correction). +// This means the CPU will trigger a compare match interrupt when the counter +// reaches the backlight level, where we turn off the LEDs, +// but also an overflow interrupt when the counter rolls back to 0, // in which we're going to turn on the LEDs. // The LED will then be on for OCRxx/0xFFFF time, adjusted every 244Hz. @@ -1229,7 +1216,7 @@ ISR(TIMERx_COMPA_vect) { } // Triggered when the counter reaches the TOP value -// this one triggers at F_CPU/65536 =~ 244 Hz +// this one triggers at F_CPU/65536 =~ 244 Hz ISR(TIMERx_OVF_vect) { #ifdef BACKLIGHT_BREATHING breathing_task(); diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index eb110bd23..3c3daf3d3 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -299,7 +299,7 @@ uint8_t _matrix_scan(void) { debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed); - return 1; + return (uint8_t)changed; } uint8_t matrix_scan(void) { diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 52546866e..85d252548 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -75,6 +75,9 @@ along with this program. If not, see . #ifdef QWIIC_ENABLE # include "qwiic.h" #endif +#ifdef OLED_DRIVER_ENABLE + #include "oled_driver.h" +#endif #ifdef VELOCIKEY_ENABLE #include "velocikey.h" #endif @@ -205,6 +208,9 @@ void keyboard_init(void) { #ifdef QWIIC_ENABLE qwiic_init(); #endif +#ifdef OLED_DRIVER_ENABLE + oled_init(OLED_ROTATION_0); +#endif #ifdef PS2_MOUSE_ENABLE ps2_mouse_init(); #endif @@ -262,7 +268,11 @@ void keyboard_task(void) uint8_t keys_processed = 0; #endif +#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) + uint8_t ret = matrix_scan(); +#else matrix_scan(); +#endif if (is_keyboard_master()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -306,6 +316,15 @@ MATRIX_LOOP_END: qwiic_task(); #endif +#ifdef OLED_DRIVER_ENABLE + oled_task(); +#ifndef OLED_DISABLE_TIMEOUT + // Wake up oled if user is using those fabulous keys! + if (ret) + oled_on(); +#endif +#endif + #ifdef MOUSEKEY_ENABLE // mousekey repeat & acceleration mousekey_task(); -- cgit v1.2.3-70-g09d2 From 12e6d412023b23c64980d30704ae11892e33c512 Mon Sep 17 00:00:00 2001 From: Rainer Clasen Date: Tue, 7 May 2019 19:45:10 +0200 Subject: [Split] fix split_common i2c backlight disabling (#3886) slave backlight was always on - as get_backlight_level() doesn't indicate if the backlight is enabled or not. also updated the corosponding code for serial transport to stop peeking directly at 'internal' backlight_config structure. --- quantum/split_common/transport.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 7ea1a9cec..a3539576f 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c @@ -13,7 +13,6 @@ #ifdef BACKLIGHT_ENABLE # include "backlight.h" -extern backlight_config_t backlight_config; #endif #ifdef ENCODER_ENABLE @@ -55,7 +54,7 @@ bool transport_master(matrix_row_t matrix[]) { // write backlight info # ifdef BACKLIGHT_ENABLE - uint8_t level = get_backlight_level(); + uint8_t level = is_backlight_enabled() ? get_backlight_level() : 0; if (level != i2c_buffer->backlight_level) { if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_BACKLIGHT_START, (void *)&level, sizeof(level), TIMEOUT) >= 0) { i2c_buffer->backlight_level = level; @@ -223,7 +222,7 @@ bool transport_master(matrix_row_t matrix[]) { # ifdef BACKLIGHT_ENABLE // Write backlight level for slave to read - serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0; + serial_m2s_buffer.backlight_level = is_backlight_enabled() ? get_backlight_level() : 0; # endif # ifdef ENCODER_ENABLE -- cgit v1.2.3-70-g09d2 From af89752bffbaf5dcea30ea16be66b4d682701bc4 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 7 May 2019 18:22:46 -0500 Subject: rgb_led struct conversion (aka: Per led (key) type rgb matrix effects - part 2) (#5783) * Initial conversion of the rgb_led struct * Converting last keyboard & updating effects to take advantage of the new structure * New struct should not be const * Updated docs * Changing define ___ for no led to NO_LED * Missed converting some keymap usages of the old struct layout --- docs/feature_rgb_matrix.md | 32 +- keyboards/boston_meetup/2019/2019.c | 40 +- keyboards/crkbd/rev1/rev1.c | 125 +++--- keyboards/doro67/rgb/rgb.c | 103 ++--- keyboards/dztech/dz40rgb/dz40rgb.c | 163 ++------ keyboards/dztech/dz40rgb/keymaps/default/keymap.c | 6 +- .../dztech/dz40rgb/keymaps/split_space/keymap.c | 6 +- keyboards/dztech/dz60rgb/dz60rgb.c | 419 +++++---------------- keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c | 5 +- keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c | 5 +- keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c | 5 +- keyboards/dztech/dz60rgb/keymaps/iso/keymap.c | 5 +- keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c | 30 +- keyboards/dztech/dz65rgb/dz65rgb.c | 90 +---- keyboards/ergodox_ez/ergodox_ez.c | 99 ++--- keyboards/exclusive/e6_rgb/e6_rgb.c | 130 +++---- keyboards/hadron/ver3/ver3.c | 45 +-- keyboards/hs60/v1/v1.c | 218 ++++------- keyboards/massdrop/alt/config_led.c | 143 ++----- keyboards/massdrop/ctrl/config_led.c | 180 +++------ keyboards/model01/leds.c | 95 ++--- keyboards/planck/ez/ez.c | 78 ++-- keyboards/planck/keymaps/tom/keymap.c | 11 +- keyboards/planck/light/light.c | 87 ++--- keyboards/sol/rev1/rev1.c | 115 ++---- keyboards/sol/sol.c | 19 - layouts/community/ergodox/drashna/keymap.c | 7 +- layouts/community/ortho_4x12/drashna/keymap.c | 5 +- quantum/rgb_matrix.c | 16 +- quantum/rgb_matrix.h | 4 +- quantum/rgb_matrix_animations/alpha_mods_anim.h | 4 +- quantum/rgb_matrix_animations/cycle_all_anim.h | 2 +- .../rgb_matrix_animations/cycle_left_right_anim.h | 5 +- quantum/rgb_matrix_animations/cycle_up_down_anim.h | 5 +- quantum/rgb_matrix_animations/dual_beacon_anim.h | 5 +- .../rgb_matrix_animations/gradient_up_down_anim.h | 5 +- .../jellybean_raindrops_anim.h | 4 +- .../rgb_matrix_animations/rainbow_beacon_anim.h | 5 +- .../rainbow_moving_chevron_anim.h | 5 +- .../rgb_matrix_animations/rainbow_pinwheels_anim.h | 5 +- quantum/rgb_matrix_animations/raindrops_anim.h | 3 +- quantum/rgb_matrix_animations/solid_color_anim.h | 1 + .../rgb_matrix_animations/solid_reactive_anim.h | 1 + .../rgb_matrix_animations/solid_reactive_cross.h | 7 +- .../rgb_matrix_animations/solid_reactive_nexus.h | 7 +- .../solid_reactive_simple_anim.h | 1 + .../rgb_matrix_animations/solid_reactive_wide.h | 7 +- quantum/rgb_matrix_animations/solid_splash_anim.h | 7 +- quantum/rgb_matrix_animations/splash_anim.h | 7 +- quantum/rgb_matrix_types.h | 18 +- tmk_core/protocol/arm_atsam/led_matrix.c | 9 +- 51 files changed, 755 insertions(+), 1644 deletions(-) (limited to 'quantum') diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index 91ec77ace..5eb9d5536 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md @@ -124,21 +124,25 @@ Configure the hardware via your `config.h`: --- -From this point forward the configuration is the same for all the drivers. The struct rgb_led array tells the system for each led, what key electrical matrix it represents, what the physical position is on the board, and if the led is for a modifier key or not. Here is a brief example: +From this point forward the configuration is the same for all the drivers. The `led_config_t` struct provides a key electrical matrix to led index lookup table, what the physical position of each LED is on the board, and what type of key or usage the LED if the LED represents. Here is a brief example: ```C -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { -/* {row | col << 4} - * | {x=0..224, y=0..64} - * | | flags - * | | | */ - {{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, - {{0|(1<<4)}, {20.36*1, 21.33*0}, 4}, - .... -} +const led_config_t g_led_config = { { + // Key Matrix to LED Index + { 5, NO_LED, NO_LED, 0 }, + { NO_LED, NO_LED, NO_LED, NO_LED }, + { 4, NO_LED, NO_LED, 1 }, + { 3, NO_LED, NO_LED, 2 } +}, { + // LED Index to Physical Position + { 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 } +}, { + // LED Index to Flag + 1, 4, 4, 4, 4, 1 +} }; ``` -The first part, `{row | col << 4}`, tells the system what key this LED represents by using the key's electrical matrix row & col. The second part, `{x=0..224, y=0..64}` represents the LED's physical position on the keyboard. The `x` is between (inclusive) 0-224, and `y` is between (inclusive) 0-64 as the effects are based on this range. The easiest way to calculate these positions is imagine your keyboard is a grid, and the top left of the keyboard represents x, y coordinate 0, 0 and the bottom right of your keyboard represents 224, 64. Using this as a basis, you can use the following formula to calculate the physical position: +The first part, `// Key Matrix to LED Index`, tells the system what key this LED represents by using the key's electrical matrix row & col. The second part, `// LED Index to Physical Position` represents the LED's physical position on the keyboard. The first value, `x`, is between 0-224 (inclusive), and the second value, `y`, is between 0-64 (inclusive). This range is due to effect that calculate the center or halves for their animations. The easiest way to calculate these positions is imagine your keyboard is a grid, and the top left of the keyboard represents x, y coordinate 0, 0 and the bottom right of your keyboard represents 224, 64. Using this as a basis, you can use the following formula to calculate the physical position: ```C x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION @@ -147,7 +151,7 @@ y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based on the physical layout of your keyboard, not the electrical layout. -`flags` is a bitmask, whether or not a certain LEDs is of a certain type. It is recommended that LEDs are set to only 1 type. +`// LED Index to Flag` is a bitmask, whether or not a certain LEDs is of a certain type. It is recommended that LEDs are set to only 1 type. ## Flags @@ -155,8 +159,8 @@ Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based |------------------------------------|-------------------------------------------| |`#define HAS_FLAGS(bits, flags)` |Returns true if `bits` has all `flags` set.| |`#define HAS_ANY_FLAGS(bits, flags)`|Returns true if `bits` has any `flags` set.| -|`#define LED_FLAG_NONE 0x00` |If thes LED has no flags. | -|`#define LED_FLAG_ALL 0xFF` |If thes LED has all flags. | +|`#define LED_FLAG_NONE 0x00` |If this LED has no flags. | +|`#define LED_FLAG_ALL 0xFF` |If this LED has all flags. | |`#define LED_FLAG_MODIFIER 0x01` |If the Key for this LED is a modifier. | |`#define LED_FLAG_UNDERGLOW 0x02` |If the LED is for underglow. | |`#define LED_FLAG_KEYLIGHT 0x04` |If the LED is for key backlight. | diff --git a/keyboards/boston_meetup/2019/2019.c b/keyboards/boston_meetup/2019/2019.c index 45c185549..933c14dee 100644 --- a/keyboards/boston_meetup/2019/2019.c +++ b/keyboards/boston_meetup/2019/2019.c @@ -19,20 +19,18 @@ #include "haptic.h" #ifdef RGB_MATRIX_ENABLE -#include "rgblight.h" - -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - /*{row | col << 4} - | {x=0..224, y=0..64} - | | modifier - | | | */ - {{1|(3<<4)}, {188, 16}, 4}, - {{3|(3<<4)}, {187, 48}, 4}, - {{4|(2<<4)}, {149, 64}, 4}, - {{4|(1<<4)}, {112, 64}, 4}, - {{3|(0<<4)}, {37, 48}, 4}, - {{1|(0<<4)}, {38, 16}, 4} -}; +#include "rgb_matrix.h" + +led_config_t g_led_config = { { + { 5, NO_LED, NO_LED, 0 }, + { NO_LED, NO_LED, NO_LED, NO_LED }, + { 4, NO_LED, NO_LED, 1 }, + { 3, NO_LED, NO_LED, 2 } +}, { + { 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 } +}, { + 4, 4, 4, 4, 4, 4 +} }; #endif uint8_t *o_fb; @@ -48,12 +46,12 @@ uint16_t counterst = 0; #define ScreenOffInterval 60000 /* milliseconds */ static uint16_t last_flush; -volatile uint8_t led_numlock = false; -volatile uint8_t led_capslock = false; +volatile uint8_t led_numlock = false; +volatile uint8_t led_capslock = false; volatile uint8_t led_scrolllock = false; static uint8_t layer; -static bool queue_for_send = false; +static bool queue_for_send = false; static uint8_t encoder_value = 32; __attribute__ ((weak)) @@ -64,13 +62,13 @@ void draw_ui(void) { /* Boston MK title is 55 x 10 pixels */ #define NAME_X 0 -#define NAME_Y 0 +#define NAME_Y 0 draw_string(NAME_X + 1, NAME_Y + 2, "BOSTON MK", PIXEL_ON, NORM, 0); /* Layer indicator is 41 x 10 pixels */ #define LAYER_INDICATOR_X 60 -#define LAYER_INDICATOR_Y 0 +#define LAYER_INDICATOR_Y 0 draw_string(LAYER_INDICATOR_X + 1, LAYER_INDICATOR_Y + 2, "LAYER", PIXEL_ON, NORM, 0); draw_rect_filled_soft(LAYER_INDICATOR_X + 32, LAYER_INDICATOR_Y + 1, 9, 9, PIXEL_ON, NORM); @@ -88,7 +86,7 @@ void draw_ui(void) { draw_pixel(MATRIX_DISPLAY_X + y + y + 3, MATRIX_DISPLAY_Y + x + x + 3,(matrix_get_row(x) & (1 << y)) > 0, NORM); } - } + } draw_rect_soft(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y, 12, 12, PIXEL_ON, NORM); /* hadron oled location on thumbnail */ draw_rect_filled_soft(MATRIX_DISPLAY_X + 5, MATRIX_DISPLAY_Y + 2, 6, 2, PIXEL_ON, NORM); @@ -195,7 +193,7 @@ void matrix_init_kb(void) { queue_for_send = true; matrix_init_user(); } - + void matrix_scan_kb(void) { if (queue_for_send) { #ifdef QWIIC_MICRO_OLED_ENABLE diff --git a/keyboards/crkbd/rev1/rev1.c b/keyboards/crkbd/rev1/rev1.c index 2345028d2..38ab92788 100644 --- a/keyboards/crkbd/rev1/rev1.c +++ b/keyboards/crkbd/rev1/rev1.c @@ -51,78 +51,65 @@ void led_set_kb(uint8_t usb_led) { // 05 06 06 05 // 15 14 07 07 14 15 3 -/* {row | col << 4} logical layout rows/cols - * | {x=0..224, y=0..64} physical layout - * | | | modifier - * | | | */ -#define RGB_MATRIX_LEFT_LEDS \ - { { 0xFF }, { 85, 16 }, 2 }, /* 1 */ \ - { { 0xFF }, { 50, 13 }, 2 }, /* 2 */ \ - { { 0xFF }, { 16, 20 }, 2 }, /* 3 */ \ - { { 0xFF }, { 16, 38 }, 2 }, /* 4 */ \ - { { 0xFF }, { 50, 48 }, 2 }, /* 5 */ \ - { { 0xFF }, { 85, 52 }, 2 }, /* 6 */ \ - { { 3 | ( 5 << 4 ) }, { 95, 63 }, 1 }, /* 7 */ \ - { { 2 | ( 5 << 4 ) }, { 85, 39 }, 4 }, /* 8 */ \ - { { 1 | ( 5 << 4 ) }, { 85, 21 }, 4 }, /* 9 */ \ - { { 0 | ( 5 << 4 ) }, { 85, 4 }, 4 }, /* 10 */ \ - { { 0 | ( 4 << 4 ) }, { 68, 02 }, 4 }, /* 11 */ \ - { { 1 | ( 4 << 4 ) }, { 68, 19 }, 4 }, /* 12 */ \ - { { 2 | ( 4 << 4 ) }, { 68, 37 }, 4 }, /* 13 */ \ - { { 3 | ( 4 << 4 ) }, { 80, 58 }, 1 }, /* 14 */ \ - { { 3 | ( 3 << 4 ) }, { 60, 55 }, 1 }, /* 15 */ \ - { { 2 | ( 3 << 4 ) }, { 50, 35 }, 4 }, /* 16 */ \ - { { 1 | ( 3 << 4 ) }, { 50, 13 }, 4 }, /* 17 */ \ - { { 0 | ( 3 << 4 ) }, { 50, 0 }, 4 }, /* 18 */ \ - { { 0 | ( 2 << 4 ) }, { 33, 3 }, 4 }, /* 19 */ \ - { { 1 | ( 2 << 4 ) }, { 33, 20 }, 4 }, /* 20 */ \ - { { 2 | ( 2 << 4 ) }, { 33, 37 }, 4 }, /* 21 */ \ - { { 2 | ( 1 << 4 ) }, { 16, 42 }, 4 }, /* 22 */ \ - { { 1 | ( 1 << 4 ) }, { 16, 24 }, 4 }, /* 23 */ \ - { { 0 | ( 1 << 4 ) }, { 16, 7 }, 4 }, /* 24 */ \ - { { 0 | ( 0 << 4 ) }, { 0, 7 }, 1 }, /* 25 */ \ - { { 1 | ( 0 << 4 ) }, { 0, 24 }, 1 }, /* 26 */ \ - { { 2 | ( 0 << 4 ) }, { 0, 41 }, 1 }, /* 27 */ - -#define RGB_MATRIX_RIGHT_LEDS \ - { { 0xFF }, { 139, 16 }, 2 }, /* 1 */ \ - { { 0xFF }, { 174, 13 }, 2 }, /* 2 */ \ - { { 0xFF }, { 208, 20 }, 2 }, /* 3 */ \ - { { 0xFF }, { 208, 38 }, 2 }, /* 4 */ \ - { { 0xFF }, { 174, 48 }, 2 }, /* 5 */ \ - { { 0xFF }, { 139, 52 }, 2 }, /* 6 */ \ - { { 7 | ( 5 << 4 ) }, { 129, 63 }, 1 }, /* 7 */ \ - { { 6 | ( 5 << 4 ) }, { 139, 39 }, 4 }, /* 8 */ \ - { { 5 | ( 5 << 4 ) }, { 139, 21 }, 4 }, /* 9 */ \ - { { 4 | ( 5 << 4 ) }, { 139, 4 }, 4 }, /* 10 */ \ - { { 4 | ( 4 << 4 ) }, { 156, 02 }, 4 }, /* 11 */ \ - { { 5 | ( 4 << 4 ) }, { 156, 19 }, 4 }, /* 12 */ \ - { { 6 | ( 4 << 4 ) }, { 156, 37 }, 4 }, /* 13 */ \ - { { 7 | ( 4 << 4 ) }, { 144, 58 }, 1 }, /* 14 */ \ - { { 7 | ( 3 << 4 ) }, { 164, 55 }, 1 }, /* 15 */ \ - { { 6 | ( 3 << 4 ) }, { 174, 35 }, 4 }, /* 16 */ \ - { { 5 | ( 3 << 4 ) }, { 174, 13 }, 4 }, /* 17 */ \ - { { 4 | ( 3 << 4 ) }, { 174, 0 }, 4 }, /* 18 */ \ - { { 4 | ( 2 << 4 ) }, { 191, 3 }, 4 }, /* 19 */ \ - { { 5 | ( 2 << 4 ) }, { 191, 20 }, 4 }, /* 20 */ \ - { { 6 | ( 2 << 4 ) }, { 191, 37 }, 4 }, /* 21 */ \ - { { 6 | ( 1 << 4 ) }, { 208, 42 }, 4 }, /* 22 */ \ - { { 5 | ( 1 << 4 ) }, { 208, 24 }, 4 }, /* 23 */ \ - { { 4 | ( 1 << 4 ) }, { 208, 7 }, 4 }, /* 24 */ \ - { { 4 | ( 0 << 4 ) }, { 224, 7 }, 1 }, /* 25 */ \ - { { 5 | ( 0 << 4 ) }, { 224, 24 }, 1 }, /* 26 */ \ - { { 6 | ( 0 << 4 ) }, { 224, 41 }, 1 }, /* 27 */ #ifdef RGB_MATRIX_SPLIT_RIGHT -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - RGB_MATRIX_RIGHT_LEDS - RGB_MATRIX_LEFT_LEDS - }; +led_config_t g_led_config = { { + { 51, 50, 45, 44, 37, 36, NO_LED }, + { 52, 49, 46, 43, 38, 35, NO_LED }, + { 53, 48, 47, 42, 39, 34, NO_LED }, + { NO_LED, NO_LED, NO_LED, 41, 40, 33, NO_LED }, + { 24, 23, 18, 17, 10, 9, NO_LED }, + { 25, 22, 19, 16, 11, 8, NO_LED }, + { 26, 21, 20, 15, 12, 7, NO_LED }, + { NO_LED, NO_LED, NO_LED, 14, 13, 6, NO_LED } +}, { + { 139, 16 }, { 174, 13 }, { 208, 20 }, { 208, 38 }, { 174, 48 }, { 139, 52 }, { 129, 63 }, + { 139, 39 }, { 139, 21 }, { 139, 4 }, { 156, 2 }, { 156, 19 }, { 156, 37 }, { 144, 58 }, + { 164, 55 }, { 174, 35 }, { 174, 13 }, { 174, 0 }, { 191, 3 }, { 191, 20 }, { 191, 37 }, + { 208, 42 }, { 208, 24 }, { 208, 7 }, { 224, 7 }, { 224, 24 }, { 224, 41 }, { 85, 16 }, + { 50, 13 }, { 16, 20 }, { 16, 38 }, { 50, 48 }, { 85, 52 }, { 95, 63 }, { 85, 39 }, + { 85, 21 }, { 85, 4 }, { 68, 2 }, { 68, 19 }, { 68, 37 }, { 80, 58 }, { 60, 55 }, + { 50, 35 }, { 50, 13 }, { 50, 0 }, { 33, 3 }, { 33, 20 }, { 33, 37 }, { 16, 42 }, + { 16, 24 }, { 16, 7 }, { 0, 7 }, { 0, 24 }, { 0, 41 } +}, { + 2, 2, 2, 2, 2, 2, 1, + 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 1, 4, + 4, 4, 4, 4, 4, 1, 1, + 4, 4, 4, 4, 4, 4, 4, + 4, 4, 1, 1, 1 +} }; #else -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - RGB_MATRIX_LEFT_LEDS - RGB_MATRIX_RIGHT_LEDS - }; +led_config_t g_led_config = { { + { 24, 23, 18, 17, 10, 9, NO_LED }, + { 25, 22, 19, 16, 11, 8, NO_LED }, + { 26, 21, 20, 15, 12, 7, NO_LED }, + { NO_LED, NO_LED, NO_LED, 14, 13, 6, NO_LED }, + { 51, 50, 45, 44, 37, 36, NO_LED }, + { 52, 49, 46, 43, 38, 35, NO_LED }, + { 53, 48, 47, 42, 39, 34, NO_LED }, + { NO_LED, NO_LED, NO_LED, 41, 40, 33, NO_LED } +}, { + { 85, 16 }, { 50, 13 }, { 16, 20 }, { 16, 38 }, { 50, 48 }, { 85, 52 }, { 95, 63 }, + { 85, 39 }, { 85, 21 }, { 85, 4 }, { 68, 2 }, { 68, 19 }, { 68, 37 }, { 80, 58 }, + { 60, 55 }, { 50, 35 }, { 50, 13 }, { 50, 0 }, { 33, 3 }, { 33, 20 }, { 33, 37 }, + { 16, 42 }, { 16, 24 }, { 16, 7 }, { 0, 7 }, { 0, 24 }, { 0, 41 }, { 139, 16 }, + { 174, 13 }, { 208, 20 }, { 208, 38 }, { 174, 48 }, { 139, 52 }, { 129, 63 }, { 139, 39 }, + { 139, 21 }, { 139, 4 }, { 156, 2 }, { 156, 19 }, { 156, 37 }, { 144, 58 }, { 164, 55 }, + { 174, 35 }, { 174, 13 }, { 174, 0 }, { 191, 3 }, { 191, 20 }, { 191, 37 }, { 208, 42 }, + { 208, 24 }, { 208, 7 }, { 224, 7 }, { 224, 24 }, { 224, 41 } +}, { + 2, 2, 2, 2, 2, 2, 1, + 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 1, 4, + 4, 4, 4, 4, 4, 1, 1, + 4, 4, 4, 4, 4, 4, 4, + 4, 4, 1, 1, 1 +} }; #endif #endif diff --git a/keyboards/doro67/rgb/rgb.c b/keyboards/doro67/rgb/rgb.c index 8aaf6ef4a..e8c9ac632 100644 --- a/keyboards/doro67/rgb/rgb.c +++ b/keyboards/doro67/rgb/rgb.c @@ -14,6 +14,7 @@ * along with this program. If not, see . */ #include "rgb.h" +#include "rgb_matrix_types.h" // Optional override functions below. // You can leave any or all of these undefined. @@ -52,76 +53,32 @@ void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); } -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{0|(0<<4)}, {15*0, 0}, 4}, // Esc - {{0|(1<<4)}, {15*1, 0}, 4}, // 1 - {{0|(2<<4)}, {15*2, 0}, 4}, // 2 - {{0|(3<<4)}, {15*3, 0}, 4}, // 3 - {{0|(4<<4)}, {15*4, 0}, 4}, // 4 - {{0|(5<<4)}, {15*5, 0}, 4}, // 5 - {{0|(6<<4)}, {15*6, 0}, 4}, // 6 - {{0|(7<<4)}, {15*7, 0}, 4}, // 7 - {{0|(8<<4)}, {15*8, 0}, 4}, // 8 - {{0|(9<<4)}, {15*9, 0}, 4}, // 9 - {{0|(10<<4)}, {15*10, 0}, 4}, // 0 - {{0|(11<<4)}, {15*11, 0}, 4}, // - - {{0|(12<<4)}, {15*12, 0}, 4}, // = - {{0|(13<<4)}, {15*13.5, 0}, 1}, // Backspace - {{0|(14<<4)}, {15*15, 0}, 1}, // Ins - - {{1|(0<<4)}, {15*0.5, 16}, 1}, // Tab - {{1|(1<<4)}, {15*1.5, 16}, 4}, // Q - {{1|(2<<4)}, {15*2.5, 16}, 4}, // W - {{1|(3<<4)}, {15*3.5, 16}, 4}, // E - {{1|(4<<4)}, {15*4.5, 16}, 4}, // R - {{1|(5<<4)}, {15*5.5, 16}, 4}, // T - {{1|(6<<4)}, {15*6.5, 16}, 4}, // Y - {{1|(7<<4)}, {15*7.5, 16}, 4}, // U - {{1|(8<<4)}, {15*8.5, 16}, 4}, // I - {{1|(9<<4)}, {15*9.5, 16}, 4}, // O - {{1|(10<<4)}, {15*10.5, 16}, 4}, // P - {{1|(11<<4)}, {15*11.5, 16}, 4}, // [ - {{1|(12<<4)}, {15*12.5, 16}, 4}, // ] - {{1|(13<<4)}, {15*13.75, 16}, 1}, // - {{1|(14<<4)}, {15*15, 16}, 1}, // Del - - {{2|(0<<4)}, {15*0.75, 32}, 1}, // Capslock - {{2|(1<<4)}, {15*1.75, 32}, 4}, // A - {{2|(2<<4)}, {15*2.75, 32}, 4}, // S - {{2|(3<<4)}, {15*3.75, 32}, 4}, // D - {{2|(4<<4)}, {15*4.75, 32}, 4}, // F - {{2|(5<<4)}, {15*5.75, 32}, 4}, // G - {{2|(6<<4)}, {15*6.75, 32}, 4}, // H - {{2|(7<<4)}, {15*7.75, 32}, 4}, // J - {{2|(8<<4)}, {15*8.75, 32}, 4}, // K - {{2|(9<<4)}, {15*9.75, 32}, 4}, // L - {{2|(10<<4)}, {15*10.75, 32}, 4}, // ; - {{2|(11<<4)}, {15*11.75, 32}, 4}, // ' - {{2|(13<<4)}, {15*13.25, 32}, 1}, // Enter - {{2|(14<<4)}, {15*15, 32}, 1}, // Pgup - - {{3|(0<<4)}, {15*1.25, 48}, 1}, // LShift - {{3|(2<<4)}, {15*2, 48}, 4}, // Z - {{3|(3<<4)}, {15*3, 48}, 4}, // X - {{3|(4<<4)}, {15*4, 48}, 4}, // C - {{3|(5<<4)}, {15*5, 48}, 4}, // V - {{3|(6<<4)}, {15*6, 48}, 4}, // B - {{3|(7<<4)}, {15*7, 48}, 4}, // N - {{3|(8<<4)}, {15*8, 48}, 4}, // M - {{3|(9<<4)}, {15*9, 48}, 4}, // , - {{3|(10<<4)}, {15*10, 48}, 4}, // . - {{3|(11<<4)}, {15*11, 48}, 4}, // / - {{3|(12<<4)}, {15*12.75, 48}, 1}, // Shift - {{3|(13<<4)}, {15*14, 48}, 1}, // Up - {{3|(14<<4)}, {15*15, 48}, 1}, // Pgdn - - {{4|(0<<4)}, {15*0.25, 64}, 1}, // Ctrl - {{4|(1<<4)}, {15*1.5, 64}, 1}, // GUI - {{4|(2<<4)}, {15*2.25, 64}, 1}, // Alt - {{4|(3<<4)}, {15*6.75, 64}, 4}, // Space - {{4|(9<<4)}, {15*9, 64}, 1}, // RAlt - {{4|(10<<4)}, {15*10.25, 64}, 1}, // FN - {{4|(12<<4)}, {15*13, 64}, 1}, // Left - {{4|(13<<4)}, {15*14, 64}, 1}, // Down - {{4|(14<<4)}, {15*15, 64}, 1}, // Right -}; +led_config_t g_led_config = { { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, + { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 }, + { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, NO_LED, 42, 43 }, + { 44, NO_LED, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 }, + { 58, 59, 60, 61, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, 62, 63, NO_LED, 64, 65, 66 } +}, { + // Esc, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -, =, Backspace, Ins + { 0, 0 }, { 15, 0 }, { 30, 0 }, { 45, 0 }, { 60, 0 }, { 75, 0 }, { 90, 0 }, { 105, 0 }, { 120, 0 }, { 135, 0 }, { 150, 0 }, { 165, 0 }, { 180, 0 }, { 202, 0 }, { 225, 0 }, + // Tab, Q, W, E, R, T, Y, U, I, O, P, [, ], , Del + { 7, 16 }, { 22, 16 }, { 37, 16 }, { 52, 16 }, { 67, 16 }, { 82, 16 }, { 97, 16 }, { 112, 16 }, { 127, 16 }, { 142, 16 }, { 157, 16 }, { 172, 16 }, { 187, 16 }, { 206, 16 }, { 225, 16 }, + // Capslock, A, S, D, F, G, H, J, K, L, ;, ', Enter, Pgup + { 11, 32 }, { 26, 32 }, { 41, 32 }, { 56, 32 }, { 71, 32 }, { 86, 32 }, { 101, 32 }, { 116, 32 }, { 131, 32 }, { 146, 32 }, { 161, 32 }, { 176, 32 }, { 198, 32 }, { 225, 32 }, + // LShift, Z, X, C, V, B, N, M, ,, ., /, Shift, Up, Pgdn + { 18, 48 }, { 30, 48 }, { 45, 48 }, { 60, 48 }, { 75, 48 }, { 90, 48 }, { 105, 48 }, { 120, 48 }, { 135, 48 }, { 150, 48 }, { 165, 48 }, { 191, 48 }, { 210, 48 }, { 225, 48 }, + // Ctrl, GUI, Alt, Space, RAlt, FN, Left, Down, Right + { 3, 64 }, { 22, 64 }, { 33, 64 }, { 101, 64 }, { 135, 64 }, { 153, 64 }, { 195, 64 }, { 210, 64 }, { 225, 64 } +}, { + // Esc, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -, =, Backspace, Ins + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, + // Tab, Q, W, E, R, T, Y, U, I, O, P, [, ], , Del + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, + // Capslock, A, S, D, F, G, H, J, K, L, ;, ', Enter, Pgup + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, + // LShift, Z, X, C, V, B, N, M, ,, ., /, Shift, Up, Pgdn + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, + // Ctrl, GUI, Alt, Space, RAlt, FN, Left, Down, Right + 1, 1, 1, 4, 1, 1, 1, 1, 1 +} }; diff --git a/keyboards/dztech/dz40rgb/dz40rgb.c b/keyboards/dztech/dz40rgb/dz40rgb.c index 34bfc4366..e5e39c92a 100644 --- a/keyboards/dztech/dz40rgb/dz40rgb.c +++ b/keyboards/dztech/dz40rgb/dz40rgb.c @@ -52,7 +52,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, E_3, D_3, F_3}, {0, E_2, D_2, F_2}, {0, E_1, D_1, F_1}, - + {0, E_13, D_13, F_13}, {0, E_14, D_14, F_14}, @@ -71,70 +71,25 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - - {{0|(11<<4)}, {20.36*11, 0}, 1}, - {{0|(10<<4)}, {20.36*10, 0}, 1}, - {{0|(9<<4)}, {20.36*9, 0}, 1}, - {{0|(8<<4)}, {20.36*8, 0}, 1}, - {{0|(7<<4)}, {20.36*7, 0}, 1}, - {{0|(6<<4)}, { 20.36*6, 0}, 1}, - {{0|(5<<4)}, { 20.36*5, 0}, 1}, - {{0|(4<<4)}, { 20.36*4, 0}, 1}, - {{0|(3<<4)}, { 20.36*3, 0}, 1}, - {{0|(2<<4)}, { 20.36*2, 0}, 1}, - {{0|(1<<4)}, { 20.36*1, 0}, 1}, - {{0|(0<<4)}, { 20.36*0, 0}, 1}, - - {{0|(12<<4)}, {20.36*11, 21.33*0.5}, 1}, - {{0|(13<<4)}, {20.36*0,21.33*0.5}, 1}, - - {{1|(11<<4)}, {20.36*11, 21.33}, 1}, - {{1|(10<<4)}, {20.36*10, 21.33}, 4}, - {{1|(9<<4)}, {20.36*9, 21.33}, 4}, - {{1|(8<<4)}, {20.36*8, 21.33}, 4}, - {{1|(7<<4)}, {20.36*7, 21.33}, 4}, - {{1|(6<<4)}, { 20.36*6, 21.33}, 4}, - {{1|(5<<4)}, { 20.36*5, 21.33}, 4}, - {{1|(4<<4)}, { 20.36*4, 21.33}, 4}, - {{1|(3<<4)}, { 20.36*3, 21.33}, 4}, - {{1|(2<<4)}, { 20.36*2, 21.33}, 4}, - {{1|(1<<4)}, { 20.36*1, 21.33}, 4}, - {{1|(0<<4)}, { 20.36*0, 21.33}, 1}, - - {{1|(12<<4)}, {20.36*11, 21.33*1.5}, 1}, - {{1|(13<<4)}, {20.36*0,21.33*1.5}, 1}, +led_config_t g_led_config = { { + { 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, + { 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14 }, + { 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28 }, + { 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42 } +}, { + { 223, 0 }, { 203, 0 }, { 183, 0 }, { 162, 0 }, { 142, 0 }, { 122, 0 }, { 101, 0 }, { 81, 0 }, { 61, 0 }, { 40, 0 }, { 20, 0 }, { 0, 0 }, + { 223, 10 }, { 0, 10 }, { 223, 21 }, { 203, 21 }, { 183, 21 }, { 162, 21 }, { 142, 21 }, { 122, 21 }, { 101, 21 }, { 81, 21 }, { 61, 21 }, { 40, 21 }, + { 20, 21 }, { 0, 21 }, { 223, 31 }, { 0, 31 }, { 223, 42 }, { 203, 42 }, { 183, 42 }, { 162, 42 }, { 142, 42 }, { 122, 42 }, { 101, 42 }, { 81, 42 }, + { 61, 42 }, { 40, 42 }, { 20, 42 }, { 0, 42 }, { 223, 53 }, { 0, 53 }, { 223, 63 }, { 203, 63 }, { 183, 63 }, { 162, 63 }, { 142, 63 }, { 122, 63 }, + { 101, 63 }, { 81, 63 }, { 61, 63 }, { 40, 63 }, { 20, 63 }, { 0, 63 } +}, { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1 +} }; - {{2|(11<<4)}, {20.36*11, 21.33*2}, 1}, - {{2|(10<<4)}, {20.36*10, 21.33*2}, 4}, - {{2|(9<<4)}, {20.36*9, 21.33*2}, 4}, - {{2|(8<<4)}, {20.36*8, 21.33*2}, 4}, - {{2|(7<<4)}, {20.36*7, 21.33*2}, 4}, - {{2|(6<<4)}, { 20.36*6, 21.33*2}, 4}, - {{2|(5<<4)}, { 20.36*5, 21.33*2}, 4}, - {{2|(4<<4)}, { 20.36*4, 21.33*2}, 4}, - {{2|(3<<4)}, { 20.36*3, 21.33*2}, 4}, - {{2|(2<<4)}, { 20.36*2, 21.33*2}, 4}, - {{2|(1<<4)}, { 20.36*1, 21.33*2}, 4}, - {{2|(0<<4)}, { 20.36*0, 21.33*2}, 1}, - - {{2|(12<<4)}, {20.36*11, 21.33*2.5}, 1}, - {{2|(13<<4)}, {20.36*0,21.33*2.5}, 1}, - - {{3|(11<<4)}, {20.36*11, 21.33*3}, 1}, - {{3|(10<<4)}, {20.36*10, 21.33*3}, 1}, - {{3|(9<<4)}, {20.36*9, 21.33*3}, 1}, - {{3|(8<<4)}, {20.36*8, 21.33*3}, 1}, - {{3|(7<<4)}, {20.36*7, 21.33*3}, 1}, - {{3|(6<<4)}, { 20.36*6, 21.33*3}, 1}, - {{3|(5<<4)}, { 20.36*5, 21.33*3}, 1}, - {{3|(4<<4)}, { 20.36*4, 21.33*3}, 1}, - {{3|(3<<4)}, { 20.36*3, 21.33*3}, 1}, - {{3|(2<<4)}, { 20.36*2, 21.33*3}, 1}, - {{3|(1<<4)}, { 20.36*1, 21.33*3}, 1}, - {{3|(0<<4)}, { 20.36*0, 21.33*3}, 1} - -}; #else const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { /* Refer to IS31 manual for these locations @@ -205,69 +160,25 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +led_config_t g_led_config = { { + { 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, + { 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14 }, + { 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28 }, + { 52, 51, 50, 49, 48, NO_LED, 47, 46, 45, 44, 43, 42 } +}, { + { 223, 0 }, { 203, 0 }, { 183, 0 }, { 162, 0 }, { 142, 0 }, { 122, 0 }, { 101, 0 }, { 81, 0 }, { 61, 0 }, { 40, 0 }, { 20, 0 }, { 0, 0 }, + { 223, 10 }, { 0, 10 }, { 223, 21 }, { 203, 21 }, { 183, 21 }, { 162, 21 }, { 142, 21 }, { 122, 21 }, { 101, 21 }, { 81, 21 }, { 61, 21 }, { 40, 21 }, + { 20, 21 }, { 0, 21 }, { 223, 31 }, { 0, 31 }, { 223, 42 }, { 203, 42 }, { 183, 42 }, { 162, 42 }, { 142, 42 }, { 122, 42 }, { 101, 42 }, { 81, 42 }, + { 61, 42 }, { 40, 42 }, { 20, 42 }, { 0, 42 }, { 223, 53 }, { 0, 53 }, { 223, 63 }, { 203, 63 }, { 183, 63 }, { 162, 63 }, { 142, 63 }, { 111, 63 }, + { 81, 63 }, { 61, 63 }, { 40, 63 }, { 20, 63 }, { 0, 63 } +}, { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 +} }; - {{0|(11<<4)}, {20.36*11, 0}, 1}, - {{0|(10<<4)}, {20.36*10, 0}, 1}, - {{0|(9<<4)}, {20.36*9, 0}, 1}, - {{0|(8<<4)}, {20.36*8, 0}, 1}, - {{0|(7<<4)}, {20.36*7, 0}, 1}, - {{0|(6<<4)}, { 20.36*6, 0}, 1}, - {{0|(5<<4)}, { 20.36*5, 0}, 1}, - {{0|(4<<4)}, { 20.36*4, 0}, 1}, - {{0|(3<<4)}, { 20.36*3, 0}, 1}, - {{0|(2<<4)}, { 20.36*2, 0}, 1}, - {{0|(1<<4)}, { 20.36*1, 0}, 1}, - {{0|(0<<4)}, { 20.36*0, 0}, 1}, - - {{0|(12<<4)}, {20.36*11, 21.33*0.5}, 1}, - {{0|(13<<4)}, {20.36*0,21.33*0.5}, 1}, - - {{1|(11<<4)}, {20.36*11, 21.33}, 1}, - {{1|(10<<4)}, {20.36*10, 21.33}, 4}, - {{1|(9<<4)}, {20.36*9, 21.33}, 4}, - {{1|(8<<4)}, {20.36*8, 21.33}, 4}, - {{1|(7<<4)}, {20.36*7, 21.33}, 4}, - {{1|(6<<4)}, { 20.36*6, 21.33}, 4}, - {{1|(5<<4)}, { 20.36*5, 21.33}, 4}, - {{1|(4<<4)}, { 20.36*4, 21.33}, 4}, - {{1|(3<<4)}, { 20.36*3, 21.33}, 4}, - {{1|(2<<4)}, { 20.36*2, 21.33}, 4}, - {{1|(1<<4)}, { 20.36*1, 21.33}, 4}, - {{1|(0<<4)}, { 20.36*0, 21.33}, 1}, - - {{1|(12<<4)}, {20.36*11, 21.33*1.5}, 1}, - {{1|(13<<4)}, {20.36*0,21.33*1.5}, 1}, - - {{2|(11<<4)}, {20.36*11, 21.33*2}, 1}, - {{2|(10<<4)}, {20.36*10, 21.33*2}, 4}, - {{2|(9<<4)}, {20.36*9, 21.33*2}, 4}, - {{2|(8<<4)}, {20.36*8, 21.33*2}, 4}, - {{2|(7<<4)}, {20.36*7, 21.33*2}, 4}, - {{2|(6<<4)}, { 20.36*6, 21.33*2}, 4}, - {{2|(5<<4)}, { 20.36*5, 21.33*2}, 4}, - {{2|(4<<4)}, { 20.36*4, 21.33*2}, 4}, - {{2|(3<<4)}, { 20.36*3, 21.33*2}, 4}, - {{2|(2<<4)}, { 20.36*2, 21.33*2}, 4}, - {{2|(1<<4)}, { 20.36*1, 21.33*2}, 4}, - {{2|(0<<4)}, { 20.36*0, 21.33*2}, 1}, - - {{2|(12<<4)}, {20.36*11, 21.33*2.5}, 1}, - {{2|(13<<4)}, {20.36*0,21.33*2.5}, 1}, - - {{3|(11<<4)}, {20.36*11, 21.33*3}, 1}, - {{3|(10<<4)}, {20.36*10, 21.33*3}, 1}, - {{3|(9<<4)}, {20.36*9, 21.33*3}, 1}, - {{3|(8<<4)}, {20.36*8, 21.33*3}, 1}, - {{3|(7<<4)}, {20.36*7, 21.33*3}, 1}, - {{3|(6<<4)}, { 20.36*5.5, 21.33*3}, 1}, - {{3|(4<<4)}, { 20.36*4, 21.33*3}, 1}, - {{3|(3<<4)}, { 20.36*3, 21.33*3}, 1}, - {{3|(2<<4)}, { 20.36*2, 21.33*3}, 1}, - {{3|(1<<4)}, { 20.36*1, 21.33*3}, 1}, - {{3|(0<<4)}, { 20.36*0, 21.33*3}, 1} - -}; #endif diff --git a/keyboards/dztech/dz40rgb/keymaps/default/keymap.c b/keyboards/dztech/dz40rgb/keymaps/default/keymap.c index 59b917121..650c178a7 100644 --- a/keyboards/dztech/dz40rgb/keymaps/default/keymap.c +++ b/keyboards/dztech/dz40rgb/keymaps/default/keymap.c @@ -31,11 +31,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), }; + +extern led_config_t g_led_config; void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) { - rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color( i, red, green, blue ); } } diff --git a/keyboards/dztech/dz40rgb/keymaps/split_space/keymap.c b/keyboards/dztech/dz40rgb/keymaps/split_space/keymap.c index 5613e3500..80741b19c 100644 --- a/keyboards/dztech/dz40rgb/keymaps/split_space/keymap.c +++ b/keyboards/dztech/dz40rgb/keymaps/split_space/keymap.c @@ -53,12 +53,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - +extern led_config_t g_led_config; void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) { - rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color( i, red, green, blue ); } } diff --git a/keyboards/dztech/dz60rgb/dz60rgb.c b/keyboards/dztech/dz60rgb/dz60rgb.c index 10b2ea7a8..28ac7ce9e 100644 --- a/keyboards/dztech/dz60rgb/dz60rgb.c +++ b/keyboards/dztech/dz60rgb/dz60rgb.c @@ -65,69 +65,26 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, K_16, J_16, L_16}, }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{0|(13<<4)}, {16*13.5, 0}, 1}, - {{0|(12<<4)}, {16*12, 0}, 1}, - {{0|(11<<4)}, {16*11, 0}, 1}, - {{0|(10<<4)}, {16*10, 0}, 1}, - {{0|(9<<4)}, {16*9, 0}, 1}, - {{0|(8<<4)}, {16*8, 0}, 1}, - {{0|(7<<4)}, {16*7, 0}, 1}, - {{0|(6<<4)}, {16*6, 0}, 1}, - {{0|(5<<4)}, {16*5, 0}, 1}, - {{0|(4<<4)}, {16*4, 0}, 1}, - {{0|(3<<4)}, {16*3, 0}, 1}, - {{0|(2<<4)}, {16*2, 0}, 1}, - {{0|(1<<4)}, {16*1, 0}, 1}, - {{0|(0<<4)}, {16*0, 0}, 1}, - {{2|(13<<4)}, {16*13.75, 24}, 1}, - {{1|(12<<4)}, {16*12.5, 16}, 4}, - {{1|(11<<4)}, {16*11.5, 16}, 4}, - {{1|(10<<4)}, {16*10.5, 16}, 4}, - {{1|(9<<4)}, { 16*9.5, 16}, 4}, - {{1|(8<<4)}, { 16*8.5, 16}, 4}, - {{1|(7<<4)}, { 16*7.5, 16}, 4}, - {{1|(6<<4)}, { 16*6.5, 16}, 4}, - {{1|(5<<4)}, { 16*5.5, 16}, 4}, - {{1|(4<<4)}, { 16*4.5, 16}, 4}, - {{1|(3<<4)}, { 16*3.5, 16}, 4}, - {{1|(2<<4)}, { 16*2.5, 16}, 4}, - {{1|(1<<4)}, { 16*1.5, 16}, 4}, - {{1|(0<<4)}, { 16*0.25, 16}, 1}, - {{1|(13<<4)}, {16*12.75, 32}, 1}, - {{2|(11<<4)}, {16*11.75, 32}, 4}, - {{2|(10<<4)}, {16*10.75, 32}, 4}, - {{2|(9<<4)}, {16*9.75, 32}, 4}, - {{2|(8<<4)}, {16*8.75, 32}, 4}, - {{2|(7<<4)}, {16*7.75, 32}, 4}, - {{2|(6<<4)}, { 16*6.75, 32}, 4}, - {{2|(5<<4)}, { 16*5.75, 32}, 4}, - {{2|(4<<4)}, { 16*4.75, 32}, 4}, - {{2|(3<<4)}, { 16*3.75, 32}, 4}, - {{2|(2<<4)}, { 16*2.75, 32}, 4}, - {{2|(1<<4)}, { 16*1.75, 32}, 4}, - {{2|(0<<4)}, { 16*0.375, 32}, 1}, - {{3|(11<<4)}, {16*13.125, 48}, 1}, - {{3|(10<<4)}, {16*11.25, 48}, 4}, - {{3|(9<<4)}, {16*10.25, 48}, 4}, - {{3|(8<<4)}, {16*9.25, 48}, 4}, - {{3|(7<<4)}, {16*8.25, 48}, 4}, - {{3|(6<<4)}, {16*7.25, 48}, 4}, - {{3|(5<<4)}, {16*6.25, 48}, 4}, - {{3|(4<<4)}, {16*5.25, 48}, 4}, - {{3|(3<<4)}, {16*4.25, 48}, 4}, - {{3|(2<<4)}, {16*3.25, 48}, 4}, - {{3|(1<<4)}, {16*1.25, 48}, 4}, - {{3|(0<<4)}, {16*0.625, 48}, 1}, - {{4|(13<<4)}, {16*13.875, 64}, 1}, - {{4|(11<<4)}, {16*12.625, 64}, 1}, - {{4|(10<<4)}, {16*11.375, 64}, 1}, - {{4|(9<<4)}, {16*10.125, 64}, 1}, - {{4|(5<<4)}, { 16*6.375, 64}, 4}, - {{4|(2<<4)}, { 16*2.625, 64}, 1}, - {{4|(1<<4)}, { 16*1.375, 64}, 1}, - {{4|(0<<4)}, { 16*0.125, 64}, 1}, -}; +led_config_t g_led_config = { { + { 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, + { 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 28 }, + { 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, NO_LED, 14 }, + { 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, NO_LED, NO_LED }, + { 60, 59, 58, NO_LED, NO_LED, 57, NO_LED, NO_LED, NO_LED, 56, 55, 54, NO_LED, 53 } +}, { + { 216, 0 }, { 192, 0 }, { 176, 0 }, { 160, 0 }, { 144, 0 }, { 128, 0 }, { 112, 0 }, { 96, 0 }, { 80, 0 }, { 64, 0 }, { 48, 0 }, { 32, 0 }, { 16, 0 }, { 0, 0 }, + { 220, 24 }, { 200, 16 }, { 184, 16 }, { 168, 16 }, { 152, 16 }, { 136, 16 }, { 120, 16 }, { 104, 16 }, { 88, 16 }, { 72, 16 }, { 56, 16 }, { 40, 16 }, { 24, 16 }, { 4, 16 }, + { 204, 32 }, { 188, 32 }, { 172, 32 }, { 156, 32 }, { 140, 32 }, { 124, 32 }, { 108, 32 }, { 92, 32 }, { 76, 32 }, { 60, 32 }, { 44, 32 }, { 28, 32 }, { 6, 32 }, { 210, 48 }, + { 180, 48 }, { 164, 48 }, { 148, 48 }, { 132, 48 }, { 116, 48 }, { 100, 48 }, { 84, 48 }, { 68, 48 }, { 52, 48 }, { 20, 48 }, { 10, 48 }, { 222, 64 }, { 202, 64 }, { 182, 64 }, + { 162, 64 }, { 102, 64 }, { 42, 64 }, { 22, 64 }, { 2, 64 } +}, { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, + 1, 4, 1, 1, 1 +} }; + #elif defined (dzrgb60_hhkb) const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, H_15, G_15, I_15}, @@ -194,70 +151,26 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, K_16, J_16, L_16}, }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{2|(12<<4)}, {16*14, 0}, 1}, - {{0|(13<<4)}, {16*13, 0}, 1}, - {{0|(12<<4)}, {16*12, 0}, 1}, - {{0|(11<<4)}, {16*11, 0}, 1}, - {{0|(10<<4)}, {16*10, 0}, 1}, - {{0|(9<<4)}, {16*9, 0}, 1}, - {{0|(8<<4)}, {16*8, 0}, 1}, - {{0|(7<<4)}, {16*7, 0}, 1}, - {{0|(6<<4)}, {16*6, 0}, 1}, - {{0|(5<<4)}, {16*5, 0}, 1}, - {{0|(4<<4)}, {16*4, 0}, 1}, - {{0|(3<<4)}, {16*3, 0}, 1}, - {{0|(2<<4)}, {16*2, 0}, 1}, - {{0|(1<<4)}, {16*1, 0}, 1}, - {{0|(0<<4)}, {16*0, 0}, 1}, - {{1|(13<<4)}, {16*13.75, 16}, 1}, - {{1|(12<<4)}, {16*12.5, 16}, 4}, - {{1|(11<<4)}, {16*11.5, 16}, 4}, - {{1|(10<<4)}, {16*10.5, 16}, 4}, - {{1|(9<<4)}, { 16*9.5, 16}, 4}, - {{1|(8<<4)}, { 16*8.5, 16}, 4}, - {{1|(7<<4)}, { 16*7.5, 16}, 4}, - {{1|(6<<4)}, { 16*6.5, 16}, 4}, - {{1|(5<<4)}, { 16*5.5, 16}, 4}, - {{1|(4<<4)}, { 16*4.5, 16}, 4}, - {{1|(3<<4)}, { 16*3.5, 16}, 4}, - {{1|(2<<4)}, { 16*2.5, 16}, 4}, - {{1|(1<<4)}, { 16*1.5, 16}, 4}, - {{1|(0<<4)}, { 16*0.25, 16}, 1}, - {{2|(13<<4)}, {16*12.75, 32}, 1}, - {{2|(11<<4)}, {16*11.75, 32}, 4}, - {{2|(10<<4)}, {16*10.75, 32}, 4}, - {{2|(9<<4)}, {16*9.75, 32}, 4}, - {{2|(8<<4)}, {16*8.75, 32}, 4}, - {{2|(7<<4)}, {16*7.75, 32}, 4}, - {{2|(6<<4)}, { 16*6.75, 32}, 4}, - {{2|(5<<4)}, { 16*5.75, 32}, 4}, - {{2|(4<<4)}, { 16*4.75, 32}, 4}, - {{2|(3<<4)}, { 16*3.75, 32}, 4}, - {{2|(2<<4)}, { 16*2.75, 32}, 4}, - {{2|(1<<4)}, { 16*1.75, 32}, 4}, - {{2|(0<<4)}, { 16*0.375, 32}, 1}, - {{3|(13<<4)}, {16*14, 48}, 1}, - {{3|(11<<4)}, {16*12.625, 48}, 4}, - {{3|(10<<4)}, {16*11.25, 48}, 4}, - {{3|(9<<4)}, {16*10.25, 48}, 4}, - {{3|(8<<4)}, {16*9.25, 48}, 4}, - {{3|(7<<4)}, {16*8.25, 48}, 4}, - {{3|(6<<4)}, {16*7.25, 48}, 4}, - {{3|(5<<4)}, {16*6.25, 48}, 4}, - {{3|(4<<4)}, {16*5.25, 48}, 4}, - {{3|(3<<4)}, {16*4.25, 48}, 4}, - {{3|(2<<4)}, {16*3.25, 48}, 4}, - {{3|(1<<4)}, {16*1.25, 48}, 4}, - {{3|(0<<4)}, {16*0.625, 48}, 1}, - {{4|(13<<4)}, {16*13.625, 64}, 1}, - {{4|(11<<4)}, {16*12.375, 64}, 1}, - {{4|(10<<4)}, {16*11.125, 64}, 1}, - {{4|(5<<4)}, { 16*7, 64}, 4}, - {{4|(2<<4)}, { 16*2.875, 64}, 1}, - {{4|(1<<4)}, { 16*1.625, 64}, 1}, - {{4|(0<<4)}, { 16*0.375, 64}, 1}, -}; +led_config_t g_led_config = { { + { 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }, + { 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15 }, + { 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 0, 29 }, + { 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, NO_LED, 42 }, + { 61, 60, 59, NO_LED, NO_LED, 58, NO_LED, NO_LED, NO_LED, NO_LED, 57, 56, NO_LED, 55 } +}, { + { 224, 0 }, { 208, 0 }, { 192, 0 }, { 176, 0 }, { 160, 0 }, { 144, 0 }, { 128, 0 }, { 112, 0 }, { 96, 0 }, { 80, 0 }, { 64, 0 }, { 48, 0 }, { 32, 0 }, { 16, 0 }, + { 0, 0 }, { 220, 16 }, { 200, 16 }, { 184, 16 }, { 168, 16 }, { 152, 16 }, { 136, 16 }, { 120, 16 }, { 104, 16 }, { 88, 16 }, { 72, 16 }, { 56, 16 }, { 40, 16 }, { 24, 16 }, + { 4, 16 }, { 204, 32 }, { 188, 32 }, { 172, 32 }, { 156, 32 }, { 140, 32 }, { 124, 32 }, { 108, 32 }, { 92, 32 }, { 76, 32 }, { 60, 32 }, { 44, 32 }, { 28, 32 }, { 6, 32 }, + { 224, 48 }, { 202, 48 }, { 180, 48 }, { 164, 48 }, { 148, 48 }, { 132, 48 }, { 116, 48 }, { 100, 48 }, { 84, 48 }, { 68, 48 }, { 52, 48 }, { 20, 48 }, { 10, 48 }, { 218, 64 }, + { 198, 64 }, { 178, 64 }, { 112, 64 }, { 46, 64 }, { 26, 64 }, { 6, 64 } +}, { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, + 1, 1, 4, 1, 1, 1 +} }; + #elif defined (dzrgb60_hhkb_iso) const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, H_15, G_15, I_15}, @@ -324,70 +237,26 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, K_16, J_16, L_16}, }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{2|(12<<4)}, {16*14, 0}, 1}, - {{0|(13<<4)}, {16*13, 0}, 1}, - {{0|(12<<4)}, {16*12, 0}, 1}, - {{0|(11<<4)}, {16*11, 0}, 1}, - {{0|(10<<4)}, {16*10, 0}, 1}, - {{0|(9<<4)}, {16*9, 0}, 1}, - {{0|(8<<4)}, {16*8, 0}, 1}, - {{0|(7<<4)}, {16*7, 0}, 1}, - {{0|(6<<4)}, {16*6, 0}, 1}, - {{0|(5<<4)}, {16*5, 0}, 1}, - {{0|(4<<4)}, {16*4, 0}, 1}, - {{0|(3<<4)}, {16*3, 0}, 1}, - {{0|(2<<4)}, {16*2, 0}, 1}, - {{0|(1<<4)}, {16*1, 0}, 1}, - {{0|(0<<4)}, {16*0, 0}, 1}, - {{2|(13<<4)}, {16*13.75, 24}, 1}, - {{1|(12<<4)}, {16*12.5, 16}, 4}, - {{1|(11<<4)}, {16*11.5, 16}, 4}, - {{1|(10<<4)}, {16*10.5, 16}, 4}, - {{1|(9<<4)}, { 16*9.5, 16}, 4}, - {{1|(8<<4)}, { 16*8.5, 16}, 4}, - {{1|(7<<4)}, { 16*7.5, 16}, 4}, - {{1|(6<<4)}, { 16*6.5, 16}, 4}, - {{1|(5<<4)}, { 16*5.5, 16}, 4}, - {{1|(4<<4)}, { 16*4.5, 16}, 4}, - {{1|(3<<4)}, { 16*3.5, 16}, 4}, - {{1|(2<<4)}, { 16*2.5, 16}, 4}, - {{1|(1<<4)}, { 16*1.5, 16}, 4}, - {{1|(0<<4)}, { 16*0.25, 16}, 1}, - {{1|(13<<4)}, {16*12.75, 32}, 1}, - {{2|(11<<4)}, {16*11.75, 32}, 4}, - {{2|(10<<4)}, {16*10.75, 32}, 4}, - {{2|(9<<4)}, {16*9.75, 32}, 4}, - {{2|(8<<4)}, {16*8.75, 32}, 4}, - {{2|(7<<4)}, {16*7.75, 32}, 4}, - {{2|(6<<4)}, { 16*6.75, 32}, 4}, - {{2|(5<<4)}, { 16*5.75, 32}, 4}, - {{2|(4<<4)}, { 16*4.75, 32}, 4}, - {{2|(3<<4)}, { 16*3.75, 32}, 4}, - {{2|(2<<4)}, { 16*2.75, 32}, 4}, - {{2|(1<<4)}, { 16*1.75, 32}, 4}, - {{2|(0<<4)}, { 16*0.375, 32}, 1}, - {{3|(13<<4)}, {16*14, 48}, 1}, - {{3|(11<<4)}, {16*12.625, 48}, 4}, - {{3|(10<<4)}, {16*11.25, 48}, 4}, - {{3|(9<<4)}, {16*10.25, 48}, 4}, - {{3|(8<<4)}, {16*9.25, 48}, 4}, - {{3|(7<<4)}, {16*8.25, 48}, 4}, - {{3|(6<<4)}, {16*7.25, 48}, 4}, - {{3|(5<<4)}, {16*6.25, 48}, 4}, - {{3|(4<<4)}, {16*5.25, 48}, 4}, - {{3|(3<<4)}, {16*4.25, 48}, 4}, - {{3|(2<<4)}, {16*3.25, 48}, 4}, - {{3|(1<<4)}, {16*1.25, 48}, 4}, - {{3|(0<<4)}, {16*0.625, 48}, 1}, - {{4|(13<<4)}, {16*13.625, 64}, 1}, - {{4|(11<<4)}, {16*12.375, 64}, 1}, - {{4|(10<<4)}, {16*11.125, 64}, 1}, - {{4|(5<<4)}, { 16*7, 64}, 4}, - {{4|(2<<4)}, { 16*2.875, 64}, 1}, - {{4|(1<<4)}, { 16*1.625, 64}, 1}, - {{4|(0<<4)}, { 16*0.375, 64}, 1}, -}; +led_config_t g_led_config = { { + { 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }, + { 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 29 }, + { 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 0, 15 }, + { 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, NO_LED, 42 }, + { 61, 60, 59, NO_LED, NO_LED, 58, NO_LED, NO_LED, NO_LED, NO_LED, 57, 56, NO_LED, 55 } +}, { + { 224, 0 }, { 208, 0 }, { 192, 0 }, { 176, 0 }, { 160, 0 }, { 144, 0 }, { 128, 0 }, { 112, 0 }, { 96, 0 }, { 80, 0 }, { 64, 0 }, { 48, 0 }, { 32, 0 }, { 16, 0 }, + { 0, 0 }, { 220, 24 }, { 200, 16 }, { 184, 16 }, { 168, 16 }, { 152, 16 }, { 136, 16 }, { 120, 16 }, { 104, 16 }, { 88, 16 }, { 72, 16 }, { 56, 16 }, { 40, 16 }, { 24, 16 }, + { 4, 16 }, { 204, 32 }, { 188, 32 }, { 172, 32 }, { 156, 32 }, { 140, 32 }, { 124, 32 }, { 108, 32 }, { 92, 32 }, { 76, 32 }, { 60, 32 }, { 44, 32 }, { 28, 32 }, { 6, 32 }, + { 224, 48 }, { 202, 48 }, { 180, 48 }, { 164, 48 }, { 148, 48 }, { 132, 48 }, { 116, 48 }, { 100, 48 }, { 84, 48 }, { 68, 48 }, { 52, 48 }, { 20, 48 }, { 10, 48 }, { 218, 64 }, + { 198, 64 }, { 178, 64 }, { 112, 64 }, { 46, 64 }, { 26, 64 }, { 6, 64 } +}, { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, + 1, 1, 4, 1, 1, 1 +} }; + #elif defined (dzrgb60_ansi) const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, K_14, J_14, L_14}, @@ -453,69 +322,26 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, K_16, J_16, L_16}, }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{0|(13<<4)}, {16*13.5, 0}, 1}, - {{0|(12<<4)}, {16*12, 0}, 1}, - {{0|(11<<4)}, {16*11, 0}, 1}, - {{0|(10<<4)}, {16*10, 0}, 1}, - {{0|(9<<4)}, {16*9, 0}, 1}, - {{0|(8<<4)}, {16*8, 0}, 1}, - {{0|(7<<4)}, {16*7, 0}, 1}, - {{0|(6<<4)}, {16*6, 0}, 1}, - {{0|(5<<4)}, {16*5, 0}, 1}, - {{0|(4<<4)}, {16*4, 0}, 1}, - {{0|(3<<4)}, {16*3, 0}, 1}, - {{0|(2<<4)}, {16*2, 0}, 1}, - {{0|(1<<4)}, {16*1, 0}, 1}, - {{0|(0<<4)}, {16*0, 0}, 1}, - {{1|(13<<4)}, {16*13.75, 16}, 1}, - {{1|(12<<4)}, {16*12.5, 16}, 4}, - {{1|(11<<4)}, {16*11.5, 16}, 4}, - {{1|(10<<4)}, {16*10.5, 16}, 4}, - {{1|(9<<4)}, { 16*9.5, 16}, 4}, - {{1|(8<<4)}, { 16*8.5, 16}, 4}, - {{1|(7<<4)}, { 16*7.5, 16}, 4}, - {{1|(6<<4)}, { 16*6.5, 16}, 4}, - {{1|(5<<4)}, { 16*5.5, 16}, 4}, - {{1|(4<<4)}, { 16*4.5, 16}, 4}, - {{1|(3<<4)}, { 16*3.5, 16}, 4}, - {{1|(2<<4)}, { 16*2.5, 16}, 4}, - {{1|(1<<4)}, { 16*1.5, 16}, 4}, - {{1|(0<<4)}, { 16*0.25, 16}, 1}, - {{2|(13<<4)}, {16*13.375, 24}, 1}, - {{2|(11<<4)}, {16*11.75, 32}, 4}, - {{2|(10<<4)}, {16*10.75, 32}, 4}, - {{2|(9<<4)}, {16*9.75, 32}, 4}, - {{2|(8<<4)}, {16*8.75, 32}, 4}, - {{2|(7<<4)}, {16*7.75, 32}, 4}, - {{2|(6<<4)}, { 16*6.75, 32}, 4}, - {{2|(5<<4)}, { 16*5.75, 32}, 4}, - {{2|(4<<4)}, { 16*4.75, 32}, 4}, - {{2|(3<<4)}, { 16*3.75, 32}, 4}, - {{2|(2<<4)}, { 16*2.75, 32}, 4}, - {{2|(1<<4)}, { 16*1.75, 32}, 4}, - {{2|(0<<4)}, { 16*0.375, 32}, 1}, - {{3|(11<<4)}, {16*13.125, 48}, 1}, - {{3|(10<<4)}, {16*11.25, 48}, 4}, - {{3|(9<<4)}, {16*10.25, 48}, 4}, - {{3|(8<<4)}, {16*9.25, 48}, 4}, - {{3|(7<<4)}, {16*8.25, 48}, 4}, - {{3|(6<<4)}, {16*7.25, 48}, 4}, - {{3|(5<<4)}, {16*6.25, 48}, 4}, - {{3|(4<<4)}, {16*5.25, 48}, 4}, - {{3|(3<<4)}, {16*4.25, 48}, 4}, - {{3|(2<<4)}, {16*3.25, 48}, 4}, - {{3|(1<<4)}, {16*1.25, 48}, 4}, - {{3|(0<<4)}, {16*0.625, 48}, 1}, - {{4|(13<<4)}, {16*13.875, 64}, 1}, - {{4|(11<<4)}, {16*12.625, 64}, 1}, - {{4|(10<<4)}, {16*11.375, 64}, 1}, - {{4|(9<<4)}, {16*10.125, 64}, 1}, - {{4|(5<<4)}, { 16*6.375, 64}, 4}, - {{4|(2<<4)}, { 16*2.625, 64}, 1}, - {{4|(1<<4)}, { 16*1.375, 64}, 1}, - {{4|(0<<4)}, { 16*0.125, 64}, 1}, -}; +led_config_t g_led_config = { { + { 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, + { 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14 }, + { 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, NO_LED, 28 }, + { 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, NO_LED, NO_LED }, + { 60, 59, 58, NO_LED, NO_LED, 57, NO_LED, NO_LED, NO_LED, 56, 55, 54, NO_LED, 53 } +}, { + { 216, 0 }, { 192, 0 }, { 176, 0 }, { 160, 0 }, { 144, 0 }, { 128, 0 }, { 112, 0 }, { 96, 0 }, { 80, 0 }, { 64, 0 }, { 48, 0 }, { 32, 0 }, { 16, 0 }, { 0, 0 }, + { 220, 16 }, { 200, 16 }, { 184, 16 }, { 168, 16 }, { 152, 16 }, { 136, 16 }, { 120, 16 }, { 104, 16 }, { 88, 16 }, { 72, 16 }, { 56, 16 }, { 40, 16 }, { 24, 16 }, { 4, 16 }, + { 214, 24 }, { 188, 32 }, { 172, 32 }, { 156, 32 }, { 140, 32 }, { 124, 32 }, { 108, 32 }, { 92, 32 }, { 76, 32 }, { 60, 32 }, { 44, 32 }, { 28, 32 }, { 6, 32 }, { 210, 48 }, + { 180, 48 }, { 164, 48 }, { 148, 48 }, { 132, 48 }, { 116, 48 }, { 100, 48 }, { 84, 48 }, { 68, 48 }, { 52, 48 }, { 20, 48 }, { 10, 48 }, { 222, 64 }, { 202, 64 }, { 182, 64 }, + { 162, 64 }, { 102, 64 }, { 42, 64 }, { 22, 64 }, { 2, 64 } +}, { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, + 1, 4, 1, 1, 1 +} }; + #else const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, K_14, J_14, L_14}, @@ -583,71 +409,26 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, K_16, J_16, L_16}, }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{0|(13<<4)}, {17.23*13, 0}, 1}, - {{0|(12<<4)}, {17.23*12, 0}, 1}, - {{0|(11<<4)}, {17.23*11, 0}, 1}, - {{0|(10<<4)}, {17.23*10, 0}, 1}, - {{0|(9<<4)}, {17.23*9, 0}, 1}, - {{0|(8<<4)}, {17.23*8, 0}, 1}, - {{0|(7<<4)}, {17.23*7, 0}, 1}, - {{0|(6<<4)}, { 17.23*6, 0}, 1}, - {{0|(5<<4)}, { 17.23*5, 0}, 1}, - {{0|(4<<4)}, { 17.23*4, 0}, 1}, - {{0|(3<<4)}, { 17.23*3, 0}, 1}, - {{0|(2<<4)}, { 17.23*2, 0}, 1}, - {{0|(1<<4)}, { 17.23*1, 0}, 1}, - {{0|(0<<4)}, { 17.23*0, 0}, 1}, - {{1|(13<<4)}, {17.23*13, 16}, 1}, - {{1|(12<<4)}, {17.23*12, 16}, 4}, - {{1|(11<<4)}, {17.23*11, 16}, 4}, - {{1|(10<<4)}, {17.23*10, 16}, 4}, - {{1|(9<<4)}, {17.23*9, 16}, 4}, - {{1|(8<<4)}, {17.23*8, 16}, 4}, - {{1|(7<<4)}, {17.23*7, 16}, 4}, - {{1|(6<<4)}, { 17.23*6, 16}, 4}, - {{1|(5<<4)}, { 17.23*5, 16}, 4}, - {{1|(4<<4)}, { 17.23*4, 16}, 4}, - {{1|(3<<4)}, { 17.23*3, 16}, 4}, - {{1|(2<<4)}, { 17.23*2, 16}, 4}, - {{1|(1<<4)}, { 17.23*1, 16}, 4}, - {{1|(0<<4)}, { 17.23*0, 16}, 1}, - {{2|(13<<4)}, {17.23*13, 32}, 1}, - {{2|(11<<4)}, {17.23*11, 32}, 4}, - {{2|(10<<4)}, {17.23*10, 32}, 4}, - {{2|(9<<4)}, {17.23*9, 32}, 4}, - {{2|(8<<4)}, {17.23*8, 32}, 4}, - {{2|(7<<4)}, {17.23*7, 32}, 4}, - {{2|(6<<4)}, { 17.23*6, 32}, 4}, - {{2|(5<<4)}, { 17.23*5, 32}, 4}, - {{2|(4<<4)}, { 17.23*4, 32}, 4}, - {{2|(3<<4)}, { 17.23*3, 32}, 4}, - {{2|(2<<4)}, { 17.23*2, 32}, 4}, - {{2|(1<<4)}, { 17.23*1, 32}, 4}, - {{2|(0<<4)}, { 17.23*0, 32}, 1}, - {{3|(13<<4)}, {17.23*13, 48}, 1}, - {{3|(11<<4)}, {17.23*11, 48}, 4}, - {{3|(10<<4)}, {17.23*10, 48}, 4}, - {{3|(9<<4)}, {17.23*9, 48}, 4}, - {{3|(8<<4)}, {17.23*8, 48}, 4}, - {{3|(7<<4)}, {17.23*7, 48}, 4}, - {{3|(6<<4)}, { 17.23*6, 48}, 4}, - {{3|(5<<4)}, { 17.23*5, 48}, 4}, - {{3|(4<<4)}, { 17.23*4, 48}, 4}, - {{3|(3<<4)}, { 17.23*3, 48}, 4}, - {{3|(2<<4)}, { 17.23*2, 48}, 4}, - {{3|(1<<4)}, { 17.23*1, 48}, 4}, - {{3|(0<<4)}, { 17.23*0, 48}, 1}, - {{4|(13<<4)}, {17.23*13, 64}, 1}, - {{4|(11<<4)}, {17.23*11, 64}, 1}, - {{4|(10<<4)}, {17.23*10, 64}, 1}, - {{4|(9<<4)}, {17.23*9, 64}, 1}, - {{4|(8<<4)}, {17.23*8, 64}, 1}, - {{4|(5<<4)}, { 17.23*5, 64}, 4}, - {{4|(2<<4)}, { 17.23*2, 64}, 1}, - {{4|(1<<4)}, { 17.23*1, 64}, 1}, - {{4|(0<<4)}, { 17.23*0, 64}, 1}, -}; +led_config_t g_led_config = { { + { 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, + { 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14 }, + { 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, NO_LED, 28 }, + { 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, NO_LED, 41 }, + { 62, 61, 60, NO_LED, NO_LED, 59, NO_LED, NO_LED, 58, 57, 56, 55, NO_LED, 54 } +}, { + { 223, 0 }, { 206, 0 }, { 189, 0 }, { 172, 0 }, { 155, 0 }, { 137, 0 }, { 120, 0 }, { 103, 0 }, { 86, 0 }, { 68, 0 }, { 51, 0 }, { 34, 0 }, { 17, 0 }, { 0, 0 }, + { 223, 16 }, { 206, 16 }, { 189, 16 }, { 172, 16 }, { 155, 16 }, { 137, 16 }, { 120, 16 }, { 103, 16 }, { 86, 16 }, { 68, 16 }, { 51, 16 }, { 34, 16 }, { 17, 16 }, { 0, 16 }, + { 223, 32 }, { 189, 32 }, { 172, 32 }, { 155, 32 }, { 137, 32 }, { 120, 32 }, { 103, 32 }, { 86, 32 }, { 68, 32 }, { 51, 32 }, { 34, 32 }, { 17, 32 }, { 0, 32 }, { 223, 48 }, + { 189, 48 }, { 172, 48 }, { 155, 48 }, { 137, 48 }, { 120, 48 }, { 103, 48 }, { 86, 48 }, { 68, 48 }, { 51, 48 }, { 34, 48 }, { 17, 48 }, { 0, 48 }, { 223, 64 }, { 189, 64 }, + { 172, 64 }, { 155, 64 }, { 137, 64 }, { 86, 64 }, { 34, 64 }, { 17, 64 }, { 0, 64 } +}, { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, + 1, 1, 1, 4, 1, 1, 1 +} }; + #endif void matrix_init_kb(void) { diff --git a/keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c b/keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c index 741fc55fb..584f035ef 100644 --- a/keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/ansi/keymap.c @@ -38,11 +38,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, TO(0), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), }; +extern led_config_t g_led_config; void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) { - rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color( i, red, green, blue ); } } diff --git a/keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c b/keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c index 1f3807c3b..5a7a56801 100644 --- a/keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/hhkb/keymap.c @@ -39,11 +39,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; +extern led_config_t g_led_config; void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) { - rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color( i, red, green, blue ); } } diff --git a/keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c b/keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c index 4575eb19d..34c1752ff 100644 --- a/keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/hhkb_iso/keymap.c @@ -39,11 +39,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, TO(0), KC_TRNS, KC_TRNS, KC_TRNS), }; +extern led_config_t g_led_config; void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) { - rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color( i, red, green, blue ); } } diff --git a/keyboards/dztech/dz60rgb/keymaps/iso/keymap.c b/keyboards/dztech/dz60rgb/keymaps/iso/keymap.c index 5e3884803..3a90d2f33 100644 --- a/keyboards/dztech/dz60rgb/keymaps/iso/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/iso/keymap.c @@ -38,11 +38,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, TO(0), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), }; +extern led_config_t g_led_config; void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) { - rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color( i, red, green, blue ); } } diff --git a/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c b/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c index 3dfa78374..a6d1e226b 100644 --- a/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c @@ -50,40 +50,36 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { -void rgb_matrix_layer_helper(uint8_t red, uint8_t green, uint8_t blue, bool default_layer) -{ - rgb_led led; - - for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { - rgb_matrix_set_color( i, red, green, blue ); - } - } +extern led_config_t g_led_config; +void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) { + for (int i = 0; i < DRIVER_LED_TOTAL; i++) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { + rgb_matrix_set_color( i, red, green, blue ); + } + } } void rgb_matrix_indicators_user(void) { uint8_t this_led = host_keyboard_leds(); - + if (!g_suspend_state) { switch (biton32(layer_state)) { case _LAYER1: rgb_matrix_layer_helper(0xFF, 0x00, 0x00, false); break; - + case _LAYER2: rgb_matrix_layer_helper(0x00, 0xFF, 0x00, false); break; - + case _LAYER4: rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, false); break; } } - + if (this_led & (1 << USB_LED_CAPS_LOCK)) { rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF); } - + switch (biton32(layer_state)) { case _LAYER3: if (this_led & (1 << USB_LED_NUM_LOCK)) { @@ -91,7 +87,7 @@ void rgb_matrix_indicators_user(void) } else { rgb_matrix_set_color(13, 0x00, 0x00, 0x00); } - + rgb_matrix_set_color(0, 0x00, 0xFF, 0x00); rgb_matrix_set_color(1, 0x00, 0x00, 0x00); rgb_matrix_set_color(1, 0x00, 0xFF, 0x00); diff --git a/keyboards/dztech/dz65rgb/dz65rgb.c b/keyboards/dztech/dz65rgb/dz65rgb.c index 78b345843..e14943d97 100644 --- a/keyboards/dztech/dz65rgb/dz65rgb.c +++ b/keyboards/dztech/dz65rgb/dz65rgb.c @@ -73,76 +73,26 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {1, C9_16, C7_15, C6_15}, // LD16 {1, C8_16, C7_16, C6_16}, // LD17 }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{1|(7<<4)}, {16*7, 16}, 4}, - {{1|(6<<4)}, {16*6, 16}, 4}, - {{1|(5<<4)}, {16*5, 16}, 4}, - {{1|(4<<4)}, {16*4, 16}, 4}, - {{1|(3<<4)}, {16*3, 16}, 4}, - {{1|(2<<4)}, {16*2, 16}, 4}, - {{1|(1<<4)}, {16*1, 16}, 4}, - {{1|(0<<4)}, {16*0, 16}, 1}, - {{2|(0<<4)}, {16*0, 32}, 1}, - {{0|(8<<4)}, {16*8, 0}, 1}, - {{0|(7<<4)}, {16*7, 0}, 1}, - {{0|(6<<4)}, {16*6, 0}, 1}, - {{0|(5<<4)}, {16*5, 0}, 1}, - {{0|(4<<4)}, {16*4, 0}, 1}, - {{0|(3<<4)}, {16*3, 0}, 1}, - {{0|(2<<4)}, {16*2, 0}, 1}, - {{0|(1<<4)}, {16*1, 0}, 1}, - {{0|(0<<4)}, {16*0, 0}, 1}, - {{0|(9<<4)}, {16*9, 0}, 1}, - {{0|(10<<4)}, {16*10, 0}, 1}, - {{0|(11<<4)}, {16*11, 0}, 1}, - {{0|(12<<4)}, {16*12, 0}, 1}, - {{0|(13<<4)}, {16*13, 0}, 1}, - {{0|(14<<4)}, {16*14, 0}, 1}, - {{1|(14<<4)}, {16*14, 16}, 1}, - {{2|(14<<4)}, {16*14, 32}, 1}, - {{1|(8<<4)}, {16*8, 16}, 4}, - {{1|(9<<4)}, {16*9, 16}, 4}, - {{1|(10<<4)}, {16*10, 16}, 4}, - {{1|(11<<4)}, {16*11, 16}, 4}, - {{1|(12<<4)}, {16*12, 16}, 4}, - {{1|(13<<4)}, {16*13, 16}, 4}, - {{3|(14<<4)}, {16*14, 48}, 1}, - {{4|(14<<4)}, {16*14, 64}, 1}, - {{4|(13<<4)}, {16*13, 64}, 1}, - {{4|(5<<4)}, {16*5, 64}, 1}, - {{3|(5<<4)}, {16*5, 48}, 4}, - {{3|(4<<4)}, {16*4, 48}, 4}, - {{3|(3<<4)}, {16*3, 48}, 4}, - {{3|(2<<4)}, {16*2, 48}, 4}, - {{3|(1<<4)}, {16*1, 48}, 4}, - {{4|(2<<4)}, {16*2, 64}, 1}, - {{4|(1<<4)}, {16*1, 64}, 1}, - {{2|(6<<4)}, {16*6, 32}, 4}, - {{2|(5<<4)}, {16*5, 32}, 4}, - {{2|(4<<4)}, {16*4, 32}, 4}, - {{2|(3<<4)}, {16*3, 32}, 4}, - {{2|(2<<4)}, {16*2, 32}, 4}, - {{2|(1<<4)}, {16*1, 32}, 4}, - {{3|(0<<4)}, {16*0, 48}, 1}, - {{4|(0<<4)}, {16*0, 64}, 1}, - {{2|(7<<4)}, {16*7, 32}, 4}, - {{2|(8<<4)}, {16*8, 32}, 4}, - {{2|(9<<4)}, {16*9, 32}, 4}, - {{2|(10<<4)}, {16*10, 32}, 4}, - {{2|(11<<4)}, {16*11, 32}, 4}, - {{2|(13<<4)}, {16*13, 32}, 4}, - {{3|(10<<4)}, {16*10, 48}, 4}, - {{3|(11<<4)}, {16*11, 48}, 4}, - {{3|(13<<4)}, {16*13, 48}, 4}, - {{3|(6<<4)}, {16*6, 48}, 4}, - {{3|(7<<4)}, {16*7, 48}, 4}, - {{3|(8<<4)}, {16*8, 48}, 4}, - {{3|(9<<4)}, {16*9, 48}, 4}, - {{4|(8<<4)}, {16*8, 64}, 1}, - {{4|(9<<4)}, {16*9, 64}, 1}, - {{4|(10<<4)}, {16*10, 64}, 1}, - {{4|(11<<4)}, {16*11, 64}, 1}, -}; + +led_config_t g_led_config = { { + { 17, 16, 15, 14, 13, 12, 11, 10, 9, 18, 19, 20, 21, 22, 23 }, + { 7, 6, 5, 4, 3, 2, 1, 0, 26, 27, 28, 29, 30, 31, 24 }, + { 8, 48, 47, 46, 45, 44, 43, 51, 52, 53, 54, 55, NO_LED, 56, 25 }, + { 49, 40, 39, 38, 37, 36, 60, 61, 62, 63, 57, 58, NO_LED, 59, 32 }, + { 50, 42, 41, NO_LED, NO_LED, 35, NO_LED, NO_LED, 64, 65, 66, 67, NO_LED, 34, 33 } +}, { + { 112, 16 }, { 96, 16 }, { 80, 16 }, { 64, 16 }, { 48, 16 }, { 32, 16 }, { 16, 16 }, { 0, 16 }, { 0, 32 }, { 128, 0 }, { 112, 0 }, { 96, 0 }, { 80, 0 }, { 64, 0 }, { 48, 0 }, + { 32, 0 }, { 16, 0 }, { 0, 0 }, { 144, 0 }, { 160, 0 }, { 176, 0 }, { 192, 0 }, { 208, 0 }, { 224, 0 }, { 224, 16 }, { 224, 32 }, { 128, 16 }, { 144, 16 }, { 160, 16 }, { 176, 16 }, + { 192, 16 }, { 208, 16 }, { 224, 48 }, { 224, 64 }, { 208, 64 }, { 80, 64 }, { 80, 48 }, { 64, 48 }, { 48, 48 }, { 32, 48 }, { 16, 48 }, { 32, 64 }, { 16, 64 }, { 96, 32 }, { 80, 32 }, + { 64, 32 }, { 48, 32 }, { 32, 32 }, { 16, 32 }, { 0, 48 }, { 0, 64 }, { 112, 32 }, { 128, 32 }, { 144, 32 }, { 160, 32 }, { 176, 32 }, { 208, 32 }, { 160, 48 }, { 176, 48 }, { 208, 48 }, + { 96, 48 }, { 112, 48 }, { 128, 48 }, { 144, 48 }, { 128, 64 }, { 144, 64 }, { 160, 64 }, { 176, 64 } +}, { + 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, + 4, 4, 1, 1, 1, 1, 4, 4, 4, 4, 4, 1, 1, 4, 4, + 4, 4, 4, 4, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 1, 1, 1, 1 +} }; void suspend_power_down_kb(void) { diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c index 13ea84302..09443cf72 100644 --- a/keyboards/ergodox_ez/ergodox_ez.c +++ b/keyboards/ergodox_ez/ergodox_ez.c @@ -269,68 +269,39 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - - /*{row | col << 4} - | {x=0..224, y=0..64} - | | flags - | | | */ - {{ 8|(0<<4)}, {17.2* 8, 12.8*0}, 4}, // LED 1 on right > Key 6 - {{ 9|(0<<4)}, {17.2* 9, 12.8*0}, 4}, // LED 2 > Key 7 - {{10|(0<<4)}, {17.2*10, 12.8*0}, 4}, // LED 3 > Key 8 - {{11|(0<<4)}, {17.2*11, 12.8*0}, 4}, // LED 4 > Key 9 - {{12|(0<<4)}, {17.2*12, 12.8*0}, 4}, // LED 5 > Key 0 - - {{ 8|(1<<4)}, {17.2* 8, 12.8*1}, 4}, // LED 6 - {{ 9|(1<<4)}, {17.2* 9, 12.8*1}, 4}, // LED 7 - {{10|(1<<4)}, {17.2*10, 12.8*1}, 4}, // LED 8 - {{11|(1<<4)}, {17.2*11, 12.8*1}, 4}, // LED 9 - {{12|(1<<4)}, {17.2*12, 12.8*1}, 4}, // LED 10 - - {{ 8|(2<<4)}, {17.2* 8, 12.8*2}, 4}, // LED 11 - {{ 9|(2<<4)}, {17.2* 9, 12.8*2}, 4}, // LED 12 - {{10|(2<<4)}, {17.2*10, 12.8*2}, 4}, // LED 13 - {{11|(2<<4)}, {17.2*11, 12.8*2}, 4}, // LED 14 - {{12|(2<<4)}, {17.2*12, 12.8*2}, 4}, // LED 15 - - {{ 8|(3<<4)}, {17.2* 8, 12.8*3}, 4}, // LED 16 - {{ 9|(3<<4)}, {17.2* 9, 12.8*3}, 4}, // LED 17 - {{10|(3<<4)}, {17.2*10, 12.8*3}, 4}, // LED 18 - {{11|(3<<4)}, {17.2*11, 12.8*3}, 4}, // LED 19 - {{12|(3<<4)}, {17.2*12, 12.8*3}, 4}, // LED 20 - - {{ 9|(4<<4)}, {17.2* 9, 12.8*4}, 1}, // LED 21 - {{10|(4<<4)}, {17.2*10, 12.8*4}, 1}, // LED 22 - {{11|(4<<4)}, {17.2*11, 12.8*4}, 1}, // LED 23 - {{12|(4<<4)}, {17.2*12, 12.8*4}, 1}, // LED 24 - - {{ 5|(0<<4)}, {17.2* 5, 12.8*0}, 4}, // LED 1 on left > Key 5 - {{ 4|(0<<4)}, {17.2* 4, 12.8*0}, 4}, // LED 2 > Key 4 - {{ 3|(0<<4)}, {17.2* 3, 12.8*0}, 4}, // LED 3 > Key 3 - {{ 2|(0<<4)}, {17.2* 2, 12.8*0}, 4}, // LED 4 > Key 2 - {{ 1|(0<<4)}, {17.2* 1, 12.8*0}, 4}, // LED 5 > Key 1 - - {{ 5|(1<<4)}, {17.2* 5, 12.8*1}, 4}, // LED 6 - {{ 4|(1<<4)}, {17.2* 4, 12.8*1}, 4}, // LED 7 - {{ 3|(1<<4)}, {17.2* 3, 12.8*1}, 4}, // LED 8 - {{ 2|(1<<4)}, {17.2* 2, 12.8*1}, 4}, // LED 9 - {{ 1|(1<<4)}, {17.2* 1, 12.8*1}, 4}, // LED 10 - - {{ 5|(2<<4)}, {17.2* 5, 12.8*2}, 4}, // LED 11 - {{ 4|(2<<4)}, {17.2* 4, 12.8*2}, 4}, // LED 12 - {{ 3|(2<<4)}, {17.2* 3, 12.8*2}, 4}, // LED 13 - {{ 2|(2<<4)}, {17.2* 2, 12.8*2}, 4}, // LED 14 - {{ 1|(2<<4)}, {17.2* 1, 12.8*2}, 4}, // LED 15 - - {{ 5|(3<<4)}, {17.2* 5, 12.8*3}, 4}, // LED 16 - {{ 4|(3<<4)}, {17.2* 4, 12.8*3}, 4}, // LED 17 - {{ 3|(3<<4)}, {17.2* 3, 12.8*3}, 4}, // LED 18 - {{ 2|(3<<4)}, {17.2* 2, 12.8*3}, 4}, // LED 19 - {{ 1|(3<<4)}, {17.2* 1, 12.8*3}, 4}, // LED 20 - - {{ 4|(4<<4)}, {17.2* 4, 12.8*4}, 1}, // LED 21 - {{ 3|(4<<4)}, {17.2* 3, 12.8*4}, 1}, // LED 22 - {{ 2|(4<<4)}, {17.2* 2, 12.8*4}, 1}, // LED 23 - {{ 1|(4<<4)}, {17.2* 1, 12.8*4}, 1}, // LED 24 > Key Hack -}; +led_config_t g_led_config = { { + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, + { 28, 33, 38, 43, 47, NO_LED }, + { 27, 32, 37, 42, 46, NO_LED }, + { 26, 31, 36, 41, 45, NO_LED }, + { 25, 30, 35, 40, 44, NO_LED }, + { 24, 29, 34, 39, NO_LED, NO_LED }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, + { 0, 5, 10, 15, NO_LED, NO_LED }, + { 1, 6, 11, 16, 20, NO_LED }, + { 2, 7, 12, 17, 21, NO_LED }, + { 3, 8, 13, 18, 22, NO_LED }, + { 4, 9, 14, 19, 23, NO_LED }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED } +}, { + { 137, 0 }, { 154, 0 }, { 172, 0 }, { 189, 0 }, { 206, 0 }, { 137, 12 }, + { 154, 12 }, { 172, 12 }, { 189, 12 }, { 206, 12 }, { 137, 25 }, { 154, 25 }, + { 172, 25 }, { 189, 25 }, { 206, 25 }, { 137, 38 }, { 154, 38 }, { 172, 38 }, + { 189, 38 }, { 206, 38 }, { 154, 51 }, { 172, 51 }, { 189, 51 }, { 206, 51 }, + { 86, 0 }, { 68, 0 }, { 51, 0 }, { 34, 0 }, { 17, 0 }, { 86, 12 }, + { 68, 12 }, { 51, 12 }, { 34, 12 }, { 17, 12 }, { 86, 25 }, { 68, 25 }, + { 51, 25 }, { 34, 25 }, { 17, 25 }, { 86, 38 }, { 68, 38 }, { 51, 38 }, + { 34, 38 }, { 17, 38 }, { 68, 51 }, { 51, 51 }, { 34, 51 }, { 17, 51 } +}, { + 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, + 4, 4, 1, 1, 1, 1, + 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, + 4, 4, 1, 1, 1, 1 +} }; + #endif diff --git a/keyboards/exclusive/e6_rgb/e6_rgb.c b/keyboards/exclusive/e6_rgb/e6_rgb.c index 42f879990..106e58497 100644 --- a/keyboards/exclusive/e6_rgb/e6_rgb.c +++ b/keyboards/exclusive/e6_rgb/e6_rgb.c @@ -114,91 +114,79 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {0, E_16, D_16, F_16}, {0, B_16, A_16, C_16}, }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { -/* {row | col << 4} - * | {x=0..224, y=0..64} - * | | flags - * | | | */ -//cs1 - {{0|(0<<4)}, { 0, 0}, 1}, - {{0|(1<<4)}, { 17, 0}, 4}, - {{1|(0<<4)}, { 0, 16}, 1}, - {{2|(0<<4)}, { 0, 32}, 1}, +led_config_t g_led_config = { { + { 0, 1, 4, 5, 12, 13, 36, 20, 21, 24, 25, 16, 17, 28 }, + { 2, 6, 7, 14, 15, 37, 38, 22, 23, 26, 27, 18, 19, 30 }, + { 3, 8, 9, 32, 33, 39, 40, 44, 45, 48, 49, 52, 31, NO_LED }, + { 59, 10, 11, 34, 35, 41, 42, 46, 47, 50, 53, 54, 56, NO_LED }, + { 60, 61, 62, NO_LED, NO_LED, 43, 51, 55, 58, 57, NO_LED, NO_LED, NO_LED, NO_LED } +}, { +//cs1 + { 0, 0 }, { 17, 0 }, { 0, 16 }, { 0, 32 }, //cs2 - {{0|(2<<4)}, { 34, 0}, 4}, - {{0|(3<<4)}, { 51, 0}, 4}, - {{1|(1<<4)}, { 17, 16}, 4}, - {{1|(2<<4)}, { 34, 16}, 4}, + { 34, 0 }, { 51, 0 }, { 17, 16 }, { 34, 16 }, //cs3 - {{2|(1<<4)}, { 17, 32}, 4}, - {{2|(2<<4)}, { 34, 32}, 4}, - {{3|(1<<4)}, { 17, 48}, 4}, - {{3|(2<<4)}, { 34, 48}, 4}, + { 17, 32 }, { 34, 32 }, { 17, 48 }, { 34, 48 }, //cs4 - {{0|(4<<4)}, { 68, 0}, 4}, - {{0|(5<<4)}, { 85, 0}, 4}, - {{1|(3<<4)}, { 51, 16}, 4}, - {{1|(4<<4)}, { 68, 16}, 4}, + { 68, 0 }, { 85, 0 }, { 51, 16 }, { 68, 16 }, //cs5 - {{0|(11<<4)}, {187, 0}, 4}, - {{0|(12<<4)}, {204, 0}, 4}, - {{1|(11<<4)}, {187, 16}, 4}, - {{1|(12<<4)}, {204, 16}, 4}, + { 187, 0 }, { 204, 0 }, { 187, 16 }, { 204, 16 }, //cs6 - {{0|(7<<4)}, {119, 0}, 4}, - {{0|(8<<4)}, {136, 0}, 4}, - {{1|(7<<4)}, {119, 16}, 4}, - {{1|(8<<4)}, {136, 16}, 4}, + { 119, 0 }, { 136, 0 }, { 119, 16 }, { 136, 16 }, //cs7 - {{0|(9<<4)}, {153, 0}, 4}, - {{0|(10<<4)}, {170, 0}, 4}, - {{1|(9<<4)}, {153, 16}, 4}, - {{1|(10<<4)}, {170, 16}, 4}, + { 153, 0 }, { 170, 0 }, { 153, 16 }, { 170, 16 }, //cs8 - {{0|(13<<4)}, {221, 0}, 4}, - {{0|(14<<4)}, {221, 0}, 4}, - {{1|(13<<4)}, {221, 32}, 1}, - {{2|(12<<4)}, {221, 16}, 1}, + { 221, 0 }, { 221, 0 }, { 221, 32 }, { 221, 16 }, //cs9 - {{2|(3<<4)}, { 51, 32}, 4}, - {{2|(4<<4)}, { 68, 32}, 4}, - {{3|(3<<4)}, { 51, 48}, 4}, - {{3|(4<<4)}, { 68, 48}, 4}, + { 51, 32 }, { 68, 32 }, { 51, 48 }, { 68, 48 }, //cs10 - {{0|(6<<4)}, {102, 0}, 4}, - {{1|(5<<4)}, { 85, 16}, 4}, - {{1|(6<<4)}, {102, 16}, 4}, - {{2|(5<<4)}, { 85, 32}, 4}, + { 102, 0 }, { 85, 16 }, { 102, 16 }, { 85, 32 }, //cs11 - {{2|(6<<4)}, {102, 32}, 4}, - {{3|(5<<4)}, { 85, 48}, 4}, - {{3|(6<<4)}, {102, 48}, 4}, - {{4|(5<<4)}, {102, 64}, 4}, + { 102, 32 }, { 85, 48 }, { 102, 48 }, { 102, 64 }, //cs12 - {{2|(7<<4)}, {119, 32}, 4}, - {{2|(8<<4)}, {136, 32}, 4}, - {{3|(7<<4)}, {119, 48}, 4}, - {{3|(8<<4)}, {136, 48}, 4}, + { 119, 32 }, { 136, 32 }, { 119, 48 }, { 136, 48 }, //cs13 - {{2|(9<<4)}, {153, 32}, 4}, - {{2|(10<<4)}, {170, 32}, 4}, - {{3|(9<<4)}, {153, 48}, 4}, - {{4|(6<<4)}, {136, 48}, 1}, + { 153, 32 }, { 170, 32 }, { 153, 48 }, { 136, 48 }, //cs14 - {{2|(11<<4)}, {187, 32}, 4}, - {{3|(10<<4)}, {170, 48}, 4}, - {{3|(11<<4)}, {187, 48}, 1}, - {{4|(7<<4)}, {153, 48}, 1}, + { 187, 32 }, { 170, 48 }, { 187, 48 }, { 153, 48 }, //cs15 - {{3|(12<<4)}, {221, 48}, 1}, - - {{4|(9<<4)}, {221, 64}, 1}, - {{4|(8<<4)}, {204, 64}, 1}, + { 221, 48 }, { 221, 64 }, { 204, 64 }, //cs16 - {{3|(0<<4)}, { 0, 48}, 1}, - {{4|(0<<4)}, { 0, 64}, 1}, - {{4|(1<<4)}, { 17, 64}, 1}, - {{4|(2<<4)}, { 34, 64}, 1}, -}; + { 0, 48 }, { 0, 64 }, { 17, 64 }, { 34, 64 } +}, { +//cs1 + 1, 4, 1, 1, +//cs2 + 4, 4, 4, 4, +//cs3 + 4, 4, 4, 4, +//cs4 + 4, 4, 4, 4, +//cs5 + 4, 4, 4, 4, +//cs6 + 4, 4, 4, 4, +//cs7 + 4, 4, 4, 4, +//cs8 + 4, 4, 1, 1, +//cs9 + 4, 4, 4, 4, +//cs10 + 4, 4, 4, 4, +//cs11 + 4, 4, 4, 4, +//cs12 + 4, 4, 4, 4, +//cs13 + 4, 4, 4, 1, +//cs14 + 4, 4, 1, 1, +//cs15 + 1, 1, 1, +//cs16 + 1, 1, 1, 1 +} }; + #endif diff --git a/keyboards/hadron/ver3/ver3.c b/keyboards/hadron/ver3/ver3.c index 5827b42e2..1491caba4 100644 --- a/keyboards/hadron/ver3/ver3.c +++ b/keyboards/hadron/ver3/ver3.c @@ -19,24 +19,19 @@ #include "haptic.h" #ifdef RGB_MATRIX_ENABLE -#include "rgblight.h" - -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - /*{row | col << 4} - | {x=0..224, y=0..64} - | | modifier - | | | */ - {{1|(13<<4)}, {195, 3}, 4}, - {{4|(13<<4)}, {195, 16}, 4}, - {{4|(10<<4)}, {150, 16}, 4}, - {{4|(7<<4)}, {105, 16}, 4}, - {{4|(4<<4)}, {60, 16}, 4}, - {{4|(1<<4)}, {15, 16}, 4}, - {{1|(1<<4)}, {15, 3}, 4}, - {{1|(4<<4)}, {60, 3}, 4}, - {{1|(7<<4)}, {105, 3}, 4}, - {{1|(10<<4)}, {150, 3}, 4} -}; +#include "rgb_matrix.h" + +led_config_t g_led_config = { { + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, + { NO_LED, 6, NO_LED, NO_LED, 7, NO_LED, NO_LED, 8, NO_LED, NO_LED, 9, NO_LED, NO_LED, 0, NO_LED }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, + { NO_LED, 5, NO_LED, NO_LED, 4, NO_LED, NO_LED, 3, NO_LED, NO_LED, 2, NO_LED, NO_LED, 1, NO_LED } +}, { + { 195, 3 }, { 195, 16 }, { 150, 16 }, { 105, 16 }, { 60, 16 }, { 15, 16 }, { 15, 3 }, { 60, 3 }, { 105, 3 }, { 150, 3 } +}, { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 +} }; #endif @@ -53,12 +48,12 @@ uint16_t counterst = 0; #define ScreenOffInterval 60000 /* milliseconds */ static uint16_t last_flush; -volatile uint8_t led_numlock = false; -volatile uint8_t led_capslock = false; +volatile uint8_t led_numlock = false; +volatile uint8_t led_capslock = false; volatile uint8_t led_scrolllock = false; static uint8_t layer; -static bool queue_for_send = false; +static bool queue_for_send = false; static uint8_t encoder_value = 32; __attribute__ ((weak)) @@ -69,7 +64,7 @@ void draw_ui(void) { /* Layer indicator is 41 x 10 pixels */ #define LAYER_INDICATOR_X 5 -#define LAYER_INDICATOR_Y 0 +#define LAYER_INDICATOR_Y 0 draw_string(LAYER_INDICATOR_X + 1, LAYER_INDICATOR_Y + 2, "LAYER", PIXEL_ON, NORM, 0); draw_rect_filled_soft(LAYER_INDICATOR_X + 32, LAYER_INDICATOR_Y + 1, 9, 9, PIXEL_ON, NORM); @@ -83,7 +78,7 @@ void draw_ui(void) { for (uint8_t y = 0; y < MATRIX_COLS; y++) { draw_pixel(MATRIX_DISPLAY_X + y + 2, MATRIX_DISPLAY_Y + x + 2,(matrix_get_row(x) & (1 << y)) > 0, NORM); } - } + } draw_rect_soft(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y, 19, 9, PIXEL_ON, NORM); /* hadron oled location on thumbnail */ draw_rect_filled_soft(MATRIX_DISPLAY_X + 14, MATRIX_DISPLAY_Y + 2, 3, 1, PIXEL_ON, NORM); @@ -162,7 +157,7 @@ void read_host_led_state(void) { if (led_capslock == false){ led_capslock = true;} } else { - if (led_capslock == true){ + if (led_capslock == true){ led_capslock = false;} } if (leds & (1 << USB_LED_SCROLL_LOCK)) { @@ -197,7 +192,7 @@ void matrix_init_kb(void) { queue_for_send = true; matrix_init_user(); } - + void matrix_scan_kb(void) { if (queue_for_send) { #ifdef QWIIC_MICRO_OLED_ENABLE diff --git a/keyboards/hs60/v1/v1.c b/keyboards/hs60/v1/v1.c index bd6dd19b2..5267c9457 100644 --- a/keyboards/hs60/v1/v1.c +++ b/keyboards/hs60/v1/v1.c @@ -165,83 +165,37 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {1, C9_16, C7_15, C6_15} //D16 }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { -// -// C7, C6, C5, C4, C3, C2, C1, A7, A6, A5, A4, A3, A2, A1, -// C8, C9, C10, C11, C12, C13, C14, A8, A9, A10, A11, A12, A13, A15, -// D4, D5, D6, D7, D8, C16, C15, B5, B6, B7, B8, A16, ---, A14, -// D3, ---, D1, D9, D10, D11, D12, B4, B3, B2, B1, B9, ---, B10, -// D16, D15, D14, ---, ---, ---, D13, ---, ---, ---, B14, B13, B12, B11 -/* {row | col << 4} - * | {x=0..224, y=0..64} - * | | flags - * | | | */ - {{0|(13<<4)}, {224, 0}, 1}, //A1-A16 - {{0|(12<<4)}, {204, 0}, 4}, - {{0|(11<<4)}, {187, 0}, 4}, - {{0|(10<<4)}, {170, 0}, 4}, - {{0|(9<<4)}, {153, 0}, 4}, - {{0|(8<<4)}, {136, 0}, 4}, - {{0|(7<<4)}, {119, 0}, 4}, - {{1|(7<<4)}, {119, 16}, 4}, - {{1|(8<<4)}, {136, 16}, 4}, - {{1|(9<<4)}, {153, 16}, 4}, - {{1|(10<<4)}, {170, 16}, 4}, - {{1|(11<<4)}, {187, 16}, 4}, - {{1|(12<<4)}, {204, 16}, 4}, - {{2|(13<<4)}, {224, 32}, 1}, - {{2|(12<<4)}, {224, 16}, 4}, - {{2|(11<<4)}, {197, 32}, 4}, - - {{3|(10<<4)}, {170, 48}, 4}, //B1-B14 - {{3|(9<<4)}, {153, 48}, 4}, - {{3|(8<<4)}, {136, 48}, 4}, - {{3|(7<<4)}, {119, 48}, 4}, - {{2|(7<<4)}, {119, 32}, 4}, - {{2|(8<<4)}, {136, 32}, 4}, - {{2|(9<<4)}, {153, 32}, 4}, - {{2|(10<<4)}, {170, 32}, 4}, - {{3|(11<<4)}, {187, 48}, 4}, - {{3|(13<<4)}, {214, 48}, 1}, - {{4|(13<<4)}, {224, 64}, 1}, - {{4|(12<<4)}, {204, 64}, 1}, - {{4|(11<<4)}, {187, 64}, 1}, - {{4|(10<<4)}, {170, 64}, 1}, - - {{0|(6<<4)}, {102, 0}, 4}, //C1-C16 - {{0|(5<<4)}, { 85, 0}, 4}, - {{0|(4<<4)}, { 68, 0}, 4}, - {{0|(3<<4)}, { 51, 0}, 4}, - {{0|(2<<4)}, { 34, 0}, 4}, - {{0|(1<<4)}, { 17, 0}, 4}, - {{0|(0<<4)}, { 0, 0}, 1}, - {{1|(0<<4)}, { 0, 16}, 1}, - {{1|(1<<4)}, { 17, 16}, 4}, - {{1|(2<<4)}, { 34, 16}, 4}, - {{1|(3<<4)}, { 51, 16}, 4}, - {{1|(4<<4)}, { 68, 16}, 4}, - {{1|(5<<4)}, { 85, 16}, 4}, - {{1|(6<<4)}, {102, 16}, 4}, - {{2|(6<<4)}, {102, 32}, 4}, - {{2|(5<<4)}, { 85, 32}, 4}, - - {{3|(2<<4)}, { 32, 48}, 4}, //D1-D16 - //D2 - {{3|(0<<4)}, { 10, 48}, 1}, - {{2|(0<<4)}, { 0, 32}, 1}, - {{2|(1<<4)}, { 17, 32}, 4}, - {{2|(2<<4)}, { 34, 32}, 4}, - {{2|(3<<4)}, { 51, 32}, 4}, - {{2|(4<<4)}, { 68, 32}, 4}, - {{3|(3<<4)}, { 51, 48}, 4}, - {{3|(4<<4)}, { 68, 48}, 4}, - {{3|(5<<4)}, { 85, 48}, 4}, - {{3|(6<<4)}, {102, 48}, 4}, - {{4|(3<<4)}, {102, 64}, 4}, - {{4|(2<<4)}, { 34, 68}, 1}, - {{4|(1<<4)}, { 17, 68}, 1}, - {{4|(0<<4)}, { 0, 68}, 1} -}; +led_config_t g_led_config = { { + { 36, 35, 34, 33, 32, 31, 30, 6, 5, 4, 3, 2, 1, 0 }, + { 37, 38, 39, 40, 41, 42, 43, 7, 8, 9, 10, 11, 12, NO_LED }, + { 48, 49, 50, 51, 52, 45, 44, 20, 21, 22, 23, 15, 14, 13 }, + { 47, NO_LED, 46, 53, 54, 55, 56, 19, 18, 17, 16, 24, NO_LED, 25 }, + { 60, 59, 58, 57, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, 29, 28, 27, 26 } +}, { + //A1-A16 + { 224, 0 }, { 204, 0 }, { 187, 0 }, { 170, 0 }, { 153, 0 }, { 136, 0 }, { 119, 0 }, { 119, 16 }, { 136, 16 }, { 153, 16 }, { 170, 16 }, { 187, 16 }, { 204, 16 }, { 224, 32 }, + { 224, 16 }, { 197, 32 }, + //B1-B14 + { 170, 48 }, { 153, 48 }, { 136, 48 }, { 119, 48 }, { 119, 32 }, { 136, 32 }, { 153, 32 }, { 170, 32 }, { 187, 48 }, { 214, 48 }, { 224, 64 }, { 204, 64 }, { 187, 64 }, { 170, 64 }, + //C1-C16 + { 102, 0 }, { 85, 0 }, { 68, 0 }, { 51, 0 }, { 34, 0 }, { 17, 0 }, { 0, 0 }, { 0, 16 }, { 17, 16 }, { 34, 16 }, { 51, 16 }, { 68, 16 }, { 85, 16 }, { 102, 16 }, + { 102, 32 }, { 85, 32 }, + //D1-D16 + { 32, 48 }, { 10, 48 }, { 0, 32 }, { 17, 32 }, { 34, 32 }, { 51, 32 }, { 68, 32 }, { 51, 48 }, { 68, 48 }, { 85, 48 }, { 102, 48 }, { 102, 64 }, { 34, 68 }, { 17, 68 }, + { 0, 68 } +}, { + //A1-A16 + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 4, 4, + //B1-B14 + 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, + //C1-C16 + 4, 4, 4, 4, 4, 4, 1, 1, 4, 4, 4, 4, 4, 4, + 4, 4, + //D1-D16 + 4, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, + 1 +} }; #else @@ -319,83 +273,37 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {1, C9_16, C7_15, C6_15} //D16 }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { -// -// C7, C6, C5, C4, C3, C2, C1, A7, A6, A5, A4, A3, A2, A1, -// C8, C9, C10, C11, C12, C13, C14, A8, A9, A10, A11, A12, A13, ---, -// D4, D5, D6, D7, D8, C16, C15, B5, B6, B7, B8, A16, A15, A14, -// D3, D2, D1, D9, D10, D11, D12, B4, B3, B2, B1, B9, ---, B10, -// D16, D15, D14, ---, ---, ---, D13, ---, ---, ---, B14, B13, B12, B11 -/* {row | col << 4} - * | {x=0..224, y=0..64} - * | | flags - * | | | */ - {{0|(13<<4)}, {224, 0}, 1}, //A1-A16 - {{0|(12<<4)}, {204, 0}, 4}, - {{0|(11<<4)}, {187, 0}, 4}, - {{0|(10<<4)}, {170, 0}, 4}, - {{0|(9<<4)}, {153, 0}, 4}, - {{0|(8<<4)}, {136, 0}, 4}, - {{0|(7<<4)}, {119, 0}, 4}, - {{1|(7<<4)}, {119, 16}, 4}, - {{1|(8<<4)}, {136, 16}, 4}, - {{1|(9<<4)}, {153, 16}, 4}, - {{1|(10<<4)}, {170, 16}, 4}, - {{1|(11<<4)}, {187, 16}, 4}, - {{1|(12<<4)}, {204, 16}, 4}, - {{2|(13<<4)}, {224, 8}, 1}, - {{2|(12<<4)}, {204, 32}, 4}, - {{2|(11<<4)}, {187, 32}, 4}, - - {{3|(10<<4)}, {170, 48}, 4}, //B1-B14 - {{3|(9<<4)}, {153, 48}, 4}, - {{3|(8<<4)}, {136, 48}, 4}, - {{3|(7<<4)}, {119, 48}, 4}, - {{2|(7<<4)}, {119, 32}, 4}, - {{2|(8<<4)}, {136, 32}, 4}, - {{2|(9<<4)}, {153, 32}, 4}, - {{2|(10<<4)}, {170, 32}, 4}, - {{3|(11<<4)}, {187, 48}, 4}, - {{3|(13<<4)}, {214, 48}, 1}, - {{4|(13<<4)}, {224, 64}, 1}, - {{4|(12<<4)}, {204, 64}, 1}, - {{4|(11<<4)}, {187, 64}, 1}, - {{4|(10<<4)}, {170, 64}, 1}, - - {{0|(6<<4)}, {102, 0}, 4}, //C1-C16 - {{0|(5<<4)}, { 85, 0}, 4}, - {{0|(4<<4)}, { 68, 0}, 4}, - {{0|(3<<4)}, { 51, 0}, 4}, - {{0|(2<<4)}, { 34, 0}, 4}, - {{0|(1<<4)}, { 17, 0}, 4}, - {{0|(0<<4)}, { 0, 0}, 1}, - {{1|(0<<4)}, { 0, 16}, 1}, - {{1|(1<<4)}, { 17, 16}, 4}, - {{1|(2<<4)}, { 34, 16}, 4}, - {{1|(3<<4)}, { 51, 16}, 4}, - {{1|(4<<4)}, { 68, 16}, 4}, - {{1|(5<<4)}, { 85, 16}, 4}, - {{1|(6<<4)}, {102, 16}, 4}, - {{2|(6<<4)}, {102, 32}, 4}, - {{2|(5<<4)}, { 85, 32}, 4}, - - {{3|(2<<4)}, { 32, 48}, 4}, //D1-D16 - {{3|(1<<4)}, { 17, 48}, 4}, - {{3|(0<<4)}, { 0, 48}, 1}, - {{2|(0<<4)}, { 0, 32}, 1}, - {{2|(1<<4)}, { 17, 32}, 4}, - {{2|(2<<4)}, { 34, 32}, 4}, - {{2|(3<<4)}, { 51, 32}, 4}, - {{2|(4<<4)}, { 68, 32}, 4}, - {{3|(3<<4)}, { 51, 48}, 4}, - {{3|(4<<4)}, { 68, 48}, 4}, - {{3|(5<<4)}, { 85, 48}, 4}, - {{3|(6<<4)}, {102, 48}, 4}, - {{4|(3<<4)}, {102, 64}, 4}, - {{4|(2<<4)}, { 34, 68}, 1}, - {{4|(1<<4)}, { 17, 68}, 1}, - {{4|(0<<4)}, { 0, 68}, 1} -}; +led_config_t g_led_config = { { + { 36, 35, 34, 33, 32, 31, 30, 6, 5, 4, 3, 2, 1, 0 }, + { 37, 38, 39, 40, 41, 42, 43, 7, 8, 9, 10, 11, 12, NO_LED }, + { 49, 50, 51, 52, 53, 45, 44, 20, 21, 22, 23, 15, 14, 13 }, + { 48, 47, 46, 54, 55, 56, 57, 19, 18, 17, 16, 24, NO_LED, 25 }, + { 61, 60, 59, 58, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, 29, 28, 27, 26 } +}, { + //A1-A16 + { 224, 0 }, { 204, 0 }, { 187, 0 }, { 170, 0 }, { 153, 0 }, { 136, 0 }, { 119, 0 }, { 119, 16 }, { 136, 16 }, { 153, 16 }, { 170, 16 }, { 187, 16 }, { 204, 16 }, { 224, 8 }, + { 204, 32 }, { 187, 32 }, + //B1-B14 + { 170, 48 }, { 153, 48 }, { 136, 48 }, { 119, 48 }, { 119, 32 }, { 136, 32 }, { 153, 32 }, { 170, 32 }, { 187, 48 }, { 214, 48 }, { 224, 64 }, { 204, 64 }, { 187, 64 }, { 170, 64 }, + //C1-C16 + { 102, 0 }, { 85, 0 }, { 68, 0 }, { 51, 0 }, { 34, 0 }, { 17, 0 }, { 0, 0 }, { 0, 16 }, { 17, 16 }, { 34, 16 }, { 51, 16 }, { 68, 16 }, { 85, 16 }, { 102, 16 }, + { 102, 32 }, { 85, 32 }, + //D1-D16 + { 32, 48 }, { 17, 48 }, { 0, 48 }, { 0, 32 }, { 17, 32 }, { 34, 32 }, { 51, 32 }, { 68, 32 }, { 51, 48 }, { 68, 48 }, { 85, 48 }, { 102, 48 }, { 102, 64 }, { 34, 68 }, + { 17, 68 }, { 0, 68 } +}, { + //A1-A16 + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 4, 4, + //B1-B14 + 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, + //C1-C16 + 4, 4, 4, 4, 4, 4, 1, 1, 4, 4, 4, 4, 4, 4, + 4, 4, + //D1-D16 + 4, 4, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 1 +} }; #endif @@ -492,4 +400,4 @@ void suspend_power_down_kb(void) void suspend_wakeup_init_kb(void) { rgb_matrix_set_suspend_state(false); -} \ No newline at end of file +} diff --git a/keyboards/massdrop/alt/config_led.c b/keyboards/massdrop/alt/config_led.c index 1a9a539a0..42d4d1474 100644 --- a/keyboards/massdrop/alt/config_led.c +++ b/keyboards/massdrop/alt/config_led.c @@ -20,123 +20,34 @@ // // There is a quick-and-dirty implementation of this under ledvis.html -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - /* 0 */ { { (0)|(0 << 4) }, { 8, 56 }, 4 }, // KC_ESC - /* 1 */ { { (0)|(1 << 4) }, { 22, 56 }, 4 }, // KC_1 - /* 2 */ { { (0)|(2 << 4) }, { 35, 56 }, 4 }, // KC_2 - /* 3 */ { { (0)|(3 << 4) }, { 49, 56 }, 4 }, // KC_3 - /* 4 */ { { (0)|(4 << 4) }, { 63, 56 }, 4 }, // KC_4 - /* 5 */ { { (0)|(5 << 4) }, { 77, 56 }, 4 }, // KC_5 - /* 6 */ { { (0)|(6 << 4) }, { 91, 56 }, 4 }, // KC_6 - /* 7 */ { { (0)|(7 << 4) }, { 105, 56 }, 4 }, // KC_7 - /* 8 */ { { (0)|(8 << 4) }, { 118, 56 }, 4 }, // KC_8 - /* 9 */ { { (0)|(9 << 4) }, { 132, 56 }, 4 }, // KC_9 - /* 10 */ { { (0)|(10 << 4) }, { 146, 56 }, 4 }, // KC_0 - /* 11 */ { { (0)|(11 << 4) }, { 160, 56 }, 4 }, // KC_MINS - /* 12 */ { { (0)|(12 << 4) }, { 174, 56 }, 4 }, // KC_EQL - /* 13 */ { { (0)|(13 << 4) }, { 195, 56 }, 4 }, // KC_BSPC - /* 14 */ { { (0)|(14 << 4) }, { 215, 56 }, 4 }, // KC_DEL - /* 15 */ { { (1)|(0 << 4) }, { 11, 44 }, 4 }, // KC_TAB - /* 16 */ { { (1)|(1 << 4) }, { 28, 44 }, 4 }, // KC_Q - /* 17 */ { { (1)|(2 << 4) }, { 42, 44 }, 4 }, // KC_W - /* 18 */ { { (1)|(3 << 4) }, { 56, 44 }, 4 }, // KC_E - /* 19 */ { { (1)|(4 << 4) }, { 70, 44 }, 4 }, // KC_R - /* 20 */ { { (1)|(5 << 4) }, { 84, 44 }, 4 }, // KC_T - /* 21 */ { { (1)|(6 << 4) }, { 98, 44 }, 4 }, // KC_Y - /* 22 */ { { (1)|(7 << 4) }, { 112, 44 }, 4 }, // KC_U - /* 23 */ { { (1)|(8 << 4) }, { 125, 44 }, 4 }, // KC_I - /* 24 */ { { (1)|(9 << 4) }, { 139, 44 }, 4 }, // KC_O - /* 25 */ { { (1)|(10 << 4) }, { 153, 44 }, 4 }, // KC_P - /* 26 */ { { (1)|(11 << 4) }, { 167, 44 }, 4 }, // KC_LBRC - /* 27 */ { { (1)|(12 << 4) }, { 181, 44 }, 4 }, // KC_RBRC - /* 28 */ { { (1)|(13 << 4) }, { 198, 44 }, 4 }, // KC_BSLS - /* 29 */ { { (1)|(14 << 4) }, { 215, 44 }, 4 }, // KC_HOME - /* 30 */ { { (2)|(0 << 4) }, { 13, 32 }, 1 }, // KC_CAPS - /* 31 */ { { (2)|(1 << 4) }, { 32, 32 }, 4 }, // KC_A - /* 32 */ { { (2)|(2 << 4) }, { 46, 32 }, 4 }, // KC_S - /* 33 */ { { (2)|(3 << 4) }, { 60, 32 }, 4 }, // KC_D - /* 34 */ { { (2)|(4 << 4) }, { 73, 32 }, 4 }, // KC_F - /* 35 */ { { (2)|(5 << 4) }, { 87, 32 }, 4 }, // KC_G - /* 36 */ { { (2)|(6 << 4) }, { 101, 32 }, 4 }, // KC_H - /* 37 */ { { (2)|(7 << 4) }, { 115, 32 }, 4 }, // KC_J - /* 38 */ { { (2)|(8 << 4) }, { 129, 32 }, 4 }, // KC_K - /* 39 */ { { (2)|(9 << 4) }, { 143, 32 }, 4 }, // KC_L - /* 40 */ { { (2)|(10 << 4) }, { 156, 32 }, 4 }, // KC_SCLN - /* 41 */ { { (2)|(11 << 4) }, { 170, 32 }, 4 }, // KC_QUOT - /* _________________________________________ */ // ____ - /* 42 */ { { (2)|(13 << 4) }, { 193, 32 }, 4 }, // KC_ENT - /* 43 */ { { (2)|(14 << 4) }, { 215, 32 }, 4 }, // KC_PGUP - /* 44 */ { { (3)|(0 << 4) }, { 16, 19 }, 4 }, // KC_LSFT - /* 45 */ { { (3)|(2 << 4) }, { 39, 19 }, 4 }, // KC_Z - /* 46 */ { { (3)|(3 << 4) }, { 53, 19 }, 4 }, // KC_X - /* 47 */ { { (3)|(4 << 4) }, { 67, 19 }, 4 }, // KC_C - /* 48 */ { { (3)|(5 << 4) }, { 80, 19 }, 4 }, // KC_V - /* 49 */ { { (3)|(6 << 4) }, { 94, 19 }, 4 }, // KC_B - /* 50 */ { { (3)|(7 << 4) }, { 108, 19 }, 4 }, // KC_N - /* 51 */ { { (3)|(8 << 4) }, { 122, 19 }, 4 }, // KC_M - /* 52 */ { { (3)|(9 << 4) }, { 136, 19 }, 4 }, // KC_COMM - /* 53 */ { { (3)|(10 << 4) }, { 150, 19 }, 4 }, // KC_DOT - /* 54 */ { { (3)|(11 << 4) }, { 163, 19 }, 4 }, // KC_SLSH - /* 55 */ { { (3)|(12 << 4) }, { 182, 19 }, 4 }, // KC_RSFT - /* _________________________________________ */ // ____ - /* 56 */ { { (3)|(13 << 4) }, { 201, 19 }, 4 }, // KC_UP - /* 57 */ { { (3)|(14 << 4) }, { 215, 19 }, 4 }, // KC_PGDN - /* 58 */ { { (4)|(0 << 4) }, { 9, 7 }, 4 }, // KC_LCTL - /* 59 */ { { (4)|(1 << 4) }, { 27, 7 }, 4 }, // KC_LGUI - /* 60 */ { { (4)|(2 << 4) }, { 44, 7 }, 4 }, // KC_LALT - /* _________________________________________ */ // ____ - /* _________________________________________ */ // ____ - /* _________________________________________ */ // ____ - /* 61 */ { { (4)|(6 << 4) }, { 96, 7 }, 4 }, // KC_SPC - /* _________________________________________ */ // ____ - /* _________________________________________ */ // ____ - /* _________________________________________ */ // ____ - /* 62 */ { { (4)|(10 << 4) }, { 148, 7 }, 4 }, // KC_RALT - /* 63 */ { { (4)|(11 << 4) }, { 165, 7 }, 4 }, // MO(1) - /* 64 */ { { (4)|(12 << 4) }, { 188, 7 }, 4 }, // KC_LEFT - /* 65 */ { { (4)|(13 << 4) }, { 201, 7 }, 4 }, // KC_DOWN - /* 66 */ { { (4)|(14 << 4) }, { 215, 7 }, 4 }, // KC_RGHT - +led_config_t g_led_config = { { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, + { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 }, + { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, NO_LED, 42, 43 }, + { 44, NO_LED, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 }, + { 58, 59, 60, NO_LED, NO_LED, NO_LED, 61, NO_LED, NO_LED, NO_LED, 62, 63, 64, 65, 66 } +}, { + { 8, 56 }, { 22, 56 }, { 35, 56 }, { 49, 56 }, { 63, 56 }, { 77, 56 }, { 91, 56 }, { 105, 56 }, { 118, 56 }, { 132, 56 }, { 146, 56 }, { 160, 56 }, { 174, 56 }, { 195, 56 }, { 215, 56 }, + { 11, 44 }, { 28, 44 }, { 42, 44 }, { 56, 44 }, { 70, 44 }, { 84, 44 }, { 98, 44 }, { 112, 44 }, { 125, 44 }, { 139, 44 }, { 153, 44 }, { 167, 44 }, { 181, 44 }, { 198, 44 }, { 215, 44 }, + { 13, 32 }, { 32, 32 }, { 46, 32 }, { 60, 32 }, { 73, 32 }, { 87, 32 }, { 101, 32 }, { 115, 32 }, { 129, 32 }, { 143, 32 }, { 156, 32 }, { 170, 32 }, { 193, 32 }, { 215, 32 }, { 16, 19 }, + { 39, 19 }, { 53, 19 }, { 67, 19 }, { 80, 19 }, { 94, 19 }, { 108, 19 }, { 122, 19 }, { 136, 19 }, { 150, 19 }, { 163, 19 }, { 182, 19 }, { 201, 19 }, { 215, 19 }, { 9, 7 }, { 27, 7 }, + { 44, 7 }, { 96, 7 }, { 148, 7 }, { 165, 7 }, { 188, 7 }, { 201, 7 }, { 215, 7 }, + // Underglow LEDs + { 1, 1 }, { 15, 0 }, { 31, 0 }, { 47, 0 }, { 63, 0 }, { 79, 0 }, { 95, 0 }, { 112, 0 }, { 128, 0 }, { 144, 0 }, { 160, 0 }, { 176, 0 }, { 192, 0 }, { 208, 0 }, { 222, 1 }, + { 224, 13 }, { 224, 25 }, { 224, 38 }, { 224, 50 }, { 222, 62 }, { 191, 64 }, { 179, 64 }, { 167, 64 }, { 153, 64 }, { 139, 64 }, { 125, 64 }, { 112, 64 }, { 98, 64 }, { 84, 64 }, { 70, 64 }, + { 56, 64 }, { 42, 64 }, { 28, 64 }, { 1, 62 }, { 0, 50 }, { 0, 38 }, { 0, 25 }, { 0, 13 } +}, { + 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, + 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, + 4, 4, 4, 4, 4, 4, 4, // Underglow LEDs - { { 255 }, { 1, 1 }, 2 }, - { { 255 }, { 15, 0 }, 2 }, - { { 255 }, { 31, 0 }, 2 }, - { { 255 }, { 47, 0 }, 2 }, - { { 255 }, { 63, 0 }, 2 }, - { { 255 }, { 79, 0 }, 2 }, - { { 255 }, { 95, 0 }, 2 }, - { { 255 }, { 112, 0 }, 2 }, - { { 255 }, { 128, 0 }, 2 }, - { { 255 }, { 144, 0 }, 2 }, - { { 255 }, { 160, 0 }, 2 }, - { { 255 }, { 176, 0 }, 2 }, - { { 255 }, { 192, 0 }, 2 }, - { { 255 }, { 208, 0 }, 2 }, - { { 255 }, { 222, 1 }, 2 }, - { { 255 }, { 224, 13 }, 2 }, - { { 255 }, { 224, 25 }, 2 }, - { { 255 }, { 224, 38 }, 2 }, - { { 255 }, { 224, 50 }, 2 }, - { { 255 }, { 222, 62 }, 2 }, - { { 255 }, { 191, 64 }, 2 }, - { { 255 }, { 179, 64 }, 2 }, - { { 255 }, { 167, 64 }, 2 }, - { { 255 }, { 153, 64 }, 2 }, - { { 255 }, { 139, 64 }, 2 }, - { { 255 }, { 125, 64 }, 2 }, - { { 255 }, { 112, 64 }, 2 }, - { { 255 }, { 98, 64 }, 2 }, - { { 255 }, { 84, 64 }, 2 }, - { { 255 }, { 70, 64 }, 2 }, - { { 255 }, { 56, 64 }, 2 }, - { { 255 }, { 42, 64 }, 2 }, - { { 255 }, { 28, 64 }, 2 }, - { { 255 }, { 1, 62 }, 2 }, - { { 255 }, { 0, 50 }, 2 }, - { { 255 }, { 0, 38 }, 2 }, - { { 255 }, { 0, 25 }, 2 }, - { { 255 }, { 0, 13 }, 2 }, -}; + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2 +} }; + #ifdef USB_LED_INDICATOR_ENABLE void rgb_matrix_indicators_kb(void) diff --git a/keyboards/massdrop/ctrl/config_led.c b/keyboards/massdrop/ctrl/config_led.c index 20d9c649e..5f1c45207 100644 --- a/keyboards/massdrop/ctrl/config_led.c +++ b/keyboards/massdrop/ctrl/config_led.c @@ -5,134 +5,72 @@ #include "rgb_matrix.h" #include "config_led.h" -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +led_config_t g_led_config = { { + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 16, 17, 18, 19, 20, 21, 22, 23 }, + { 33, 34, 35, 36, 37, 38, 39, 40 }, + { 50, 51, 52, 53, 54, 55, 56, 57 }, + { 63, 64, 65, 66, 67, 68, 69, 70 }, + { 76, 77, 78, 79, 80, 81, 82, 83 }, + { 8, 9, 10, 11, 12, 13, 14, 15 }, + { 24, 25, 26, 27, 28, 29, 30, 31 }, + { 41, 42, 43, 44, 45, 46, 47, 48 }, + { 58, 59, 60, 61, 62, 75, 49, 32 }, + { 71, 72, 73, 74, 84, 85, 86, NO_LED } +}, { // KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_PAUS - { { 0|(0<<4) }, { 7, 5 }, 4 }, - { { 0|(1<<4) }, { 31, 5 }, 4 }, - { { 0|(2<<4) }, { 43, 5 }, 4 }, - { { 0|(3<<4) }, { 55, 5 }, 4 }, - { { 0|(4<<4) }, { 67, 5 }, 4 }, - { { 0|(5<<4) }, { 85, 5 }, 4 }, - { { 0|(6<<4) }, { 97, 5 }, 4 }, - { { 0|(7<<4) }, { 109, 5 }, 4 }, - { { 6|(0<<4) }, { 121, 5 }, 4 }, - { { 6|(1<<4) }, { 139, 5 }, 4 }, - { { 6|(2<<4) }, { 151, 5 }, 4 }, - { { 6|(3<<4) }, { 163, 5 }, 4 }, - { { 6|(4<<4) }, { 175, 5 }, 4 }, - { { 6|(5<<4) }, { 193, 5 }, 4 }, - { { 6|(6<<4) }, { 205, 5 }, 1 }, - { { 6|(7<<4) }, { 217, 5 }, 4 }, + { 7, 5 }, { 31, 5 }, { 43, 5 }, { 55, 5 }, { 67, 5 }, { 85, 5 }, { 97, 5 }, { 109, 5 }, + { 121, 5 }, { 139, 5 }, { 151, 5 }, { 163, 5 }, { 175, 5 }, { 193, 5 }, { 205, 5 }, { 217, 5 }, // KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP - { { 1|(0<<4) }, { 7, 20 }, 4 }, - { { 1|(1<<4) }, { 19, 20 }, 4 }, - { { 1|(2<<4) }, { 31, 20 }, 4 }, - { { 1|(3<<4) }, { 43, 20 }, 4 }, - { { 1|(4<<4) }, { 55, 20 }, 4 }, - { { 1|(5<<4) }, { 67, 20 }, 4 }, - { { 1|(6<<4) }, { 79, 20 }, 4 }, - { { 1|(7<<4) }, { 91, 20 }, 4 }, - { { 7|(0<<4) }, { 103, 20 }, 4 }, - { { 7|(1<<4) }, { 115, 20 }, 4 }, - { { 7|(2<<4) }, { 127, 20 }, 4 }, - { { 7|(3<<4) }, { 139, 20 }, 4 }, - { { 7|(4<<4) }, { 151, 20 }, 4 }, - { { 7|(5<<4) }, { 169, 20 }, 4 }, - { { 7|(6<<4) }, { 193, 20 }, 4 }, - { { 7|(7<<4) }, { 205, 20 }, 4 }, - { { 9|(7<<4) }, { 217, 20 }, 4 }, + { 7, 20 }, { 19, 20 }, { 31, 20 }, { 43, 20 }, { 55, 20 }, { 67, 20 }, { 79, 20 }, { 91, 20 }, + { 103, 20 }, { 115, 20 }, { 127, 20 }, { 139, 20 }, { 151, 20 }, { 169, 20 }, { 193, 20 }, { 205, 20 }, + { 217, 20 }, // KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN - { { 2|(0<<4) }, { 10, 30 }, 4 }, - { { 2|(1<<4) }, { 25, 30 }, 4 }, - { { 2|(2<<4) }, { 37, 30 }, 4 }, - { { 2|(3<<4) }, { 49, 30 }, 4 }, - { { 2|(4<<4) }, { 61, 30 }, 4 }, - { { 2|(5<<4) }, { 73, 30 }, 4 }, - { { 2|(6<<4) }, { 85, 30 }, 4 }, - { { 2|(7<<4) }, { 97, 30 }, 4 }, - { { 8|(0<<4) }, { 109, 30 }, 4 }, - { { 8|(1<<4) }, { 121, 30 }, 4 }, - { { 8|(2<<4) }, { 133, 30 }, 4 }, - { { 8|(3<<4) }, { 145, 30 }, 4 }, - { { 8|(4<<4) }, { 157, 30 }, 4 }, - { { 8|(5<<4) }, { 172, 30 }, 4 }, - { { 8|(6<<4) }, { 193, 30 }, 4 }, - { { 8|(7<<4) }, { 205, 30 }, 4 }, - { { 9|(6<<4) }, { 217, 30 }, 4 }, + { 10, 30 }, { 25, 30 }, { 37, 30 }, { 49, 30 }, { 61, 30 }, { 73, 30 }, { 85, 30 }, { 97, 30 }, + { 109, 30 }, { 121, 30 }, { 133, 30 }, { 145, 30 }, { 157, 30 }, { 172, 30 }, { 193, 30 }, { 205, 30 }, + { 217, 30 }, // KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT - { { 3|(0<<4) }, { 11, 39 }, 1 }, - { { 3|(1<<4) }, { 28, 39 }, 4 }, - { { 3|(2<<4) }, { 40, 39 }, 4 }, - { { 3|(3<<4) }, { 52, 39 }, 4 }, - { { 3|(4<<4) }, { 64, 39 }, 4 }, - { { 3|(5<<4) }, { 76, 39 }, 4 }, - { { 3|(6<<4) }, { 88, 39 }, 4 }, - { { 3|(7<<4) }, { 100, 39 }, 4 }, - { { 9|(0<<4) }, { 112, 39 }, 4 }, - { { 9|(1<<4) }, { 124, 39 }, 4 }, - { { 9|(2<<4) }, { 136, 39 }, 4 }, - { { 9|(3<<4) }, { 148, 39 }, 4 }, - { { 9|(4<<4) }, { 168, 39 }, 4 }, + { 11, 39 }, { 28, 39 }, { 40, 39 }, { 52, 39 }, { 64, 39 }, { 76, 39 }, { 88, 39 }, { 100, 39 }, + { 112, 39 }, { 124, 39 }, { 136, 39 }, { 148, 39 }, { 168, 39 }, // KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP - { { 4|(0<<4) }, { 14, 49 }, 4 }, - { { 4|(1<<4) }, { 34, 49 }, 4 }, - { { 4|(2<<4) }, { 46, 49 }, 4 }, - { { 4|(3<<4) }, { 58, 49 }, 4 }, - { { 4|(4<<4) }, { 70, 49 }, 4 }, - { { 4|(5<<4) }, { 82, 49 }, 4 }, - { { 4|(6<<4) }, { 94, 49 }, 4 }, - { { 4|(7<<4) }, { 106, 49 }, 4 }, - { { 10|(0<<4) }, { 118, 49 }, 4 }, - { { 10|(1<<4) }, { 130, 49 }, 4 }, - { { 10|(2<<4) }, { 142, 49 }, 4 }, - { { 10|(3<<4) }, { 165, 49 }, 4 }, - { { 9|(5<<4) }, { 205, 49 }, 4 }, + { 14, 49 }, { 34, 49 }, { 46, 49 }, { 58, 49 }, { 70, 49 }, { 82, 49 }, { 94, 49 }, { 106, 49 }, + { 118, 49 }, { 130, 49 }, { 142, 49 }, { 165, 49 }, { 205, 49 }, // KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT - { { 5|(0<<4) }, { 8, 59 }, 4 }, - { { 5|(1<<4) }, { 23, 59 }, 4 }, - { { 5|(2<<4) }, { 38, 59 }, 4 }, - { { 5|(3<<4) }, { 83, 59 }, 4 }, - { { 5|(4<<4) }, { 129, 59 }, 4 }, - { { 5|(5<<4) }, { 144, 59 }, 4 }, - { { 5|(6<<4) }, { 159, 59 }, 4 }, - { { 5|(7<<4) }, { 174, 59 }, 4 }, - { { 10|(4<<4) }, { 193, 59 }, 4 }, - { { 10|(5<<4) }, { 205, 59 }, 4 }, - { { 10|(6<<4) }, { 217, 59 }, 4 }, + { 8, 59 }, { 23, 59 }, { 38, 59 }, { 83, 59 }, { 129, 59 }, { 144, 59 }, { 159, 59 }, { 174, 59 }, + { 193, 59 }, { 205, 59 }, { 217, 59 }, // Underglow / Border - { { 0xFF }, { 222, 64 }, 2 }, - { { 0xFF }, { 204, 64 }, 2 }, - { { 0xFF }, { 186, 64 }, 2 }, - { { 0xFF }, { 167, 64 }, 2 }, - { { 0xFF }, { 149, 64 }, 2 }, - { { 0xFF }, { 130, 64 }, 2 }, - { { 0xFF }, { 112, 64 }, 2 }, - { { 0xFF }, { 94, 64 }, 2 }, - { { 0xFF }, { 75, 64 }, 2 }, - { { 0xFF }, { 57, 64 }, 2 }, - { { 0xFF }, { 38, 64 }, 2 }, - { { 0xFF }, { 20, 64 }, 2 }, - { { 0xFF }, { 0, 64 }, 2 }, - { { 0xFF }, { 0, 47 }, 2 }, - { { 0xFF }, { 0, 32 }, 2 }, - { { 0xFF }, { 0, 17 }, 2 }, - { { 0xFF }, { 0, 0 }, 2 }, - { { 0xFF }, { 20, 0 }, 2 }, - { { 0xFF }, { 38, 0 }, 2 }, - { { 0xFF }, { 57, 0 }, 2 }, - { { 0xFF }, { 75, 0 }, 2 }, - { { 0xFF }, { 94, 0 }, 2 }, - { { 0xFF }, { 112, 0 }, 2 }, - { { 0xFF }, { 130, 0 }, 2 }, - { { 0xFF }, { 149, 0 }, 2 }, - { { 0xFF }, { 167, 0 }, 2 }, - { { 0xFF }, { 186, 0 }, 2 }, - { { 0xFF }, { 204, 0 }, 2 }, - { { 0xFF }, { 222, 1 }, 2 }, - { { 0xFF }, { 224, 17 }, 2 }, - { { 0xFF }, { 224, 32 }, 2 }, - { { 0xFF }, { 224, 47 }, 2 }, -}; + { 222, 64 }, { 204, 64 }, { 186, 64 }, { 167, 64 }, { 149, 64 }, { 130, 64 }, { 112, 64 }, { 94, 64 }, + { 75, 64 }, { 57, 64 }, { 38, 64 }, { 20, 64 }, { 0, 64 }, { 0, 47 }, { 0, 32 }, { 0, 17 }, + { 0, 0 }, { 20, 0 }, { 38, 0 }, { 57, 0 }, { 75, 0 }, { 94, 0 }, { 112, 0 }, { 130, 0 }, + { 149, 0 }, { 167, 0 }, { 186, 0 }, { 204, 0 }, { 222, 1 }, { 224, 17 }, { 224, 32 }, { 224, 47 } +}, { + // KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_PAUS + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 1, 4, + // KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, + // KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, + // KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT + 1, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, + // KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, + // KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, + // Underglow / Border + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2 +} }; + #ifdef USB_LED_INDICATOR_ENABLE void rgb_matrix_indicators_kb(void) diff --git a/keyboards/model01/leds.c b/keyboards/model01/leds.c index 0abc1f0da..b21c1a5c8 100644 --- a/keyboards/model01/leds.c +++ b/keyboards/model01/leds.c @@ -46,72 +46,35 @@ void set_led_to(int led, uint8_t r, uint8_t g, uint8_t b) { #ifdef RGB_MATRIX_ENABLE __attribute__ ((weak)) -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - {{0x73}, { 3, 35}, 4}, - {{0x72}, { 0, 26}, 4}, - {{0x71}, { 0, 17}, 4}, - {{0x70}, { 0, 6}, 4}, - {{0x60}, { 14, 5}, 4}, - {{0x61}, { 15, 16}, 4}, - {{0x62}, { 16, 25}, 4}, - {{0x63}, { 17, 34}, 4}, - {{0x53}, { 31, 29}, 4}, - {{0x52}, { 31, 19}, 4}, - {{0x51}, { 30, 11}, 4}, - {{0x50}, { 30, 1}, 4}, - {{0x40}, { 45, 0}, 4}, - {{0x41}, { 45, 8}, 4}, - {{0x42}, { 46, 17}, 4}, - {{0x43}, { 46, 27}, 4}, - {{0x33}, { 60, 27}, 4}, - {{0x32}, { 60, 18}, 4}, - {{0x31}, { 60, 9}, 4}, - {{0x30}, { 60, 0}, 4}, - {{0x20}, { 74, 2}, 4}, - {{0x21}, { 74, 11}, 4}, - {{0x22}, { 75, 20}, 4}, - {{0x23}, { 74, 28}, 4}, - {{0x12}, { 89, 30}, 4}, - {{0x11}, { 89, 19}, 4}, - {{0x10}, { 89, 7}, 4}, - {{0x00}, { 70, 38}, 1}, - {{0x01}, { 82, 41}, 1}, - {{0x02}, { 93, 45}, 1}, - {{0x03}, {104, 50}, 1}, - {{0x13}, { 74, 64}, 1}, - {{0x67}, {149, 64}, 1}, - {{0x77}, {119, 50}, 1}, - {{0x76}, {130, 45}, 1}, - {{0x75}, {141, 41}, 1}, - {{0x74}, {153, 38}, 1}, - {{0x64}, {134, 7}, 4}, - {{0x65}, {134, 19}, 4}, - {{0x66}, {134, 30}, 4}, - {{0x57}, {149, 28}, 4}, - {{0x56}, {148, 20}, 4}, - {{0x55}, {149, 11}, 4}, - {{0x54}, {149, 2}, 4}, - {{0x44}, {163, 0}, 4}, - {{0x45}, {163, 9}, 4}, - {{0x46}, {163, 18}, 4}, - {{0x47}, {163, 27}, 4}, - {{0x37}, {177, 27}, 4}, - {{0x36}, {177, 17}, 4}, - {{0x35}, {178, 8}, 4}, - {{0x34}, {178, 0}, 4}, - {{0x24}, {193, 1}, 4}, - {{0x25}, {193, 11}, 4}, - {{0x26}, {192, 19}, 4}, - {{0x27}, {192, 29}, 4}, - {{0x17}, {206, 34}, 4}, - {{0x16}, {207, 25}, 4}, - {{0x15}, {208, 16}, 4}, - {{0x14}, {209, 5}, 4}, - {{0x04}, {224, 6}, 4}, - {{0x05}, {223, 17}, 4}, - {{0x06}, {223, 26}, 4}, - {{0x07}, {220, 35}, 4}, -}; +led_config_t g_led_config = { { + { 27, 26, 20, 19, 12, 11, 4, 3 }, + { 28, 25, 21, 18, 13, 10, 5, 2 }, + { 29, 24, 22, 17, 14, 9, 6, 1 }, + { 30, 31, 23, 16, 15, 8, 7, 0 }, + { 60, 59, 52, 51, 44, 43, 37, 36 }, + { 61, 58, 53, 50, 45, 42, 38, 35 }, + { 62, 57, 54, 49, 46, 41, 39, 34 }, + { 63, 56, 55, 48, 47, 40, 32, 33 } +}, { + { 3, 35 }, { 0, 26 }, { 0, 17 }, { 0, 6 }, { 14, 5 }, { 15, 16 }, { 16, 25 }, { 17, 34 }, + { 31, 29 }, { 31, 19 }, { 30, 11 }, { 30, 1 }, { 45, 0 }, { 45, 8 }, { 46, 17 }, { 46, 27 }, + { 60, 27 }, { 60, 18 }, { 60, 9 }, { 60, 0 }, { 74, 2 }, { 74, 11 }, { 75, 20 }, { 74, 28 }, + { 89, 30 }, { 89, 19 }, { 89, 7 }, { 70, 38 }, { 82, 41 }, { 93, 45 }, { 104, 50 }, { 74, 64 }, + { 149, 64 }, { 119, 50 }, { 130, 45 }, { 141, 41 }, { 153, 38 }, { 134, 7 }, { 134, 19 }, { 134, 30 }, + { 149, 28 }, { 148, 20 }, { 149, 11 }, { 149, 2 }, { 163, 0 }, { 163, 9 }, { 163, 18 }, { 163, 27 }, + { 177, 27 }, { 177, 17 }, { 178, 8 }, { 178, 0 }, { 193, 1 }, { 193, 11 }, { 192, 19 }, { 192, 29 }, + { 206, 34 }, { 207, 25 }, { 208, 16 }, { 209, 5 }, { 224, 6 }, { 223, 17 }, { 223, 26 }, { 220, 35 } +}, { + 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, 1, 1, 1, 1, + 1, 1, 1, 1, 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 +} }; + static struct { uint8_t b; diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c index 94f507189..3ad694c4a 100644 --- a/keyboards/planck/ez/ez.c +++ b/keyboards/planck/ez/ez.c @@ -79,63 +79,27 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - - /*{row | col << 4} - | {x=0..224, y=0..64} - | | flags - | | | */ - {{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, - {{0|(1<<4)}, {20.36*1, 21.33*0}, 4}, - {{0|(2<<4)}, {20.36*2, 21.33*0}, 4}, - {{0|(3<<4)}, {20.36*3, 21.33*0}, 4}, - {{0|(4<<4)}, {20.36*4, 21.33*0}, 4}, - {{0|(5<<4)}, {20.36*5, 21.33*0}, 4}, - {{4|(0<<4)}, {20.36*6, 21.33*0}, 4}, - {{4|(1<<4)}, {20.36*7, 21.33*0}, 4}, - {{4|(2<<4)}, {20.36*8, 21.33*0}, 4}, - {{4|(3<<4)}, {20.36*9, 21.33*0}, 4}, - {{4|(4<<4)}, {20.36*10,21.33*0}, 4}, - {{4|(5<<4)}, {20.36*11,21.33*0}, 1}, - - {{1|(0<<4)}, {20.36*0, 21.33*1}, 1}, - {{1|(1<<4)}, {20.36*1, 21.33*1}, 4}, - {{1|(2<<4)}, {20.36*2, 21.33*1}, 4}, - {{1|(3<<4)}, {20.36*3, 21.33*1}, 4}, - {{1|(4<<4)}, {20.36*4, 21.33*1}, 4}, - {{1|(5<<4)}, {20.36*5, 21.33*1}, 4}, - {{5|(0<<4)}, {20.36*6, 21.33*1}, 4}, - {{5|(1<<4)}, {20.36*7, 21.33*1}, 4}, - {{5|(2<<4)}, {20.36*8, 21.33*1}, 4}, - {{5|(3<<4)}, {20.36*9, 21.33*1}, 4}, - {{5|(4<<4)}, {20.36*10,21.33*1}, 4}, - {{5|(5<<4)}, {20.36*11,21.33*1}, 1}, - - {{2|(0<<4)}, {20.36*0, 21.33*2}, 1}, - {{2|(1<<4)}, {20.36*1, 21.33*2}, 4}, - {{2|(2<<4)}, {20.36*2, 21.33*2}, 4}, - {{2|(3<<4)}, {20.36*3, 21.33*2}, 4}, - {{2|(4<<4)}, {20.36*4, 21.33*2}, 4}, - {{2|(5<<4)}, {20.36*5, 21.33*2}, 4}, - {{6|(0<<4)}, {20.36*6, 21.33*2}, 4}, - {{6|(1<<4)}, {20.36*7, 21.33*2}, 4}, - {{6|(2<<4)}, {20.36*8, 21.33*2}, 4}, - {{6|(3<<4)}, {20.36*9, 21.33*2}, 4}, - {{6|(4<<4)}, {20.36*10,21.33*2}, 4}, - {{6|(5<<4)}, {20.36*11,21.33*2}, 1}, - - {{3|(0<<4)}, {20.36*0, 21.33*3}, 1}, - {{3|(1<<4)}, {20.36*1, 21.33*3}, 1}, - {{3|(2<<4)}, {20.36*2, 21.33*3}, 1}, - {{7|(3<<4)}, {20.36*3, 21.33*3}, 1}, - {{7|(4<<4)}, {20.36*4, 21.33*3}, 1}, - {{7|(5<<4)}, {20.36*5.5,21.33*3}, 4}, - {{7|(0<<4)}, {20.36*7, 21.33*3}, 1}, - {{7|(1<<4)}, {20.36*8, 21.33*3}, 1}, - {{7|(2<<4)}, {20.36*9, 21.33*3}, 1}, - {{3|(3<<4)}, {20.36*10,21.33*3}, 1}, - {{3|(4<<4)}, {20.36*11,21.33*3}, 1} -}; +led_config_t g_led_config = { { + { 0, 1, 2, 3, 4, 5 }, + { 12, 13, 14, 15, 16, 17 }, + { 24, 25, 26, 27, 28, 29 }, + { 36, 37, 38, 45, 46, NO_LED }, + { 6, 7, 8, 9, 10, 11 }, + { 18, 19, 20, 21, 22, 23 }, + { 30, 31, 32, 33, 34, 35 }, + { 42, 43, 44, 39, 40, 41 } +}, { + { 0, 0 }, { 20, 0 }, { 40, 0 }, { 61, 0 }, { 81, 0 }, { 101, 0 }, { 122, 0 }, { 142, 0 }, { 162, 0 }, { 183, 0 }, { 203, 0 }, { 223, 0 }, + { 0, 21 }, { 20, 21 }, { 40, 21 }, { 61, 21 }, { 81, 21 }, { 101, 21 }, { 122, 21 }, { 142, 21 }, { 162, 21 }, { 183, 21 }, { 203, 21 }, { 223, 21 }, + { 0, 42 }, { 20, 42 }, { 40, 42 }, { 61, 42 }, { 81, 42 }, { 101, 42 }, { 122, 42 }, { 142, 42 }, { 162, 42 }, { 183, 42 }, { 203, 42 }, { 223, 42 }, + { 0, 63 }, { 20, 63 }, { 40, 63 }, { 61, 63 }, { 81, 63 }, { 111, 63 }, { 142, 63 }, { 162, 63 }, { 183, 63 }, { 203, 63 }, { 223, 63 } +}, { + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1 +} }; + void matrix_init_kb(void) { matrix_init_user(); diff --git a/keyboards/planck/keymaps/tom/keymap.c b/keyboards/planck/keymaps/tom/keymap.c index 5b7177c6c..0ffff4e69 100644 --- a/keyboards/planck/keymaps/tom/keymap.c +++ b/keyboards/planck/keymaps/tom/keymap.c @@ -224,14 +224,16 @@ bool music_mask_user(uint16_t keycode) { } } +#ifdef RGB_MATRIX_ENABLE +extern led_config_t g_led_config; +#endif + void rgb_matrix_indicators_user(void) { #ifdef RGB_MATRIX_ENABLE - rgb_led led; switch (biton32(layer_state)) { case _RAISE: for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color(i, 0x6B, 0x00, 0x80); } else { rgb_matrix_set_color(i, 0x00, 0xFF, 0x00); @@ -241,8 +243,7 @@ void rgb_matrix_indicators_user(void) { case _LOWER: for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color(i, 0xFF, 0xA5, 0x00); } else { rgb_matrix_set_color(i, 0x00, 0x67, 0xC7); diff --git a/keyboards/planck/light/light.c b/keyboards/planck/light/light.c index 178d28274..896ec4458 100644 --- a/keyboards/planck/light/light.c +++ b/keyboards/planck/light/light.c @@ -77,65 +77,24 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { {1, C9_14, C8_14, C7_14} }; -rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { - - /*{row | col << 4} - | {x=0..224, y=0..64} - | | flags - | | | */ - {{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, - {{0|(1<<4)}, {20.36*1, 21.33*0}, 4}, - {{0|(2<<4)}, {20.36*2, 21.33*0}, 4}, - {{0|(3<<4)}, {20.36*3, 21.33*0}, 4}, - {{0|(4<<4)}, {20.36*4, 21.33*0}, 4}, - {{0|(5<<4)}, {20.36*5, 21.33*0}, 4}, - {{0|(6<<4)}, {20.36*6, 21.33*0}, 4}, - {{0|(7<<4)}, {20.36*7, 21.33*0}, 4}, - {{0|(8<<4)}, {20.36*8, 21.33*0}, 4}, - {{0|(9<<4)}, {20.36*9, 21.33*0}, 4}, - {{0|(10<<4)}, {20.36*10,21.33*0}, 4}, - {{0|(11<<4)}, {20.36*11,21.33*0}, 1}, - - {{1|(0<<4)}, {20.36*0, 21.33*1}, 1}, - {{1|(1<<4)}, {20.36*1, 21.33*1}, 4}, - {{1|(2<<4)}, {20.36*2, 21.33*1}, 4}, - {{1|(3<<4)}, {20.36*3, 21.33*1}, 4}, - {{1|(4<<4)}, {20.36*4, 21.33*1}, 4}, - {{1|(5<<4)}, {20.36*5, 21.33*1}, 4}, - {{1|(6<<4)}, {20.36*6, 21.33*1}, 4}, - {{1|(7<<4)}, {20.36*7, 21.33*1}, 4}, - {{1|(8<<4)}, {20.36*8, 21.33*1}, 4}, - {{1|(9<<4)}, {20.36*9, 21.33*1}, 4}, - {{1|(10<<4)}, {20.36*10,21.33*1}, 4}, - {{1|(11<<4)}, {20.36*11,21.33*1}, 1}, - - {{2|(0<<4)}, {20.36*0, 21.33*2}, 1}, - {{2|(1<<4)}, {20.36*1, 21.33*2}, 4}, - {{2|(2<<4)}, {20.36*2, 21.33*2}, 4}, - {{2|(3<<4)}, {20.36*3, 21.33*2}, 4}, - {{2|(4<<4)}, {20.36*4, 21.33*2}, 4}, - {{2|(5<<4)}, {20.36*5, 21.33*2}, 4}, - {{2|(6<<4)}, {20.36*6, 21.33*2}, 4}, - {{2|(7<<4)}, {20.36*7, 21.33*2}, 4}, - {{2|(8<<4)}, {20.36*8, 21.33*2}, 4}, - {{2|(9<<4)}, {20.36*9, 21.33*2}, 4}, - {{2|(10<<4)}, {20.36*10,21.33*2}, 4}, - {{2|(11<<4)}, {20.36*11,21.33*2}, 1}, - - {{3|(0<<4)}, {20.36*0, 21.33*3}, 1}, - {{3|(1<<4)}, {20.36*1, 21.33*3}, 1}, - {{3|(2<<4)}, {20.36*2, 21.33*3}, 1}, - {{3|(3<<4)}, {20.36*3, 21.33*3}, 1}, - {{3|(4<<4)}, {20.36*4, 21.33*3}, 1}, - {{3|(5<<4)}, {20.36*5, 21.33*3}, 4}, - {{3|(5<<4)}, {20.36*5.5,21.33*3}, 4}, - {{3|(6<<4)}, {20.36*6, 21.33*3}, 4}, - {{3|(7<<4)}, {20.36*7, 21.33*3}, 1}, - {{3|(8<<4)}, {20.36*8, 21.33*3}, 1}, - {{3|(9<<4)}, {20.36*9, 21.33*3}, 1}, - {{3|(10<<4)}, {20.36*10,21.33*3}, 1}, - {{3|(11<<4)}, {20.36*11,21.33*3}, 1} -}; +led_config_t g_led_config = { { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, + { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, + { 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 }, + { 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48 } +}, { + { 0, 0 }, { 20, 0 }, { 40, 0 }, { 61, 0 }, { 81, 0 }, { 101, 0 }, { 122, 0 }, { 142, 0 }, { 162, 0 }, { 183, 0 }, { 203, 0 }, { 223, 0 }, + { 0, 21 }, { 20, 21 }, { 40, 21 }, { 61, 21 }, { 81, 21 }, { 101, 21 }, { 122, 21 }, { 142, 21 }, { 162, 21 }, { 183, 21 }, { 203, 21 }, { 223, 21 }, + { 0, 42 }, { 20, 42 }, { 40, 42 }, { 61, 42 }, { 81, 42 }, { 101, 42 }, { 122, 42 }, { 142, 42 }, { 162, 42 }, { 183, 42 }, { 203, 42 }, { 223, 42 }, + { 0, 63 }, { 20, 63 }, { 40, 63 }, { 61, 63 }, { 81, 63 }, { 101, 63 }, { 111, 63 }, { 122, 63 }, { 142, 63 }, { 162, 63 }, { 183, 63 }, { 203, 63 }, + { 223, 63 } +}, { + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 1, + 1 +} }; void matrix_init_kb(void) { @@ -151,6 +110,16 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) return process_record_user(keycode, record); } +uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { + // Spacebar has 2 leds 41 & 42, so add 42 to the array here, and 41 will be added + // by the default lookup code that runs after this + if (row == 3 && column == 5) { + led_i[0] = 42; + return 1; + } + return 0; +} + void matrix_scan_kb(void) { matrix_scan_user(); diff --git a/keyboards/sol/rev1/rev1.c b/keyboards/sol/rev1/rev1.c index 23896860e..68e64af79 100644 --- a/keyboards/sol/rev1/rev1.c +++ b/keyboards/sol/rev1/rev1.c @@ -1,83 +1,46 @@ #include "quantum.h" #ifdef RGB_MATRIX_ENABLE - rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { +led_config_t g_led_config = { { + { 0, 1, 2, 3, 4, 5, 6 }, + { 7, 8, 9, 10, 11, 12, 13 }, + { 14, 15, 16, 17, 18, 19, 20 }, + { 21, 22, 23, 24, 25, 26, 27 }, + { 28, 29, 30, 31, 32, 33, 34 }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, 33, 34 }, + { 35, 36, 37, 38, 39, 40, 41 }, + { 42, 43, 44, 45, 46, 47, 48 }, + { 49, 50, 51, 52, 53, 54, 55 }, + { 56, 57, 58, 59, 60, 61, 62 }, + { 63, 64, 65, 66, 67, 68, 68 }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, 68, 68 } +}, { // Left Hand Mapped Left to Right - { { 0 | (0 << 4) }, { 0, 0 }, 1}, - { { 0 | (1 << 4) }, { 22, 0 }, 4}, - { { 0 | (2 << 4) }, { 37, 0 }, 4}, - { { 0 | (3 << 4) }, { 37, 0 }, 4}, - { { 0 | (4 << 4) }, { 67, 0 }, 4}, - { { 0 | (5 << 4) }, { 82, 0 }, 4}, - { { 0 | (6 << 4) }, { 104, 0 }, 1}, - { { 1 | (0 << 4) }, { 0, 16 }, 1}, - { { 1 | (1 << 4) }, { 22, 16 }, 4}, - { { 1 | (2 << 4) }, { 37, 16 }, 4}, - { { 1 | (3 << 4) }, { 37, 16 }, 4}, - { { 1 | (4 << 4) }, { 67, 16 }, 4}, - { { 1 | (5 << 4) }, { 82, 16 }, 4}, - { { 1 | (6 << 4) }, { 104, 16 }, 1}, - { { 2 | (0 << 4) }, { 0, 32 }, 1}, - { { 2 | (1 << 4) }, { 22, 32 }, 4}, - { { 2 | (2 << 4) }, { 37, 32 }, 4}, - { { 2 | (3 << 4) }, { 37, 32 }, 4}, - { { 2 | (4 << 4) }, { 67, 32 }, 4}, - { { 2 | (5 << 4) }, { 82, 32 }, 4}, - { { 2 | (6 << 4) }, { 104, 32 }, 1}, - { { 3 | (0 << 4) }, { 0, 48 }, 1}, - { { 3 | (1 << 4) }, { 22, 48 }, 4}, - { { 3 | (2 << 4) }, { 37, 48 }, 4}, - { { 3 | (3 << 4) }, { 37, 48 }, 4}, - { { 3 | (4 << 4) }, { 67, 48 }, 4}, - { { 3 | (5 << 4) }, { 82, 48 }, 4}, - { { 3 | (6 << 4) }, { 104, 48 }, 1}, - { { 4 | (0 << 4) }, { 0, 64 }, 1}, - { { 4 | (1 << 4) }, { 22, 64 }, 1}, - { { 4 | (2 << 4) }, { 37, 64 }, 1}, - { { 4 | (3 << 4) }, { 37, 64 }, 1}, - { { 4 | (4 << 4) }, { 67, 64 }, 1}, - // These two control the 4 LEDs in the thumb cluster - // Top keys are { 4 | (5 << 4) & { 4 | (6 << 4) - { { 5 | (5 << 4) }, { 89, 45 }, 1}, - { { 5 | (6 << 4) }, { 97, 55 }, 1}, + { 0, 0 }, { 22, 0 }, { 37, 0 }, { 37, 0 }, { 67, 0 }, { 82, 0 }, { 104, 0 }, + { 0, 16 }, { 22, 16 }, { 37, 16 }, { 37, 16 }, { 67, 16 }, { 82, 16 }, { 104, 16 }, + { 0, 32 }, { 22, 32 }, { 37, 32 }, { 37, 32 }, { 67, 32 }, { 82, 32 }, { 104, 32 }, + { 0, 48 }, { 22, 48 }, { 37, 48 }, { 37, 48 }, { 67, 48 }, { 82, 48 }, { 104, 48 }, + { 0, 64 }, { 22, 64 }, { 37, 64 }, { 37, 64 }, { 67, 64 }, { 89, 45 }, { 97, 55 }, // Left Hand Mapped Right to Left - { { 6 | (0 << 4) }, { 224, 0 }, 1}, - { { 6 | (1 << 4) }, { 202, 0 }, 4}, - { { 6 | (2 << 4) }, { 187, 0 }, 4}, - { { 6 | (3 << 4) }, { 172, 0 }, 4}, - { { 6 | (4 << 4) }, { 157, 0 }, 4}, - { { 6 | (5 << 4) }, { 142, 0 }, 4}, - { { 6 | (6 << 4) }, { 120, 0 }, 1}, - { { 7 | (0 << 4) }, { 224, 16 }, 1}, - { { 7 | (1 << 4) }, { 202, 16 }, 4}, - { { 7 | (2 << 4) }, { 187, 16 }, 4}, - { { 7 | (3 << 4) }, { 172, 16 }, 4}, - { { 7 | (4 << 4) }, { 157, 16 }, 4}, - { { 7 | (5 << 4) }, { 142, 16 }, 4}, - { { 7 | (6 << 4) }, { 120, 16 }, 1}, - { { 8 | (0 << 4) }, { 224, 32 }, 1}, - { { 8 | (1 << 4) }, { 202, 32 }, 4}, - { { 8 | (2 << 4) }, { 187, 32 }, 4}, - { { 8 | (3 << 4) }, { 172, 32 }, 4}, - { { 8 | (4 << 4) }, { 157, 32 }, 4}, - { { 8 | (5 << 4) }, { 142, 32 }, 4}, - { { 8 | (6 << 4) }, { 120, 32 }, 1}, - { { 9 | (0 << 4) }, { 224, 48 }, 1}, - { { 9 | (1 << 4) }, { 202, 48 }, 4}, - { { 9 | (2 << 4) }, { 187, 48 }, 4}, - { { 9 | (3 << 4) }, { 172, 48 }, 4}, - { { 9 | (4 << 4) }, { 157, 48 }, 4}, - { { 9 | (5 << 4) }, { 142, 48 }, 4}, - { { 9 | (6 << 4) }, { 120, 48 }, 1}, - { { 10 | (0 << 4) }, { 224, 64 }, 1}, - { { 10 | (1 << 4) }, { 202, 64 }, 1}, - { { 10 | (2 << 4) }, { 187, 64 }, 1}, - { { 10 | (3 << 4) }, { 172, 64 }, 1}, - { { 10 | (4 << 4) }, { 157, 64 }, 1}, - // These two control the 4 LEDs in the thumb cluster - // Top keys are { 10 | (5 << 4) & { 10 | (6 << 4) - { { 11 | (5 << 4) }, { 135, 45 }, 1}, - { { 11 | (6 << 4) }, { 127, 55 }, 1} - }; + { 224, 0 }, { 202, 0 }, { 187, 0 }, { 172, 0 }, { 157, 0 }, { 142, 0 }, { 120, 0 }, + { 224, 16 }, { 202, 16 }, { 187, 16 }, { 172, 16 }, { 157, 16 }, { 142, 16 }, { 120, 16 }, + { 224, 32 }, { 202, 32 }, { 187, 32 }, { 172, 32 }, { 157, 32 }, { 142, 32 }, { 120, 32 }, + { 224, 48 }, { 202, 48 }, { 187, 48 }, { 172, 48 }, { 157, 48 }, { 142, 48 }, { 120, 48 }, + { 224, 64 }, { 202, 64 }, { 187, 64 }, { 172, 64 }, { 157, 64 }, { 135, 45 }, { 127, 55 } +}, { + // Left Hand Mapped Left to Right + 1, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 1, + 1, 1, 1, 1, 1, 1, 1, + // Left Hand Mapped Right to Left + 1, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 1, + 1, 1, 1, 1, 1, 1, 1 +} }; + #endif diff --git a/keyboards/sol/sol.c b/keyboards/sol/sol.c index a65d4c15f..5945cc60a 100644 --- a/keyboards/sol/sol.c +++ b/keyboards/sol/sol.c @@ -1,20 +1 @@ #include "sol.h" - -#if defined(RGB_MATRIX_ENABLE) -uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { - if (row == 4 && column == 5) { - led_i[0] = 33; - return 1; - } else if (row == 4 && column == 6) { - led_i[0] = 34; - return 1; - } else if (row == 10 && column == 5) { - led_i[0] = 68; - return 1; - } else if (row == 10 && column == 6) { - led_i[0] = 69; - return 1; - } - return 0; -} -#endif diff --git a/layouts/community/ergodox/drashna/keymap.c b/layouts/community/ergodox/drashna/keymap.c index eeb21501b..3cfce966b 100644 --- a/layouts/community/ergodox/drashna/keymap.c +++ b/layouts/community/ergodox/drashna/keymap.c @@ -403,11 +403,10 @@ void suspend_wakeup_init_keymap(void) { rgb_matrix_set_suspend_state(false); } -void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) { - rgb_led led; +extern led_config_t g_led_config; +void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) { for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color( i, red, green, blue ); } } diff --git a/layouts/community/ortho_4x12/drashna/keymap.c b/layouts/community/ortho_4x12/drashna/keymap.c index 5eef2e023..e8dc185a1 100644 --- a/layouts/community/ortho_4x12/drashna/keymap.c +++ b/layouts/community/ortho_4x12/drashna/keymap.c @@ -184,11 +184,10 @@ void suspend_wakeup_init_keymap(void) { rgb_matrix_set_suspend_state(false); } +extern led_config_t g_led_config; void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) { - rgb_led led; for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - led = g_rgb_leds[i]; - if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color( i, red, green, blue ); } } diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 5528a0834..edbcee9cd 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -105,6 +105,7 @@ bool g_suspend_state = false; +extern led_config_t g_led_config; rgb_config_t rgb_matrix_config; rgb_counters_t g_rgb_counters; @@ -150,14 +151,11 @@ uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t } uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { - // TODO: This is kinda expensive, fix this soonish uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); - for (uint8_t i = 0; i < DRIVER_LED_TOTAL && led_count < LED_HITS_TO_REMEMBER; i++) { - matrix_co_t matrix_co = g_rgb_leds[i].matrix_co; - if (row == matrix_co.row && column == matrix_co.col) { - led_i[led_count] = i; - led_count++; - } + uint8_t led_index = g_led_config.matrix_co[row][column]; + if (led_index != NO_LED) { + led_i[led_count] = led_index; + led_count++; } return led_count; } @@ -201,8 +199,8 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { for(uint8_t i = 0; i < led_count; i++) { uint8_t index = last_hit_buffer.count; - last_hit_buffer.x[index] = g_rgb_leds[led[i]].point.x; - last_hit_buffer.y[index] = g_rgb_leds[led[i]].point.y; + last_hit_buffer.x[index] = g_led_config.point[led[i]].x; + last_hit_buffer.y[index] = g_led_config.point[led[i]].y; last_hit_buffer.index[index] = led[i]; last_hit_buffer.tick[index] = 0; last_hit_buffer.count++; diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 33665ffff..365a92bbf 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -54,9 +54,7 @@ uint8_t max = DRIVER_LED_TOTAL; #endif -#define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) continue - -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +#define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue typedef struct { diff --git a/quantum/rgb_matrix_animations/alpha_mods_anim.h b/quantum/rgb_matrix_animations/alpha_mods_anim.h index 4bd01c4fc..d7f6f4655 100644 --- a/quantum/rgb_matrix_animations/alpha_mods_anim.h +++ b/quantum/rgb_matrix_animations/alpha_mods_anim.h @@ -1,7 +1,7 @@ #pragma once #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; // alphas = color1, mods = color2 @@ -15,7 +15,7 @@ bool rgb_matrix_alphas_mods(effect_params_t* params) { for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); - if (HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_MODIFIER)) { + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b); } else { rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); diff --git a/quantum/rgb_matrix_animations/cycle_all_anim.h b/quantum/rgb_matrix_animations/cycle_all_anim.h index 513dff128..e93798f90 100644 --- a/quantum/rgb_matrix_animations/cycle_all_anim.h +++ b/quantum/rgb_matrix_animations/cycle_all_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL extern rgb_counters_t g_rgb_counters; -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_cycle_all(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/cycle_left_right_anim.h b/quantum/rgb_matrix_animations/cycle_left_right_anim.h index 428adea22..4b09d5826 100644 --- a/quantum/rgb_matrix_animations/cycle_left_right_anim.h +++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT extern rgb_counters_t g_rgb_counters; -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_cycle_left_right(effect_params_t* params) { @@ -12,8 +12,7 @@ bool rgb_matrix_cycle_left_right(effect_params_t* params) { uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); - point_t point = g_rgb_leds[i].point; - hsv.h = point.x - time; + hsv.h = g_led_config.point[i].x - time; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/cycle_up_down_anim.h b/quantum/rgb_matrix_animations/cycle_up_down_anim.h index ea63095d2..403214bb7 100644 --- a/quantum/rgb_matrix_animations/cycle_up_down_anim.h +++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN extern rgb_counters_t g_rgb_counters; -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_cycle_up_down(effect_params_t* params) { @@ -12,8 +12,7 @@ bool rgb_matrix_cycle_up_down(effect_params_t* params) { uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); - point_t point = g_rgb_leds[i].point; - hsv.h = point.y - time; + hsv.h = g_led_config.point[i].y - time; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/dual_beacon_anim.h b/quantum/rgb_matrix_animations/dual_beacon_anim.h index 00f6e5088..dcb594029 100644 --- a/quantum/rgb_matrix_animations/dual_beacon_anim.h +++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON extern rgb_counters_t g_rgb_counters; -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_dual_beacon(effect_params_t* params) { @@ -14,8 +14,7 @@ bool rgb_matrix_dual_beacon(effect_params_t* params) { int8_t sin_value = sin8(time) - 128; for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); - point_t point = g_rgb_leds[i].point; - hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue; + hsv.h = ((g_led_config.point[i].y - 32) * cos_value + (g_led_config.point[i].x - 112) * sin_value) / 128 + rgb_matrix_config.hue; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/gradient_up_down_anim.h b/quantum/rgb_matrix_animations/gradient_up_down_anim.h index 05117540a..7a6ed1421 100644 --- a/quantum/rgb_matrix_animations/gradient_up_down_anim.h +++ b/quantum/rgb_matrix_animations/gradient_up_down_anim.h @@ -1,7 +1,7 @@ #pragma once #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_gradient_up_down(effect_params_t* params) { @@ -11,10 +11,9 @@ bool rgb_matrix_gradient_up_down(effect_params_t* params) { uint8_t scale = scale8(64, rgb_matrix_config.speed); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); - point_t point = g_rgb_leds[i].point; // The y range will be 0..64, map this to 0..4 // Relies on hue being 8-bit and wrapping - hsv.h = rgb_matrix_config.hue + scale * (point.y >> 4); + hsv.h = rgb_matrix_config.hue + scale * (g_led_config.point[i].y >> 4); RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h index dffa53264..5ea971435 100644 --- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h @@ -2,11 +2,11 @@ #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS extern rgb_counters_t g_rgb_counters; -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; static void jellybean_raindrops_set_color(int i, effect_params_t* params) { - if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) return; + if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val }; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h index 89f6965c3..d46288073 100644 --- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON extern rgb_counters_t g_rgb_counters; -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_rainbow_beacon(effect_params_t* params) { @@ -14,8 +14,7 @@ bool rgb_matrix_rainbow_beacon(effect_params_t* params) { int16_t sin_value = 2 * (sin8(time) - 128); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); - point_t point = g_rgb_leds[i].point; - hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue; + hsv.h = ((g_led_config.point[i].y - 32) * cos_value + (g_led_config.point[i].x - 112) * sin_value) / 128 + rgb_matrix_config.hue; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h index 0d57aef57..3b7d9689f 100644 --- a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON extern rgb_counters_t g_rgb_counters; -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) { @@ -12,8 +12,7 @@ bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) { uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); - point_t point = g_rgb_leds[i].point; - hsv.h = abs8(point.y - 32) + (point.x - time) + rgb_matrix_config.hue; + hsv.h = abs8(g_led_config.point[i].y - 32) + (g_led_config.point[i].x - time) + rgb_matrix_config.hue; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h index 03652758c..e92f35176 100644 --- a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h @@ -2,7 +2,7 @@ #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS extern rgb_counters_t g_rgb_counters; -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) { @@ -14,8 +14,7 @@ bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) { int16_t sin_value = 3 * (sin8(time) - 128); for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); - point_t point = g_rgb_leds[i].point; - hsv.h = ((point.y - 32) * cos_value + (56 - abs8(point.x - 112)) * sin_value) / 128 + rgb_matrix_config.hue; + hsv.h = ((g_led_config.point[i].y - 32) * cos_value + (56 - abs8(g_led_config.point[i].x - 112)) * sin_value) / 128 + rgb_matrix_config.hue; RGB rgb = hsv_to_rgb(hsv); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } diff --git a/quantum/rgb_matrix_animations/raindrops_anim.h b/quantum/rgb_matrix_animations/raindrops_anim.h index 0e3a87864..4ce1d65e5 100644 --- a/quantum/rgb_matrix_animations/raindrops_anim.h +++ b/quantum/rgb_matrix_animations/raindrops_anim.h @@ -3,10 +3,11 @@ #include "rgb_matrix_types.h" extern rgb_counters_t g_rgb_counters; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; static void raindrops_set_color(int i, effect_params_t* params) { - if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) return; + if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; HSV hsv = { 0 , rgb_matrix_config.sat, rgb_matrix_config.val }; // Take the shortest path between hues diff --git a/quantum/rgb_matrix_animations/solid_color_anim.h b/quantum/rgb_matrix_animations/solid_color_anim.h index 033c1f933..ba2cea15e 100644 --- a/quantum/rgb_matrix_animations/solid_color_anim.h +++ b/quantum/rgb_matrix_animations/solid_color_anim.h @@ -1,5 +1,6 @@ #pragma once +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; bool rgb_matrix_solid_color(effect_params_t* params) { diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index 82483653a..c3dba8a5a 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -2,6 +2,7 @@ #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; diff --git a/quantum/rgb_matrix_animations/solid_reactive_cross.h b/quantum/rgb_matrix_animations/solid_reactive_cross.h index 1dec1886d..8858f71e6 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_cross.h +++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -13,11 +13,10 @@ static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_par uint8_t count = g_last_hit_tracker.count; for (uint8_t i = led_min; i < led_max; i++) { hsv.v = 0; - point_t point = g_rgb_leds[i].point; for (uint8_t j = start; j < count; j++) { RGB_MATRIX_TEST_LED_FLAGS(); - int16_t dx = point.x - g_last_hit_tracker.x[j]; - int16_t dy = point.y - g_last_hit_tracker.y[j]; + int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; + int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; uint8_t dist = sqrt16(dx * dx + dy * dy); int16_t dist2 = 16; uint8_t dist3; diff --git a/quantum/rgb_matrix_animations/solid_reactive_nexus.h b/quantum/rgb_matrix_animations/solid_reactive_nexus.h index 8952a1e2b..c0e3c2450 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_nexus.h +++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -13,11 +13,10 @@ static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_par uint8_t count = g_last_hit_tracker.count; for (uint8_t i = led_min; i < led_max; i++) { hsv.v = 0; - point_t point = g_rgb_leds[i].point; for (uint8_t j = start; j < count; j++) { RGB_MATRIX_TEST_LED_FLAGS(); - int16_t dx = point.x - g_last_hit_tracker.x[j]; - int16_t dy = point.y - g_last_hit_tracker.y[j]; + int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; + int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; uint8_t dist = sqrt16(dx * dx + dy * dy); int16_t dist2 = 8; uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h index 9fc4d527a..abc7e36a8 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h @@ -2,6 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; diff --git a/quantum/rgb_matrix_animations/solid_reactive_wide.h b/quantum/rgb_matrix_animations/solid_reactive_wide.h index d86cb1284..3d1d38e80 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_wide.h +++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -13,11 +13,10 @@ static bool rgb_matrix_solid_reactive_multiwide_range(uint8_t start, effect_para uint8_t count = g_last_hit_tracker.count; for (uint8_t i = led_min; i < led_max; i++) { hsv.v = 0; - point_t point = g_rgb_leds[i].point; for (uint8_t j = start; j < count; j++) { RGB_MATRIX_TEST_LED_FLAGS(); - int16_t dx = point.x - g_last_hit_tracker.x[j]; - int16_t dy = point.y - g_last_hit_tracker.y[j]; + int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; + int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; uint8_t dist = sqrt16(dx * dx + dy * dy); uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist * 5; if (effect > 255) diff --git a/quantum/rgb_matrix_animations/solid_splash_anim.h b/quantum/rgb_matrix_animations/solid_splash_anim.h index 14312f33d..4e5565d0d 100644 --- a/quantum/rgb_matrix_animations/solid_splash_anim.h +++ b/quantum/rgb_matrix_animations/solid_splash_anim.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH) -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -14,10 +14,9 @@ static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* p for (uint8_t i = led_min; i < led_max; i++) { RGB_MATRIX_TEST_LED_FLAGS(); hsv.v = 0; - point_t point = g_rgb_leds[i].point; for (uint8_t j = start; j < count; j++) { - int16_t dx = point.x - g_last_hit_tracker.x[j]; - int16_t dy = point.y - g_last_hit_tracker.y[j]; + int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; + int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; uint8_t dist = sqrt16(dx * dx + dy * dy); uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; if (effect > 255) diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h index 3c96d451e..fbe776111 100644 --- a/quantum/rgb_matrix_animations/splash_anim.h +++ b/quantum/rgb_matrix_animations/splash_anim.h @@ -2,7 +2,7 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) -extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; +extern led_config_t g_led_config; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; @@ -15,10 +15,9 @@ static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params) RGB_MATRIX_TEST_LED_FLAGS(); hsv.h = rgb_matrix_config.hue; hsv.v = 0; - point_t point = g_rgb_leds[i].point; for (uint8_t j = start; j < count; j++) { - int16_t dx = point.x - g_last_hit_tracker.x[j]; - int16_t dy = point.y - g_last_hit_tracker.y[j]; + int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; + int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; uint8_t dist = sqrt16(dx * dx + dy * dy); uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; if (effect > 255) diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h index 7a3bc6714..f890edd94 100644 --- a/quantum/rgb_matrix_types.h +++ b/quantum/rgb_matrix_types.h @@ -59,14 +59,6 @@ typedef struct PACKED { uint8_t y; } point_t; -typedef union { - uint8_t raw; - struct { - uint8_t row:4; // 16 max - uint8_t col:4; // 16 max - }; -} matrix_co_t; - #define HAS_FLAGS(bits, flags) ((bits & flags) == flags) #define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00) @@ -76,11 +68,13 @@ typedef union { #define LED_FLAG_UNDERGLOW 0x02 #define LED_FLAG_KEYLIGHT 0x04 +#define NO_LED 255 + typedef struct PACKED { - matrix_co_t matrix_co; - point_t point; - uint8_t flags; -} rgb_led; + uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS]; + point_t point[DRIVER_LED_TOTAL]; + uint8_t flags[DRIVER_LED_TOTAL]; +} led_config_t; typedef union { uint32_t raw; diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index a2eab1b56..ea067a743 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.c +++ b/tmk_core/protocol/arm_atsam/led_matrix.c @@ -431,6 +431,7 @@ static void led_run_pattern(led_setup_t *f, float* ro, float* go, float* bo, flo } } +extern led_config_t g_led_config; static void led_matrix_massdrop_config_override(int i) { float ro = 0; @@ -438,14 +439,14 @@ static void led_matrix_massdrop_config_override(int i) float bo = 0; float po = (led_animation_orientation) - ? (float)g_rgb_leds[i].point.y / 64.f * 100 - : (float)g_rgb_leds[i].point.x / 224.f * 100; + ? (float)g_led_config.point[i].y / 64.f * 100 + : (float)g_led_config.point[i].x / 224.f * 100; uint8_t highest_active_layer = biton32(layer_state); - if (led_lighting_mode == LED_MODE_KEYS_ONLY && HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_UNDERGLOW)) { + if (led_lighting_mode == LED_MODE_KEYS_ONLY && HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) { //Do not act on this LED - } else if (led_lighting_mode == LED_MODE_NON_KEYS_ONLY && !HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_UNDERGLOW)) { + } else if (led_lighting_mode == LED_MODE_NON_KEYS_ONLY && !HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) { //Do not act on this LED } else if (led_lighting_mode == LED_MODE_INDICATORS_ONLY) { //Do not act on this LED (Only show indicators) -- cgit v1.2.3-70-g09d2 From 60eae7335b711e8d4be7d48ad2290141e04debe7 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 7 May 2019 21:17:00 -0500 Subject: RGB Matrix Typing Heatmap (#5786) * RGB Matrix Typing Heatmap Effect * Fixing file name and effect init --- docs/feature_rgb_matrix.md | 4 ++ quantum/rgb_matrix.c | 21 ++++++ quantum/rgb_matrix.h | 5 ++ quantum/rgb_matrix_animations/digital_rain_anim.h | 33 +++++----- .../rgb_matrix_animations/typing_heatmap_anim.h | 75 ++++++++++++++++++++++ 5 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 quantum/rgb_matrix_animations/typing_heatmap_anim.h (limited to 'quantum') diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index 5eb9d5536..1e4341467 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md @@ -201,7 +201,10 @@ enum rgb_matrix_effects { RGB_MATRIX_RAINBOW_PINWHEELS, // Full dual gradients spinning two halfs of keyboard RGB_MATRIX_RAINDROPS, // Randomly changes a single key's hue RGB_MATRIX_JELLYBEAN_RAINDROPS, // Randomly changes a single key's hue and saturation +#if define(RGB_MATRIX_FRAMEBUFFER_EFFECTS) + RGB_MATRIX_TYPING_HEATMAP, // How hot is your WPM! RGB_MATRIX_DIGITAL_RAIN, // That famous computer simulation +#endif #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) RGB_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit to hue & value then fades value out RGB_MATRIX_SOLID_REACTIVE, // Static single hue, pulses keys hit to shifted hue then fades to current hue @@ -237,6 +240,7 @@ You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `con |`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` | |`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` | |`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` | +|`#define DISABLE_RGB_MATRIX_TYPING_HEATMAP` |Disables `RGB_MATRIX_TYPING_HEATMAP` | |`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLE` | diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index edbcee9cd..92a94df80 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -38,6 +38,7 @@ #include "rgb_matrix_animations/rainbow_pinwheels_anim.h" #include "rgb_matrix_animations/rainbow_moving_chevron_anim.h" #include "rgb_matrix_animations/jellybean_raindrops_anim.h" +#include "rgb_matrix_animations/typing_heatmap_anim.h" #include "rgb_matrix_animations/digital_rain_anim.h" #include "rgb_matrix_animations/solid_reactive_simple_anim.h" #include "rgb_matrix_animations/solid_reactive_anim.h" @@ -111,6 +112,10 @@ rgb_config_t rgb_matrix_config; rgb_counters_t g_rgb_counters; static uint32_t rgb_counters_buffer; +#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS +uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; +#endif + #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED last_hit_t g_last_hit_tracker; static last_hit_t last_hit_buffer; @@ -206,6 +211,13 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { last_hit_buffer.count++; } #endif // RGB_MATRIX_KEYREACTIVE_ENABLED + +#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) + if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) { + process_rgb_matrix_typing_heatmap(record); + } +#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) + return true; } @@ -370,11 +382,20 @@ static void rgb_task_render(uint8_t effect) { rendering = rgb_matrix_jellybean_raindrops(&rgb_effect_params); // Max 1ms Avg 0ms break; #endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS + +#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS +#ifndef DISABLE_RGB_MATRIX_TYPING_HEATMAP + case RGB_MATRIX_TYPING_HEATMAP: + rendering = rgb_matrix_typing_heatmap(&rgb_effect_params); // Max 4ms Avg 3ms + break; +#endif // DISABLE_RGB_MATRIX_TYPING_HEATMAP #ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN case RGB_MATRIX_DIGITAL_RAIN: rendering = rgb_matrix_digital_rain(&rgb_effect_params); // Max 9ms Avg 8ms | this is expensive, fix it break; #endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN +#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS + #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE case RGB_MATRIX_SOLID_REACTIVE_SIMPLE: diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 365a92bbf..add0715d9 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -101,9 +101,14 @@ enum rgb_matrix_effects { #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS RGB_MATRIX_JELLYBEAN_RAINDROPS, #endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS +#ifndef DISABLE_RGB_MATRIX_TYPING_HEATMAP + RGB_MATRIX_TYPING_HEATMAP, +#endif // DISABLE_RGB_MATRIX_TYPING_HEATMAP #ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN RGB_MATRIX_DIGITAL_RAIN, #endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN +#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE RGB_MATRIX_SOLID_REACTIVE_SIMPLE, diff --git a/quantum/rgb_matrix_animations/digital_rain_anim.h b/quantum/rgb_matrix_animations/digital_rain_anim.h index 4ba3c1c87..6ccba392a 100644 --- a/quantum/rgb_matrix_animations/digital_rain_anim.h +++ b/quantum/rgb_matrix_animations/digital_rain_anim.h @@ -1,11 +1,13 @@ #pragma once -#ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN +#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN) #ifndef RGB_DIGITAL_RAIN_DROPS // lower the number for denser effect/wider keyboard #define RGB_DIGITAL_RAIN_DROPS 24 #endif +extern uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS]; + bool rgb_matrix_digital_rain(effect_params_t* params) { // algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain const uint8_t drop_ticks = 28; @@ -13,24 +15,24 @@ bool rgb_matrix_digital_rain(effect_params_t* params) { const uint8_t max_brightness_boost = 0xc0; const uint8_t max_intensity = 0xff; - static uint8_t map[MATRIX_COLS][MATRIX_ROWS] = {{0}}; static uint8_t drop = 0; if (params->init) { rgb_matrix_set_color_all(0, 0, 0); - memset(map, 0, sizeof map); + memset(rgb_frame_buffer, 0, sizeof rgb_frame_buffer); drop = 0; } + for (uint8_t col = 0; col < MATRIX_COLS; col++) { for (uint8_t row = 0; row < MATRIX_ROWS; row++) { if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) { // top row, pixels have just fallen and we're // making a new rain drop in this column - map[col][row] = max_intensity; + rgb_frame_buffer[col][row] = max_intensity; } - else if (map[col][row] > 0 && map[col][row] < max_intensity) { + else if (rgb_frame_buffer[col][row] > 0 && rgb_frame_buffer[col][row] < max_intensity) { // neither fully bright nor dark, decay it - map[col][row]--; + rgb_frame_buffer[col][row]--; } // set the pixel colour uint8_t led[LED_HITS_TO_REMEMBER]; @@ -38,32 +40,33 @@ bool rgb_matrix_digital_rain(effect_params_t* params) { // TODO: multiple leds are supported mapped to the same row/column if (led_count > 0) { - if (map[col][row] > pure_green_intensity) { - const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost * (map[col][row] - pure_green_intensity) / (max_intensity - pure_green_intensity)); + if (rgb_frame_buffer[col][row] > pure_green_intensity) { + const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost * (rgb_frame_buffer[col][row] - pure_green_intensity) / (max_intensity - pure_green_intensity)); rgb_matrix_set_color(led[0], boost, max_intensity, boost); } else { - const uint8_t green = (uint8_t) ((uint16_t) max_intensity * map[col][row] / pure_green_intensity); + const uint8_t green = (uint8_t) ((uint16_t) max_intensity * rgb_frame_buffer[col][row] / pure_green_intensity); rgb_matrix_set_color(led[0], 0, green, 0); } } } } + if (++drop > drop_ticks) { // reset drop timer drop = 0; for (uint8_t row = MATRIX_ROWS - 1; row > 0; row--) { for (uint8_t col = 0; col < MATRIX_COLS; col++) { // if ths is on the bottom row and bright allow decay - if (row == MATRIX_ROWS - 1 && map[col][row] == max_intensity) { - map[col][row]--; + if (row == MATRIX_ROWS - 1 && rgb_frame_buffer[col][row] == max_intensity) { + rgb_frame_buffer[col][row]--; } // check if the pixel above is bright - if (map[col][row - 1] == max_intensity) { + if (rgb_frame_buffer[col][row - 1] == max_intensity) { // allow old bright pixel to decay - map[col][row - 1]--; + rgb_frame_buffer[col][row - 1]--; // make this pixel bright - map[col][row] = max_intensity; + rgb_frame_buffer[col][row] = max_intensity; } } } @@ -71,4 +74,4 @@ bool rgb_matrix_digital_rain(effect_params_t* params) { return false; } -#endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN +#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN) diff --git a/quantum/rgb_matrix_animations/typing_heatmap_anim.h b/quantum/rgb_matrix_animations/typing_heatmap_anim.h new file mode 100644 index 000000000..aade53fcc --- /dev/null +++ b/quantum/rgb_matrix_animations/typing_heatmap_anim.h @@ -0,0 +1,75 @@ +#pragma once +#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) + +extern rgb_config_t rgb_matrix_config; +extern uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS]; + +void process_rgb_matrix_typing_heatmap(keyrecord_t *record) { + uint8_t row = record->event.key.row; + uint8_t col = record->event.key.col; + uint8_t m_row = row - 1; + uint8_t p_row = row + 1; + uint8_t m_col = col - 1; + uint8_t p_col = col + 1; + + if (m_col < col) + rgb_frame_buffer[row][m_col] = qadd8(rgb_frame_buffer[row][m_col], 16); + rgb_frame_buffer[row][col] = qadd8(rgb_frame_buffer[row][col], 32); + if (p_col < MATRIX_COLS) + rgb_frame_buffer[row][p_col] = qadd8(rgb_frame_buffer[row][p_col], 16); + + if (p_row < MATRIX_ROWS) { + if (m_col < col) + rgb_frame_buffer[p_row][m_col] = qadd8(rgb_frame_buffer[p_row][m_col], 13); + rgb_frame_buffer[p_row][col] = qadd8(rgb_frame_buffer[p_row][col], 16); + if (p_col < MATRIX_COLS) + rgb_frame_buffer[p_row][p_col] = qadd8(rgb_frame_buffer[p_row][p_col], 13); + } + + if (m_row < row) { + if (m_col < col) + rgb_frame_buffer[m_row][m_col] = qadd8(rgb_frame_buffer[m_row][m_col], 13); + rgb_frame_buffer[m_row][col] = qadd8(rgb_frame_buffer[m_row][col], 16); + if (p_col < MATRIX_COLS) + rgb_frame_buffer[m_row][p_col] = qadd8(rgb_frame_buffer[m_row][p_col], 13); + } +} + +bool rgb_matrix_typing_heatmap(effect_params_t* params) { + // Modified version of RGB_MATRIX_USE_LIMITS to work off of matrix row / col size + uint8_t led_min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; + uint8_t led_max = led_min + RGB_MATRIX_LED_PROCESS_LIMIT; + if (led_max > sizeof(rgb_frame_buffer)) + led_max = sizeof(rgb_frame_buffer); + + if (params->init) { + rgb_matrix_set_color_all(0, 0, 0); + memset(rgb_frame_buffer, 0, sizeof rgb_frame_buffer); + } + + // Render heatmap & decrease + for (int i = led_min; i < led_max; i++) { + uint8_t row = i % MATRIX_ROWS; + uint8_t col = i / MATRIX_ROWS; + uint8_t val = rgb_frame_buffer[row][col]; + + // set the pixel colour + uint8_t led[LED_HITS_TO_REMEMBER]; + uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led); + for (uint8_t j = 0; j < led_count; ++j) + { + if (!HAS_ANY_FLAGS(g_led_config.flags[led[j]], params->flags)) + continue; + + HSV hsv = { 170 - qsub8(val, 85), rgb_matrix_config.sat, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.val) }; + RGB rgb = hsv_to_rgb(hsv); + rgb_matrix_set_color(led[j], rgb.r, rgb.g, rgb.b); + } + + rgb_frame_buffer[row][col] = qsub8(val, 1); + } + + return led_max < sizeof(rgb_frame_buffer); +} + +#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) -- cgit v1.2.3-70-g09d2