diff --git a/ESP_Code/DisplayHal.h b/ESP_Code/DisplayHal.h index dfde2490..75b0b5ab 100644 --- a/ESP_Code/DisplayHal.h +++ b/ESP_Code/DisplayHal.h @@ -21,6 +21,12 @@ static byte msec[] = {0x0A, 0x15, 0x11, 0x06, 0x08, 0x04, 0x02, 0x0C}; #endif +#if defined(DISPLAY_ST7789) + // Define some colors + #define WHITE TFT_WHITE + #define BLACK TFT_BLACK +#endif + #if defined(DISPLAY_SSD1306) void drawStrMultiline(const char *msg, int xloc, int yloc) { ///~https://github.com/olikraus/u8g2/discussions/1479 @@ -56,7 +62,7 @@ } #endif -#if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) +#if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) void screen_setup() { // Ran during setup() // Abstraction layer: screen initialization @@ -78,6 +84,13 @@ lcd.home(); lcd.clear(); #endif + + #if defined(DISPLAY_ST7789) + tft.begin(); + tft.setRotation(1); + tft.init(); + tft.fillScreen(BLACK); + #endif } @@ -290,6 +303,39 @@ lcd.print(sharerate); lcd.print("s"); #endif + + #if defined(DISPLAY_ST7789) + tft.init(); + tft.fillScreen(BLACK); + tft.setTextColor(WHITE); + + tft.setTextSize(2); + tft.setCursor(2, 10); + tft.print("Hashrate: " + hashrate + " kH"); + + tft.setCursor(2, 30); + tft.print("Node: " + node); + + tft.setCursor(2, 50); + tft.print("Accepted/Total: " + accepted_shares + "/" + total_shares); + tft.setCursor(2, 70); + tft.print("Accepted Rate: " + accept_rate + "%"); + + tft.setCursor(2, 90); + tft.print("Ping: " + ping + " ms"); + + tft.setCursor(2, 110); + tft.print("Uptime: " + uptime); + + tft.setCursor(2, 130); + tft.print("Share Rate: " + sharerate); + tft.setCursor(2, 150); + tft.print("Difficulty: " + difficulty); + + tft.setCursor(2, 200); + tft.print("IP: " + WiFi.localIP().toString()); + + #endif } #endif diff --git a/ESP_Code/ESP_Code.ino b/ESP_Code/ESP_Code.ino index 29f71200..c2cac592 100644 --- a/ESP_Code/ESP_Code.ino +++ b/ESP_Code/ESP_Code.ino @@ -59,7 +59,7 @@ #include "Dashboard.h" #endif -#if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) +#if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) #include "DisplayHal.h" #endif @@ -140,7 +140,7 @@ void RestartESP(String msg) { Serial.println("Restarting ESP..."); #endif - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) display_info("Restarting ESP..."); #endif @@ -213,7 +213,7 @@ namespace { Serial.println("Poolpicker selected the best mining node: " + node_id); #endif - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) display_info(node_id); #endif } @@ -264,7 +264,7 @@ namespace { Serial.printf("Error fetching node from poolpicker: %s\n", https.errorToString(httpCode).c_str()); VerifyWifi(); #endif - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) display_info(http.errorToString(httpCode)); #endif } @@ -380,7 +380,7 @@ namespace { #endif - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) display_info("Waiting for node..."); #endif SelectNode(); @@ -495,7 +495,7 @@ void task1_func(void *) { VOID LOOP() { job[0]->mine(); - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) float hashrate_float = (hashrate+hashrate_core_two) / 1000.0; float accept_rate = (accepted_share_count / 0.01 / share_count); @@ -524,7 +524,7 @@ void task2_func(void *) { VOID LOOP() { job[1]->mine(); - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) float hashrate_float = (hashrate+hashrate_core_two) / 1000.0; float accept_rate = (accepted_share_count / 0.01 / share_count); @@ -574,7 +574,7 @@ void setup() { } #endif - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) screen_setup(); display_boot(); delay(2500); @@ -693,8 +693,7 @@ void setup() { #if defined(BLUSHYBOX) blinker.detach(); #endif - - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) display_info("Waiting for node..."); #endif #if defined(BLUSHYBOX) @@ -705,7 +704,7 @@ void setup() { blinker.detach(); #endif #else - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) display_info("Waiting for WiFi..."); #endif SetupWifi(); @@ -780,7 +779,7 @@ void single_core_loop() { lwdtFeed(); - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) float hashrate_float = (hashrate+hashrate_core_two) / 1000.0; float accept_rate = (accepted_share_count / 0.01 / share_count); diff --git a/ESP_Code/Settings.h b/ESP_Code/Settings.h index 9a57d46a..9defd714 100644 --- a/ESP_Code/Settings.h +++ b/ESP_Code/Settings.h @@ -60,6 +60,9 @@ extern const char PASSWORD[] = "PASSW0RD"; // Uncomment if your device is a Duino BlushyBox device // #define BLUSHYBOX + +// Uncomment to enable a ST7789 LCD screen, like t-display s3, on a direct bus to display mining info in real time +// #define DISPLAY_ST7789 // -------------------------------------------------------------- // // ---------------------- IoT examples -------------------------- // @@ -167,6 +170,14 @@ extern unsigned int ping = 0; Adafruit_LiquidCrystal lcd(1, 2, 3, 4, 5, 6); #endif + +#if defined(DISPLAY_ST7789) + #include + + // initialize the library + TFT_eSPI tft = TFT_eSPI(); +#endif + #if defined(USE_HSU07M) #include "Wire.h" #define HSU07M_ADDRESS 0x4B // Change this if your sensor has a different address