summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2015-01-09 05:13:43 +0100
committerDavid Lamparter <equinox@diac24.net>2015-01-09 05:13:43 +0100
commite00e1f3f80c1235570975f3a75fcff9c9456c7e7 (patch)
tree368e2ee4ccc058332e67a3246da531904b4a63b5
parent8b5d8e578d8244e330e93c717e4e47ad0963dbd5 (diff)
lightctrl: abstract some stuff
-rw-r--r--dim.c8
-rw-r--r--lightctrl.c5
2 files changed, 9 insertions, 4 deletions
diff --git a/dim.c b/dim.c
index 78ae5a3..21ea528 100644
--- a/dim.c
+++ b/dim.c
@@ -12,11 +12,11 @@ struct switchcfg sw;
static uint8_t tast_curstate(void)
{
uint16_t sum = 0;
- sum += target[sw.targets0[0]];
- sum += target[sw.targets0[1]];
+ sum += target_get(sw.targets0[0]);
+ sum += target_get(sw.targets0[1]);
if (sw.tgt1active) {
- sum += target[sw.targets1[0]];
- sum += target[sw.targets1[1]];
+ sum += target_get(sw.targets1[0]);
+ sum += target_get(sw.targets1[1]);
sum++;
sum >>= 1;
}
diff --git a/lightctrl.c b/lightctrl.c
index 5b5e1c0..7c0f1e9 100644
--- a/lightctrl.c
+++ b/lightctrl.c
@@ -31,6 +31,11 @@ const uint8_t __signature[3] __attribute__((section (".signature"), used)) =
static uint8_t target[0x40] = { 0 };
static uint8_t cooldown[0x40] = { 0 };
static void target_set(uint8_t dst, uint8_t val);
+#define target_get(idx) target[idx]
+/* [0] bit 0 => addr 0, [0] bit 1 => addr 1, etc. */
+static uint8_t dali_map[8];
+#define target_present(addr) (dali_map[(addr) >> 3] & (1 << ((addr) & 0x07)))
+#define target_set_present(addr) dali_map[(addr) >> 3] |= 1 << ((addr) & 0x7)
#include "uart.c"
#include "tick.c"