Commit efc613be authored by Eric Duminil's avatar Eric Duminil
Browse files

Trying to use integer sine for LED breathing

parent 26bf5a15
...@@ -11,10 +11,9 @@ namespace config { ...@@ -11,10 +11,9 @@ namespace config {
/***************************************************************** /*****************************************************************
* Configuration (calculated from above values) * * Configuration (calculated from above values) *
*****************************************************************/ *****************************************************************/
namespace config //TODO: Use a class instead. NightMode could then be another state. namespace config //NOTE: Use a class instead? NightMode could then be another state.
{ {
const float average_brightness = 0.5 * (config::max_brightness + config::min_brightness); const uint8_t brightness_amplitude = config::max_brightness - config::min_brightness;
const float brightness_amplitude = 0.5 * (config::max_brightness - config::min_brightness);
bool night_mode = false; bool night_mode = false;
} }
...@@ -176,9 +175,9 @@ namespace LedEffects { ...@@ -176,9 +175,9 @@ namespace LedEffects {
void breathe(int16_t co2) { void breathe(int16_t co2) {
if (!config::night_mode) { if (!config::night_mode) {
static uint16_t breathing_offset = 0; static uint16_t breathing_offset = 0;
//TODO: use integer sine uint16_t brightness = config::min_brightness
pixels.setBrightness( + pixels.sine8(breathing_offset * 3) * config::brightness_amplitude / 255;
static_cast<int>(config::average_brightness + cos(breathing_offset * 0.1) * config::brightness_amplitude)); pixels.setBrightness(brightness);
pixels.show(); pixels.show();
breathing_offset++; breathing_offset++;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment