summaryrefslogtreecommitdiff
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
authorFlorian Didron <fdidron@users.noreply.github.com>2019-05-06 10:01:42 +0900
committerGitHub <noreply@github.com>2019-05-06 10:01:42 +0900
commit8e9ac7d14232eeb642244e3b3351804203ccfaac (patch)
tree0b01026b1054c034e18bec54d4a8aebed2fc3ffc /quantum/rgblight.c
parent46ea7dfd516c4d617da96ef385e7699123bb3222 (diff)
parent4550e29f9567df5cb8fb161433d323fa74595282 (diff)
Merge pull request #40 from zsa/feature/rgblight_static_breathing_table
Use a fixed table if breathing center is not defined for RGB Light
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 98755ff08b..77772e2925 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 <rgblight_breathe_table.h>
+#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);
}