summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2015-01-13 22:42:19 +0100
committerDavid Lamparter <equinox@diac24.net>2015-01-13 23:50:33 +0100
commit86df55b4f275855381a47d6b2fc4b0a0c9959776 (patch)
tree64a179394ff9f690766dc9edc0ed43a7c2e89490
parent455913cca424976c03bc4b87500d69e115b2b517 (diff)
lightctrl_v2: allow disabling hw switchHEADmaster
-rw-r--r--dim.c10
-rw-r--r--lightctrl_v2.c7
2 files changed, 14 insertions, 3 deletions
diff --git a/dim.c b/dim.c
index 21ea528..424615a 100644
--- a/dim.c
+++ b/dim.c
@@ -3,11 +3,13 @@ struct switchcfg {
uint8_t targets1[2];
uint8_t lastclick;
int8_t dir;
- uint8_t tgt1active;
+ __extension__ uint8_t tgt1active : 1;
+ __extension__ uint8_t enabled : 1;
+ __extension__ uint8_t unused : 6;
};
#define T_DOUBLECLICK 75
-struct switchcfg sw;
+static struct switchcfg sw;
static uint8_t tast_curstate(void)
{
@@ -27,6 +29,9 @@ static uint8_t tast_curstate(void)
static void tast_applystate(uint8_t all, uint8_t target)
{
+ if (!sw.enabled)
+ return;
+
target_set(sw.targets0[0], target);
target_set(sw.targets0[1], target);
if (all) {
@@ -120,4 +125,5 @@ static void dim_init(void)
sw.lastclick = 0xff;
sw.dir = 1;
sw.tgt1active = 0;
+ sw.enabled = 1;
}
diff --git a/lightctrl_v2.c b/lightctrl_v2.c
index 22dc0b2..f9ff43a 100644
--- a/lightctrl_v2.c
+++ b/lightctrl_v2.c
@@ -166,12 +166,17 @@ static void can_handle_light(uint16_t sublab_addr)
/* - 7 allows overlapping writes to a nonaligned address.
* "base" below will start out at 0xf9~0xff in that case */
- if (sublab_addr < CANA_DALI_BASE - 7)
+ if (sublab_addr < CANA_DALI_BASE - 8)
return;
uint8_t base = sublab_addr - CANA_DALI_BASE, len = can_rx_len(), pos;
for (pos = 0; pos < len; pos++) {
uint8_t dst = base + pos, val;
+ if (dst == 0xff) {
+ /* bus element 43f: hw switch disable */
+ sw.enabled = can_rx_data[pos] != 0;
+ continue;
+ }
if (dst >= 0x40)
continue;
val = can_rx_data[pos];