summaryrefslogtreecommitdiff
path: root/quantum/rgblight
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgblight')
-rw-r--r--quantum/rgblight/rgblight.c31
-rw-r--r--quantum/rgblight/rgblight.h26
2 files changed, 47 insertions, 10 deletions
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c
index 3bacbda876..e5d3a98bea 100644
--- a/quantum/rgblight/rgblight.c
+++ b/quantum/rgblight/rgblight.c
@@ -559,12 +559,8 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
// static gradient
uint8_t delta = rgblight_config.mode - rgblight_status.base_mode;
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
+
+ uint8_t range = pgm_read_byte(&RGBLED_GRADIENT_RANGES[delta / 2]);
for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) {
uint8_t _hue = ((uint16_t)i * (uint16_t)range) / rgblight_ranges.effect_num_leds;
if (direction) {
@@ -826,6 +822,21 @@ void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t ti
_repeat_timer = sync_timer_read() + duration_ms;
}
+void rgblight_unblink_layer(uint8_t layer) {
+ rgblight_set_layer_state(layer, false);
+ _blinking_layer_mask &= ~((rgblight_layer_mask_t)1 << layer);
+}
+
+void rgblight_unblink_all_but_layer(uint8_t layer) {
+ for (uint8_t i = 0; i < RGBLIGHT_MAX_LAYERS; i++) {
+ if (i != layer) {
+ if ((_blinking_layer_mask & (rgblight_layer_mask_t)1 << i) != 0) {
+ rgblight_unblink_layer(i);
+ }
+ }
+ }
+}
+
void rgblight_blink_layer_repeat_helper(void) {
if (_blinking_layer_mask != 0 && timer_expired(sync_timer_read(), _repeat_timer)) {
for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) {
@@ -1259,19 +1270,19 @@ void rgblight_effect_snake(animation_status_t *anim) {
}
rgblight_set();
if (increment == 1) {
- if (pos - 1 < 0) {
+ if (pos - RGBLIGHT_EFFECT_SNAKE_INCREMENT < 0) {
pos = rgblight_ranges.effect_num_leds - 1;
# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
anim->pos = 0;
# endif
} else {
- pos -= 1;
+ pos -= RGBLIGHT_EFFECT_SNAKE_INCREMENT;
# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
anim->pos = 1;
# endif
}
} else {
- pos = (pos + 1) % rgblight_ranges.effect_num_leds;
+ pos = (pos + RGBLIGHT_EFFECT_SNAKE_INCREMENT) % rgblight_ranges.effect_num_leds;
# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
anim->pos = pos;
# endif
@@ -1285,7 +1296,7 @@ __attribute__((weak)) const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63
void rgblight_effect_knight(animation_status_t *anim) {
static int8_t low_bound = 0;
static int8_t high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
- static int8_t increment = 1;
+ static int8_t increment = RGBLIGHT_EFFECT_KNIGHT_INCREMENT;
uint8_t i, cur;
# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h
index 7076dc41ac..a08b9a7b6b 100644
--- a/quantum/rgblight/rgblight.h
+++ b/quantum/rgblight/rgblight.h
@@ -126,10 +126,18 @@ enum RGBLIGHT_EFFECT_MODE {
# define RGBLIGHT_EFFECT_SNAKE_LENGTH 4
#endif
+#ifndef RGBLIGHT_EFFECT_SNAKE_INCREMENT
+# define RGBLIGHT_EFFECT_SNAKE_INCREMENT 1
+#endif
+
#ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH
# define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3
#endif
+#ifndef RGBLIGHT_EFFECT_KNIGHT_INCREMENT
+# define RGBLIGHT_EFFECT_KNIGHT_INCREMENT 1
+#endif
+
#ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET
# define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0
#endif
@@ -217,6 +225,24 @@ extern const rgblight_segment_t *const *rgblight_layers;
# define RGBLIGHT_USE_TIMER
void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms);
void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times);
+/**
+ * \brief Stop blinking on one layer.
+ *
+ * Stop a layer that is blinking. If the layer is not blinking it will
+ * be unaffected.
+ *
+ * \param layer Layer number to stop blinking.
+ */
+void rgblight_unblink_layer(uint8_t layer);
+/**
+ * \brief Stop blinking all layers except one.
+ *
+ * Stop all layers that are blinking except for one specific layer.
+ * Layers that are not blinking are unaffected.
+ *
+ * \param layer Layer number to keep blinking.
+ */
+void rgblight_unblink_all_but_layer(uint8_t layer);
# endif
#endif