add battery and sdcard pins 1-bit
This commit is contained in:
parent
c13960acb3
commit
8f1426ac1d
@ -265,9 +265,9 @@ lib_deps =
|
|||||||
https://github.com/takkaO/OpenFontRender
|
https://github.com/takkaO/OpenFontRender
|
||||||
bblanchon/ArduinoJson@^6.21.2
|
bblanchon/ArduinoJson@^6.21.2
|
||||||
https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.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
|
arduino-libraries/NTPClient
|
||||||
bodmer/TFT_eSPI @ ^2.5.31
|
bodmer/TFT_eSPI @ ^2.5.31
|
||||||
https://github.com/achillhasler/TFT_eTouch
|
https://github.com/achillhasler/TFT_eTouch
|
||||||
|
|
||||||
;--------------------------------------------------------------------
|
;--------------------------------------------------------------------
|
||||||
|
@ -9,30 +9,53 @@
|
|||||||
#define BUTTON1_PIN (0)
|
#define BUTTON1_PIN (0)
|
||||||
#define BUTTON2_PIN (21)
|
#define BUTTON2_PIN (21)
|
||||||
|
|
||||||
#define PIN_BUTTON_1 BUTTON1_PIN
|
#define PIN_BUTTON_1 (0)
|
||||||
// #define PIN_BUTTON_2 BUTTON2_PIN
|
//#define PIN_BUTTON_2 (21)
|
||||||
|
|
||||||
|
|
||||||
// touch screen
|
// touch screen
|
||||||
#define TOUCHSCREEN_SCLK_PIN (1)
|
#define TOUCH_IRQ (9)
|
||||||
#define TOUCHSCREEN_MISO_PIN (4)
|
#define TOUCH_CLK (1)
|
||||||
#define TOUCHSCREEN_MOSI_PIN (3)
|
#define TOUCH_MISO (4)
|
||||||
#define TOUCHSCREEN_CS_PIN (2)
|
#define TOUCH_MOSI (3)
|
||||||
#define TOUCHSCREEN_IRQ_PIN (9)
|
#define ETOUCH_CS (2)
|
||||||
#define TOUCH_CLK TOUCHSCREEN_SCLK_PIN
|
|
||||||
#define TOUCH_MISO TOUCHSCREEN_MISO_PIN
|
|
||||||
#define TOUCH_MOSI TOUCHSCREEN_MOSI_PIN
|
|
||||||
#define ETOUCH_CS TOUCHSCREEN_CS_PIN
|
|
||||||
|
|
||||||
|
|
||||||
// lcd
|
// 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 PCLK_PIN (8)
|
||||||
#define CS_PIN (6)
|
#define CS_PIN (6)
|
||||||
#define DC_PIN (7)
|
#define DC_PIN (7)
|
||||||
#define RST_PIN (-1)
|
#define RST_PIN (-1)
|
||||||
#define BK_LIGHT_PIN (38)
|
#define BK_LIGHT_PIN (38)
|
||||||
|
#define BK_LIGHT_LEVEL (1)
|
||||||
#define LED_PIN (8)
|
#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
|
#ifndef TFT_BL
|
||||||
// XXX - defined in User_Setups/Setup207_LilyGo_T_HMI.h:37
|
// XXX - defined in User_Setups/Setup207_LilyGo_T_HMI.h:37
|
||||||
#define TFT_BL (38) // LED back-light
|
#define TFT_BL (38) // LED back-light
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "OpenFontRender.h"
|
#include "OpenFontRender.h"
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <esp_adc_cal.h>
|
||||||
|
|
||||||
#define WIDTH 320
|
#define WIDTH 320
|
||||||
#define HEIGHT 240
|
#define HEIGHT 240
|
||||||
|
|
||||||
@ -21,16 +24,38 @@ TFT_eSprite background = TFT_eSprite(&tft); // Invoke library sprite
|
|||||||
|
|
||||||
|
|
||||||
SPIClass hSPI(HSPI);
|
SPIClass hSPI(HSPI);
|
||||||
TFT_eTouch<TFT_eSPI> touch(tft, ETOUCH_CS, 0xFF, hSPI);
|
// TFT_eTouch<TFT_eSPI> touch(tft, ETOUCH_CS, 0xFF, hSPI);
|
||||||
bool showbtcprice = false;
|
bool showbtcprice = false;
|
||||||
|
|
||||||
extern monitor_data mMonitor;
|
extern monitor_data mMonitor;
|
||||||
extern pool_data pData;
|
extern pool_data pData;
|
||||||
extern DisplayDriver *currentDisplayDriver;
|
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)
|
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.init();
|
||||||
tft.setRotation(1);
|
tft.setRotation(1);
|
||||||
tft.setSwapBytes(true); // Swap the colour byte order when rendering
|
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 };
|
TFT_eTouchBase::Calibation calibation = { 233, 3785, 3731, 120, 2 };
|
||||||
touch.setCalibration(calibation);
|
touch.setCalibration(calibation);
|
||||||
*/
|
*/
|
||||||
Serial.println(F("Power on peripherals, such as the LCD backlight"));
|
Serial.println(F("Turn on the LCD backlight"));
|
||||||
pinMode(PWR_EN_PIN, OUTPUT);
|
|
||||||
digitalWrite(PWR_EN_PIN, HIGH);
|
|
||||||
pinMode(LED_PIN, OUTPUT);
|
pinMode(LED_PIN, OUTPUT);
|
||||||
|
pinMode(BK_LIGHT_PIN, OUTPUT);
|
||||||
|
digitalWrite(BK_LIGHT_PIN, BK_LIGHT_LEVEL);
|
||||||
pData.bestDifficulty = "0";
|
pData.bestDifficulty = "0";
|
||||||
pData.workersHash = "0";
|
pData.workersHash = "0";
|
||||||
pData.workersCount = 0;
|
pData.workersCount = 0;
|
||||||
@ -73,6 +98,7 @@ void t_hmiDisplay_AlternateRotation(void)
|
|||||||
tft.getRotation() == 1 ? tft.setRotation(3) : tft.setRotation(1);
|
tft.getRotation() == 1 ? tft.setRotation(3) : tft.setRotation(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printPoolData()
|
void printPoolData()
|
||||||
{
|
{
|
||||||
// Serial.print("\nPool ============ Free Heap:");
|
// Serial.print("\nPool ============ Free Heap:");
|
||||||
@ -88,6 +114,7 @@ void printPoolData()
|
|||||||
render.setFontSize(18);
|
render.setFontSize(18);
|
||||||
render.drawString(pData.workersHash.c_str(), 216, 170+34, TFT_BLACK);
|
render.drawString(pData.workersHash.c_str(), 216, 170+34, TFT_BLACK);
|
||||||
render.drawString(pData.bestDifficulty.c_str(), 5, 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.drawChar('<', 245, 170+32, TFT_RED);
|
||||||
render.drawString(data.minimumFee.c_str(), 250, 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);
|
render.drawString(data.fastestFee.c_str(), 30, 170+32, TFT_BLACK);
|
||||||
|
// printBatteryVoltage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void t_hmiDisplay_MinerScreen(unsigned long mElapsed)
|
void t_hmiDisplay_MinerScreen(unsigned long mElapsed)
|
||||||
|
Loading…
Reference in New Issue
Block a user