|
|
@ -60,20 +60,22 @@ |
|
|
|
static uint8_t node_id PROGMEM= { NODE_ID }; |
|
|
|
static OW_switch_t switches[N_SWITCHES] PROGMEM={ |
|
|
|
// nick, addr[8], event_tag[sw1, sw2]
|
|
|
|
{ 255, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0, 0, 0, 0 } }, |
|
|
|
{ 201, { 0x12, 0x5b, 0x27, 0x50, 0x0, 0x0, 0x0, 0x26 }, { 1, 11, 2, 12 } }, // Flur -> Bad
|
|
|
|
// { 202, { 0x12, 0xF7, 0x95, 0x4F, 0x0, 0x0, 0x0, 0x69 }, { 3, 4 } },
|
|
|
|
// { 203, { 0x12, 0x68, 0x31, 0x67, 0x0, 0x0, 0x0, 0xBC }, { 5, 6 } },
|
|
|
|
{ 204, { 0x12, 0x5E, 0xFF, 0x55, 0x0, 0x0, 0x0, 0x2C }, { 3, 3, 7, 7 } }, // Treppe u??
|
|
|
|
{ 205, { 0x12, 0x7B, 0x44, 0x4D, 0x0, 0x0, 0x0, 0x6A }, { 7, 7, 3, 3 } }, // Treppe o
|
|
|
|
{ 204, { 0x12, 0x5E, 0xFF, 0x55, 0x0, 0x0, 0x0, 0x2C }, { 0, 0, 7, 7 } }, // Treppe Unten
|
|
|
|
{ 205, { 0x12, 0x7B, 0x44, 0x4D, 0x0, 0x0, 0x0, 0x6A }, { 7, 7, 3, 3 } }, // Treppe Oben
|
|
|
|
{ 101, { 0x12, 0xC1, 0x4E, 0x67, 0x0, 0x0, 0x0, 0x74 }, { 3, 3, 0, 0 } }, // Flur -> Flur
|
|
|
|
{ 102, { 0x12, 0xA9, 0x97, 0x4F, 0x0, 0x0, 0x0, 0xD7 }, { 4, 4, 0, 0 } }, // Inka
|
|
|
|
{ 011, { 0x12, 0x9A, 0x94, 0x4F, 0x0, 0x0, 0x0, 0x2D }, { 6, 6, 255, 254 } }, // Bjarne
|
|
|
|
{ 012, { 0x12, 0x2F, 0x98, 0x4F, 0x0, 0x0, 0x0, 0xE0 }, { 8, 8, 0, 0 } }, // SZ
|
|
|
|
{ 255, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0, 0, 0, 0 } }, |
|
|
|
{ 0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0, 0, 0, 0 } } |
|
|
|
}; |
|
|
|
static uint8_t switches_state[N_SWITCHES]; |
|
|
|
static outputs_t outputs[N_OUTPUTS] PROGMEM={ |
|
|
|
|
|
|
|
// type, address(PIN), initial value, inverted
|
|
|
|
{ GPIO, 0, 0, true }, // 0 Bad Decke
|
|
|
|
{ GPIO, 1, 0, true }, // 1 Bad Spiegel
|
|
|
|
{ GPIO, 23, 255, true }, // 2 Flur Oben
|
|
|
@ -92,26 +94,26 @@ static uint8_t outputs_state[N_OUTPUTS]; |
|
|
|
static event_t tx_events[N_EVENTS] PROGMEM={ |
|
|
|
// | --- ID --- |
|
|
|
|
// tag, prio, dst, cmd, data
|
|
|
|
{ 1, 0x03, 0x01, 0x0, 0x01}, |
|
|
|
{ 2, 0x03, 0x01, 0x0, 0x02}, |
|
|
|
{ 3, 0x03, 0x01, 0x03, 0x03}, |
|
|
|
{ 4, 0x03, 0x01, 0x03, 0x04}, |
|
|
|
{ 5, 0x03, 0x01, 0x03, 0x05}, |
|
|
|
{ 6, 0x03, 0x01, 0x03, 0x06}, |
|
|
|
{ 7, 0x03, 0x01, 0x03, 0x07}, |
|
|
|
{ 8, 0x03, 0x01, 0x03, 0x08}, |
|
|
|
{ 11, 0x03, 0x01, 0x01, 0x01}, |
|
|
|
{ 12, 0x03, 0x01, 0x01, 0x02}, |
|
|
|
{ 1, 0x03, 0x01, OFF, 0x01}, |
|
|
|
{ 2, 0x03, 0x01, OFF, 0x02}, |
|
|
|
{ 3, 0x03, 0x01, TOGGLE, 0x03}, |
|
|
|
{ 4, 0x03, 0x01, TOGGLE, 0x04}, |
|
|
|
{ 5, 0x03, 0x01, TOGGLE, 0x05}, |
|
|
|
{ 6, 0x03, 0x01, TOGGLE, 0x06}, |
|
|
|
{ 7, 0x03, 0x01, TOGGLE, 0x07}, |
|
|
|
{ 8, 0x03, 0x01, TOGGLE, 0x08}, |
|
|
|
{ 11, 0x03, 0x01, ON, 0x01}, |
|
|
|
{ 12, 0x03, 0x01, ON, 0x02}, |
|
|
|
{ 255, 0x03, 0xff, OFF, 0x09}, |
|
|
|
{ 254, 0x03, 0xff, ON, 0x09}, |
|
|
|
{ 10, 0x03, 0xff, 0x03, 0x01}, |
|
|
|
{ 10, 0x03, 0xff, 0x03, 0x02}, |
|
|
|
{ 10, 0x03, 0xff, 0x03, 0x03}, |
|
|
|
{ 10, 0x03, 0xff, 0x03, 0x04}, |
|
|
|
{ 10, 0x03, 0xff, 0x03, 0x05}, |
|
|
|
{ 10, 0x03, 0xff, 0x03, 0x06}, |
|
|
|
{ 10, 0x03, 0xff, 0x03, 0x07}, |
|
|
|
{ 10, 0x03, 0xff, 0x03, 0x08}, |
|
|
|
{ 10, 0x03, 0xff, TOGGLE, 0x01}, |
|
|
|
{ 10, 0x03, 0xff, TOGGLE, 0x02}, |
|
|
|
{ 10, 0x03, 0xff, TOGGLE, 0x03}, |
|
|
|
{ 10, 0x03, 0xff, TOGGLE, 0x04}, |
|
|
|
{ 10, 0x03, 0xff, TOGGLE, 0x05}, |
|
|
|
{ 10, 0x03, 0xff, TOGGLE, 0x06}, |
|
|
|
{ 10, 0x03, 0xff, TOGGLE, 0x07}, |
|
|
|
{ 10, 0x03, 0xff, TOGGLE, 0x08}, |
|
|
|
|
|
|
|
// { 0x01, 0x0CFF0103, 1, { 0xDE, 0xAD } },
|
|
|
|
// { 0x01, 0x0102DEAD, 2, { 0xDE, 0xAD } },
|
|
|
@ -144,6 +146,8 @@ static action_t action_map[N_ACTIONS] PROGMEM={ |
|
|
|
#define DEBUG_WRITE(a) |
|
|
|
#endif /* DEBUG */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t led = LED; |
|
|
|
uint8_t state; |
|
|
|
uint8_t pin_state; |
|
|
@ -154,6 +158,7 @@ Metro METRO_OW_read = Metro(METRO_OW_read_tick); |
|
|
|
Metro METRO_OW_search = Metro(METRO_OW_search_tick); |
|
|
|
// CAN bus
|
|
|
|
FlexCAN CANbus(CAN_speed); |
|
|
|
// FLEXCAN0_MCR &= ~FLEXCAN_MCR_SRX_DIS;
|
|
|
|
// OneWire
|
|
|
|
uint8_t addr[8]; |
|
|
|
uint8_t buffer[DS2406_BUF_LEN]; |
|
|
@ -203,7 +208,7 @@ uint8_t read_DS2406(uint8_t* addr) { |
|
|
|
OW_1.write(DS2406_CHANNEL_CONTROL1,1); |
|
|
|
OW_1.write(DS2406_CHANNEL_CONTROL2,1); |
|
|
|
tmp = OW_1.read(); |
|
|
|
OW_1.reset(); |
|
|
|
//OW_1.reset();
|
|
|
|
#if DEBUG |
|
|
|
PrintBytes(&tmp,1,1); |
|
|
|
#endif /* DEBUG */ |
|
|
@ -355,6 +360,7 @@ void loop(void) |
|
|
|
if (METRO_OW_read.check() ) { |
|
|
|
for (uint8_t s_idx = 0; switches[s_idx].nick != 0; ++s_idx ){ |
|
|
|
readout = read_DS2406(switches[s_idx].addr); |
|
|
|
//if ((switches_state[s_idx] != readout) && (readout & 1<<7)) {
|
|
|
|
if (switches_state[s_idx] != readout) { |
|
|
|
tmp = readout ^ switches_state[s_idx]; |
|
|
|
switches_state[s_idx] = readout; |
|
|
|