add main alogo WIP

This commit is contained in:
2023-10-25 22:36:09 +02:00
parent 92943ff3e9
commit f49d3de893
5 changed files with 63 additions and 5 deletions

View File

@ -52,11 +52,56 @@ void Program::sendTime(String timeEnd){
void Program::loop() {
if(this->encoder->update()){
switch (this->encoder->getMenu()){
case 1:{
if(!this->ntpUpdated){
this->timeClient->update();
this->encoder->resetMenu();
this->ntpUpdated = true;
}
int currentHour = this->timeClient->getHours();
if(currentHour > 12){
currentHour -= 12;
}
//TODO: debug this shit
int startLed = currentHour * 2;
startLed += this->timeClient->getMinutes()/30;
int encValue = this->encoder->getValue();
Serial.println(startLed);
this->ledLib->actLed(encValue+1, startLed-1);
break;
}case 2:{
int finalEncValue = this->encoder->getValue();
int finalHour = this->timeClient->getHours();
int finalMinute = this->timeClient->getMinutes();
Serial.print("finalHour: ");
Serial.print(finalHour);
Serial.print("h");
Serial.print(finalMinute);
Serial.print(" finalEncValue: ");
Serial.println(finalEncValue);
// TODO: send time sur discord
//this->sendTime()
this->ledLib->okBlink();
this->ntpUpdated = false;
this->encoder->resetMenu();
this->resetMillis = millis();
break;
}}
Serial.print(this->encoder->getValue());
this->ledLib->actLed(this->encoder->getValue(), 5);
Serial.print(" ");
Serial.println(this->encoder->getMenu());
//this->ledLib->actLed(this->encoder->getValue(), 5);
}
if(this->resetMillis + RESET_TIME == millis()){
this->encoder->resetMenu();
this->resetMillis = millis();
this->ntpUpdated = false;
}
// delay(1000);
// this->timeClient->update();