First pass at bundling the LED code into its own class

pull/18/head
Jesse Vincent 9 years ago
parent 16411878aa
commit 0ae7e1b0fd

@ -1,37 +1,14 @@
#include "led_control.h" #include "led_control.h"
static uint8_t led_mode; uint8_t LEDControl::pos= 0;
static uint8_t last_led_mode; uint8_t LEDControl::rainbow_hue=0;
static uint8_t stored_led_mode; uint8_t LEDControl::rainbow_steps = 1;
static uint8_t pos = 0; uint8_t LEDControl::rainbow_wave_steps=1;
long LEDControl::rainbow_current_ticks =0;
static cRGB led_off = { .r = 0, .g = 0, .b = 0 }; uint8_t LEDControl::breathe_brightness=0;
static cRGB led_steady = { .r = 0, .g = 255, .b = 0}; uint8_t LEDControl::breathe_fadeAmount=1;
static cRGB led_blue = { .r = 0, .g = 0, .b = 255 }; uint8_t LEDControl::chase_pixels= 1;
static cRGB led_dark_blue = { .r = 0, .g = 0, .b = 127 }; uint8_t LEDControl::current_chase_counter = 0;
static cRGB led_bright_red = { .r = 255, .g = 0, .b = 0};
static cRGB led_breathe;
static cRGB rainbow;
static uint8_t rainbow_hue = 0; //stores 0 to 614
static uint8_t rainbow_steps = 1; //number of hues we skip in a 360 range per update
static uint8_t rainbow_wave_steps =1; //number of hues we skip in a 360 range per update
static byte rainbow_saturation = 255;
static byte rainbow_value = 190;
static long rainbow_wave_ticks = 1; //delays between update
static long rainbow_ticks = 5; //delays between update
static long rainbow_current_ticks =0;
static uint8_t breathe_brightness = 0; // how bright the LED is
static uint8_t breathe_fadeAmount = 1; // how many pouint8_ts to fade the LED by
static uint8_t chase_pixels = 1;
static uint8_t chase_threshold = 6;
static uint8_t current_chase_counter = 0;
// End RGB stuff
void LEDControl::set_key_color(byte row, byte col, cRGB color) { void LEDControl::set_key_color(byte row, byte col, cRGB color) {
implementation_led_set_crgb_at(row, col, color); implementation_led_set_crgb_at(row, col, color);

@ -17,33 +17,65 @@
class LEDControl { class LEDControl {
public: public:
void next_led_mode(); void next_led_mode();
void led_bootup(); void led_bootup();
void update_leds(uint8_t numlock_enabled); void update_leds(uint8_t numlock_enabled);
void led_type_letter(uint8_t letter); void led_type_letter(uint8_t letter);
void set_led_mode(uint8_t mode); void set_led_mode(uint8_t mode);
private: private:
void set_key_color(uint8_t row, uint8_t col, cRGB color); uint8_t led_mode;
cRGB get_key_color(uint8_t row, uint8_t col); uint8_t last_led_mode;
void led_compute_breath(); uint8_t stored_led_mode;
void led_effect_breathe_init(); static uint8_t pos;
void led_effect_rainbow_init();
void led_effect_chase_init(); cRGB led_off = { .r = 0, .g = 0, .b = 0 };
void led_effect_steady_init(); cRGB led_steady = { .r = 0, .g = 255, .b = 0};
void led_effect_heatmap_init(); cRGB led_blue = { .r = 0, .g = 0, .b = 255 };
cRGB led_dark_blue = { .r = 0, .g = 0, .b = 127 };
void led_effect_breathe_update(); cRGB led_bright_red = { .r = 255, .g = 0, .b = 0};
void led_effect_rainbow_update(); cRGB led_breathe;
void led_effect_rainbow_wave_update(); cRGB rainbow;
void led_effect_chase_update();
void led_effect_steady_update();
void led_effect_heatmap_update(); static uint8_t rainbow_hue; //stores 0 to 614
void led_effect_numlock_update();
void set_all_leds_to(cRGB color); static uint8_t rainbow_steps; //number of hues we skip in a 360 range per update
void SetHSV(cRGB crgb, int hue, byte sat, byte val); static uint8_t rainbow_wave_steps; //number of hues we skip in a 360 range per update
void initialize_led_mode(uint8_t mode);
static const byte rainbow_saturation = 255;
static const byte rainbow_value = 190;
static const long rainbow_wave_ticks = 1; //delays between update
static const long rainbow_ticks = 5; //delays between update
static long rainbow_current_ticks;
static uint8_t breathe_brightness; // how bright the LED is
static uint8_t breathe_fadeAmount; // how many points to fade the LED by
static uint8_t chase_pixels;
static uint8_t current_chase_counter;
static const uint8_t chase_threshold = 6;
// End RGB stuff
void set_key_color(uint8_t row, uint8_t col, cRGB color);
cRGB get_key_color(uint8_t row, uint8_t col);
void led_compute_breath();
void led_effect_breathe_init();
void led_effect_rainbow_init();
void led_effect_chase_init();
void led_effect_steady_init();
void led_effect_heatmap_init();
void led_effect_breathe_update();
void led_effect_rainbow_update();
void led_effect_rainbow_wave_update();
void led_effect_chase_update();
void led_effect_steady_update();
void led_effect_heatmap_update();
void led_effect_numlock_update();
void set_all_leds_to(cRGB color);
void SetHSV(cRGB crgb, int hue, byte sat, byte val);
void initialize_led_mode(uint8_t mode);
}; };

Loading…
Cancel
Save