From 3da8d46a07167fc862e90b6bb232812d5cb64651 Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Thu, 2 May 2019 23:59:29 +0900 Subject: If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin() (#5484) * If RGBLIGHT_EFFECT_BREATHE_CENTER is undefined, use fixed breathe table instead of exp() and sin() * Change rgblight breathing table size to be easily selectable. add RGBLIGHT_BREATHE_TABLE_SIZE macro for customize breathing effect. --- quantum/rgblight.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'quantum/rgblight.c') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 98755ff08..77772e292 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 +#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); } -- cgit v1.2.3-24-g4f1b