If I wrap the rf12recvDone block at the end in while(1), I'm able to skip through the steps remotely. Seems like it's looping too fast for the rf12recvDone function to get data. Anyone have any suggestions or improvements? Thanks!
totalsteps = 3;
while(step<=totalsteps) {
switch (step) {
case 1:
if (!(cyclecount % 1)) { //only update display each 1000th time thru loop //TODO increase value when process is running fast (ie checking time properly)
float currenttemp1F = sensors.getTempC(sensor1);
float currenttemp2F = sensors.getTempC(sensor2);
stepData buf;
buf.rfcurrenttemp1F = currenttemp1F;
buf.rfcurrenttemp2F = currenttemp2F; rf12recvDone();
if (rf12canSend()){
rf12sendStart(0, &buf, sizeof buf);
}
cyclecount++;
}
break;
case 2:
if (!(cyclecount % 1)) { //only update display each 1000th time thru loop //TODO increase value when process is running fast (ie checking time properly)
float currenttemp1F = sensors.getTempC(sensor1);
float currenttemp2F = sensors.getTempC(sensor2);
stepData buf;
buf.rfcurrenttemp1F = currenttemp1F;
buf.rfcurrenttemp2F = currenttemp2F; rf12recvDone();
if (rf12canSend()){
rf12sendStart(0, &buf, sizeof buf);
}
cyclecount++;
}
break;
case 3:
if (!(cyclecount % 1)) { //only update display each 1000th time thru loop //TODO increase value when process is running fast (ie checking time properly)
float currenttemp1F = sensors.getTempC(sensor1);
float currenttemp2F = sensors.getTempC(sensor2);
stepData buf;
buf.rfcurrenttemp1F = currenttemp1F;
buf.rfcurrenttemp2F = currenttemp2F; rf12recvDone();
if (rf12canSend()){
rf12sendStart(0, &buf, sizeof buf);
}
cyclecount++;
}
}
if (rf12recvDone()) {
//Serial.print(remoteincoming->jtChooseMenuItem);
remoteControl remoteincoming = (remoteControl) rf12data;
Serial.print("rf12recDone");
if (rf12crc == 0) {
if (remoteincoming->jtChooseMenuItem == '3')
{
if (testmode == 1) /// in testmode this will allow me to skip to the next step and is configured elsewhere
{
digitalWrite(PinElementHlt, LOW);
digitalWrite(PinPumpHlt, LOW);
digitalWrite(PinPumpMT, LOW);
digitalWrite(PinMotorMT, LOW);
step++;
msgdisplayed=0;
timercalculated=0; // next step's timer not yet calculated
}
}
}
}
} //end loop
