summaryrefslogtreecommitdiff
path: root/lightctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'lightctrl.c')
-rw-r--r--lightctrl.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/lightctrl.c b/lightctrl.c
index 464a0ae..404ca33 100644
--- a/lightctrl.c
+++ b/lightctrl.c
@@ -27,6 +27,27 @@ const uint8_t __signature[3] __attribute__((section (".signature"), used)) =
#include "dim.c"
#include "can.c"
+static void can_rx_exec(void)
+{
+ if (can_rx_addr.b[0] == 0xcc
+ && (can_rx_addr.b[1] & 0xfb) == 0x08
+ && can_rx_addr.b[2] == 0x04
+ && can_rx_addr.b[3] == 0x7f
+ && (can_rx_dlc & 0x4f) == 1) {
+ uart_puts("-- SET\n");
+
+ if (!can_rx_data[0]) {
+ dim_state = 0;
+ dali_send(DALI_ADDR | 0x100);
+ } else {
+ if (!dim_state && can_rx_data[0])
+ dali_send(DALI_ADDR | 0x108);
+ dim_state = can_rx_data[0];
+ dali_send(DALI_ADDR | dim_state);
+ }
+ }
+}
+
int main(void)
{
DDRD |= (1 << D_LED1) | (1 << D_LED2 ) | (1 << D_TXD) | (1 << D_DALIO);
@@ -51,6 +72,11 @@ int main(void)
if (canint) {
canint = false;
can_int();
+
+ if (can_rx_addr.b[0]) {
+ can_rx_exec();
+ can_rx_addr.u = 0;
+ }
}
_delay_ms(5);
do_tick();