summaryrefslogtreecommitdiffstats
path: root/keyboards/clueboard/keymaps/magicmonty/keymap.c
diff options
context:
space:
mode:
authorMartin Gondermann <magicmonty@users.noreply.github.com>2017-07-03 20:43:32 +0200
committerskullydazed <skullydazed@users.noreply.github.com>2017-07-03 11:43:32 -0700
commit827dc6c715f8099562ef8b9d9208afbb51f706b8 (patch)
tree40f25fdd82212e9ed207262d505931896bd9647e /keyboards/clueboard/keymaps/magicmonty/keymap.c
parentfe47b36065c59b7972abd6b28368d829f266ba5c (diff)
Add octave lights for midi layer (#1457)
Diffstat (limited to 'keyboards/clueboard/keymaps/magicmonty/keymap.c')
-rw-r--r--keyboards/clueboard/keymaps/magicmonty/keymap.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/keyboards/clueboard/keymaps/magicmonty/keymap.c b/keyboards/clueboard/keymaps/magicmonty/keymap.c
index 05ea1fa33e..69772baf74 100644
--- a/keyboards/clueboard/keymaps/magicmonty/keymap.c
+++ b/keyboards/clueboard/keymaps/magicmonty/keymap.c
@@ -179,6 +179,47 @@ void clueboard_set_led(uint8_t id, uint8_t val) {
}
};
+const uint16_t oct_hues[10] = {
+ 0,
+ 30,
+ 60,
+ 90,
+ 120,
+ 150,
+ 180,
+ 210,
+ 240,
+ 300
+};
+
+#define MAX_OCT 9
+
+void clueboard_set_midi_led(uint8_t base_oct, uint8_t val)
+{
+ uint8_t sat = 255;
+
+ for (uint8_t i = 0; i < RGBLED_NUM; i++) {
+ sethsv(oct_hues[base_oct], sat, val, (LED_TYPE *)&led[i]);
+ }
+
+ uint8_t next_oct = base_oct < MAX_OCT ? base_oct + 1 : base_oct;
+
+ uint16_t next_hue = base_oct < MAX_OCT ? oct_hues[next_oct] : 0;
+ uint8_t next_val = base_oct < MAX_OCT ? val : 0;
+ uint8_t next_sat = base_oct < MAX_OCT ? sat : 0;
+
+
+ for (uint8_t i = 0; i < 3; i++) {
+ sethsv(next_hue, next_sat, next_val, (LED_TYPE *)&led[i]);
+ }
+
+ for (uint8_t i = 11; i < 14; i++) {
+ sethsv(next_hue, next_sat, next_val, (LED_TYPE *)&led[i]);
+ }
+
+ rgblight_set();
+}
+
void matrix_scan_user(void) {
rgblight_config_t rgblight_config;
rgblight_config.raw = eeconfig_read_rgblight();
@@ -197,10 +238,10 @@ void matrix_scan_user(void) {
clueboard_set_led(LAYER_FUNCTION, val);
}
} else if (layer & (1<<_ML)) {
- clueboard_set_led(LAYER_MOUSE, val);
+ clueboard_set_led(LAYER_MOUSE, val);
#if defined(MIDI_ENABLE)
} else if (layer & (1<<_MI)) {
- clueboard_set_led(LAYER_MIDI, val);
+ clueboard_set_midi_led(midi_config.octave, val);
#endif
} else {
clueboard_set_led(LAYER_BASE, val);