Add a `led.theme` Focus command

Allows setting all of the LEDs to custom, distinct colors (as opposed to
`led.setAll`, which sets them all to the same color). This allows one to
upload a theme in one go, without having to set each LED one by one.

Fixes #5.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago committed by Gergely Nagy
parent b4debe142d
commit 55c42928f9

@ -161,7 +161,8 @@ LEDControl_::focusHook (const char *command) {
enum { enum {
SETALL, SETALL,
MODE, MODE,
AT AT,
THEME,
} subCommand; } subCommand;
if (strncmp_P (command, PSTR ("led."), 4) != 0) if (strncmp_P (command, PSTR ("led."), 4) != 0)
@ -172,6 +173,8 @@ LEDControl_::focusHook (const char *command) {
subCommand = SETALL; subCommand = SETALL;
else if (strcmp_P (command + 4, PSTR ("mode")) == 0) else if (strcmp_P (command + 4, PSTR ("mode")) == 0)
subCommand = MODE; subCommand = MODE;
else if (strcmp_P (command + 4, PSTR ("theme")) == 0)
subCommand = THEME;
else else
return false; return false;
@ -226,6 +229,32 @@ LEDControl_::focusHook (const char *command) {
} }
break; break;
} }
case THEME:
{
if (Serial.peek () == '\n') {
for (uint8_t idx = 0; idx < LED_COUNT; idx++) {
cRGB c = LEDControl.led_get_crgb_at (idx);
Focus.printColor (c);
Focus.printSpace ();
}
Serial.println ();
break;
}
uint8_t idx = 0;
while (idx < LED_COUNT && Serial.peek() != '\n') {
cRGB color;
color.r = Serial.parseInt ();
color.g = Serial.parseInt ();
color.b = Serial.parseInt ();
LEDControl.led_set_crgb_at (idx, color);
idx++;
}
break;
}
} }
return true; return true;

@ -59,4 +59,5 @@ extern LEDControl_ LEDControl;
#define FOCUS_HOOK_LEDCONTROL FOCUS_HOOK (LEDControl.focusHook, \ #define FOCUS_HOOK_LEDCONTROL FOCUS_HOOK (LEDControl.focusHook, \
"led.at\n" \ "led.at\n" \
"led.setAll\n" \ "led.setAll\n" \
"led.theme\n" \
"led.mode") "led.mode")

Loading…
Cancel
Save