Merge branch 'pr/420' into dev
This commit is contained in:
commit
2ea20ab143
@ -61,6 +61,7 @@ Every time an stratum job notification is received miner update its current work
|
||||
- ESP32-C3 Devkit ([Board Info](https://docs.platformio.org/en/latest/boards/espressif32/esp32-c3-devkitm-1.html))
|
||||
- ESP32-C3 Super Mini ([Board Info](https://docs.platformio.org/en/latest/boards/espressif32/seeed_xiao_esp32c3.html))
|
||||
- Waveshare ESP32-S3-GEEK ([Board Info](https://www.waveshare.com/wiki/ESP32-S3-GEEK))
|
||||
- LILYGO T-HMI ([Aliexpress link\*](https://s.click.aliexpress.com/e/_oFII4s2)) / Dev support: @cosmicpsyop
|
||||
|
||||
\*Affiliate links
|
||||
|
||||
|
@ -760,12 +760,13 @@ build_flags =
|
||||
|
||||
board_build.arduino.memory_type = qio_opi
|
||||
lib_deps =
|
||||
https://github.com/takkaO/OpenFontRender#v1.2
|
||||
bblanchon/ArduinoJson@^6.21.5
|
||||
https://github.com/tzapu/WiFiManager.git#v2.0.17
|
||||
https://github.com/liangyingy/arduino_xpt2046_library
|
||||
https://github.com/takkaO/OpenFontRender
|
||||
bblanchon/ArduinoJson@^6.21.2
|
||||
https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2
|
||||
mathertel/OneButton @ ^2.5.0
|
||||
arduino-libraries/NTPClient@^3.2.1
|
||||
bodmer/TFT_eSPI@^2.5.43
|
||||
arduino-libraries/NTPClient
|
||||
bodmer/TFT_eSPI @ ^2.5.31
|
||||
https://github.com/achillhasler/TFT_eTouch
|
||||
lib_ignore =
|
||||
HANSOLOminerv2
|
||||
|
@ -15,6 +15,10 @@
|
||||
#include "drivers/storage/SDCard.h"
|
||||
#include "timeconst.h"
|
||||
|
||||
#ifdef TOUCH_ENABLE
|
||||
#include "TouchHandler.h"
|
||||
#endif
|
||||
|
||||
//3 seconds WDT
|
||||
#define WDT_TIMEOUT 3
|
||||
//15 minutes WDT for miner task
|
||||
@ -28,6 +32,10 @@
|
||||
OneButton button2(PIN_BUTTON_2);
|
||||
#endif
|
||||
|
||||
#ifdef TOUCH_ENABLE
|
||||
extern TouchHandler touchHandler;
|
||||
#endif
|
||||
|
||||
extern monitor_data mMonitor;
|
||||
|
||||
#ifdef SD_ID
|
||||
@ -101,6 +109,10 @@ void setup()
|
||||
mMonitor.NerdStatus = NM_waitingConfig;
|
||||
doLedStuff(0);
|
||||
|
||||
#ifdef SDMMC_1BIT_FIX
|
||||
SDCrd.initSDcard();
|
||||
#endif
|
||||
|
||||
/******** INIT WIFI ************/
|
||||
init_WifiManager();
|
||||
|
||||
@ -161,6 +173,9 @@ void loop() {
|
||||
button2.tick();
|
||||
#endif
|
||||
|
||||
#ifdef TOUCH_ENABLE
|
||||
touchHandler.isTouched();
|
||||
#endif
|
||||
wifiManagerProcess(); // avoid delays() in loop when non-blocking and other long running code
|
||||
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
|
73
src/TouchHandler.cpp
Normal file
73
src/TouchHandler.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
#include "drivers/devices/device.h"
|
||||
#ifdef TOUCH_ENABLE
|
||||
#include "TouchHandler.h"
|
||||
|
||||
|
||||
|
||||
TouchHandler::~TouchHandler() {
|
||||
}
|
||||
|
||||
TouchHandler::TouchHandler(TFT_eSPI& tft, uint8_t csPin, uint8_t irqPin, SPIClass& spi)
|
||||
: tft(tft), csPin(csPin), irqPin(irqPin), spi(spi), lastTouchTime(0),
|
||||
screenSwitchCallback(nullptr), screenSwitchAltCallback(nullptr), touch(spi, csPin, irqPin) {
|
||||
|
||||
}
|
||||
|
||||
void TouchHandler::begin(uint16_t xres, uint16_t yres) {
|
||||
spi.begin(TOUCH_CLK, TOUCH_MISO, TOUCH_MOSI);
|
||||
touch.begin(xres, yres);
|
||||
}
|
||||
|
||||
void TouchHandler::setScreenSwitchCallback(void (*callback)()) {
|
||||
screenSwitchCallback = callback;
|
||||
}
|
||||
|
||||
void TouchHandler::setScreenSwitchAltCallback(void (*callback)()) {
|
||||
screenSwitchAltCallback = callback;
|
||||
}
|
||||
|
||||
|
||||
uint16_t TouchHandler::isTouched() {
|
||||
// XXX - move touch_x, touch_y to private and min_x, min_y,max_x, max_y
|
||||
uint16_t touch_x, touch_y, code = 0;
|
||||
|
||||
if (touch.pressed()) {
|
||||
touch_x = touch.RawX();
|
||||
touch_y = touch.RawY();
|
||||
|
||||
// Perform actions based on touch coordinates
|
||||
// if (y < y_min + (y_max - y_min) / 4) {
|
||||
if (touch_x < 200 + (1700 - 200) / 4) {
|
||||
// bottom
|
||||
code = 1;
|
||||
if (debounce() && screenSwitchAltCallback) {
|
||||
screenSwitchAltCallback();
|
||||
}
|
||||
} else {
|
||||
// top
|
||||
code = 2;
|
||||
if (debounce() && screenSwitchCallback) {
|
||||
screenSwitchCallback();
|
||||
}
|
||||
}
|
||||
|
||||
if (code) {
|
||||
if (code == 1)
|
||||
Serial.print("Touch bottom\n");
|
||||
else
|
||||
Serial.print("Touch top\n");
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
bool TouchHandler::debounce() {
|
||||
unsigned long currentTime = millis();
|
||||
if (currentTime - lastTouchTime >= 2000) {
|
||||
lastTouchTime = currentTime;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
31
src/TouchHandler.h
Normal file
31
src/TouchHandler.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef _TOUCHHANDLER_H_
|
||||
#define _TOUCHHANDLER_H_
|
||||
#ifdef TOUCH_ENABLE
|
||||
#include <TFT_eSPI.h> // TFT display library
|
||||
#include <xpt2046.h> // https://github.com/liangyingy/arduino_xpt2046_library
|
||||
|
||||
|
||||
class TouchHandler {
|
||||
public:
|
||||
TouchHandler();
|
||||
~TouchHandler();
|
||||
TouchHandler(TFT_eSPI& tft, uint8_t csPin, uint8_t irqPin, SPIClass& spi);
|
||||
void begin(uint16_t xres, uint16_t yres);
|
||||
uint16_t isTouched();
|
||||
void setScreenSwitchCallback(void (*callback)());
|
||||
void setScreenSwitchAltCallback(void (*callback)());
|
||||
private:
|
||||
bool debounce();
|
||||
TFT_eSPI& tft;
|
||||
XPT2046 touch;
|
||||
uint8_t csPin;
|
||||
uint8_t irqPin;
|
||||
SPIClass& spi;
|
||||
unsigned long lastTouchTime;
|
||||
// unsigned int lower_switch;
|
||||
void (*screenSwitchCallback)();
|
||||
void (*screenSwitchAltCallback)();
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
@ -4,6 +4,7 @@
|
||||
#define T_HMI_DISPLAY
|
||||
|
||||
#define PWR_EN_PIN (10)
|
||||
#define PIN_ENABLE5V PWR_EN_PIN
|
||||
#define PWR_ON_PIN (14)
|
||||
#define BAT_ADC_PIN (5)
|
||||
#define BUTTON1_PIN (0)
|
||||
@ -29,12 +30,13 @@
|
||||
|
||||
// sd card
|
||||
// 1-bit SD MMC
|
||||
#ifdef DEFINE_SDMMC_1BIT
|
||||
#define SDMMC_CLK (12)
|
||||
#define SDMMC_CMD (11)
|
||||
#define SDMMC_D0 (13)
|
||||
#endif
|
||||
|
||||
#define TOUCH_ENABLE (1)
|
||||
#define SDMMC_1BIT_FIX (1)
|
||||
#define SD_FREQUENCY (20000)
|
||||
#ifndef TFT_BL
|
||||
// XXX - defined in User_Setups/Setup207_LilyGo_T_HMI.h:37
|
||||
#define TFT_BL (38) // LED back-light
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "displayDriver.h"
|
||||
|
||||
#ifdef T_HMI_DISPLAY
|
||||
|
||||
#include <FS.h>
|
||||
#include <xpt2046.h> // https://github.com/liangyingy/arduino_xpt2046_library
|
||||
#include <TFT_eSPI.h>
|
||||
#include <TFT_eTouch.h>
|
||||
#include "media/images_320_170.h"
|
||||
@ -11,7 +12,9 @@
|
||||
#include "version.h"
|
||||
#include "monitor.h"
|
||||
#include "OpenFontRender.h"
|
||||
|
||||
#ifdef TOUCH_ENABLE
|
||||
#include "TouchHandler.h"
|
||||
#endif
|
||||
#include <Arduino.h>
|
||||
#include <esp_adc_cal.h>
|
||||
|
||||
@ -22,15 +25,22 @@ OpenFontRender render;
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
|
||||
TFT_eSprite background = TFT_eSprite(&tft); // Invoke library sprite
|
||||
|
||||
#ifdef TOUCH_ENABLE
|
||||
TouchHandler touchHandler = TouchHandler(tft, ETOUCH_CS, TOUCH_IRQ, SPI);
|
||||
#endif
|
||||
|
||||
SPIClass hSPI(HSPI);
|
||||
// TFT_eTouch<TFT_eSPI> touch(tft, ETOUCH_CS, 0xFF, hSPI);
|
||||
bool showbtcprice = false;
|
||||
|
||||
unsigned int lowerScreen = 1;
|
||||
|
||||
extern void switchToNextScreen();
|
||||
extern monitor_data mMonitor;
|
||||
extern pool_data pData;
|
||||
extern DisplayDriver *currentDisplayDriver;
|
||||
|
||||
void toggleBottomScreen() { lowerScreen = 3 - lowerScreen; }
|
||||
|
||||
|
||||
uint32_t readAdcVoltage(int pin) {
|
||||
esp_adc_cal_characteristics_t adc_chars;
|
||||
|
||||
@ -70,12 +80,14 @@ void t_hmiDisplay_Init(void)
|
||||
Serial.println("Initialise error");
|
||||
return;
|
||||
}
|
||||
/* XXX - Pass for first version
|
||||
|
||||
#ifdef TOUCH_ENABLE
|
||||
Serial.println(F("Initialize the touch screen"));
|
||||
hSPI.begin(TOUCH_CLK, TOUCH_MISO, TOUCH_MOSI, ETOUCH_CS);
|
||||
TFT_eTouchBase::Calibation calibation = { 233, 3785, 3731, 120, 2 };
|
||||
touch.setCalibration(calibation);
|
||||
*/
|
||||
touchHandler.begin(HEIGHT, WIDTH);
|
||||
touchHandler.setScreenSwitchCallback(switchToNextScreen);
|
||||
touchHandler.setScreenSwitchAltCallback(toggleBottomScreen);
|
||||
#endif
|
||||
|
||||
Serial.println(F("Turn on the LCD backlight"));
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
pinMode(BK_LIGHT_PIN, OUTPUT);
|
||||
@ -83,7 +95,6 @@ void t_hmiDisplay_Init(void)
|
||||
pData.bestDifficulty = "0";
|
||||
pData.workersHash = "0";
|
||||
pData.workersCount = 0;
|
||||
|
||||
}
|
||||
|
||||
void t_hmiDisplay_AlternateScreenState(void)
|
||||
@ -188,7 +199,11 @@ void t_hmiDisplay_MinerScreen(unsigned long mElapsed)
|
||||
render.setFontSize(10);
|
||||
render.rdrawString(data.currentTime.c_str(), 286, 1, TFT_BLACK);
|
||||
|
||||
if (lowerScreen == 1)
|
||||
printPoolData();
|
||||
else
|
||||
printMemPoolFees(mElapsed);
|
||||
|
||||
// Push prepared background to screen
|
||||
background.pushSprite(0, 0);
|
||||
}
|
||||
@ -226,7 +241,10 @@ void t_hmiDisplay_ClockScreen(unsigned long mElapsed)
|
||||
background.setTextColor(0xDEDB, TFT_BLACK);
|
||||
|
||||
background.drawString(data.currentTime.c_str(), 130, 50, GFXFF);
|
||||
if (lowerScreen == 1)
|
||||
printMemPoolFees(mElapsed);
|
||||
else
|
||||
printPoolData();
|
||||
// Push prepared background to screen
|
||||
background.pushSprite(0, 0);
|
||||
}
|
||||
@ -286,7 +304,11 @@ void t_hmiDisplay_GlobalHashScreen(unsigned long mElapsed)
|
||||
background.setTextColor(TFT_BLACK);
|
||||
background.drawString(data.remainingBlocks.c_str(), 72, 159, FONT2);
|
||||
|
||||
if (lowerScreen == 1)
|
||||
printMemPoolFees(mElapsed);
|
||||
else
|
||||
printPoolData();
|
||||
|
||||
// Push prepared background to screen
|
||||
background.pushSprite(0, 0);
|
||||
}
|
||||
@ -326,7 +348,10 @@ void t_hmiDisplay_BTCprice(unsigned long mElapsed)
|
||||
background.setTextSize(1);
|
||||
background.setTextColor(0xDEDB, TFT_BLACK);
|
||||
background.drawString(data.btcPrice.c_str(), 300, 58, GFXFF);
|
||||
if (lowerScreen == 1)
|
||||
printPoolData();
|
||||
else
|
||||
printMemPoolFees(mElapsed);
|
||||
// Push prepared background to screen
|
||||
background.pushSprite(0, 0);
|
||||
}
|
||||
|
@ -34,7 +34,9 @@ SDCard::SDCard(int ID):cardInitialized_(false),cardBusy_(false)
|
||||
}
|
||||
iSD_ = &SD;
|
||||
#endif // interface type
|
||||
#ifndef SDMMC_1BIT_FIX
|
||||
initSDcard();
|
||||
#endif
|
||||
}
|
||||
|
||||
SDCard::~SDCard()
|
||||
@ -187,7 +189,12 @@ bool SDCard::initSDcard()
|
||||
#elif defined (BUILD_SDMMC_1)
|
||||
#warning SDMMC : 1 - bit mode is not always working. If you experience issues, try other modes.
|
||||
iSD_->setPins(SDMMC_CLK, SDMMC_CMD, SDMMC_D0);
|
||||
#ifdef SD_FREQUENCY
|
||||
// Need to lower frequency to 20000 for proper detection
|
||||
cardInitialized_ = iSD_->begin("/sd", true, false, SD_FREQUENCY);
|
||||
#else
|
||||
cardInitialized_ = iSD_->begin("/sd", true);
|
||||
#endif
|
||||
Serial.println("SDCard: 1-Bit Mode.");
|
||||
}
|
||||
#elif defined (BUILD_SDSPI)
|
||||
|
@ -59,8 +59,13 @@ public:
|
||||
bool cardAvailable();
|
||||
bool cardBusy();
|
||||
void terminate();
|
||||
#ifdef SDMMC_1BIT_FIX
|
||||
bool initSDcard();
|
||||
private:
|
||||
#else
|
||||
private:
|
||||
bool initSDcard();
|
||||
#endif
|
||||
bool cardInitialized_;
|
||||
bool cardBusy_;
|
||||
#if defined (BUILD_SDMMC_1) || defined(BUILD_SDMMC_4)
|
||||
|
@ -336,13 +336,12 @@ String getPoolAPIUrl(void) {
|
||||
else {
|
||||
switch (Settings.PoolPort) {
|
||||
case 3333:
|
||||
if (Settings.PoolAddress == "pool.vkbit.com")
|
||||
poolAPIUrl = "https://vkbit.com/miner/";
|
||||
else if (Settings.PoolAddress == "pool.sethforprivacy.com")
|
||||
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:
|
||||
// Local instance of public-pool.io on Umbrel or Start9
|
||||
poolAPIUrl = "http://" + Settings.PoolAddress + ":2019/api/client/";
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user