diff options
Diffstat (limited to 'control/ledctl.c')
-rw-r--r-- | control/ledctl.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/control/ledctl.c b/control/ledctl.c index d6fdd1e..76bdc67 100644 --- a/control/ledctl.c +++ b/control/ledctl.c @@ -1,37 +1,25 @@ #include "ledctl.h" +#include <bcl.h> +#include "state.h" +#include "gui.h" -enum { - MODE_SOLID_RED, - MODE_SOLID_GREEN, - MODE_SOLID_BLUE, - MODE_SOLID_YELLOW, - MODE_RAINBOW, -} mode; -int brightness = 7; -int enabled = 0; -int current_brightness = 0; const char *mode_string[] = { [MODE_SOLID_RED] = "#FF0000", [MODE_SOLID_GREEN] = "#00FF00", [MODE_SOLID_BLUE] = "#0000FF", [MODE_SOLID_YELLOW] = "#FFFF00", - [MODE_RAINBOW] = "{\"type\":\"rainbow\", \"wait\":50}", + [MODE_RAINBOW] = "rainbow", }; -enum { - STATE_DEFAULT, - STATE_COLOR_SELECT, - STATE_BRIGHTNESS_SELECT, -} state = STATE_DEFAULT; - +int current_brightness = 0; void update_brightness() { if (!enabled) current_brightness = 0; else - current_brightness = brightness > 7 ? 100 : (1 << (brightness - 1)); + current_brightness = brightness >= brightness_max ? 100 : (1 << (brightness - 1)); bc_radio_pub_int("led/brightness/set", ¤t_brightness); } @@ -49,7 +37,7 @@ void click_left() { update_brightness(); break; case STATE_BRIGHTNESS_SELECT: - if (brightness <= 8) + if (brightness < brightness_max) brightness++; update_brightness(); break; @@ -72,7 +60,7 @@ void click_right() { update_brightness(); break; case STATE_BRIGHTNESS_SELECT: - if (brightness >= 1) + if (brightness > 1) brightness--; update_brightness(); break; @@ -92,15 +80,12 @@ void hold_left() { switch (state) { case STATE_DEFAULT: state = STATE_BRIGHTNESS_SELECT; - // TODO update image break; case STATE_COLOR_SELECT: state = STATE_COLOR_SELECT; - // TODO break; case STATE_BRIGHTNESS_SELECT: state = STATE_DEFAULT; - // TODO break; default: break; @@ -111,15 +96,12 @@ void hold_right() { switch (state) { case STATE_DEFAULT: state = STATE_COLOR_SELECT; - // TODO update image break; case STATE_COLOR_SELECT: state = STATE_DEFAULT; - // TODO break; case STATE_BRIGHTNESS_SELECT: state = STATE_BRIGHTNESS_SELECT; - // TODO break; default: break; |