Page 3 of 3
Re: Controller does not get ack from z-uno
Posted: 04 Dec 2017 12:22
by sega66
petergebruers
I tried your code for 6 switches with debugging. I even tried it for 12 switches. All works well and the delay does not exceed 1 sec.
Problems start if I add sensors: ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, getter1)
Then a big delay begins...
Re: Controller does not get ack from z-uno
Posted: 04 Dec 2017 12:48
by sega66
knst08
You did so that each cycle call finds one channel. Could you write how to do this in relation to my code ..
Code: Select all
#define BTN_1_PIN 8 //
#define BTN_2_PIN 7 //
byte lastButtonState1;
byte lastButtonState2;
#define SWITCH_ON 0xff
#define SWITCH_OFF 0
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_ALWAYS_AWAKE);
ZUNO_SETUP_CHANNELS(
ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, getter1),
ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, getter2)
);
byte currenButtonState1;
byte currenButtonState2;
void setup() {
pinMode(BTN_1_PIN, INPUT_PULLUP); // set button pin as input
pinMode(BTN_2_PIN, INPUT_PULLUP); // set button pin as input
}
void loop()
{
currenButtonState1 = digitalRead(BTN_1_PIN);
if (currenButtonState1 != lastButtonState1) { // if state changes
lastButtonState1 = currenButtonState1; // save new state
zunoSendReport(9);
}
currenButtonState2 = digitalRead(BTN_2_PIN);
if (currenButtonState2 != lastButtonState2) { // if state changes
lastButtonState2 = currenButtonState2; // save new state
zunoSendReport(10);
}
}
byte getter1() {
if (lastButtonState1 == 0) { // if button is pressed
return 0xff; // return "Triggered" state to the controller
} else { // if button is released
return 0; // return "Idle" state to the controller
}
}
byte getter2() {
if (lastButtonState2 == 0) { // if button is pressed
return 0xff; // return "Triggered" state to the controller
} else { // if button is released
return 0; // return "Idle" state to the controller
}
}
Re: Controller does not get ack from z-uno
Posted: 05 Dec 2017 11:06
by sega66
knst08
Could you please lay out your code completely. I can not figure out how to transfer only one state per cycle.
Code: Select all
void ZWaveController::main(long millis){
if (millis - timer>100 && !context->zwaveLearning){
lastReportedChannel++;
if (lastReportedChannel == 11) lastReportedChannel=1;
if(lastReportedChannel==1){
if(lastReportedRelayState[lastReportedChannel] != (context->bypass?255:0) ) {
report(lastReportedChannel);
lastReportedRelayState[lastReportedChannel] = (context->bypass?255:0);
}
}
else if(lastReportedChannel<10){
byte channelMask = 1 << (lastReportedChannel-2);
boolean currentValue = ((context->requestedRelayOnOff & channelMask) == channelMask ? 255 :0);
if(lastReportedRelayState[lastReportedChannel] != currentValue) {
report(lastReportedChannel);
lastReportedRelayState[lastReportedChannel] = currentValue;
}
}
else if (lastPower!=context->power && (millis - lastPowerReport>30000) ){
report(lastReportedChannel);
lastPowerReport=millis ;
lastPower = context->power;
}
timer=millis ;
}
if(learningStart!=0 && millis - learningStart>learningTime*1000){
context->zwaveLearning=false;
learningStart=0;
}
}