From 8f1426ac1da13072308fa4bff0b6d50dc583ab44 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Fri, 12 Apr 2024 00:43:35 -0700 Subject: [PATCH 1/5] add battery and sdcard pins 1-bit --- platformio.ini | 4 +- src/drivers/devices/lilygoT_HMI.h | 45 ++++++++++++++++----- src/drivers/displays/t_hmiDisplayDriver.cpp | 36 +++++++++++++++-- 3 files changed, 68 insertions(+), 17 deletions(-) diff --git a/platformio.ini b/platformio.ini index fc4e962..328320e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -265,9 +265,9 @@ lib_deps = https://github.com/takkaO/OpenFontRender bblanchon/ArduinoJson@^6.21.2 https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2 - mathertel/OneButton @ ^2.0.3 + mathertel/OneButton @ 2.0.3 arduino-libraries/NTPClient - bodmer/TFT_eSPI @ ^2.5.31 + bodmer/TFT_eSPI @ ^2.5.31 https://github.com/achillhasler/TFT_eTouch ;-------------------------------------------------------------------- diff --git a/src/drivers/devices/lilygoT_HMI.h b/src/drivers/devices/lilygoT_HMI.h index d80be04..03919d7 100644 --- a/src/drivers/devices/lilygoT_HMI.h +++ b/src/drivers/devices/lilygoT_HMI.h @@ -9,30 +9,53 @@ #define BUTTON1_PIN (0) #define BUTTON2_PIN (21) -#define PIN_BUTTON_1 BUTTON1_PIN -// #define PIN_BUTTON_2 BUTTON2_PIN +#define PIN_BUTTON_1 (0) +//#define PIN_BUTTON_2 (21) // touch screen -#define TOUCHSCREEN_SCLK_PIN (1) -#define TOUCHSCREEN_MISO_PIN (4) -#define TOUCHSCREEN_MOSI_PIN (3) -#define TOUCHSCREEN_CS_PIN (2) -#define TOUCHSCREEN_IRQ_PIN (9) -#define TOUCH_CLK TOUCHSCREEN_SCLK_PIN -#define TOUCH_MISO TOUCHSCREEN_MISO_PIN -#define TOUCH_MOSI TOUCHSCREEN_MOSI_PIN -#define ETOUCH_CS TOUCHSCREEN_CS_PIN +#define TOUCH_IRQ (9) +#define TOUCH_CLK (1) +#define TOUCH_MISO (4) +#define TOUCH_MOSI (3) +#define ETOUCH_CS (2) // lcd + +#define LCD_DATA0_PIN (48) +#define LCD_DATA1_PIN (47) +#define LCD_DATA2_PIN (39) +#define LCD_DATA3_PIN (40) +#define LCD_DATA4_PIN (41) +#define LCD_DATA5_PIN (42) +#define LCD_DATA6_PIN (45) +#define LCD_DATA7_PIN (46) + #define PCLK_PIN (8) #define CS_PIN (6) #define DC_PIN (7) #define RST_PIN (-1) #define BK_LIGHT_PIN (38) +#define BK_LIGHT_LEVEL (1) #define LED_PIN (8) +// sd card +// 1-bit SD_MMC +#ifdef DEFINE_1BIT + +#define SDMMC_CLK (12) +#define SDMMC_CMD (11) +#define SDMMC_D0 (13) + +#else + +#define SDSPI_MISO (13) +#define SDSPI_MOSI (11) +#define SDSPI_CLK (12) + +#endif + #ifndef TFT_BL // XXX - defined in User_Setups/Setup207_LilyGo_T_HMI.h:37 #define TFT_BL (38) // LED back-light diff --git a/src/drivers/displays/t_hmiDisplayDriver.cpp b/src/drivers/displays/t_hmiDisplayDriver.cpp index 44b7822..d3b0510 100644 --- a/src/drivers/displays/t_hmiDisplayDriver.cpp +++ b/src/drivers/displays/t_hmiDisplayDriver.cpp @@ -12,6 +12,9 @@ #include "monitor.h" #include "OpenFontRender.h" +#include +#include + #define WIDTH 320 #define HEIGHT 240 @@ -21,16 +24,38 @@ TFT_eSprite background = TFT_eSprite(&tft); // Invoke library sprite SPIClass hSPI(HSPI); -TFT_eTouch touch(tft, ETOUCH_CS, 0xFF, hSPI); +// TFT_eTouch touch(tft, ETOUCH_CS, 0xFF, hSPI); bool showbtcprice = false; extern monitor_data mMonitor; extern pool_data pData; extern DisplayDriver *currentDisplayDriver; +uint32_t readAdcVoltage(int pin) { + esp_adc_cal_characteristics_t adc_chars; + + esp_adc_cal_value_t val_type = esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, 1100, &adc_chars); + return esp_adc_cal_raw_to_voltage(analogRead(pin), &adc_chars); +} + +void printBatteryVoltage() { + uint32_t voltage = readAdcVoltage(BAT_ADC_PIN) * 2; + Serial.print("Battery voltage: "); + Serial.println((float)voltage/1000); + delay(500); +} void t_hmiDisplay_Init(void) { + pinMode(PWR_ON_PIN, OUTPUT); + digitalWrite(PWR_ON_PIN, HIGH); + + delay(10); + Serial.println(F("Turn on the main power")); + + pinMode(PWR_EN_PIN, OUTPUT); + digitalWrite(PWR_EN_PIN, HIGH); + tft.init(); tft.setRotation(1); tft.setSwapBytes(true); // Swap the colour byte order when rendering @@ -51,10 +76,10 @@ void t_hmiDisplay_Init(void) TFT_eTouchBase::Calibation calibation = { 233, 3785, 3731, 120, 2 }; touch.setCalibration(calibation); */ - Serial.println(F("Power on peripherals, such as the LCD backlight")); - pinMode(PWR_EN_PIN, OUTPUT); - digitalWrite(PWR_EN_PIN, HIGH); + Serial.println(F("Turn on the LCD backlight")); pinMode(LED_PIN, OUTPUT); + pinMode(BK_LIGHT_PIN, OUTPUT); + digitalWrite(BK_LIGHT_PIN, BK_LIGHT_LEVEL); pData.bestDifficulty = "0"; pData.workersHash = "0"; pData.workersCount = 0; @@ -73,6 +98,7 @@ void t_hmiDisplay_AlternateRotation(void) tft.getRotation() == 1 ? tft.setRotation(3) : tft.setRotation(1); } + void printPoolData() { // Serial.print("\nPool ============ Free Heap:"); @@ -88,6 +114,7 @@ void printPoolData() render.setFontSize(18); render.drawString(pData.workersHash.c_str(), 216, 170+34, TFT_BLACK); render.drawString(pData.bestDifficulty.c_str(), 5, 170+34, TFT_BLACK); + // printBatteryVoltage(); } @@ -116,6 +143,7 @@ void printMemPoolFees(unsigned long mElapsed) // render.drawChar('<', 245, 170+32, TFT_RED); render.drawString(data.minimumFee.c_str(), 250, 170+32, TFT_RED); render.drawString(data.fastestFee.c_str(), 30, 170+32, TFT_BLACK); + // printBatteryVoltage(); } void t_hmiDisplay_MinerScreen(unsigned long mElapsed) From ac6cd6a3f0ee6906c534740f2dac65bc9d8dd248 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Sat, 13 Apr 2024 14:02:47 -0700 Subject: [PATCH 2/5] add pool data api discovery --- src/monitor.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- src/monitor.h | 2 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/monitor.cpp b/src/monitor.cpp index df6c889..0d129a0 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -32,6 +32,8 @@ unsigned int bitcoin_price=0; String current_block = "793261"; global_data gData; pool_data pData; +String poolAPIUrl; + void setup_monitor(void){ /******** TIME ZONE SETTING *****/ @@ -42,7 +44,11 @@ void setup_monitor(void){ // GMT +2 in seconds (zona horaria de Europa Central) timeClient.setTimeOffset(3600 * Settings.Timezone); - Serial.println("TimeClient setup done"); + Serial.println("TimeClient setup done"); +#ifdef NERDMINER_T_HMI + poolAPIUrl = getPoolAPIUrl(); + Serial.println("poolAPIUrl: " + poolAPIUrl); +#endif } unsigned long mGlobalUpdate =0; @@ -317,6 +323,36 @@ coin_data getCoinData(unsigned long mElapsed) return data; } +String getPoolAPIUrl(void) { + poolAPIUrl = String(getPublicPool); + if (Settings.PoolAddress == "public-pool.io") { + poolAPIUrl = "https://public-pool.io:40557/api/client/"; + } + else { + if (Settings.PoolAddress == "nerdminers.org") { + poolAPIUrl = "https://pool.nerdminers.org/users/"; + } + else { + switch (Settings.PoolPort) { + case 3333: + if (Settings.PoolAddress == "pool.vkbit.com") + poolAPIUrl = "https://vkbit.com/miner/"; + else if (Settings.PoolAddress == "pool.sethforprivacy.com") + poolAPIUrl = "https://pool.sethforprivacy.com/api/client/"; + // Add more cases for other addresses with port 3333 if needed + break; + case 2018: + poolAPIUrl = "http://" + Settings.PoolAddress + ":2019/api/client/"; + break; + default: + poolAPIUrl = String(getPublicPool); + break; + } + } + } + return poolAPIUrl; +} + pool_data getPoolData(void){ //pool_data pData; if((mPoolUpdate == 0) || (millis() - mPoolUpdate > UPDATE_POOL_min * 60 * 1000)){ @@ -329,7 +365,12 @@ pool_data getPoolData(void){ String btcWallet = Settings.BtcWallet; Serial.println(btcWallet); if (btcWallet.indexOf(".")>0) btcWallet = btcWallet.substring(0,btcWallet.indexOf(".")); +#ifdef NERDMINER_T_HMI + Serial.println("Pool API : " + poolAPIUrl+btcWallet); + http.begin(poolAPIUrl+btcWallet); +#else http.begin(String(getPublicPool)+btcWallet); +#endif int httpCode = http.GET(); if (httpCode == HTTP_CODE_OK) { String payload = http.getString(); diff --git a/src/monitor.h b/src/monitor.h index ff89c19..8c458d2 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -127,6 +127,6 @@ coin_data getCoinData(unsigned long mElapsed); pool_data getPoolData(void); clock_data_t getClockData_t(unsigned long mElapsed); - +String getPoolAPIUrl(void); #endif //MONITOR_API_H From 3b439dbbb3609a30a407570f6594e33063ec7e38 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Mon, 6 May 2024 00:22:33 -0700 Subject: [PATCH 3/5] clean up lilygoT_HMI.h; leave DEFINE_SDMMC_1BIT disabled --- src/drivers/devices/lilygoT_HMI.h | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/drivers/devices/lilygoT_HMI.h b/src/drivers/devices/lilygoT_HMI.h index 03919d7..ab384b8 100644 --- a/src/drivers/devices/lilygoT_HMI.h +++ b/src/drivers/devices/lilygoT_HMI.h @@ -12,7 +12,6 @@ #define PIN_BUTTON_1 (0) //#define PIN_BUTTON_2 (21) - // touch screen #define TOUCH_IRQ (9) #define TOUCH_CLK (1) @@ -20,18 +19,6 @@ #define TOUCH_MOSI (3) #define ETOUCH_CS (2) - -// lcd - -#define LCD_DATA0_PIN (48) -#define LCD_DATA1_PIN (47) -#define LCD_DATA2_PIN (39) -#define LCD_DATA3_PIN (40) -#define LCD_DATA4_PIN (41) -#define LCD_DATA5_PIN (42) -#define LCD_DATA6_PIN (45) -#define LCD_DATA7_PIN (46) - #define PCLK_PIN (8) #define CS_PIN (6) #define DC_PIN (7) @@ -41,19 +28,11 @@ #define LED_PIN (8) // sd card -// 1-bit SD_MMC -#ifdef DEFINE_1BIT - +// 1-bit SD MMC +#ifdef DEFINE_SDMMC_1BIT #define SDMMC_CLK (12) #define SDMMC_CMD (11) #define SDMMC_D0 (13) - -#else - -#define SDSPI_MISO (13) -#define SDSPI_MOSI (11) -#define SDSPI_CLK (12) - #endif #ifndef TFT_BL From 7b546c04ae8c5d98ea3403df31df578de21a6ec0 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Tue, 7 May 2024 10:54:32 -0700 Subject: [PATCH 4/5] README update --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ed51e7b..d431d30 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Every time an stratum job notification is received miner update its current work - ESP32-2432S028R 2,8" ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DdXkvLv) / Dev support: @nitroxgas / ⚡jadeddonald78@walletofsatoshi.com) - ESP32-cam ([Board Info](https://lastminuteengineers.com/getting-started-with-esp32-cam/) / Dev support: @elmo128) - M5-StampS3 ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DevABY3) / Dev support: @gyengus) +- LILYGO T-HMI ([Aliexpress link\*](https://s.click.aliexpress.com/e/_oFII4s2)) / Dev support: @cosmicpsyop \*Affiliate links From ff1efe00847c9aaf9185f5a5b4f8d10956eab99b Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Fri, 10 May 2024 21:41:30 -0700 Subject: [PATCH 5/5] unupdate --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d431d30..ed51e7b 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,6 @@ Every time an stratum job notification is received miner update its current work - ESP32-2432S028R 2,8" ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DdXkvLv) / Dev support: @nitroxgas / ⚡jadeddonald78@walletofsatoshi.com) - ESP32-cam ([Board Info](https://lastminuteengineers.com/getting-started-with-esp32-cam/) / Dev support: @elmo128) - M5-StampS3 ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DevABY3) / Dev support: @gyengus) -- LILYGO T-HMI ([Aliexpress link\*](https://s.click.aliexpress.com/e/_oFII4s2)) / Dev support: @cosmicpsyop \*Affiliate links