Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Compatibility with ST7789 LCD (T-Display S3) #1811

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion ESP_Code/DisplayHal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -78,6 +84,13 @@
lcd.home();
lcd.clear();
#endif

#if defined(DISPLAY_ST7789)
tft.begin();
tft.setRotation(1);
tft.init();
tft.fillScreen(BLACK);
#endif
}


Expand Down Expand Up @@ -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

Expand Down
23 changes: 11 additions & 12 deletions ESP_Code/ESP_Code.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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();
Expand Down Expand Up @@ -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);

Expand Down
11 changes: 11 additions & 0 deletions ESP_Code/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------------------------- //
Expand Down Expand Up @@ -167,6 +170,14 @@ extern unsigned int ping = 0;
Adafruit_LiquidCrystal lcd(1, 2, 3, 4, 5, 6);
#endif


#if defined(DISPLAY_ST7789)
#include <TFT_eSPI.h>

// 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
Expand Down