summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'command.c')
-rw-r--r--command.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/command.c b/command.c
index 0212ce9..8e0cc15 100644
--- a/command.c
+++ b/command.c
@@ -22,6 +22,7 @@
#include "pwm.h"
#include "serial.h"
+#include "sequencer.h"
#include "util.h"
#include "shiftbrite.h"
@@ -50,20 +51,49 @@ static void handle_immediate(char *buffer, uint16_t len)
command_error();
return;
}
-
+
+ sequencer_disable();
uint8_t sb_no;
if ((len > sizeof("irrggbb\r") - 1)
&& parse_hex_number(&buffer[7], &sb_no)==0
&& sb_no) {
sb_setcolor(sb_no-1, new_red, new_green, new_blue);
command_success();
- }
- else {
+ } else {
pwm_set_rgb(new_red, new_green, new_blue);
command_success();
- }
+ }
}
+static void handle_sequence(char *buffer, uint16_t len)
+{
+ uint8_t steps = 0;
+
+ buffer += 1;
+ len -= 1;
+
+ while (len >= 10) {
+ uint8_t tout, lamp, new_red, new_blue, new_green;
+
+ if (parse_hex_number(&buffer[0], &tout)
+ || parse_hex_number(&buffer[2], &lamp)
+ || parse_hex_number(&buffer[4], &new_red)
+ || parse_hex_number(&buffer[6], &new_blue)
+ || parse_hex_number(&buffer[8], &new_green)) {
+ command_error();
+ return;
+ }
+
+ sequencer_set(steps, tout, lamp, new_red, new_blue, new_green);
+ steps += 1;
+ buffer += 10;
+ len -= 10;
+ }
+ sequencer_len(steps);
+ sequencer_enable();
+}
+
+
uint16_t serial_rx_cb(char *buffer, uint16_t len)
{
switch (buffer[len - 1]) {
@@ -86,6 +116,10 @@ uint16_t serial_rx_cb(char *buffer, uint16_t len)
serial_toggle_verbose();
command_success();
break;
+ case 's':
+ case 'S':
+ handle_sequence(buffer, len);
+ break;
default:
command_error();
}