aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2019-05-02 23:59:29 +0900
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-05-02 07:59:29 -0700
commit3da8d46a07167fc862e90b6bb232812d5cb64651 (patch)
tree5af2e45ad1349b21afb075441a5032897e3b812d /quantum/rgblight.c
parent4db31fb374d365bfa0f5c8a25d089bb2f967352f (diff)
downloadqmk_firmware-3da8d46a07167fc862e90b6bb232812d5cb64651.tar.gz
qmk_firmware-3da8d46a07167fc862e90b6bb232812d5cb64651.zip
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.
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 98755ff08..77772e292 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -879,6 +879,14 @@ void rgblight_task(void) {
879 879
880// Effects 880// Effects
881#ifdef RGBLIGHT_EFFECT_BREATHING 881#ifdef RGBLIGHT_EFFECT_BREATHING
882
883#ifndef RGBLIGHT_EFFECT_BREATHE_CENTER
884 #ifndef RGBLIGHT_BREATHE_TABLE_SIZE
885 #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64
886 #endif
887 #include <rgblight_breathe_table.h>
888#endif
889
882__attribute__ ((weak)) 890__attribute__ ((weak))
883const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; 891const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
884 892
@@ -886,7 +894,11 @@ void rgblight_effect_breathing(animation_status_t *anim) {
886 float val; 894 float val;
887 895
888 // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ 896 // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
897#ifdef RGBLIGHT_EFFECT_BREATHE_TABLE
898 val = pgm_read_byte(&rgblight_effect_breathe_table[anim->pos / table_scale]);
899#else
889 val = (exp(sin((anim->pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)); 900 val = (exp(sin((anim->pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E));
901#endif
890 rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); 902 rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val);
891 anim->pos = (anim->pos + 1); 903 anim->pos = (anim->pos + 1);
892} 904}