add sendTime

This commit is contained in:
Clement 2023-09-01 21:09:08 +02:00
parent 2c138a3225
commit 2a61d59edc
2 changed files with 18 additions and 1 deletions

View File

@ -25,6 +25,13 @@ private:
DiscordAPI* discord; DiscordAPI* discord;
WiFiUDP* ntpUDP; WiFiUDP* ntpUDP;
NTPClient* timeClient; 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 #endif

View File

@ -26,7 +26,17 @@ Program::Program() {
this->ntpUDP = new WiFiUDP(); this->ntpUDP = new WiFiUDP();
this->timeClient = new NTPClient(*this->ntpUDP, "pool.ntp.org", 3600*2);//*2 = gnt+2 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() { void Program::loop() {