From ff8cea0036e2ae9ac1c457914ed87c1edacc4a65 Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 14 Jun 2022 09:40:34 -0700 Subject: [PATCH] Made LED map definitions readable with a few macros --- betalupi_ergodox.h | 37 +++++++++++++++++++++++++++++++ keymaps/default/keymap.h | 28 +++++++++++++++++++++++ keymaps/default/layers/arrows.h | 16 ++++++++++--- keymaps/default/layers/colemak.h | 16 ++++++++++--- keymaps/default/layers/desktop.h | 16 ++++++++++--- keymaps/default/layers/fkeys.h | 16 ++++++++++--- keymaps/default/layers/navigate.h | 16 ++++++++++--- keymaps/default/layers/numpad.h | 16 ++++++++++--- keymaps/default/layers/russian.h | 28 +++++++++++------------ keymaps/default/layers/symbols.h | 16 ++++++++++--- 10 files changed, 169 insertions(+), 36 deletions(-) diff --git a/betalupi_ergodox.h b/betalupi_ergodox.h index 88ad017..8b0901d 100644 --- a/betalupi_ergodox.h +++ b/betalupi_ergodox.h @@ -136,6 +136,43 @@ typedef union { extern keyboard_config_t keyboard_config; +// Turns {h, s, v} triples into a macro, so that +// the LEDS_ergodox macro can take them as inputs. +#define LC_HSV(h, s, v) {h, s, v} + +// Rearrange a human-readable LED layout into the correct Ergodox order. +// LEDS_ergodox ONLY WORKS WITH MACROS. +// Don't input a standalone triple {h, s, v}; +// Use LC_HSV if you need a single-instance color. +#define LEDS_ergodox( \ + l01,l02,l03,l04,l05, \ + l06,l07,l08,l09,l10, \ + l11,l12,l13,l14,l15, \ + l16,l17,l18,l19,l20, \ + l21,l22,l23,l24, \ + \ + l25,l26,l27,l28,l29, \ + l30,l31,l32,l33,l34, \ + l35,l36,l37,l38,l39, \ + l40,l41,l42,l43,l44, \ + l45,l46,l47,l48 \ + ) \ + { \ + l25,l26,l27,l28,l29, \ + l30,l31,l32,l33,l34, \ + l35,l36,l37,l38,l39, \ + l40,l41,l42,l43,l44, \ + l45,l46,l47,l48, \ + \ + l05,l04,l03,l02,l01, \ + l10,l09,l08,l07,l06, \ + l15,l14,l13,l12,l11, \ + l20,l19,l18,l17,l16, \ + l24,l23,l22,l21 \ + } + + + /* LEFT HAND: LINES 115-122 RIGHT HAND: LINES 124-131 diff --git a/keymaps/default/keymap.h b/keymaps/default/keymap.h index 51cadb0..9e160a9 100644 --- a/keymaps/default/keymap.h +++ b/keymaps/default/keymap.h @@ -74,3 +74,31 @@ void set_lang_long(int lang, bool force); * | |ace | End | | PgDn | | | * `--------------------' `----------------------' */ + +/* LED layout template +#define LAYER_COLEMAK_LEDS LEDS_ergodox(\ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF \ +) +*/ + +// LED colors, in HSV. +#define LC_OFF LC_HSV( 0, 0, 0) +#define LC_GREEN LC_HSV( 85, 203, 158) +#define LC_YELLOW LC_HSV( 32, 176, 255) +#define LC_PINK LC_HSV(243, 222, 234) +#define LC_CYAN LC_HSV(134, 255, 213) +#define LC_ORANGE LC_HSV( 14, 255, 255) + +#define LC_RU_B LC_HSV( 0, 0, 165) +#define LC_RU_G LC_HSV(153, 255, 153) +#define LC_RU_K LC_HSV( 0, 255, 145) diff --git a/keymaps/default/layers/arrows.h b/keymaps/default/layers/arrows.h index ecf0d19..f9b3fd4 100644 --- a/keymaps/default/layers/arrows.h +++ b/keymaps/default/layers/arrows.h @@ -24,6 +24,16 @@ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT\ ) - -#define LAYER_ARROWS_LEDS \ -{ {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {32,176,255}, {32,176,255}, {0,0,0}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0} } +#define LAYER_ARROWS_LEDS LEDS_ergodox(\ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_YELLOW, LC_YELLOW, LC_GREEN, LC_OFF, LC_OFF, \ + LC_OFF, LC_GREEN, LC_GREEN, LC_GREEN, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_PINK, \ + \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_GREEN, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_GREEN, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF \ +) diff --git a/keymaps/default/layers/colemak.h b/keymaps/default/layers/colemak.h index 8b136d2..da2d721 100644 --- a/keymaps/default/layers/colemak.h +++ b/keymaps/default/layers/colemak.h @@ -24,6 +24,16 @@ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT\ ) - -#define LAYER_COLEMAK_LEDS \ -{ {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} } +#define LAYER_COLEMAK_LEDS LEDS_ergodox(\ + LC_PINK, LC_PINK, LC_PINK, LC_PINK, LC_PINK, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + \ + LC_PINK, LC_PINK, LC_PINK, LC_PINK, LC_PINK, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF \ +) diff --git a/keymaps/default/layers/desktop.h b/keymaps/default/layers/desktop.h index 0ac565e..72fbb0e 100644 --- a/keymaps/default/layers/desktop.h +++ b/keymaps/default/layers/desktop.h @@ -24,6 +24,16 @@ KC_AUDIO_VOL_DOWN, KC_MEDIA_STOP, KC_MEDIA_PLAY_PAUSE\ ) - -#define LAYER_DESKTOP_LEDS \ -{ {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {0,0,0}, {14,255,255}, {0,0,0}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {0,0,0}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {134,255,213}, {0,0,0}, {85,203,158}, {0,0,0}, {134,255,213}, {134,255,213}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} } +#define LAYER_DESKTOP_LEDS LEDS_ergodox(\ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_CYAN, LC_CYAN, \ + LC_OFF, LC_OFF, LC_OFF, LC_CYAN, LC_CYAN, \ + LC_OFF, LC_OFF, LC_OFF, LC_CYAN, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_GREEN, LC_OFF, LC_ORANGE, \ + LC_OFF, LC_GREEN, LC_GREEN, LC_GREEN, LC_OFF, \ + LC_OFF, LC_CYAN, LC_CYAN, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF \ +) diff --git a/keymaps/default/layers/fkeys.h b/keymaps/default/layers/fkeys.h index 3aafee6..6e59258 100644 --- a/keymaps/default/layers/fkeys.h +++ b/keymaps/default/layers/fkeys.h @@ -24,6 +24,16 @@ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT \ ) - -#define LAYER_FKEYS_LEDS \ -{ {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} } +#define LAYER_FKEYS_LEDS LEDS_ergodox(\ + LC_CYAN, LC_CYAN, LC_CYAN, LC_CYAN, LC_CYAN, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + \ + LC_CYAN, LC_CYAN, LC_CYAN, LC_CYAN, LC_CYAN, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF \ +) diff --git a/keymaps/default/layers/navigate.h b/keymaps/default/layers/navigate.h index 90231b5..b1658f5 100644 --- a/keymaps/default/layers/navigate.h +++ b/keymaps/default/layers/navigate.h @@ -24,6 +24,16 @@ KC_NO, KC_LGUI, KC_TRANSPARENT\ ) - -#define LAYER_NAVIGATE_LEDS \ -{ {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {243,222,234}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0} } +#define LAYER_NAVIGATE_LEDS LEDS_ergodox(\ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_PINK, LC_OFF, LC_OFF, \ + LC_OFF, LC_PINK, LC_PINK, LC_PINK, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_PINK, \ + \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF \ +) diff --git a/keymaps/default/layers/numpad.h b/keymaps/default/layers/numpad.h index 68a3adc..1b53788 100644 --- a/keymaps/default/layers/numpad.h +++ b/keymaps/default/layers/numpad.h @@ -24,6 +24,16 @@ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT\ ) - -#define LAYER_NUMPAD_LEDS \ -{ {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {32,176,255}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {85,203,158}, {85,203,158}, {85,203,158}, {85,203,158}, {32,176,255}, {32,176,255}, {85,203,158}, {85,203,158}, {85,203,158}, {32,176,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} } +#define LAYER_NUMPAD_LEDS LEDS_ergodox(\ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_GREEN, LC_GREEN, LC_GREEN, LC_YELLOW, \ + LC_YELLOW, LC_GREEN, LC_GREEN, LC_GREEN, LC_GREEN, \ + LC_YELLOW, LC_GREEN, LC_GREEN, LC_GREEN, LC_YELLOW, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF \ +) diff --git a/keymaps/default/layers/russian.h b/keymaps/default/layers/russian.h index d145d8b..d70fe1c 100644 --- a/keymaps/default/layers/russian.h +++ b/keymaps/default/layers/russian.h @@ -24,18 +24,16 @@ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT\ ) - -#define LAYER_RUSSIAN_LEDS \ -{\ - { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0},\ - { 0, 0, 165}, { 0, 0, 165}, { 0, 0, 165}, { 0, 0, 165}, { 0, 0, 165},\ - {153, 255, 153}, {153, 255, 153}, {153, 255, 153}, {153, 255, 153}, {153, 255, 153},\ - { 0, 255, 145}, { 0, 255, 145}, { 0, 255, 145}, { 0, 255, 145}, { 0, 255, 145},\ - { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0},\ -\ - { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0},\ - { 0, 0, 165}, { 0, 0, 165}, { 0, 0, 165}, { 0, 0, 165}, { 0, 0, 165},\ - {153, 255, 153}, {153, 255, 153}, {153, 255, 153}, {153, 255, 153}, {153, 255, 153},\ - { 0, 255, 145}, { 0, 255, 145}, { 0, 255, 145}, { 0, 255, 145}, { 0, 255, 145},\ - { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0},\ -} +#define LAYER_RUSSIAN_LEDS LEDS_ergodox(\ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_RU_B, LC_RU_B, LC_RU_B, LC_RU_B, LC_RU_B, \ + LC_RU_G, LC_RU_G, LC_RU_G, LC_RU_G, LC_RU_G, \ + LC_RU_K, LC_RU_K, LC_RU_K, LC_RU_K, LC_RU_K, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_RU_B, LC_RU_B, LC_RU_B, LC_RU_B, LC_RU_B, \ + LC_RU_G, LC_RU_G, LC_RU_G, LC_RU_G, LC_RU_G, \ + LC_RU_K, LC_RU_K, LC_RU_K, LC_RU_K, LC_RU_K, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF \ +) diff --git a/keymaps/default/layers/symbols.h b/keymaps/default/layers/symbols.h index 82f49ee..e2e274d 100644 --- a/keymaps/default/layers/symbols.h +++ b/keymaps/default/layers/symbols.h @@ -24,6 +24,16 @@ KC_NO, KC_NO, KC_TRANSPARENT\ ) - -#define LAYER_SYMBOLS_LEDS \ -{ {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {85,203,158}, {134,255,213}, {0,0,0}, {134,255,213}, {134,255,213}, {85,203,158}, {243,222,234}, {10,225,255}, {134,255,213}, {85,203,158}, {85,203,158}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {10,225,255}, {243,222,234}, {243,222,234}, {243,222,234}, {243,222,234}, {10,225,255}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} } +#define LAYER_SYMBOLS_LEDS LEDS_ergodox(\ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_ORANGE, LC_CYAN, LC_CYAN, LC_PINK, LC_CYAN, \ + LC_ORANGE, LC_PINK, LC_PINK, LC_PINK, LC_PINK, \ + LC_OFF, LC_CYAN, LC_CYAN, LC_PINK, LC_CYAN, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF, LC_OFF, \ + LC_GREEN, LC_GREEN, LC_CYAN, LC_OFF, LC_CYAN, \ + LC_CYAN, LC_GREEN, LC_PINK, LC_ORANGE, LC_CYAN, \ + LC_GREEN, LC_GREEN, LC_PINK, LC_OFF, LC_OFF, \ + LC_OFF, LC_OFF, LC_OFF, LC_OFF \ +)