aboutsummaryrefslogtreecommitdiff
path: root/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2025-10-05 12:08:48 +0200
committerSébastien Dailly <sebastien@dailly.me>2025-10-05 12:08:48 +0200
commit08d739a701e0068047437b5012e42c53068fee48 (patch)
tree32b0d457dc88ca996778d6e1cf12871b01434dac /qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
parent2890e5fa537f981be41fe7ccd914e78914fffd72 (diff)
Updated the code for LED
Diffstat (limited to 'qmk/keyboards/sofle_choc/keymaps/custom/lighting.c')
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/lighting.c67
1 files changed, 42 insertions, 25 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
index 3060dce..fd491e6 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
@@ -1,6 +1,7 @@
#include QMK_KEYBOARD_H
uint8_t flags = 0;
#include "keycodes.h"
+#include "lighting.h"
// The variable is defined in star_key.h
// The LED is on when the key is pressed.
@@ -17,10 +18,15 @@ HSV hsv_of_color(uint8_t h, uint8_t s, uint8_t v) {
return (HSV){h, s, v > 100 ? 100:v};
}
-#define KEY_5 MT(MOD_LCTL, KC_P5)
-#define KEY_DOWN MT(MOD_RCTL, KC_DOWN)
-bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
- // Activate effects depending of mods
+void lighting_init(void) {
+ rgb_matrix_sethsv_noeeprom(HSV_WHITE);
+ rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_REACTIVE_SIMPLE);
+}
+
+
+static uint8_t last_flags;
+
+void housekeeping_task_lighting(void) {
// Colors for the mods
HSV const colors[] = {
@@ -34,14 +40,6 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
hsv_of_color(HSV_WHITE), // 111
};
- if (is_caps_word_on()) {
- if (rgb_matrix_get_mode() != RGB_MATRIX_BREATHING) {
- rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING);
- }
- rgb_matrix_sethsv_noeeprom(HSV_SPRINGGREEN);
- return false;
- }
-
uint8_t counter = 0;
uint8_t flags = 0;
if (get_mods() & MOD_MASK_CTRL) {
@@ -57,6 +55,38 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
counter += 1;
}
+ if (flags == last_flags) {
+ return;
+ }
+ last_flags = flags;
+
+ if (get_mods()) {
+ if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_COLOR) {
+ rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
+ }
+ uint8_t v = colors[flags].v;
+ if (counter >= 2)
+ v *= 2;
+ rgb_matrix_sethsv_noeeprom(colors[flags].h, colors[flags].s, v);
+ } else if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_REACTIVE_SIMPLE) {
+ rgb_matrix_sethsv_noeeprom(HSV_WHITE);
+ rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_REACTIVE_SIMPLE);
+ }
+}
+
+#define KEY_5 MT(MOD_LCTL, KC_P5)
+#define KEY_DOWN MT(MOD_RCTL, KC_DOWN)
+bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
+ // Activate effects depending of mods
+
+ if (is_caps_word_on()) {
+ if (rgb_matrix_get_mode() != RGB_MATRIX_BREATHING) {
+ rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING);
+ }
+ rgb_matrix_sethsv_noeeprom(HSV_SPRINGGREEN);
+ return false;
+ }
+
for (uint8_t row = 0; row < MATRIX_ROWS; ++row) {
for (uint8_t col = 0; col < MATRIX_COLS; ++col) {
uint8_t index = g_led_config.matrix_co[row][col];
@@ -103,18 +133,5 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
}
}
- if (get_mods()) {
- if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_COLOR) {
- rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
- }
- uint8_t v = colors[flags].v;
- if (counter == 2)
- v *= 2;
- rgb_matrix_sethsv_noeeprom(colors[flags].h, colors[flags].s, v);
- } else if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_REACTIVE_SIMPLE) {
- rgb_matrix_sethsv_noeeprom(HSV_WHITE);
- rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_REACTIVE_SIMPLE);
- }
-
return false;
}