ZUNO_SWITCH_MULTILEVEL()
This macro is used to setup multilevel 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_MULTILEVEL(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. Setter function will accept one parameter with values from 0 (off) to 99 (maximum)
Functions getter should return 0-99, where 0 is Off and 99 is maximal brightness
BYTE getter(void)
Functions setter accepts values 0-99 (0 is Off, 99 is maximal value) and 255 (usually means On on previous brightness level, this behavior can be different depending on user sketch)
void setter(BYTE value)
Channel generated using this macro will have Z-Wave Device Class GENERIC_TYPE_SWITCH_MULTILEVEL / SPECIFIC_TYPE_POWER_SWITCH_MULTILEVEL with Switch Multilevel Command Class.
ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_MULTILEVEL(getterFunction, setterFunction))
void setup() {
...
}
void loop() {
...
}
BYTE getterFunction() {
return currentValue;
}
void setterFunction(BYTE newValue) {
...
}
ZUNO_SWITCH_MULTILEVEL(variable, NULL)
variable
variable that stores the current value for this channel. 0-99, where 0 is Off and 99 is maximal brightness
Variable change can be detected using function zunoIsChannelUpdated(channelNum).
ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_MULTILEVEL(dimmerState, NULL))
byte dimmerState = 0;
void setup() {
...
}
void loop() {
...
dimmerState = ...;
...
}