void RemoteControl::sendTimerDetailMenu(int timerIdx, boolean update){
if (update) serialPort->print("{:"); else serialPort->print(F("{.Details"));
serialPort->print("|p0");
serialPort->print(timerIdx);
serialPort->print("~Use ");
sendYesNo(robot->timer[timerIdx].active);
int startm = time2minutes(robot->timer[timerIdx].startTime);
int stopm = time2minutes(robot->timer[timerIdx].stopTime);
String sidx = String(timerIdx);
sendSlider("p1"+sidx, F("Start hour "), robot->timer[timerIdx].startTime.hour, "", 1, 23, 0);
sendSlider("p2"+sidx, F("Start minute "), robot->timer[timerIdx].startTime.minute, "", 1, 59, 0);
sendSlider("p3"+sidx, F("Stop hour "), robot->timer[timerIdx].stopTime.hour, "", 1, 23, 0);
sendSlider("p4"+sidx, F("Stop minute "), robot->timer[timerIdx].stopTime.minute, "", 1, 59, 0);
for (int i=0; i < 7; i++){
serialPort->print("|p5");
serialPort->print(timerIdx);
serialPort->print(i);
serialPort->print("~");
if ((robot->timer[timerIdx].daysOfWeek >> i) & 1) serialPort->print("(X) ");
else serialPort->print("( ) ");
serialPort->print(dayOfWeek[i]);
}
serialPort->print("|p9");
serialPort->print(timerIdx);
serialPort->print(F("~Set to current time"));
sendSlider("p8"+sidx, F("Area "), robot->timer[timerIdx].Area_Timer, "", 1, 5, 0);
serialPort->println("}");
}
void RemoteControl::processTimerDetailMenu(String pfodCmd){
timehm_t time;
boolean checkStop = false;
boolean checkStart = false;
int startmin, stopmin;
int timerIdx = pfodCmd[2]-'0';
if (pfodCmd.startsWith("p0")) robot->timer[timerIdx].active = !robot->timer[timerIdx].active;
else if (pfodCmd.startsWith("p1")) { processSlider(pfodCmd, robot->timer[timerIdx].startTime.hour, 1); checkStop = true; }
else if (pfodCmd.startsWith("p2")) { processSlider(pfodCmd, robot->timer[timerIdx].startTime.minute, 1); checkStop = true; }
else if (pfodCmd.startsWith("p3")) { processSlider(pfodCmd, robot->timer[timerIdx].stopTime.hour, 1); checkStart = true; }
else if (pfodCmd.startsWith("p4")) { processSlider(pfodCmd, robot->timer[timerIdx].stopTime.minute, 1); checkStart = true; }
else if (pfodCmd.startsWith("p8")) { processSlider(pfodCmd, robot->timer[timerIdx].Area_Timer, 1);checkStart = false; }
else if (pfodCmd.startsWith("p9")) {
robot->timer[timerIdx].startTime = robot->datetime.time; checkStop = true;
robot->timer[timerIdx].daysOfWeek = (1 << robot->datetime.date.dayOfWeek);
}
else if (pfodCmd.startsWith("p5")) {
int day = pfodCmd[3]-'0';
robot->timer[timerIdx].daysOfWeek = robot->timer[timerIdx].daysOfWeek ^ (1 << day);
}
if (checkStop){
// adjust start time
startmin = min(1434, time2minutes(robot->timer[timerIdx].startTime));
minutes2time(startmin, time);
robot->timer[timerIdx].startTime = time;
// check stop time
stopmin = time2minutes(robot->timer[timerIdx].stopTime);
stopmin = max(stopmin, startmin + 5);
minutes2time(stopmin, time);
robot->timer[timerIdx].stopTime = time;
} else if (checkStart){
// adjust stop time
stopmin = max(5, time2minutes(robot->timer[timerIdx].stopTime));
minutes2time(stopmin, time);
robot->timer[timerIdx].stopTime = time;
// check start time
startmin = time2minutes(robot->timer[timerIdx].startTime);
startmin = min(startmin, stopmin - 5);
minutes2time(startmin, time);
robot->timer[timerIdx].startTime = time;
}
sendTimerDetailMenu(timerIdx, true);
}