summaryrefslogtreecommitdiffstats
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
authorskullydazed <skullydazed@users.noreply.github.com>2017-10-18 01:47:49 +0200
committerGitHub <noreply@github.com>2017-10-18 01:47:49 +0200
commitad49db8cd2557b6c54531059d4d162623520bd17 (patch)
tree574183832900a40562e6f9c4de78c33ac6cc018d /quantum/rgblight.c
parentd3fe6a0588965b71c6876b060d05abfceabacbb5 (diff)
downloadqmk_firmware-ad49db8cd2557b6c54531059d4d162623520bd17.tar.gz
qmk_firmware-ad49db8cd2557b6c54531059d4d162623520bd17.tar.xz
Address #1689 by using a formula to define the breathing curve (#1692)
* Address #1689 by using a formula to define the breathing curve and exposing defines to control the shape of the curve. * Tweak the behavior of breathing for clueboard
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 0f02b9a64..78072a61d 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -13,6 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <math.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <util/delay.h>
@@ -465,13 +466,17 @@ void rgblight_task(void) {
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();
- rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, pgm_read_byte(&LED_BREATHING_TABLE[pos]));
+
+ // 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;
}
void rgblight_effect_rainbow_mood(uint8_t interval) {