From 53157f1ecf7a3f6ee67be4fffbd39692cdd8222f Mon Sep 17 00:00:00 2001 From: yonijuerga Date: Tue, 11 Jun 2024 12:16:08 +0200 Subject: [PATCH 01/15] Update monitor.h all credits to this changes for https://github.com/ChimpRocket --- src/monitor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monitor.h b/src/monitor.h index bf2b7b6..e0d1880 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -13,7 +13,7 @@ #define UPDATE_PERIOD_h 5 //API BTC price (Update to USDT cus it's more liquidity and flow price updade) -#define getBTCAPI "https://api.blockchain.com/v3/exchange/tickers/BTC-USDT" +#define getBTCAPI "https://api.coinbase.com/v2/prices/BTC-USD/spot" #define UPDATE_BTC_min 1 //API Block height From 496fcecc7dca1cd2dae6dccafde27013e462e15d Mon Sep 17 00:00:00 2001 From: yonijuerga Date: Tue, 11 Jun 2024 12:20:53 +0200 Subject: [PATCH 02/15] Update monitor.cpp all credits to this changes for https://github.com/ChimpRocket --- src/monitor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/monitor.cpp b/src/monitor.cpp index f7dc057..44d1145 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -152,7 +152,7 @@ String getBTCprice(void){ if((mBTCUpdate == 0) || (millis() - mBTCUpdate > UPDATE_BTC_min * 60 * 1000)){ - if (WiFi.status() != WL_CONNECTED) return (String(bitcoin_price) + "$"); + if (WiFi.status() != WL_CONNECTED) return "$" + String(bitcoin_price); HTTPClient http; try { @@ -164,7 +164,7 @@ String getBTCprice(void){ DynamicJsonDocument doc(1024); deserializeJson(doc, payload); - if (doc.containsKey("last_trade_price")) bitcoin_price = doc["last_trade_price"]; + if (doc.containsKey("data") && doc["data"].containsKey("amount")) bitcoin_price = doc["data"]["amount"]; doc.clear(); @@ -177,7 +177,7 @@ String getBTCprice(void){ } } - return (String(bitcoin_price) + "$"); + return "$" + String(bitcoin_price); } unsigned long mTriggerUpdate = 0; From 7678c3d657a9b6ea6a501c57e0a588c1d6839a94 Mon Sep 17 00:00:00 2001 From: Valerio Vaccaro Date: Mon, 12 Aug 2024 17:49:28 +0200 Subject: [PATCH 03/15] add automagic firmware version name calculation --- auto_firmware_version.py | 17 +++++++ platformio.ini | 52 ++++++++++++++++++++++ src/drivers/displays/wt32DisplayDriver.cpp | 6 ++- 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 auto_firmware_version.py diff --git a/auto_firmware_version.py b/auto_firmware_version.py new file mode 100644 index 0000000..5a60603 --- /dev/null +++ b/auto_firmware_version.py @@ -0,0 +1,17 @@ +import subprocess + +Import("env") + +def get_firmware_specifier_build_flag(): + ret = subprocess.run(["git", "describe"], stdout=subprocess.PIPE, text=True) #Uses only annotated tags + #ret = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True) #Uses any tags + build_version = ret.stdout.strip() + # fix unwanted and verbose tags + build_version = build_version.replace('Release', '') + build_flag = "-D AUTO_VERSION=\\\"" + build_version + "\\\"" + print ("Firmware Revision: " + build_version) + return (build_flag) + +env.Append( + BUILD_FLAGS=[get_firmware_specifier_build_flag()] +) diff --git a/platformio.ini b/platformio.ini index 03906cd..5ef99d1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,6 +17,8 @@ default_envs = NerdminerV2-T-HMI, wt32-sc01, wt32-sc01-plus, han_m5stack, M5Stic platform = espressif32 board = m5stick-c framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -48,6 +50,8 @@ lib_ignore = platform = espressif32 board = esp-wrover-kit framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -80,6 +84,8 @@ lib_ignore = platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -115,6 +121,8 @@ lib_ignore = platform = espressif32 board = lolin_s3_mini framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -147,6 +155,8 @@ lib_ignore = platform = espressif32 board = m5stack-core-esp32 framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -177,6 +187,8 @@ lib_ignore = platform = espressif32 board = lolin_s2_mini framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -206,6 +218,8 @@ lib_ignore = platform = espressif32 board = lolin_s3_mini framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -241,6 +255,8 @@ lib_ignore = platform = espressif32 board = esp32dev framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -270,6 +286,8 @@ lib_ignore = platform = espressif32 board = seeed_xiao_esp32c3 framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -300,6 +318,8 @@ lib_ignore = platform = espressif32 board = esp32-c3-devkitm-1 framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -331,6 +351,8 @@ lib_ignore = platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -363,6 +385,8 @@ lib_ignore = platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -398,6 +422,8 @@ lib_ignore = platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -433,6 +459,8 @@ lib_ignore = platform = espressif32 board = esp32dev framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -460,6 +488,8 @@ lib_ignore = platform = espressif32 board = esp32dev ;esp-wrover-kit framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -491,6 +521,8 @@ lib_ignore = platform = espressif32 board = lilygo-t-amoled framework = arduino +extra_scripts = + pre:auto_firmware_version.py board_build.partitions = huge_app.csv build_flags = -DNERMINER_S3_AMOLED @@ -513,6 +545,8 @@ lib_ignore = platform = espressif32 board = lilygo-t-amoled framework = arduino +extra_scripts = + pre:auto_firmware_version.py board_build.partitions = huge_app.csv build_flags = -DNERMINER_S3_AMOLED @@ -535,6 +569,8 @@ lib_ignore = platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino +extra_scripts = + pre:auto_firmware_version.py board_build.partitions = huge_app.csv build_flags = -DNERMINER_S3_DONGLE @@ -559,6 +595,8 @@ lib_ignore = platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino +extra_scripts = + pre:auto_firmware_version.py board_build.partitions = huge_app.csv build_flags = -DNERMINER_S3_GEEK @@ -581,6 +619,8 @@ lib_ignore = platform = espressif32 ;(ESP32-D0WD-V3) board = esp32cam framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -610,6 +650,8 @@ lib_ignore = platform = espressif32 board = esp32-s3-t-qt-pro framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time @@ -639,6 +681,8 @@ lib_ignore = platform = espressif32 board = esp32dev framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_speed = 115200 upload_speed = 921600 ;build_type = debug @@ -687,6 +731,8 @@ lib_ignore = platform = espressif32 board = esp32dev framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_speed = 115200 monitor_filters = esp32_exception_decoder @@ -740,6 +786,8 @@ lib_ignore = platform = espressif32 board = lilygo-t-hmi framework = arduino +extra_scripts = + pre:auto_firmware_version.py board_build.partitions = default_16MB.csv monitor_filters = esp32_exception_decoder @@ -776,6 +824,8 @@ lib_ignore = platform = espressif32 board = ttgo-lora32-v1 framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_speed = 115200 upload_speed = 115200 board_build.partitions = huge_app.csv @@ -797,6 +847,8 @@ lib_ignore = platform = espressif32 board = m5stack-stamps3 framework = arduino +extra_scripts = + pre:auto_firmware_version.py monitor_filters = esp32_exception_decoder time diff --git a/src/drivers/displays/wt32DisplayDriver.cpp b/src/drivers/displays/wt32DisplayDriver.cpp index f1d51d9..ed6b379 100644 --- a/src/drivers/displays/wt32DisplayDriver.cpp +++ b/src/drivers/displays/wt32DisplayDriver.cpp @@ -323,10 +323,12 @@ void wt32Display_NoScreen(unsigned long mElapsed) void wt32Display_LoadingScreen(void) { Serial.println("Initializing..."); + Serial.print("Firmware Version: "); + Serial.println(AUTO_VERSION); lv_label_set_text(ui_lblssid, "SSID HanSoloAP"); lv_label_set_text(ui_lblpassword, "Password MineYourCoins"); - lv_label_set_text(ui_lblversion, "Version 1.6.4 (RC1)"); - _ui_screen_change(&ui_HomeScreen, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, &ui_HomeScreen_screen_init); + lv_label_set_text(ui_lblversion, AUTO_VERSION); + _ui_screen_change(&ui_HomeScreen, LV_SCR_LOAD_ANIM_FADE_ON, 2000, 0, &ui_HomeScreen_screen_init); } void wt32Display_SetupScreen(void) From cccb38b985582d48763c3d336d9b9a9ea53bdcdc Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Fri, 13 Sep 2024 23:40:19 -0700 Subject: [PATCH 04/15] add platform to allow calling workers metrics api --- src/drivers/devices/esp322432s028r.h | 3 +++ src/drivers/devices/lilygoT_HMI.h | 7 ++++++- src/monitor.cpp | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/drivers/devices/esp322432s028r.h b/src/drivers/devices/esp322432s028r.h index 9e407f2..535fd6f 100644 --- a/src/drivers/devices/esp322432s028r.h +++ b/src/drivers/devices/esp322432s028r.h @@ -32,4 +32,7 @@ #define SDSPI_MOSI 23 #define SDSPI_MISO 19 +// calls api to retrieve worker metrics +#define SCREEN_WORKERS_ENABLE (1) + #endif diff --git a/src/drivers/devices/lilygoT_HMI.h b/src/drivers/devices/lilygoT_HMI.h index abb631f..cc5d145 100644 --- a/src/drivers/devices/lilygoT_HMI.h +++ b/src/drivers/devices/lilygoT_HMI.h @@ -37,10 +37,15 @@ #define TOUCH_ENABLE (1) #define SDMMC_1BIT_FIX (1) #define SD_FREQUENCY (20000) + +// calls api to retrieve worker metrics +#define SCREEN_WORKERS_ENABLE (1) +// retrieve current btc fees data +#define SCREEN_FEES_ENABLE (1) + #ifndef TFT_BL // XXX - defined in User_Setups/Setup207_LilyGo_T_HMI.h:37 #define TFT_BL (38) // LED back-light #endif - #endif diff --git a/src/monitor.cpp b/src/monitor.cpp index f7dc057..2f1c6b3 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -364,7 +364,7 @@ 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 +#ifdef SCREEN_WORKERS_ENABLE Serial.println("Pool API : " + poolAPIUrl+btcWallet); http.begin(poolAPIUrl+btcWallet); #else From 93582b6c593be4495561e20b36118179ba7e8d66 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Sat, 21 Sep 2024 10:18:58 -0700 Subject: [PATCH 05/15] replace NERDMINER_T_HMI specific with global generic symbol --- src/monitor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/monitor.cpp b/src/monitor.cpp index 2f1c6b3..59da4c0 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -46,7 +46,7 @@ void setup_monitor(void){ timeClient.setTimeOffset(3600 * Settings.Timezone); Serial.println("TimeClient setup done"); -#ifdef NERDMINER_T_HMI +#ifdef SCREEN_WORKERS_ENABLE poolAPIUrl = getPoolAPIUrl(); Serial.println("poolAPIUrl: " + poolAPIUrl); #endif @@ -98,7 +98,7 @@ void updateGlobalData(void){ deserializeJson(doc, payload); String temp = ""; if (doc.containsKey("halfHourFee")) gData.halfHourFee = doc["halfHourFee"].as(); -#ifdef NERDMINER_T_HMI +#ifdef SCREEN_FEES_ENABLE if (doc.containsKey("fastestFee")) gData.fastestFee = doc["fastestFee"].as(); if (doc.containsKey("hourFee")) gData.hourFee = doc["hourFee"].as(); if (doc.containsKey("economyFee")) gData.economyFee = doc["economyFee"].as(); @@ -305,7 +305,7 @@ coin_data getCoinData(unsigned long mElapsed) data.currentHashRate = getCurrentHashRate(mElapsed); data.btcPrice = getBTCprice(); data.currentTime = getTime(); -#ifdef NERDMINER_T_HMI +#ifdef SCREEN_FEES_ENABLE data.hourFee = String(gData.hourFee); data.fastestFee = String(gData.fastestFee); data.economyFee = String(gData.economyFee); From 27b4f428982d0774c1c08dbb21ae9bc8b51ddfa0 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Sun, 22 Sep 2024 12:35:29 -0700 Subject: [PATCH 06/15] add header with device specific symbols --- src/monitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/monitor.cpp b/src/monitor.cpp index 59da4c0..c1931c9 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -8,6 +8,7 @@ #include "utils.h" #include "monitor.h" #include "drivers/storage/storage.h" +#include "drivers/devices/device.h" extern uint32_t templates; extern uint32_t hashes; From 15fabda1a9252919d01cca6e593757f5837f5f67 Mon Sep 17 00:00:00 2001 From: Julio MATARRANZ Date: Wed, 23 Oct 2024 00:08:16 +0200 Subject: [PATCH 07/15] feat : start s3 dongle without screen on and back screen functions if BL is off. --- platformio.ini | 2 +- src/drivers/displays/dongleDisplayDriver.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 66ea812..25ac57c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -537,7 +537,7 @@ build_flags = -DNERMINER_S3_DONGLE -DBOARD_HAS_PSRAM -DARDUINO_USB_CDC_ON_BOOT - -DTFT_BACKLIGHT_ON=LOW + -DTFT_BACKLIGHT_ON=HIGH -DTFT_BL=38 lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 diff --git a/src/drivers/displays/dongleDisplayDriver.cpp b/src/drivers/displays/dongleDisplayDriver.cpp index 7a71df5..40ffc9a 100644 --- a/src/drivers/displays/dongleDisplayDriver.cpp +++ b/src/drivers/displays/dongleDisplayDriver.cpp @@ -116,6 +116,10 @@ void dongleDisplay_AlternateRotation(void) void dongleDisplay_MinerScreen(unsigned long mElapsed) { + if (digitalRead(TFT_BL)) + { + return; + } max_y = BUFFER_HEIGHT; mining_data data = getMiningData(mElapsed); @@ -144,6 +148,10 @@ void dongleDisplay_MinerScreen(unsigned long mElapsed) void dongleDisplay_LoadingScreen(void) { + if (digitalRead(TFT_BL)) + { + return; + } CLEAR_SCREEN(); PRINT_STR("Initializing..."); PUSH_SCREEN(); @@ -151,6 +159,10 @@ void dongleDisplay_LoadingScreen(void) void dongleDisplay_SetupScreen(void) { + if (digitalRead(TFT_BL)) + { + return; + } CLEAR_SCREEN(); PRINT_STR("Use WiFi for setup..."); PUSH_SCREEN(); @@ -158,6 +170,10 @@ void dongleDisplay_SetupScreen(void) void dongleDisplay_AnimateCurrentScreen(unsigned long frame) { + if (digitalRead(TFT_BL)) + { + return; + } if (pos_y > max_y) { pos_y = 0; From 55891d987e1dc0eaffba7653e061bdb0b23626fd Mon Sep 17 00:00:00 2001 From: Julio MATARRANZ Date: Wed, 23 Oct 2024 00:01:45 +0200 Subject: [PATCH 08/15] fix : nerdminer typo --- lib/TFT_eSPI/User_Setup_Select.h | 8 ++++---- platformio.ini | 24 ++++++++++++------------ src/drivers/devices/device.h | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/TFT_eSPI/User_Setup_Select.h b/lib/TFT_eSPI/User_Setup_Select.h index bd72af9..0955318 100644 --- a/lib/TFT_eSPI/User_Setup_Select.h +++ b/lib/TFT_eSPI/User_Setup_Select.h @@ -134,7 +134,7 @@ #ifdef NERDMINERV2 #include #endif -#ifdef NERMINER_S3_AMOLED +#ifdef NERDMINER_S3_AMOLED #include //Just a stub. No driver implementation for S3 AMOLED in TFT_eSPI #endif #ifdef NERDMINER_T_HMI @@ -146,16 +146,16 @@ #ifdef LILYGO_S3_T_EMBED #include // For the LilyGo T-Embed S3 based ESP32S3 with ST7789 170 x 320 TFT #endif -#ifdef NERMINER_T_QT +#ifdef NERDMINER_T_QT #include // For the LilyGo T-QT Pro S3 based ESP32S3 with GC9A01 128 x 128 TFT #endif -#ifdef NERMINER_S3_DONGLE +#ifdef NERDMINER_S3_DONGLE #include // For the LilyGo T-Dongle S3 based ESP32 with ST7735 80 x 160 TFT #endif #ifdef ESP32_CAM #include // For the LilyGo T-Dongle S3 based ESP32 with ST7735 80 x 160 TFT #endif -#ifdef NERMINER_S3_GEEK +#ifdef NERDMINER_S3_GEEK #include // Setup file for Waveshare Setup303_WaveShare ESP32S3_GEEK with ST7789 135*240 TFT #endif //#include // Setup file for Bw16-based boards with ST7735 160 x 80 TFT diff --git a/platformio.ini b/platformio.ini index 66ea812..2a9718c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [platformio] globallib_dir = lib -default_envs = NerdminerV2-T-HMI, wt32-sc01, wt32-sc01-plus, han_m5stack, M5Stick-C, esp32cam, ESP32-2432S028R, ESP32_2432S028_2USB, NerminerV2, Lilygo-T-Embed, ESP32-devKitv1, NerminerV2-S3-DONGLE, NerminerV2-S3-GEEK, NerminerV2-S3-AMOLED, NerminerV2-S3-AMOLED-TOUCH, NerminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R, M5-StampS3, ESP32-S3-devKitv1, ESP32-S3-mini-wemos, ESP32-S2-mini-wemos, ESP32-S3-mini-weact, ESP32-D0WD-V3-weact, ESP32-C3-devKitmv1, ESP32-C3-super-mini +default_envs = NerdminerV2-T-HMI, wt32-sc01, wt32-sc01-plus, han_m5stack, M5Stick-C, esp32cam, ESP32-2432S028R, ESP32_2432S028_2USB, NerdminerV2, Lilygo-T-Embed, ESP32-devKitv1, NerdminerV2-S3-DONGLE, NerdminerV2-S3-GEEK, NerdminerV2-S3-AMOLED, NerdminerV2-S3-AMOLED-TOUCH, NerdminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R, M5-StampS3, ESP32-S3-devKitv1, ESP32-S3-mini-wemos, ESP32-S2-mini-wemos, ESP32-S3-mini-weact, ESP32-D0WD-V3-weact, ESP32-C3-devKitmv1, ESP32-C3-super-mini [env:M5Stick-C] platform = espressif32@6.6.0 @@ -359,7 +359,7 @@ lib_ignore = ;-------------------------------------------------------------------- -[env:NerminerV2] +[env:NerdminerV2] platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 framework = arduino @@ -484,13 +484,13 @@ lib_ignore = ;-------------------------------------------------------------------- -[env:NerminerV2-S3-AMOLED] +[env:NerdminerV2-S3-AMOLED] platform = espressif32@6.6.0 board = lilygo-t-amoled framework = arduino board_build.partitions = huge_app.csv build_flags = - -DNERMINER_S3_AMOLED + -DNERDMINER_S3_AMOLED -DTOUCH=0 -DBOARD_HAS_PSRAM -DARDUINO_USB_CDC_ON_BOOT @@ -506,13 +506,13 @@ lib_ignore = ;-------------------------------------------------------------------- -[env:NerminerV2-S3-AMOLED-TOUCH] +[env:NerdminerV2-S3-AMOLED-TOUCH] platform = espressif32@6.6.0 board = lilygo-t-amoled framework = arduino board_build.partitions = huge_app.csv build_flags = - -DNERMINER_S3_AMOLED + -DNERDMINER_S3_AMOLED -DTOUCH=1 -DBOARD_HAS_PSRAM -DARDUINO_USB_CDC_ON_BOOT @@ -528,13 +528,13 @@ lib_ignore = ;-------------------------------------------------------------------- -[env:NerminerV2-S3-DONGLE] +[env:NerdminerV2-S3-DONGLE] platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 framework = arduino board_build.partitions = huge_app.csv build_flags = - -DNERMINER_S3_DONGLE + -DNERDMINER_S3_DONGLE -DBOARD_HAS_PSRAM -DARDUINO_USB_CDC_ON_BOOT -DTFT_BACKLIGHT_ON=LOW @@ -551,13 +551,13 @@ lib_ignore = ;-------------------------------------------------------------------- -[env:NerminerV2-S3-GEEK] +[env:NerdminerV2-S3-GEEK] platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 framework = arduino board_build.partitions = huge_app.csv build_flags = - -DNERMINER_S3_GEEK + -DNERDMINER_S3_GEEK -DBOARD_HAS_PSRAM -DARDUINO_USB_CDC_ON_BOOT -DTFT_BACKLIGHT_ON=HIGH @@ -606,7 +606,7 @@ lib_ignore = ;-------------------------------------------------------------------- -[env:NerminerV2-T-QT] +[env:NerdminerV2-T-QT] platform = espressif32@6.6.0 board = esp32-s3-t-qt-pro framework = arduino @@ -619,7 +619,7 @@ monitor_speed = 115200 upload_speed = 115200 build_flags = -D BOARD_HAS_PSRAM - -D NERMINER_T_QT=1 + -D NERDMINER_T_QT=1 lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 diff --git a/src/drivers/devices/device.h b/src/drivers/devices/device.h index 5f82fef..9f72dde 100644 --- a/src/drivers/devices/device.h +++ b/src/drivers/devices/device.h @@ -9,9 +9,9 @@ #include "esp32DevKit.h" #elif defined(TDISPLAY) #include "lilygoS3TDisplay.h" -#elif defined(NERMINER_S3_AMOLED) +#elif defined(NERDMINER_S3_AMOLED) #include "lilygoS3Amoled.h" -#elif defined(NERMINER_S3_DONGLE) +#elif defined(NERDMINER_S3_DONGLE) #include "lilygoS3Dongle.h" #elif defined(LILYGO_S3_T_EMBED) #include "lilygoS3TEmbed.h" @@ -19,7 +19,7 @@ #include "esp322432s028r.h" #elif defined(ESP32_2432S028_2USB) // For another type of ESP32_2432S028 version with 2 USB connectors #include "esp322432s028r.h" -#elif defined(NERMINER_T_QT) +#elif defined(NERDMINER_T_QT) #include "lilygoT_QT.h" #elif defined(NERDMINER_T_DISPLAY_V1) #include "lilygoV1TDisplay.h" @@ -39,7 +39,7 @@ #include "m5stack.h" #elif defined(WT32_BOARD) #include "wt32.h" -#elif defined(NERMINER_S3_GEEK) +#elif defined(NERDMINER_S3_GEEK) #include "waveshareS3Geek.h" #elif defined(NERDMINER_T_HMI) #include "lilygoT_HMI.h" From 8b82bd139f38654f27df88dc359d4b9fc166f86c Mon Sep 17 00:00:00 2001 From: Julio MATARRANZ Date: Wed, 23 Oct 2024 01:28:49 +0200 Subject: [PATCH 09/15] chore : update fastled and onebutton --- platformio.ini | 62 +++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/platformio.ini b/platformio.ini index 2a9718c..54c89b9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,7 +32,7 @@ build_flags = lib_deps = bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 m5stack/M5StickC@^0.2.5 lib_ignore = @@ -62,7 +62,7 @@ lib_deps = lovyan03/LovyanGFX@^1.1.12 https://github.com/tzapu/WiFiManager.git#v2.0.17 arduino-libraries/NTPClient@^3.2.1 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 build_flags = -D BOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue @@ -96,7 +96,7 @@ lib_deps = lovyan03/LovyanGFX@^1.1.12 https://github.com/tzapu/WiFiManager.git#v2.0.17 arduino-libraries/NTPClient@^3.2.1 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 build_flags = -D BOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue @@ -134,9 +134,9 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 - fastled/FastLED@^3.6.0 + fastled/FastLED@3.7.8 lib_ignore = TFT_eSPI HANSOLOminerv2 @@ -163,7 +163,7 @@ build_flags = lib_deps = bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 m5stack/M5Stack@^0.4.6 lib_ignore = @@ -194,7 +194,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 lib_ignore = TFT_eSPI @@ -225,9 +225,9 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 - fastled/FastLED@^3.6.0 + fastled/FastLED@3.7.8 lib_ignore = TFT_eSPI HANSOLOminerv2 @@ -258,7 +258,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 lib_ignore = TFT_eSPI @@ -288,7 +288,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 lib_ignore = TFT_eSPI @@ -318,9 +318,9 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 - fastled/FastLED@^3.6.0 + fastled/FastLED@3.7.8 lib_ignore = TFT_eSPI HANSOLOminerv2 @@ -350,9 +350,9 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 - fastled/FastLED@^3.6.0 + fastled/FastLED@3.7.8 lib_ignore = TFT_eSPI HANSOLOminerv2 @@ -386,7 +386,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 lib_ignore = HANSOLOminerv2 @@ -420,7 +420,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 lib_ignore = HANSOLOminerv2 @@ -447,7 +447,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 lib_ignore = HANSOLOminerv2 @@ -477,7 +477,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 lib_ignore = HANSOLOminerv2 @@ -498,7 +498,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4 lib_ignore = @@ -520,7 +520,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4 lib_ignore = @@ -543,9 +543,9 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 - fastled/FastLED@^3.6.0 + fastled/FastLED@3.7.8 lib_ignore = HANSOLOminerv2 @@ -570,7 +570,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 lib_ignore = HANSOLOminerv2 @@ -598,7 +598,7 @@ build_flags = lib_deps = bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 https://github.com/takkaO/OpenFontRender#v1.2 lib_ignore = @@ -624,7 +624,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 lib_ignore = HANSOLOminerv2 @@ -674,7 +674,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 bodmer/TFT_eSPI@^2.5.43 https://github.com/achillhasler/TFT_eTouch @@ -727,7 +727,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 bodmer/TFT_eSPI@^2.5.43 https://github.com/achillhasler/TFT_eTouch @@ -787,7 +787,7 @@ lib_deps = https://github.com/takkaO/OpenFontRender#v1.2 bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 https://github.com/arduino-libraries/NTPClient@^3.2.1 lib_ignore = HANSOLOminerv2 @@ -813,9 +813,9 @@ build_flags = lib_deps = bblanchon/ArduinoJson@^6.21.5 https://github.com/tzapu/WiFiManager.git#v2.0.17 - mathertel/OneButton@^2.5.0 + mathertel/oneButton@^2.6.1 arduino-libraries/NTPClient@^3.2.1 - fastled/FastLED@^3.6.0 + fastled/FastLED@3.7.8 lib_ignore = TFT_eSPI SD From 9dfb54f86d13b54a5edab7386fd116e93b0b9e6c Mon Sep 17 00:00:00 2001 From: Xundi007 Date: Sun, 1 Dec 2024 03:39:16 +0100 Subject: [PATCH 10/15] Variant ESP32_2432S028_2USB missing invert screen config option, extra screen heap --- src/NerdMinerV2.ino.cpp | 2 +- src/wManager.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/NerdMinerV2.ino.cpp b/src/NerdMinerV2.ino.cpp index 486e0ed..fa822bc 100644 --- a/src/NerdMinerV2.ino.cpp +++ b/src/NerdMinerV2.ino.cpp @@ -127,7 +127,7 @@ void setup() /******** CREATE STRATUM TASK *****/ sprintf(name, "(%s)", "Stratum"); - #ifdef ESP32_2432S028R + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) // Free a little bit of the heap to the screen BaseType_t res2 = xTaskCreatePinnedToCore(runStratumWorker, "Stratum", 13500, (void*)name, 3, NULL,1); #else diff --git a/src/wManager.cpp b/src/wManager.cpp index f4eee2c..75a5149 100644 --- a/src/wManager.cpp +++ b/src/wManager.cpp @@ -179,7 +179,7 @@ void init_WifiManager() wm.addParameter(&time_text_box_num); wm.addParameter(&features_html); wm.addParameter(&save_stats_to_nvs); - #ifdef ESP32_2432S028R + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) char checkboxParams2[24] = "type=\"checkbox\""; if (Settings.invertColors) { @@ -208,7 +208,7 @@ void init_WifiManager() Settings.Timezone = atoi(time_text_box_num.getValue()); //Serial.println(save_stats_to_nvs.getValue()); Settings.saveStats = (strncmp(save_stats_to_nvs.getValue(), "T", 1) == 0); - #ifdef ESP32_2432S028R + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) Settings.invertColors = (strncmp(invertColors.getValue(), "T", 1) == 0); #endif nvMem.saveConfig(&Settings); @@ -238,7 +238,7 @@ void init_WifiManager() Settings.Timezone = atoi(time_text_box_num.getValue()); // Serial.println(save_stats_to_nvs.getValue()); Settings.saveStats = (strncmp(save_stats_to_nvs.getValue(), "T", 1) == 0); - #ifdef ESP32_2432S028R + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) Settings.invertColors = (strncmp(invertColors.getValue(), "T", 1) == 0); #endif nvMem.saveConfig(&Settings); @@ -284,7 +284,7 @@ void init_WifiManager() Serial.print("TimeZone fromUTC: "); Serial.println(Settings.Timezone); - #ifdef ESP32_2432S028R + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) Settings.invertColors = (strncmp(invertColors.getValue(), "T", 1) == 0); Serial.print("Invert Colors: "); Serial.println(Settings.invertColors); @@ -296,7 +296,7 @@ void init_WifiManager() if (shouldSaveConfig) { nvMem.saveConfig(&Settings); - #ifdef ESP32_2432S028R + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) if (Settings.invertColors) ESP.restart(); #endif } From d68516607ca0e26409c31c54e3e2b95f56e7d0a2 Mon Sep 17 00:00:00 2001 From: Xundi007 Date: Sun, 1 Dec 2024 05:31:16 +0100 Subject: [PATCH 11/15] CYD ESP32_2432S028 Brightness option in config --- src/drivers/displays/esp23_2432s028r.cpp | 19 +++++++++++++++++-- src/drivers/storage/SDCard.cpp | 5 +++++ src/drivers/storage/nvMemory.cpp | 6 ++++++ src/drivers/storage/storage.h | 4 ++++ src/wManager.cpp | 22 ++++++++++++++++++++++ 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/drivers/displays/esp23_2432s028r.cpp b/src/drivers/displays/esp23_2432s028r.cpp index fe2545d..98fe986 100644 --- a/src/drivers/displays/esp23_2432s028r.cpp +++ b/src/drivers/displays/esp23_2432s028r.cpp @@ -75,6 +75,12 @@ void esp32_2432S028R_Init(void) TFT_eTouchBase::Calibation calibation = { 233, 3785, 3731, 120, 2 }; touch.setCalibration(calibation); + + // Configuring screen backlight brightness using ledcontrol channel 0. + // Using 5000Hz in 8bit resolution, which gives 0-255 possible duty cycle setting. + ledcSetup(0, 5000, 8); + ledcAttachPin(TFT_BL, 0); + ledcWrite(0, Settings.Brightness); //background.createSprite(WIDTH, HEIGHT); // Background Sprite //background.setSwapBytes(true); @@ -103,9 +109,14 @@ void esp32_2432S028R_Init(void) void esp32_2432S028R_AlternateScreenState(void) { - int screen_state = digitalRead(TFT_BL); Serial.println("Switching display state"); - digitalWrite(TFT_BL, !screen_state); + int screen_state_duty = ledcRead(0); + // Switching the duty cycle for the ledc channel, where the TFT_BL pin is attached. + if (screen_state_duty > 0) { + ledcWrite(0, 0); + } else { + ledcWrite(0, Settings.Brightness); + } } void esp32_2432S028R_AlternateRotation(void) @@ -533,6 +544,10 @@ void esp32_2432S028R_DoLedStuff(unsigned long frame) if (((t_x > 109)&&(t_x < 211)) && ((t_y > 185)&&(t_y < 241))) { bottomScreenBlue ^= true; hasChangedScreen = true; + } else if((t_x > 235) && ((t_y > 0)&&(t_y < 16))) { + // Touching the top right corner of the screen, roughly in the gray status label. + // Disabling the screen backlight. + esp32_2432S028R_AlternateScreenState(); } else if (t_x > 160) { diff --git a/src/drivers/storage/SDCard.cpp b/src/drivers/storage/SDCard.cpp index 1431232..c8c579d 100644 --- a/src/drivers/storage/SDCard.cpp +++ b/src/drivers/storage/SDCard.cpp @@ -128,6 +128,11 @@ bool SDCard::loadConfigFile(TSettings* Settings) } else { Settings->invertColors = false; } + if (json.containsKey(JSON_KEY_BRIGHTNESS)) { + Settings->Brightness = json[JSON_KEY_BRIGHTNESS].as(); + } else { + Settings->Brightness = 250; + } // Serial.printf("Carteira Lida SD:%s\n", Settings.BtcWallet); Serial.printf("Carteira Lida SDs:%s\n", Settings->BtcWallet); return true; diff --git a/src/drivers/storage/nvMemory.cpp b/src/drivers/storage/nvMemory.cpp index 2dbb0aa..f71ee22 100644 --- a/src/drivers/storage/nvMemory.cpp +++ b/src/drivers/storage/nvMemory.cpp @@ -36,6 +36,7 @@ bool nvMemory::saveConfig(TSettings* Settings) json[JSON_SPIFFS_KEY_TIMEZONE] = Settings->Timezone; json[JSON_SPIFFS_KEY_STATS2NV] = Settings->saveStats; json[JSON_SPIFFS_KEY_INVCOLOR] = Settings->invertColors; + json[JSON_SPIFFS_KEY_BRIGHTNESS] = Settings->Brightness; // Open config file File configFile = SPIFFS.open(JSON_CONFIG_FILE, "w"); @@ -103,6 +104,11 @@ bool nvMemory::loadConfig(TSettings* Settings) } else { Settings->invertColors = false; } + if (json.containsKey(JSON_SPIFFS_KEY_BRIGHTNESS)) { + Settings->Brightness = json[JSON_SPIFFS_KEY_BRIGHTNESS].as(); + } else { + Settings->Brightness = 250; + } return true; } else diff --git a/src/drivers/storage/storage.h b/src/drivers/storage/storage.h index b667966..4a0fa6c 100644 --- a/src/drivers/storage/storage.h +++ b/src/drivers/storage/storage.h @@ -19,6 +19,7 @@ #define DEFAULT_TIMEZONE 2 #define DEFAULT_SAVESTATS false #define DEFAULT_INVERTCOLORS false +#define DEFAULT_BRIGHTNESS 250 // JSON config files #define JSON_CONFIG_FILE "/config.json" @@ -33,6 +34,7 @@ #define JSON_KEY_TIMEZONE "Timezone" #define JSON_KEY_STATS2NV "SaveStats" #define JSON_KEY_INVCOLOR "invertColors" +#define JSON_KEY_BRIGHTNESS "Brightness" // JSON config file SPIFFS (different for backward compatibility with existing devices) #define JSON_SPIFFS_KEY_POOLURL "poolString" @@ -42,6 +44,7 @@ #define JSON_SPIFFS_KEY_TIMEZONE "gmtZone" #define JSON_SPIFFS_KEY_STATS2NV "saveStatsToNVS" #define JSON_SPIFFS_KEY_INVCOLOR "invertColors" +#define JSON_SPIFFS_KEY_BRIGHTNESS "Brightness" // settings struct TSettings @@ -55,6 +58,7 @@ struct TSettings int Timezone{ DEFAULT_TIMEZONE }; bool saveStats{ DEFAULT_SAVESTATS }; bool invertColors{ DEFAULT_INVERTCOLORS }; + int Brightness{ DEFAULT_BRIGHTNESS }; }; #endif // _STORAGE_H_ \ No newline at end of file diff --git a/src/wManager.cpp b/src/wManager.cpp index f4eee2c..32f818e 100644 --- a/src/wManager.cpp +++ b/src/wManager.cpp @@ -187,6 +187,13 @@ void init_WifiManager() } WiFiManagerParameter invertColors("inverColors", "Invert Display Colors (if the colors looks weird)", "T", 2, checkboxParams2, WFM_LABEL_AFTER); wm.addParameter(&invertColors); + #endif + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) + char brightnessConvValue[2]; + sprintf(brightnessConvValue, "%d", Settings.Brightness); + // Text box (Number) - 3 characters maximum + WiFiManagerParameter brightness_text_box_num("Brightness", "Screen backlight Duty Cycle (0-255)", brightnessConvValue, 3); + wm.addParameter(&brightness_text_box_num); #endif Serial.println("AllDone: "); @@ -211,6 +218,9 @@ void init_WifiManager() #ifdef ESP32_2432S028R Settings.invertColors = (strncmp(invertColors.getValue(), "T", 1) == 0); #endif + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) + Settings.Brightness = atoi(brightness_text_box_num.getValue()); + #endif nvMem.saveConfig(&Settings); delay(3*SECOND_MS); //reset and try again, or maybe put it to deep sleep @@ -241,6 +251,9 @@ void init_WifiManager() #ifdef ESP32_2432S028R Settings.invertColors = (strncmp(invertColors.getValue(), "T", 1) == 0); #endif + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) + Settings.Brightness = atoi(brightness_text_box_num.getValue()); + #endif nvMem.saveConfig(&Settings); vTaskDelay(2000 / portTICK_PERIOD_MS); } @@ -290,6 +303,12 @@ void init_WifiManager() Serial.println(Settings.invertColors); #endif + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) + Settings.Brightness = atoi(brightness_text_box_num.getValue()); + Serial.print("Brightness: "); + Serial.println(Settings.Brightness); + #endif + } // Save the custom parameters to FS @@ -299,6 +318,9 @@ void init_WifiManager() #ifdef ESP32_2432S028R if (Settings.invertColors) ESP.restart(); #endif + #if defined(ESP32_2432S028R) || defined(ESP32_2432S028_2USB) + if (Settings.Brightness != 250) ESP.restart(); + #endif } } From 4102e735a3d9a1012a350dce0a93aa50b98d416a Mon Sep 17 00:00:00 2001 From: TheMiner203 Date: Fri, 20 Dec 2024 21:18:21 +0800 Subject: [PATCH 12/15] M5StickC Plus2 Support --- boards/m5stick-c-plus2.json | 35 ++++++++++ .../variants/m5stick_c_plus2/pins_arduino.h | 33 ++++++++++ lib/TFT_eSPI/User_Setup_Select.h | 3 + .../User_Setups/Setup304_M5StickCPlus2.h | 65 +++++++++++++++++++ src/drivers/devices/M5Stick-C-Plus2.h | 10 +++ src/drivers/devices/device.h | 2 + 6 files changed, 148 insertions(+) create mode 100644 boards/m5stick-c-plus2.json create mode 100644 boards/variants/m5stick_c_plus2/pins_arduino.h create mode 100644 lib/TFT_eSPI/User_Setups/Setup304_M5StickCPlus2.h create mode 100644 src/drivers/devices/M5Stick-C-Plus2.h diff --git a/boards/m5stick-c-plus2.json b/boards/m5stick-c-plus2.json new file mode 100644 index 0000000..a0065d8 --- /dev/null +++ b/boards/m5stick-c-plus2.json @@ -0,0 +1,35 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": "-DARDUINO_M5Stick_C_Plus2", + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variants_dir": "boards/variants", + "variant": "m5stick_c_plus2" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stick-С-Plus2", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 2095104, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 1500000 + }, + "url": "https://docs.m5stack.com/en/core/M5StickC%20PLUS2", + "vendor": "M5Stack" +} diff --git a/boards/variants/m5stick_c_plus2/pins_arduino.h b/boards/variants/m5stick_c_plus2/pins_arduino.h new file mode 100644 index 0000000..1948afc --- /dev/null +++ b/boards/variants/m5stick_c_plus2/pins_arduino.h @@ -0,0 +1,33 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 32; +static const uint8_t SCL = 33; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 15; +static const uint8_t MISO = 36; +static const uint8_t SCK = 13; + +static const uint8_t G9 = 9; +static const uint8_t G10 = 10; +static const uint8_t G37 = 37; +static const uint8_t G39 = 39; +static const uint8_t G32 = 32; +static const uint8_t G33 = 33; +static const uint8_t G26 = 26; +static const uint8_t G36 = 36; +static const uint8_t G0 = 0; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +static const uint8_t ADC1 = 35; +static const uint8_t ADC2 = 36; + +#endif /* Pins_Arduino_h */ diff --git a/lib/TFT_eSPI/User_Setup_Select.h b/lib/TFT_eSPI/User_Setup_Select.h index 0955318..6f9a082 100644 --- a/lib/TFT_eSPI/User_Setup_Select.h +++ b/lib/TFT_eSPI/User_Setup_Select.h @@ -158,6 +158,9 @@ #ifdef NERDMINER_S3_GEEK #include // Setup file for Waveshare Setup303_WaveShare ESP32S3_GEEK with ST7789 135*240 TFT #endif +#ifdef M5STICK_C_PLUS2 +#include // Setup file for ESP32 configured for ST7735 128 x 128 animated eyes +#endif //#include // Setup file for Bw16-based boards with ST7735 160 x 80 TFT //#include // Template file for a setup diff --git a/lib/TFT_eSPI/User_Setups/Setup304_M5StickCPlus2.h b/lib/TFT_eSPI/User_Setups/Setup304_M5StickCPlus2.h new file mode 100644 index 0000000..f4a1dd5 --- /dev/null +++ b/lib/TFT_eSPI/User_Setups/Setup304_M5StickCPlus2.h @@ -0,0 +1,65 @@ +// ST7789 135 x 240 display + +#define USER_SETUP_ID 304 + +// #define DISABLE_ALL_LIBRARY_WARNINGS + +#define ST7789_DRIVER + +#define TFT_WIDTH 135 +#define TFT_HEIGHT 240 + +#define TFT_BL 27 +#define TFT_BACKLIGHT_ON HIGH +#define TFT_MISO -1 +#define TFT_MOSI 15 +#define TFT_SCLK 13 +#define TFT_CS 5 +#define TFT_DC 14 +#define TFT_RST 12 + + +#define CGRAM_OFFSET // Library will add offsets required + +//#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue +//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red + +//#define TFT_INVERSION_ON +//#define TFT_INVERSION_OFF + +// DSTIKE stepup +//#define TFT_DC 23 +//#define TFT_RST 32 +//#define TFT_MOSI 26 +//#define TFT_SCLK 27 + +// Generic ESP32 setup +//#define TFT_MISO 19 +//#define TFT_MOSI 23 +//#define TFT_SCLK 18 +//#define TFT_CS -1 // Not connected +//#define TFT_DC 2 +//#define TFT_RST 4 // Connect reset to ensure display initialises + +// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation + +#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH +#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters +#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters +#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm +#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. +#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. +//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT +#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts + +#define SMOOTH_FONT + + +// #define SPI_FREQUENCY 27000000 +#define SPI_FREQUENCY 40000000 + +#define SPI_READ_FREQUENCY 20000000 + +#define SPI_TOUCH_FREQUENCY 2500000 + +// #define SUPPORT_TRANSACTIONS \ No newline at end of file diff --git a/src/drivers/devices/M5Stick-C-Plus2.h b/src/drivers/devices/M5Stick-C-Plus2.h new file mode 100644 index 0000000..6f27f1f --- /dev/null +++ b/src/drivers/devices/M5Stick-C-Plus2.h @@ -0,0 +1,10 @@ +#ifndef _M5_STICK_C_PLUS2_H +#define _M5_STICK_C_PLUS2_H + +#define PIN_BUTTON_1 37 +#define PIN_BUTTON_2 39 +#define LED_PIN 19 + +#define V1_DISPLAY + +#endif \ No newline at end of file diff --git a/src/drivers/devices/device.h b/src/drivers/devices/device.h index 9f72dde..6739663 100644 --- a/src/drivers/devices/device.h +++ b/src/drivers/devices/device.h @@ -5,6 +5,8 @@ #include "nerdMinerV2.h" #elif defined(M5STICK_C) #include "M5Stick-C.h" +#elif defined(M5STICK_C_PLUS2) +#include "M5Stick-C-Plus2.h" #elif defined(DEVKITV1) #include "esp32DevKit.h" #elif defined(TDISPLAY) From 814d667fbb09e137d067e9d38e54882966081e3d Mon Sep 17 00:00:00 2001 From: TheMiner203 Date: Fri, 20 Dec 2024 21:19:27 +0800 Subject: [PATCH 13/15] M5StickC Plus 2 Support --- platformio.ini | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/platformio.ini b/platformio.ini index 54c89b9..cbfa40f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,6 +13,37 @@ globallib_dir = lib default_envs = NerdminerV2-T-HMI, wt32-sc01, wt32-sc01-plus, han_m5stack, M5Stick-C, esp32cam, ESP32-2432S028R, ESP32_2432S028_2USB, NerdminerV2, Lilygo-T-Embed, ESP32-devKitv1, NerdminerV2-S3-DONGLE, NerdminerV2-S3-GEEK, NerdminerV2-S3-AMOLED, NerdminerV2-S3-AMOLED-TOUCH, NerdminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R, M5-StampS3, ESP32-S3-devKitv1, ESP32-S3-mini-wemos, ESP32-S2-mini-wemos, ESP32-S3-mini-weact, ESP32-D0WD-V3-weact, ESP32-C3-devKitmv1, ESP32-C3-super-mini +[env:M5Stick-C-Plus2] +platform = espressif32@6.6.0 +board = m5stick-c-plus2 +framework = arduino +monitor_filters = + esp32_exception_decoder + time + log2file +;board_build.arduino.memory_type = qio_opi +monitor_speed = 115200 +upload_speed = 1500000 +# 2 x 4.5MB app, 6.875MB SPIFFS +board_build.partitions = huge_app.csv +build_flags = + -D M5STICK_C_PLUS2=1 + ;-D DEBUG_MINING=1 +lib_deps = + bblanchon/ArduinoJson@^6.21.5 + https://github.com/tzapu/WiFiManager.git#v2.0.17 + https://github.com/takkaO/OpenFontRender#v1.2 + mathertel/OneButton@^2.5.0 + arduino-libraries/NTPClient@^3.2.1 + m5stack/M5StickCPlus2 +lib_ignore = + SD + SD_MMC + rm67162 + HANSOLOminerv2 + +;-------------------------------------------------------------------- + [env:M5Stick-C] platform = espressif32@6.6.0 board = m5stick-c From 3b18355b6f7d1652ae63ea26639c8731cd70cb18 Mon Sep 17 00:00:00 2001 From: Thiti Yamsung Date: Wed, 18 Dec 2024 23:18:02 +0700 Subject: [PATCH 14/15] feat: support ESP32-C3 and ESP32-S3 0.42 OLED --- boards/esp32-s3-0.42oled.json | 38 +++++ platformio.ini | 58 +++++++ src/drivers/devices/device.h | 4 + src/drivers/devices/esp32C3042OLED.h | 14 ++ src/drivers/devices/esp32S3042OLED.h | 14 ++ src/drivers/displays/display.cpp | 4 + src/drivers/displays/displayDriver.h | 1 + src/drivers/displays/oled042DisplayDriver.cpp | 156 ++++++++++++++++++ 8 files changed, 289 insertions(+) create mode 100644 boards/esp32-s3-0.42oled.json create mode 100644 src/drivers/devices/esp32C3042OLED.h create mode 100644 src/drivers/devices/esp32S3042OLED.h create mode 100644 src/drivers/displays/oled042DisplayDriver.cpp diff --git a/boards/esp32-s3-0.42oled.json b/boards/esp32-s3-0.42oled.json new file mode 100644 index 0000000..6ea023f --- /dev/null +++ b/boards/esp32-s3-0.42oled.json @@ -0,0 +1,38 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [["0x239A", "0x811B"]], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": ["bluetooth", "wifi"], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": ["esp-builtin"], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": ["arduino", "espidf"], + "name": "ESP32 S3 0.42 OLED (4 MB QD, 2MB PSRAM)", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 532480, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 54c89b9..2215446 100644 --- a/platformio.ini +++ b/platformio.ini @@ -327,6 +327,64 @@ lib_ignore = ;-------------------------------------------------------------------- +[env:ESP32-C3-042-OLED] +platform = espressif32@6.6.0 +board = esp32-c3-devkitm-1 +framework = arduino +monitor_filters = + esp32_exception_decoder + time + log2file +monitor_speed = 115200 +upload_speed = 115200 +board_build.partitions = huge_app.csv +build_flags = + -D ARDUINO_USB_MODE=1 + -D ARDUINO_USB_CDC_ON_BOOT=1 + -D ESP32_C3_042_OLED + -D PIN_BUTTON_1=9 +lib_deps = + https://github.com/takkaO/OpenFontRender#v1.2 + bblanchon/ArduinoJson@^6.21.5 + https://github.com/tzapu/WiFiManager.git#v2.0.17 + mathertel/oneButton@^2.6.1 + arduino-libraries/NTPClient@^3.2.1 + olikraus/U8g2@^2.34.17 +lib_ignore = + TFT_eSPI + HANSOLOminerv2 + +;-------------------------------------------------------------------- + +[env:ESP32-S3-042-OLED] +platform = espressif32@6.6.0 +board = esp32-s3-0.42oled +framework = arduino +monitor_filters = + esp32_exception_decoder + time + log2file +monitor_speed = 115200 +upload_speed = 115200 +board_build.partitions = huge_app.csv +build_flags = + -D ARDUINO_USB_MODE=1 + -D ARDUINO_USB_CDC_ON_BOOT=1 + -D ESP32_S3_042_OLED + -D PIN_BUTTON_1=0 +lib_deps = + https://github.com/takkaO/OpenFontRender#v1.2 + bblanchon/ArduinoJson@^6.21.5 + https://github.com/tzapu/WiFiManager.git#v2.0.17 + mathertel/oneButton@^2.6.1 + arduino-libraries/NTPClient@^3.2.1 + olikraus/U8g2@^2.34.17 +lib_ignore = + TFT_eSPI + HANSOLOminerv2 + +;-------------------------------------------------------------------- + [env:ESP32-S3-devKitv1] platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 diff --git a/src/drivers/devices/device.h b/src/drivers/devices/device.h index 9f72dde..93ca449 100644 --- a/src/drivers/devices/device.h +++ b/src/drivers/devices/device.h @@ -7,6 +7,10 @@ #include "M5Stick-C.h" #elif defined(DEVKITV1) #include "esp32DevKit.h" +#elif defined(ESP32_C3_042_OLED) +#include "esp32C3042OLED.h" +#elif defined(ESP32_S3_042_OLED) +#include "esp32S3042OLED.h" #elif defined(TDISPLAY) #include "lilygoS3TDisplay.h" #elif defined(NERDMINER_S3_AMOLED) diff --git a/src/drivers/devices/esp32C3042OLED.h b/src/drivers/devices/esp32C3042OLED.h new file mode 100644 index 0000000..c081ef6 --- /dev/null +++ b/src/drivers/devices/esp32C3042OLED.h @@ -0,0 +1,14 @@ +#ifndef _ESP32_C3_042_OLED_H +#define _ESP32_C3_042_OLED_H + +#ifndef SDA_PIN +#define SDA_PIN 5 +#endif + +#ifndef SCL_PIN +#define SCL_PIN 6 +#endif + +#define OLED_042_DISPLAY + +#endif \ No newline at end of file diff --git a/src/drivers/devices/esp32S3042OLED.h b/src/drivers/devices/esp32S3042OLED.h new file mode 100644 index 0000000..1848d68 --- /dev/null +++ b/src/drivers/devices/esp32S3042OLED.h @@ -0,0 +1,14 @@ +#ifndef _ESP32_S3_042_OLED_H +#define _ESP32_S3_042_OLED_H + +#ifndef SDA_PIN +#define SDA_PIN 41 +#endif + +#ifndef SCL_PIN +#define SCL_PIN 40 +#endif + +#define OLED_042_DISPLAY + +#endif \ No newline at end of file diff --git a/src/drivers/displays/display.cpp b/src/drivers/displays/display.cpp index d8118ec..2508b35 100644 --- a/src/drivers/displays/display.cpp +++ b/src/drivers/displays/display.cpp @@ -16,6 +16,10 @@ DisplayDriver *currentDisplayDriver = &wt32DisplayDriver; DisplayDriver *currentDisplayDriver = &ledDisplayDriver; #endif +#ifdef OLED_042_DISPLAY +DisplayDriver *currentDisplayDriver = &oled042DisplayDriver; +#endif + #ifdef T_DISPLAY DisplayDriver *currentDisplayDriver = &tDisplayDriver; #endif diff --git a/src/drivers/displays/displayDriver.h b/src/drivers/displays/displayDriver.h index c2dff75..e7c9d8d 100644 --- a/src/drivers/displays/displayDriver.h +++ b/src/drivers/displays/displayDriver.h @@ -32,6 +32,7 @@ extern DisplayDriver m5stackDisplayDriver; extern DisplayDriver wt32DisplayDriver; extern DisplayDriver noDisplayDriver; extern DisplayDriver ledDisplayDriver; +extern DisplayDriver oled042DisplayDriver; extern DisplayDriver tDisplayDriver; extern DisplayDriver amoledDisplayDriver; extern DisplayDriver dongleDisplayDriver; diff --git a/src/drivers/displays/oled042DisplayDriver.cpp b/src/drivers/displays/oled042DisplayDriver.cpp new file mode 100644 index 0000000..02c18c4 --- /dev/null +++ b/src/drivers/displays/oled042DisplayDriver.cpp @@ -0,0 +1,156 @@ + +#include "displayDriver.h" + +#ifdef OLED_042_DISPLAY + +#include +#include "monitor.h" + +#ifdef U8X8_HAVE_HW_SPI +#include +#endif +#ifdef U8X8_HAVE_HW_I2C +#include +#endif + +static uint8_t btc_icon[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xF0, 0x03, 0x00, 0x00, 0xFE, 0x1F, 0x00, 0x00, 0xFF, 0x3F, 0x00, + 0x80, 0xFF, 0x7F, 0x00, 0xC0, 0xFF, 0xFF, 0x00, 0xE0, 0x3F, 0xFF, 0x01, + 0xF0, 0x3F, 0xFF, 0x03, 0xF0, 0x0F, 0xFC, 0x03, 0xF0, 0x0F, 0xF8, 0x03, + 0xF8, 0xCF, 0xF9, 0x07, 0xF8, 0xCF, 0xF9, 0x07, 0xF8, 0x0F, 0xFC, 0x07, + 0xF8, 0x0F, 0xF8, 0x07, 0xF8, 0xCF, 0xF9, 0x07, 0xF8, 0xCF, 0xF9, 0x07, + 0xF0, 0x0F, 0xF8, 0x03, 0xF0, 0x0F, 0xFC, 0x03, 0xF0, 0x3F, 0xFF, 0x03, + 0xE0, 0x3F, 0xFF, 0x01, 0xC0, 0xFF, 0xFF, 0x00, 0x80, 0xFF, 0x7F, 0x00, + 0x00, 0xFF, 0x3F, 0x00, 0x00, 0xFE, 0x1F, 0x00, 0x00, 0xF0, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static uint8_t setup_icon[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00, 0xE0, 0x01, 0x00, + 0x00, 0xF0, 0x03, 0x00, 0xC0, 0xF0, 0xC3, 0x00, 0xE0, 0xF9, 0xE3, 0x01, + 0xF0, 0xFF, 0xFF, 0x03, 0xF0, 0xFF, 0xFF, 0x03, 0xE0, 0xFF, 0xFF, 0x01, + 0xC0, 0xFF, 0xFF, 0x00, 0xC0, 0xFF, 0xFF, 0x00, 0xE0, 0x1F, 0xFE, 0x00, + 0xF8, 0x0F, 0xFC, 0x07, 0xFE, 0x07, 0xF8, 0x1F, 0xFE, 0x07, 0xF8, 0x1F, + 0xFE, 0x07, 0xF8, 0x1F, 0xFE, 0x07, 0xF8, 0x1F, 0xF8, 0x0F, 0xFC, 0x07, + 0xE0, 0x1F, 0xFE, 0x00, 0xC0, 0xFF, 0xFF, 0x00, 0xC0, 0xFF, 0xFF, 0x00, + 0xE0, 0xFF, 0xFF, 0x01, 0xF0, 0xFF, 0xFF, 0x03, 0xF0, 0xFF, 0xFF, 0x03, + 0xE0, 0xF9, 0xE3, 0x01, 0xC0, 0xF0, 0xC3, 0x00, 0x00, 0xF0, 0x03, 0x00, + 0x00, 0xE0, 0x01, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +U8G2_SSD1306_72X40_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); + +void clearScreen(void) { + u8g2.clearBuffer(); + u8g2.sendBuffer(); +} + +void serialPrint(unsigned long mElapsed) { + mining_data data = getMiningData(mElapsed); + + // Print hashrate to serial + Serial.printf(">>> Completed %s share(s), %s Khashes, avg. hashrate %s KH/s\n", + data.completedShares.c_str(), data.totalKHashes.c_str(), data.currentHashRate.c_str()); + + // Print extended data to serial for no display devices + Serial.printf(">>> Valid blocks: %s\n", data.valids.c_str()); + Serial.printf(">>> Block templates: %s\n", data.templates.c_str()); + Serial.printf(">>> Best difficulty: %s\n", data.bestDiff.c_str()); + Serial.printf(">>> 32Bit shares: %s\n", data.completedShares.c_str()); + Serial.printf(">>> Temperature: %s\n", data.temp.c_str()); + Serial.printf(">>> Total MHashes: %s\n", data.totalMHashes.c_str()); + Serial.printf(">>> Time mining: %s\n", data.timeMining.c_str()); +} + +void oledDisplay_Init(void) +{ + Serial.println("OLED 0.42 display driver initialized"); + Wire.begin(SDA_PIN, SCL_PIN); + u8g2.begin(); + u8g2.clear(); + u8g2.setFlipMode(1); + clearScreen(); +} + +void oledDisplay_AlternateScreenState(void) +{ + Serial.println("Switching display state"); +} + +void oledDisplay_AlternateRotation(void) +{ +} + +void oledDisplay_Screen1(unsigned long mElapsed) +{ + mining_data data = getMiningData(mElapsed); + + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_helvB18_tf); + u8g2.drawStr(0, 20, data.currentHashRate.c_str()); + u8g2.setFont(u8g2_font_helvB08_tf); + u8g2.drawStr(45, 36, "KH/s"); + u8g2.sendBuffer(); + + serialPrint(mElapsed); +} + +void oledDisplay_Screen2(unsigned long mElapsed) +{ + mining_data data = getMiningData(mElapsed); + char temp[8]; + sprintf(temp, "%s°c", data.temp.c_str()); + + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_helvB18_tf); + u8g2.drawUTF8(0, 20, temp); + u8g2.sendBuffer(); + + serialPrint(mElapsed); +} + +void oledDisplay_LoadingScreen(void) +{ + Serial.println("Initializing..."); + u8g2.clearBuffer(); + u8g2.drawXBMP(20,5,30,30, btc_icon); + u8g2.sendBuffer(); +} + +void oledDisplay_SetupScreen(void) +{ + Serial.println("Setup..."); + u8g2.clearBuffer(); + u8g2.drawXBMP(20,0,30,30, setup_icon); + u8g2.setFont(u8g2_font_helvB08_tf); + u8g2.drawUTF8(20, 38, "Setup"); + u8g2.sendBuffer(); +} + +void oledDisplay_DoLedStuff(unsigned long frame) +{ +} + +void oledDisplay_AnimateCurrentScreen(unsigned long frame) +{ +} + +CyclicScreenFunction oledDisplayCyclicScreens[] = {oledDisplay_Screen1, oledDisplay_Screen2}; + +DisplayDriver oled042DisplayDriver = { + oledDisplay_Init, + oledDisplay_AlternateScreenState, + oledDisplay_AlternateRotation, + oledDisplay_LoadingScreen, + oledDisplay_SetupScreen, + oledDisplayCyclicScreens, + oledDisplay_AnimateCurrentScreen, + oledDisplay_DoLedStuff, + SCREENS_ARRAY_SIZE(oledDisplayCyclicScreens), + 0, + 0, + 0, +}; + +#endif From f62d4ab624e5976f2f2529df21004a9dfead2538 Mon Sep 17 00:00:00 2001 From: Mouflon <54674592+Mouflon23@users.noreply.github.com> Date: Mon, 30 Dec 2024 15:29:53 +0100 Subject: [PATCH 15/15] Update NerdMinerV2.ino.cpp --- src/NerdMinerV2.ino.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NerdMinerV2.ino.cpp b/src/NerdMinerV2.ino.cpp index 486e0ed..5894b83 100644 --- a/src/NerdMinerV2.ino.cpp +++ b/src/NerdMinerV2.ino.cpp @@ -157,7 +157,7 @@ void app_error_fault_handler(void *arg) { char *stack = (char *)arg; // Print the stack errors in the console - esp_log_write(ESP_LOG_ERROR, "APP_ERROR", "Pila de errores:\n%s", stack); + esp_log_write(ESP_LOG_ERROR, "APP_ERROR", "Error Stack Code:\n%s", stack); // restart ESP32 esp_restart();