-
aleconakad
- Posts: 68
- Joined: 18 Jan 2016 15:25
Post
by aleconakad »
I want in my sketch to revert the relays defined in channel 1 to 3 to the default state after a restart event. I do it like this:
Code: Select all
void setup() {
relais1_state = 0;
relais2_state = 0;
relais3_state = 0;
zunoSendReport (1);
zunoSendReport (2);
zunoSendReport (3);
}
void loop() {
...
}
byte relais1_getter() {
if (relais1_state) {
return ZUNO_SWITCHED_ON;
} else {
return ZUNO_SWITCHED_OFF;
}
}
byte relais2_getter() {
if (relais2_state ) {
return ZUNO_SWITCHED_ON;
} else {
return ZUNO_SWITCHED_OFF;
}
}
byte relais3_getter() {
if (relais3_state ) {
return ZUNO_SWITCHED_ON;
} else {
return ZUNO_SWITCHED_OFF;
}
}
is this allowed? does it have any side effects? will the Z-Wave stack be fully initialized before running code from the setup() routine?
thanks
-
PoltoS
- Posts: 7579
- Joined: 26 Jan 2011 19:36
Post
by PoltoS »
No! As stated in the documentation, setup () bus only for hardware initialization.
Define a variable book firstBoot = True and in the loop:
if (firstBoot) { firstBoot = false; zunoSendReport(....); ... }