From a1236a39e7842ed24b3a9c986dba177d02be5114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 6 Mar 2019 22:36:22 +0100 Subject: 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. --- control/ledctl.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'control/ledctl.c') 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 +#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; -- cgit v1.2.3