Skip to content

Instantly share code, notes, and snippets.

@theVDude
Last active December 6, 2017 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theVDude/3725960a5adeec7c64c7ac0bed090634 to your computer and use it in GitHub Desktop.
Save theVDude/3725960a5adeec7c64c7ac0bed090634 to your computer and use it in GitHub Desktop.
void rgblight_effect_breathing(uint8_t interval) {
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(rgblight_config.hue, rgblight_config.sat, val);
pos = (pos + 1) % 256;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment