Created
December 6, 2017 06:38
-
-
Save theVDude/3366f258ddcb1acb95cae2f3fcb38f23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void rgblight_effect_breathing_xmas(uint8_t interval) { | |
static uint16_t current_hue = 0; | |
static uint8_t pos = 0; | |
static uint16_t last_timer = 0; | |
float val; | |
if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) { | |
return; | |
} | |
last_timer = timer_read(); | |
// http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ | |
val = (exp(sin((pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)); | |
rgblight_sethsv_noeeprom(current_hue, rgblight_config.sat, val); | |
if (pos == 0) { | |
if (current_hue == 0){ | |
current_hue = 120; | |
} else { | |
current_hue = 0; | |
} | |
} | |
pos = (pos + 1) % 256; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lines 17-21 can be stuck in a ternary operator but i don't know how to use them in c