diff options
author | Karel Kočí <cynerd@email.cz> | 2019-03-06 22:36:22 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2019-03-06 22:40:31 +0100 |
commit | a1236a39e7842ed24b3a9c986dba177d02be5114 (patch) | |
tree | 127ee3ce519961c627fd14e9850e553b502a0205 /control/ledctl.c | |
parent | fe2ce269997dcc23f5eac51ee64e2d06570bf6d4 (diff) | |
download | bigclown-leds-a1236a39e7842ed24b3a9c986dba177d02be5114.tar.gz bigclown-leds-a1236a39e7842ed24b3a9c986dba177d02be5114.tar.bz2 bigclown-leds-a1236a39e7842ed24b3a9c986dba177d02be5114.zip |
Implement gui and fix rainbow selection
For some reason when I use " in payload it is not send. I have no idea
why but it is just probably some bug in bigclown.
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; |