#if C
#include <WiFi.h>
#include "esp_wifi.h"
#include "sntp.h"
#include <time.h>
TFT_eSPI tft = TFT_eSPI();
void ConfigNTP(B4R::Object* o) {
esp_wifi_set_ps(WIFI_PS_NONE);
configTime(-18000, 0, "pool.ntp.org", "time.nist.gov");
}
B4R::Object* GetEpoch(B4R::Object* o) {
time_t now;
time(&now);
static B4R::Object ret;
if (now < 1767225600) {
return ret.wrapNumber((ULong)0);
}
return ret.wrapNumber((ULong)now);
}
void FormatDateTime(B4R::Object* o) {
time_t now;
time(&now);
char* dest = (char*)b4r_main::_text2draw->data;
if (now >= 1767225600) {
struct tm* timeinfo = localtime(&now);
strftime(dest, 100, "%Y-%m-%d %H:%M:%S", timeinfo);
} else {
dest[0] = 0;
}
}
#End If