Merge pull request #1 from keyboardio/f/led-api-update

Updated to use the new LEDMode/LEDControl API
pull/365/head
Gergely Nagy 7 years ago committed by GitHub
commit be10584f52

@ -1,9 +1,8 @@
#include "Kaleidoscope-LEDEffect-Rainbow.h" #include "Kaleidoscope-LEDEffect-Rainbow.h"
LEDRainbowEffect_::LEDRainbowEffect_(void) { namespace kaleidoscope {
}
void LEDRainbowEffect_::update(void) { void LEDRainbowEffect::update(void) {
if (rainbow_current_ticks++ < rainbow_ticks) { if (rainbow_current_ticks++ < rainbow_ticks) {
return; return;
} else { } else {
@ -16,21 +15,17 @@ void LEDRainbowEffect_::update(void) {
if (rainbow_hue >= 255) { if (rainbow_hue >= 255) {
rainbow_hue -= 255; rainbow_hue -= 255;
} }
LEDControl.set_all_leds_to(rainbow); ::LEDControl.set_all_leds_to(rainbow);
} }
void LEDRainbowEffect_::brightness(byte brightness) { void LEDRainbowEffect::brightness(byte brightness) {
rainbow_value = brightness; rainbow_value = brightness;
} }
LEDRainbowEffect_ LEDRainbowEffect;
// --------- // ---------
LEDRainbowWaveEffect_::LEDRainbowWaveEffect_(void) { void LEDRainbowWaveEffect::update(void) {
}
void LEDRainbowWaveEffect_::update(void) {
if (rainbow_current_ticks++ < rainbow_wave_ticks) { if (rainbow_current_ticks++ < rainbow_wave_ticks) {
return; return;
} else { } else {
@ -43,7 +38,7 @@ void LEDRainbowWaveEffect_::update(void) {
key_hue -= 255; key_hue -= 255;
} }
cRGB rainbow = hsvToRgb(key_hue, rainbow_saturation, rainbow_value); cRGB rainbow = hsvToRgb(key_hue, rainbow_saturation, rainbow_value);
LEDControl.setCrgbAt(i, rainbow); ::LEDControl.setCrgbAt(i, rainbow);
} }
rainbow_hue += rainbow_wave_steps; rainbow_hue += rainbow_wave_steps;
if (rainbow_hue >= 255) { if (rainbow_hue >= 255) {
@ -51,8 +46,10 @@ void LEDRainbowWaveEffect_::update(void) {
} }
} }
void LEDRainbowWaveEffect_::brightness(byte brightness) { void LEDRainbowWaveEffect::brightness(byte brightness) {
rainbow_value = brightness; rainbow_value = brightness;
} }
}
LEDRainbowWaveEffect_ LEDRainbowWaveEffect; kaleidoscope::LEDRainbowEffect LEDRainbowEffect;
kaleidoscope::LEDRainbowWaveEffect LEDRainbowWaveEffect;

@ -3,9 +3,10 @@
#include "Kaleidoscope-LEDControl.h" #include "Kaleidoscope-LEDControl.h"
#include "LEDUtils.h" #include "LEDUtils.h"
class LEDRainbowEffect_ : public LEDMode { namespace kaleidoscope {
class LEDRainbowEffect : public LEDMode {
public: public:
LEDRainbowEffect_(void); LEDRainbowEffect(void) {}
void brightness(byte); void brightness(byte);
void update(void) final; void update(void) final;
@ -21,11 +22,10 @@ class LEDRainbowEffect_ : public LEDMode {
byte rainbow_value = 50; byte rainbow_value = 50;
}; };
extern LEDRainbowEffect_ LEDRainbowEffect;
class LEDRainbowWaveEffect_ : public LEDMode { class LEDRainbowWaveEffect : public LEDMode {
public: public:
LEDRainbowWaveEffect_(void); LEDRainbowWaveEffect(void) {}
void brightness(byte); void brightness(byte);
void update(void) final; void update(void) final;
@ -40,5 +40,7 @@ class LEDRainbowWaveEffect_ : public LEDMode {
byte rainbow_saturation = 255; byte rainbow_saturation = 255;
byte rainbow_value = 50; byte rainbow_value = 50;
}; };
}
extern LEDRainbowWaveEffect_ LEDRainbowWaveEffect; extern kaleidoscope::LEDRainbowEffect LEDRainbowEffect;
extern kaleidoscope::LEDRainbowWaveEffect LEDRainbowWaveEffect;

Loading…
Cancel
Save