Sync work
This commit is contained in:
parent
43d1811d2e
commit
d4e346c5a0
7 changed files with 241 additions and 28 deletions
|
|
@ -69,37 +69,37 @@ void receive(const MyMessage* mymsg)
|
|||
// We only expect one type of message from controller. But we better check anyway.
|
||||
if (mymsg->type == V_STATUS) {
|
||||
sensor = mymsg->sensor;
|
||||
if (sensor == 1)
|
||||
if (sensor == 0)
|
||||
relay = (relay & 0xFE) + ((mymsg->data[0]=='1')?1:0);
|
||||
if (sensor == 2)
|
||||
if (sensor == 1)
|
||||
relay = (relay & 0xFD) + ((mymsg->data[0]=='1')?2:0);
|
||||
if (sensor == 3)
|
||||
if (sensor == 2)
|
||||
relay = (relay & 0xFB) + ((mymsg->data[0]=='1')?4:0);
|
||||
if (sensor == 4)
|
||||
if (sensor == 3)
|
||||
relay = (relay & 0xF7) + ((mymsg->data[0]=='1')?8:0);
|
||||
if (sensor == 5)
|
||||
if (sensor == 4)
|
||||
relay = (relay & 0xEF) + ((mymsg->data[0]=='1')?0x10:0);
|
||||
if (sensor == 6)
|
||||
if (sensor == 5)
|
||||
relay = (relay & 0xDF) + ((mymsg->data[0]=='1')?0x20:0);
|
||||
if (sensor == 7)
|
||||
if (sensor == 6)
|
||||
relay = (relay & 0xBF) + ((mymsg->data[0]=='1')?0x40:0);
|
||||
if (sensor == 8)
|
||||
if (sensor == 7)
|
||||
relay = (relay & 0x7F) + ((mymsg->data[0]=='1')?0x80:0);
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void present_node(void) {
|
||||
present(NODE_SENSOR_ID, S_ARDUINO_NODE,"Nuvoton Relay Board");
|
||||
sendSketchInfo("Relay_Nuvoton", "1.1");
|
||||
present(1, S_BINARY, "Relay 1");
|
||||
present(2, S_BINARY, "Relay 2");
|
||||
present(3, S_BINARY, "Relay 3");
|
||||
present(4, S_BINARY, "Relay 4");
|
||||
present(5, S_BINARY, "Relay 5");
|
||||
present(6, S_BINARY, "Relay 6");
|
||||
present(7, S_BINARY, "Relay 7");
|
||||
present(8, S_BINARY, "Relay 8");
|
||||
present(NODE_SENSOR_ID, S_ARDUINO_NODE,"2.3.2");
|
||||
sendSketchInfo("Relay_Nuvoton", "1.2");
|
||||
present(0, S_BINARY, "Relay 1");
|
||||
present(1, S_BINARY, "Relay 2");
|
||||
present(2, S_BINARY, "Relay 3");
|
||||
present(3, S_BINARY, "Relay 4");
|
||||
present(4, S_BINARY, "Relay 5");
|
||||
present(5, S_BINARY, "Relay 6");
|
||||
present(6, S_BINARY, "Relay 7");
|
||||
present(7, S_BINARY, "Relay 8");
|
||||
registerNode();
|
||||
delay(20);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue