summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Kroll <jkroll@lavabit.com>2012-03-06 20:46:41 +0100
committerJohannes Kroll <jkroll@lavabit.com>2012-03-06 20:46:41 +0100
commit7fe5913b904880137f80ba4a4260039ba610776b (patch)
treeccdb86f0f93d09400e9216ec5c48b45961a9901e
parentf8bf5cf4bb61ef4b8c01c68dfc3fe826d9e91360 (diff)
begin coding shiftbrite support
-rw-r--r--command.c16
-rw-r--r--moodlamp.c2
2 files changed, 15 insertions, 3 deletions
diff --git a/command.c b/command.c
index 91489e6..0212ce9 100644
--- a/command.c
+++ b/command.c
@@ -23,6 +23,7 @@
#include "pwm.h"
#include "serial.h"
#include "util.h"
+#include "shiftbrite.h"
static void command_error(void)
{
@@ -49,9 +50,18 @@ static void handle_immediate(char *buffer, uint16_t len)
command_error();
return;
}
-
- pwm_set_rgb(new_red, new_green, new_blue);
- command_success();
+
+ 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 {
+ pwm_set_rgb(new_red, new_green, new_blue);
+ command_success();
+ }
}
uint16_t serial_rx_cb(char *buffer, uint16_t len)
diff --git a/moodlamp.c b/moodlamp.c
index 2cdd5b5..6392a4e 100644
--- a/moodlamp.c
+++ b/moodlamp.c
@@ -21,11 +21,13 @@
#include "serial.h"
#include "pwm.h"
+#include "shiftbrite.h"
int main(void)
{
serial_init();
pwm_init();
+ sb_init();
sei();
pwm_worker_loop();