gestion mardi/vendredi

This commit is contained in:
Clement 2023-11-18 19:51:23 +01:00
parent 2e593cb4e0
commit 92493c7d8f

View File

@ -57,7 +57,7 @@ void Program::sendTime(String timeEnd){
void Program::loop() {
switch (this->menu){
case MainMenu::INITIAL_STATE: // feault state
case MainMenu::INITIAL_STATE: // default state
this->encoder->resetValue();
this->ledLib->actLed(0,0);
break;
@ -67,6 +67,7 @@ void Program::loop() {
this->timeClient->update();
int hour = this->timeClient->getHours();
int min = this->timeClient->getMinutes();
int day = this->timeClient->getDay();
if(hour >= 12){
hour -= 12;
this->pm = true;
@ -79,8 +80,11 @@ void Program::loop() {
}
this->menu=MainMenu::SELECT_END_HOUR;
this->resetMillis = millis();
this->ledLib->okBlink();//TODO: faire en sorte d'avoir une led d'alumé par defaut
//TODO: géré les mardi et jeudi
if(day == 2 || day == 5){
this->encoder->setValue(21-this->nLedStart);
}else{
this->encoder->setValue(1);
}
break;}
case MainMenu::SELECT_END_HOUR: // select Close hour
this->ledLib->actLed(this->encoder->getValue(), this->nLedStart);
@ -90,12 +94,7 @@ void Program::loop() {
bool min = false;
int endLed = this->encoder->getValue();
int hour = (this->nLedStart + endLed)/2;
if(this->pm){
hour += 12;
}
if(hour >= 24){
hour -= 24;
}
if(this->pm)hour += 12;
if(this->nLedStart % 2 == 1){
if(endLed % 2 == 1){
hour -=1;
@ -107,11 +106,11 @@ void Program::loop() {
min = true;
}
}
if(hour >= 24)hour -= 24;
strTime += hour;
strTime += "h";
if(min)strTime += "30";
Serial.println(strTime);
//this->sendTime(strTime);
this->sendTime(strTime);
this->menu = MainMenu::INITIAL_STATE;
this->encoder->resetMenu();
this->encoder->resetValue();
@ -137,6 +136,8 @@ void Program::loop() {
this->resetMillis = millis();
this->menu = MainMenu::INITIAL_STATE;
}
//TODO: gestion cas d'erreur (pas de wifi, discord down,...)
//TODO: gestion d'une ouverture de plus de 12h avec les led (chagement de couleur)
// int currentDayOfWeek = this->timeClient->getDay();
// Serial.print("Day of week: ");