From 27f9537e3156423ed842ad318ece97387b37b451 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 13 Aug 2024 23:43:18 -0300 Subject: [PATCH 1/3] feat: ST7789 display --- ESP_Code/DisplayHal.h | 40 +++++++++++++++++++++++++++++++++++++++- ESP_Code/ESP_Code.ino | 22 +++++++++++----------- ESP_Code/Settings.h | 11 +++++++++++ 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/ESP_Code/DisplayHal.h b/ESP_Code/DisplayHal.h index dfde2490..078cbb72 100644 --- a/ESP_Code/DisplayHal.h +++ b/ESP_Code/DisplayHal.h @@ -56,7 +56,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 +78,12 @@ lcd.home(); lcd.clear(); #endif + + #if defined(DISPLAY_ST7789) + tft.begin(); + tft.setRotation(1); + tft.fillScreen(BLACK); + #endif } @@ -290,6 +296,38 @@ lcd.print(sharerate); lcd.print("s"); #endif + + #if defined(DISPLAY_ST7789) + 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 6e907d50..ab45709b 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 @@ -211,7 +211,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 } @@ -233,7 +233,7 @@ namespace { #if defined(SERIAL_PRINTING) Serial.printf("Error fetching node from poolpicker: %s\n", http.errorToString(httpCode).c_str()); #endif - #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) + #if defined(DISPLAY_SSD1306) || defined(DISPLAY_16X2) || defined(DISPLAY_ST7789) display_info(http.errorToString(httpCode)); #endif @@ -368,7 +368,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(); @@ -497,7 +497,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); @@ -526,7 +526,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); @@ -576,7 +576,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); @@ -686,7 +686,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) @@ -697,7 +697,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(); @@ -772,7 +772,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 13bc34fc..8485a7ad 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 -------------------------- // @@ -157,6 +160,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 From af0d7b2b73cc17edffca8f979f47d8aa365747bd Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 14 Aug 2024 00:27:09 -0300 Subject: [PATCH 2/3] feat: ST7789 colors --- ESP_Code/DisplayHal.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ESP_Code/DisplayHal.h b/ESP_Code/DisplayHal.h index 078cbb72..1c30a4bb 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 From 2aae8318b208973777d322b601ed69a686854956 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 17 Aug 2024 13:24:07 -0300 Subject: [PATCH 3/3] feat: reset screen --- ESP_Code/DisplayHal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ESP_Code/DisplayHal.h b/ESP_Code/DisplayHal.h index 1c30a4bb..75b0b5ab 100644 --- a/ESP_Code/DisplayHal.h +++ b/ESP_Code/DisplayHal.h @@ -88,6 +88,7 @@ #if defined(DISPLAY_ST7789) tft.begin(); tft.setRotation(1); + tft.init(); tft.fillScreen(BLACK); #endif } @@ -304,6 +305,7 @@ #endif #if defined(DISPLAY_ST7789) + tft.init(); tft.fillScreen(BLACK); tft.setTextColor(WHITE);