ZUNO_SWITŠ”H_BINARY()

This macro is used to setup binary switch channel for Z-Uno board using ZUNO_SETUP_CHANNELS. Z-Uno understands two ways to define a channel: using getter function and using a variable.
  • With getter definition the getter function is called each time a value is requested. This allows to do some calculus before returning a value.
  • With variable definition Z-Uno will automatically return the variable status. This allows to minimize your code.
ZUNO_SWITCH_BINARY(getter, setter) getter pointer to a user defined function, which is supposed to return current value for this channel. setter pointer to a user defined function, which is called when new value is received for this channel. Functions getter should return 0 for Off and any non-zero value for On BYTE getter(void) Functions setter accepts next values:
  • 0 for off
  • 255 for on
void setter(BYTE value) Channel generated using this macro will have Z-Wave Device Class GENERIC_TYPE_SWITCH_BINARY / SPECIFIC_TYPE_POWER_SWITCH_BINARY with Switch Binary Command Class.
        ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_BINARY(getterFunction, setterFunction));
           
void setup() {
    ...
}

void loop() {
    ...
}

BYTE getterFunction() {
    return currentValue;
}

void setterFunction(BYTE newValue) {
    ...
}
        
    
ZUNO_SWITCH_BINARY(variable, NULL) variable variable that stores the current value for this channel. 0 for Off and any non-zero value for On. Variable change can be detected using function zunoIsChannelUpdated(channelNum).
        ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_BINARY(lightStatus, NULL));

byte lightStatus = 0;

void setup() {
    ...
}

void loop() {
    ...
    if (zunoIsChannelUpdated(1)) {
        // Do something on new value received via Z-Wave
    }
    ...
    lightStatus = ...;
    ...
}