zunoStartDeviceConfiguration()
This function instructs Z-Uno to start channels. Use it to configure your Z-Uno right from the user code.
After changing the number or types of channels or association groups Z-Uno must be excluded and included back. Z-Uno will not adopt any channel type change without being excluded.
zunoStartDeviceConfiguration()
Z-Uno dynamic configuration uses the following functions:
- zunoStartDeviceConfiguration(),
- zunoAddChannel(),
- zunoSetZWChannel(),
- zunoAppendChannelHandler(),
- zunoAddAssociation(),
- zunoCommitCfg(),
Do not forget to enable all channel types you will use in your sketch with ZUNO_ENABLE(WITH_CC_...);
In runtime you can get channel values using macro ZUNO_CFG_CHANNEL(CHANNEL):
- CHANNEL Z-Uno channel number. Value in range [0;31]. You can examine how many channels you have using macro ZUNO_CFG_CHANNEL_COUNT.
- ZUNO_CFG_CHANNEL(CHANNEL).type Represents channel type. See types list in zunoAddChannel description.
- ZUNO_CFG_CHANNEL(CHANNEL).sub_type and ZUNO_CFG_CHANNEL(CHANNEL).params - optional parameters for some channel types
- ZUNO_CFG_CHANNEL(CHANNEL).zw_channel Represent Z-Wave Multichannel intance of described channel.
Example #1
Below is the Radio Blink sketch from Z-Uno paper manual made in a static getter/setter style
byte dimmerValue = 99;
ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_MULTILEVEL(getSwitchMultilevelValue, setSwitchMultilevelValue));
ZUNO_SETUP_ASSOCIATIONS(ZUNO_ASSOCIATION_GROUP_SET_VALUE, ZUNO_ASSOCIATION_GROUP_SET_VALUE_AND_DIM)
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(dimmerValue*10);
digitalWrite(LED_BUILTIN, LOW);
delay(dimmerValue*10);
}
void setSwitchMultilevelValue(byte newValue) {
dimmerValue = newValue;
}
byte getSwitchMultilevelValue(void) {
return dimmerValue;
}
Example 2
Below is the Radio Blink sketch from Z-Uno paper manual made in dynamic getter/setter style
// Define special command class macroses
// We use SwitchMultilevel and Basic command classes for dimmer, so we have to enable them:
ZUNO_ENABLE(WITH_CC_SWITCH_MULTILEVEL WITH_CC_BASIC)
byte dimmerValue = 99;
// create a structure to store getter & setter handlers
static zuno_handler_single_gettersetter_t switch_multilevel_handlers={(void*)&getSwitchMultilevelValue,(void*)&setSwitchMultilevelValue};
void setup() {
if(zunoStartDeviceConfiguration()) { // Check if we are able to reconfigure the device.
// Device can change its characterictics ONLY if it's not included
zunoAddChannel(ZUNO_SWITCH_MULTILEVEL_CHANNEL_NUMBER, 0, 0); // Add SWITCH_MULTILEVEL channel. It doesn't require any optional parameters.
zunoSetZWChannel(0, 0); // Setup Z-Wave Multichannel instance, 0 - main EndPoint
zunoAddAssociation(ZUNO_ASSOC_BASIC_SET_NUMBER, 0);// Add Association for Basic control
zunoAddAssociation(ZUNO_ASSOC_BASIC_SET_AND_DIM_NUMBER, 0);// Add Association for Basic and SwitchMultilevel control
zunoCommitCfg(); // Apply settings ^^^
}
// Bind handler functions for 0 channel. You have to setup handler every time device powers on
zunoAppendChannelHandler(0, 1, CHANNEL_HANDLER_SINGLE_GETTERSETTER, (void*)&switch_multilevel_handlers);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(dimmerValue*10);
digitalWrite(LED_BUILTIN, LOW);
delay(dimmerValue*10);
}
static void setSwitchMultilevelValue(byte newValue) {
dimmerValue = newValue;
}
static byte getSwitchMultilevelValue(void) {
return dimmerValue;
}
Example 3
Below is the Radio Blink sketch from Z-Uno paper manual made in static variable style
byte dimmerValue = 99;
ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_MULTILEVEL(dimmerValue, NULL));
ZUNO_SETUP_ASSOCIATIONS(ZUNO_ASSOCIATION_GROUP_SET_VALUE, ZUNO_ASSOCIATION_GROUP_SET_VALUE_AND_DIM)
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(dimmerValue*10);
digitalWrite(LED_BUILTIN, LOW);
delay(dimmerValue*10);
}
Example 4
Below is the Radio Blink sketch from Z-Uno paper manual made in dynamic variable style
// Define special command class macroses
// We use SwitchMultilevel and Basic command classes for dimmer, so we have to enable them:
ZUNO_ENABLE(WITH_CC_SWITCH_MULTILEVEL WITH_CC_BASIC)
byte dimmerValue = 99;
void setup() {
if(zunoStartDeviceConfiguration()) { // Check if we are able to reconfigure the device.
// Device can change its characterictics ONLY if it's not included
zunoAddChannel(ZUNO_SWITCH_MULTILEVEL_CHANNEL_NUMBER, 0, 0); // Add SWITCH_MULTILEVEL channel. It doesn't require any optional parameters.
zunoSetZWChannel(0, 0); // Setup Z-Wave Multichannel instance, 0 - main EndPoint
zunoAddAssociation(ZUNO_ASSOC_BASIC_SET_NUMBER, 0);// Add Association for Basic control
zunoAddAssociation(ZUNO_ASSOC_BASIC_SET_AND_DIM_NUMBER, 0);// Add Association for Basic and SwitchMultilevel control
zunoCommitCfg(); // Apply settings ^^^
}
// Bind variable "dimmerValue" for 0 channel. You have to map the variable every time the device powers on
zunoAppendChannelHandler(0, 1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&dimmerValue);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(dimmerValue*10);
digitalWrite(LED_BUILTIN, LOW);
delay(dimmerValue*10);
}