feat: add-ntp-support #4

Merged
Clement merged 3 commits from feat--add-ntp-support into master 2023-10-21 17:14:02 +00:00
2 changed files with 18 additions and 1 deletions
Showing only changes of commit 2a61d59edc - Show all commits

View File

@ -25,6 +25,13 @@ private:
DiscordAPI* discord;
WiFiUDP* ntpUDP;
NTPClient* timeClient;
/**
* @brief Send time to discord
* the start time is automaticly set to the current time
* @param[in] timeEnd LabOuest closing time
*/
void sendTime(String timeEnd);
};
#endif

View File

@ -26,7 +26,17 @@ Program::Program() {
this->ntpUDP = new WiFiUDP();
this->timeClient = new NTPClient(*this->ntpUDP, "pool.ntp.org", 3600*2);//*2 = gnt+2
//Serial.println(this->discord->sendHeure("10h", "18h"));
this->timeClient->update();
this->sendTime("18h12");
}
void Program::sendTime(String timeEnd){
String start = (String)this->timeClient->getHours() + "h";
int startQuater = this->timeClient->getMinutes()/15;
if (startQuater != 0){
start += (String)(startQuater * 15);
}
this->discord->sendHeure(start, timeEnd);
}
void Program::loop() {