diff --git a/src/NerdMinerV2.ino.cpp b/src/NerdMinerV2.ino.cpp index 7ff9f88..3d45e92 100644 --- a/src/NerdMinerV2.ino.cpp +++ b/src/NerdMinerV2.ino.cpp @@ -28,6 +28,7 @@ TFT_eSprite background = TFT_eSprite(&tft); // Invoke library sprite int oldStatus = 0; unsigned long start = millis(); +const char* ntpServer = "pool.ntp.org"; //void runMonitor(void *name); @@ -90,6 +91,10 @@ void setup() BaseType_t res = xTaskCreate(runWorker, name, 30000, (void*)name, 1, NULL); Serial.printf("Starting %s %s!\n", name, res == pdPASS? "successful":"failed"); } + + /******** TIME ZONE SETTING *****/ + configTime(0, 0, ntpServer); + setenv("TZ", "CET-1CEST,M3.5.0,M10.5.0/3", 1); } void app_error_fault_handler(void *arg) { diff --git a/src/mining.cpp b/src/mining.cpp index 9400f1b..233ada1 100644 --- a/src/mining.cpp +++ b/src/mining.cpp @@ -17,6 +17,7 @@ static unsigned long templates = 0; static unsigned long hashes= 0; static unsigned long Mhashes = 0; static unsigned long totalKHashes = 0; +static String temp; static int halfshares; // increase if blockhash has 16 bits of zeroes static int shares; // increase if blockhash has 32 bits of zeroes @@ -631,11 +632,23 @@ void runMonitor(void *name){ render.setFontSize(48); render.drawString(String(valids).c_str(), 285, 56, 0xDEDB); //Print Temp - background.setTextColor(TFT_BLACK); + //background.setTextColor(TFT_BLACK); //background.setFreeFont(FF0); - background.drawString("30", 230, 4); + //background.drawString("30", 230, 4); //Print Hour - background.drawString("22:10", 250, 4); + //background.drawString("22:10", 250, 4); + + //Print Temp + temp = String(temperatureRead(), 0); + render.setFontSize(20); + render.rdrawString(String(temp).c_str(), 239, 1, TFT_BLACK); + + render.setFontSize(7); + render.rdrawString(String(0).c_str(), 244, 3, TFT_BLACK); + + //Print Hour + render.setFontSize(20); + render.rdrawString(String(printLocalTime()).c_str(), 286, 1, TFT_BLACK); //Push prepared background to screen background.pushSprite(0,0); @@ -644,3 +657,14 @@ void runMonitor(void *name){ vTaskDelay(2000 / portTICK_PERIOD_MS); } } +String printLocalTime(){ + struct tm timeinfo; + if(!getLocalTime(&timeinfo)){ + Serial.println("Failed to obtain time"); + return "00:00"; + } + char LocalHour[80]; + strftime (LocalHour, 80, "%H:%M", &timeinfo); //4 digit year, 2 digit month + String mystring(LocalHour); + return LocalHour; +} diff --git a/src/mining.h b/src/mining.h index bfbb74b..57ca6da 100644 --- a/src/mining.h +++ b/src/mining.h @@ -6,4 +6,5 @@ void runMonitor(void *name); void runWorker(void *name); -void runMiner(void); \ No newline at end of file +void runMiner(void); +String printLocalTime(void); \ No newline at end of file