From b461309910c021107a9b88640449ea5800db1e74 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 1 Feb 2016 19:33:46 -0800 Subject: [PATCH] Make cRGB initialization not depend on struct order. --- LEDControl.cpp | 19 ++++++++++++++++++- LEDControl.h | 13 +++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/LEDControl.cpp b/LEDControl.cpp index d5eeb1c7..d1a81f77 100644 --- a/LEDControl.cpp +++ b/LEDControl.cpp @@ -1,6 +1,23 @@ #include "LEDControl.h" + + LEDControl_::LEDControl_(void) { + led_off.r = 0; + led_off.g = 0; + led_off.b = 0; + led_steady.r = 0; + led_steady.g = 255; + led_steady.b = 0; + led_blue.r = 0; + led_blue.g = 0; + led_blue.b = 255; + led_dark_blue.r = 0; + led_dark_blue.g = 0; + led_dark_blue .b = 127; + led_bright_red.r = 255; + led_bright_red.g = 0; + led_bright_red.b = 0; } @@ -107,7 +124,7 @@ void LEDControl_::led_compute_breath() { } - led_breathe.SetHSV(200, 255, breathe_brightness); + hsv_to_rgb(&led_breathe,200, 255, breathe_brightness); } void LEDControl_::effect_breathe_update() { diff --git a/LEDControl.h b/LEDControl.h index 0fc6f184..f633b3c6 100644 --- a/LEDControl.h +++ b/LEDControl.h @@ -32,17 +32,14 @@ class LEDControl_ { uint8_t pos = 0; void hsv_to_rgb(cRGB *cRGB, uint16_t h, uint16_t s, uint16_t v); - - - cRGB led_off = { .r = 0, .g = 0, .b = 0 }; - cRGB led_steady = { .r = 0, .g = 255, .b = 0}; - cRGB led_blue = { .r = 0, .g = 0, .b = 255 }; - cRGB led_dark_blue = { .r = 0, .g = 0, .b = 127 }; - cRGB led_bright_red = { .r = 255, .g = 0, .b = 0}; + cRGB led_off; + cRGB led_steady; + cRGB led_blue; + cRGB led_dark_blue; + cRGB led_bright_red; cRGB led_breathe; cRGB rainbow; - uint16_t rainbow_hue = 0; //stores 0 to 614 static const uint8_t rainbow_steps = 1; //number of hues we skip in a 360 range per update