From dcddb26fa0453ec99313358080895cfe06450848 Mon Sep 17 00:00:00 2001 From: Ben Gemperline Date: Sat, 10 Mar 2018 16:17:47 -0700 Subject: [PATCH] Add ability to change hue / saturation in breath_compute Allow the breath_compute function to take optional parameters for hue and saturation to allow for differently colored breath effects. --- src/LEDUtils.cpp | 13 ++++++++++++- src/LEDUtils.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/LEDUtils.cpp b/src/LEDUtils.cpp index 734771ce..d5831277 100644 --- a/src/LEDUtils.cpp +++ b/src/LEDUtils.cpp @@ -2,6 +2,16 @@ cRGB breath_compute() { + return breath_compute(170); +} + +cRGB +breath_compute(uint8_t hue) { + return breath_compute(hue, 255); +} + +cRGB +breath_compute(uint8_t hue, uint8_t saturation) { // This code is adapted from FastLED lib8tion.h as of dd5d96c6b289cb6b4b891748a4aeef3ddceaf0e6 // Eventually, we should consider just using FastLED @@ -17,9 +27,10 @@ breath_compute() { i = (((3 * (uint16_t)(ii)) - (2 * (uint16_t)(iii))) / 2) + 80; - return hsvToRgb(170, 255, i); + return hsvToRgb(hue, saturation, i); } +//For rgb to hsv, might take a look at: http://web.mit.edu/storborg/Public/hsvtorgb.c // From http://web.mit.edu/storborg/Public/hsvtorgb.c - talk to Scott about licensing diff --git a/src/LEDUtils.h b/src/LEDUtils.h index f49e6200..aaafe549 100644 --- a/src/LEDUtils.h +++ b/src/LEDUtils.h @@ -3,4 +3,6 @@ #include cRGB breath_compute(void); +cRGB breath_compute(uint8_t hue); +cRGB breath_compute(uint8_t hue, uint8_t saturation); cRGB hsvToRgb(uint16_t h, uint16_t s, uint16_t v);