port T-QT Device

This commit is contained in:
Shaune Jan 2023-09-08 23:48:10 +08:00
parent 7baf783f48
commit 8a3d22ab2f
11 changed files with 4483 additions and 0 deletions

View File

@ -0,0 +1,51 @@
{
"build": {
"arduino":{
"ldscript": "esp32s3_out.ld",
"partitions": "default.csv"
},
"core": "esp32",
"extra_flags": [
"-DARDUINO_ESP32S3_DEV",
"-DARDUINO_USB_MODE=1",
"-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"hwids": [
[
"0x303A",
"0x1001"
]
],
"mcu": "esp32s3",
"variant": "esp32s3"
},
"connectivity": [
"wifi"
],
"debug": {
"default_tool": "esp-builtin",
"onboard_tools": [
"esp-builtin"
],
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif ESP32-S3-T-QT (4 MB QD, No PSRAM)",
"upload": {
"flash_size": "4MB",
"maximum_ram_size": 327680,
"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"
}

View File

@ -139,6 +139,9 @@
#include <User_Setups/Setup300_TTGO_T_Dongle.h> #include <User_Setups/Setup300_TTGO_T_Dongle.h>
#endif #endif
#ifdef NERMINER_T_QT
#include <User_Setups/Setup211_LilyGo_T_QT_Pro_S3.h>
#endif
//#include <User_Setups/Setup301_BW16_ST7735.h> // Setup file for Bw16-based boards with ST7735 160 x 80 TFT //#include <User_Setups/Setup301_BW16_ST7735.h> // Setup file for Bw16-based boards with ST7735 160 x 80 TFT
//#include <User_Setups/SetupX_Template.h> // Template file for a setup //#include <User_Setups/SetupX_Template.h> // Template file for a setup

View File

@ -0,0 +1,45 @@
// GC9A01 128 x 128 display with no chip select line
#define USER_SETUP_ID 211
#define GC9A01_DRIVER // Configure all registers
#define TFT_WIDTH 128
#define TFT_HEIGHT 128
// #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
#define TFT_BACKLIGHT_ON 0
#define CGRAM_OFFSET
#define TFT_BL 10 // LED back-light
#define TFT_MISO -1 // Not connected
#define TFT_MOSI 2
#define TFT_SCLK 3
#define TFT_CS 5
#define TFT_DC 6
#define TFT_RST 1 // Connect reset to ensure display initialises
#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

View File

@ -137,3 +137,26 @@ lib_deps =
arduino-libraries/NTPClient arduino-libraries/NTPClient
https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4 https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4
https://github.com/FastLED/FastLED https://github.com/FastLED/FastLED
[env:NerminerV2-T-QT]
platform = espressif32
board = esp32-s3-t-qt-pro
framework = arduino
monitor_filters =
esp32_exception_decoder
time
log2file
;board_build.arduino.memory_type = qio_opi
monitor_speed = 115200
upload_speed = 115200
build_flags =
-DBOARD_HAS_PSRAM
-DNERMINER_T_QT=1
lib_deps =
https://github.com/takkaO/OpenFontRender
bblanchon/ArduinoJson@^6.21.2
https://github.com/tzapu/WiFiManager.git
mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient

View File

@ -0,0 +1,10 @@
#ifndef _NERD_MINER_T_QT_H
#define _NERD_MINER_T_QT_H
#define PIN_BUTTON_1 0
#define PIN_BUTTON_2 47
#define PIN_ENABLE5V 4
#define T_QT_DISPLAY
#endif

View File

@ -16,6 +16,10 @@ DisplayDriver *currentDisplayDriver = &amoledDisplayDriver;
DisplayDriver *currentDisplayDriver = &dongleDisplayDriver; DisplayDriver *currentDisplayDriver = &dongleDisplayDriver;
#endif #endif
#ifdef T_QT_DISPLAY
DisplayDriver *currentDisplayDriver = &t_qtDisplayDriver;
#endif
// Initialize the display // Initialize the display
void initDisplay() void initDisplay()
{ {

View File

@ -0,0 +1,180 @@
#include "../drivers.h"
#ifdef T_QT_DISPLAY
#include <TFT_eSPI.h>
#include "media/images_128_128.h"
#include "media/myFonts.h"
#include "media/Free_Fonts.h"
#include "version.h"
#include "monitor.h"
#include "OpenFontRender.h"
#define WIDTH 128
#define HEIGHT 128
OpenFontRender render;
TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
TFT_eSprite background = TFT_eSprite(&tft); // Invoke library sprite
void t_qtDisplay_Init(void)
{
tft.init();
tft.setRotation(1);
tft.setSwapBytes(true); // Swap the colour byte order when rendering
background.createSprite(WIDTH, HEIGHT); // Background Sprite
background.setSwapBytes(true);
render.setDrawer(background); // Link drawing object to background instance (so font will be rendered on background)
render.setLineSpaceRatio(0.9); // Espaciado entre texto
// Load the font and check it can be read OK
// if (render.loadFont(NotoSans_Bold, sizeof(NotoSans_Bold))) {
if (render.loadFont(DigitalNumbers, sizeof(DigitalNumbers)))
{
Serial.println("Initialise error");
return;
}
}
void t_qtDisplay_AlternateScreenState(void)
{
int screen_state = digitalRead(TFT_BL);
Serial.println("Switching display state");
digitalWrite(TFT_BL, !screen_state);
}
void t_qtDisplay_AlternateRotation(void)
{
tft.setRotation((tft.getRotation()+1) % 4);
}
void t_qtDisplay_MinerScreen(unsigned long mElapsed)
{
mining_data data = getMiningData(mElapsed);
// Print background screen
background.pushImage(0, 0, MinerWidth, MinerHeight, MinerScreen);
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());
//Hashrate
render.setFontSize(32);
render.setCursor(0, 0);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 114, 24, TFT_DARKGREY);
//Valid Blocks
render.setFontSize(22);
render.drawString(data.valids.c_str(), 15, 92, TFT_BLACK);
//Mining Time
char timeMining[15];
unsigned long secElapsed = millis() / 1000;
int days = secElapsed / 86400;
int hours = (secElapsed - (days * 86400)) / 3600; //Number of seconds in an hour
int mins = (secElapsed - (days * 86400) - (hours * 3600)) / 60; //Remove the number of hours and calculate the minutes.
int secs = secElapsed - (days * 86400) - (hours * 3600) - (mins * 60);
sprintf(timeMining, "%01d %02d:%02d:%02d", days, hours, mins, secs);
render.setFontSize(10);
render.setCursor(0, 10);
render.rdrawString(String(timeMining).c_str(), 124, 0, TFT_BLACK);
//Push prepared background to screen
background.pushSprite(0,0);
}
uint16_t osx=64, osy=64, omx=64, omy=64, ohx=64, ohy=64; // Saved H, M, S x & y coords
void t_qtDisplay_ClockScreen(unsigned long mElapsed)
{
clock_data_t data = getClockData_t(mElapsed);
// Print background screen
background.pushImage(0, 0, minerClockWidth, minerClockHeight, minerClockScreen);
// 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());
render.setCursor(0, 0);
//Hashrate
render.setFontSize(18);
render.setFontColor(TFT_BLACK);
render.cdrawString(data.currentHashRate.c_str(), 64, 74, TFT_DARKGREY);
//Valid Blocks
render.setFontSize(15);
render.rdrawString(data.valids.c_str(), 96, 54, TFT_BLACK);
if (data.currentHours > 12)
data.currentHours -= 12;
float sdeg = data.currentSeconds*6; // 0-59 -> 0-354
float mdeg = data.currentMinutes*6+sdeg*0.01666667; // 0-59 -> 0-360 - includes seconds
float hdeg = data.currentHours*30+mdeg*0.0833333; // 0-11 -> 0-360 - includes minutes and seconds
float hx = cos((hdeg-90)*0.0174532925);
float hy = sin((hdeg-90)*0.0174532925);
float mx = cos((mdeg-90)*0.0174532925);
float my = sin((mdeg-90)*0.0174532925);
float sx = cos((sdeg-90)*0.0174532925);
float sy = sin((sdeg-90)*0.0174532925);
ohx = hx*33+60;
ohy = hy*33+60;
omx = mx*44+60;
omy = my*44+60;
// Redraw new hand positions, hour and minute hands not erased here to avoid flicker
background.drawLine(ohx, ohy, 65, 65, TFT_BLACK);
background.drawLine(omx, omy, 65, 65, TFT_BLACK);
osx = sx*47+60;
osy = sy*47+60;
background.drawLine(osx, osy, 65, 65, TFT_RED);
background.fillCircle(65, 65, 3, TFT_RED);
//Push prepared background to screen
background.pushSprite(0,0);
}
void t_qtDisplay_GlobalHashScreen(unsigned long mElapsed)
{
}
void t_qtDisplay_LoadingScreen(void)
{
tft.fillScreen(TFT_BLACK);
tft.pushImage(0, 0, initWidth, initHeight, initScreen);
tft.setTextColor(TFT_GOLD);
tft.drawString(CURRENT_VERSION, 2, 100, FONT2);
}
void t_qtDisplay_SetupScreen(void)
{
tft.pushImage(0, 0, setupModeWidth, setupModeHeight, setupModeScreen);
}
void t_qtDisplay_AnimateCurrentScreen(unsigned long frame)
{
}
void t_qtDisplay_DoLedStuff(unsigned long frame)
{
}
CyclicScreenFunction t_qtDisplayCyclicScreens[] = {t_qtDisplay_MinerScreen, t_qtDisplay_ClockScreen};
DisplayDriver t_qtDisplayDriver = {
t_qtDisplay_Init,
t_qtDisplay_AlternateScreenState,
t_qtDisplay_AlternateRotation,
t_qtDisplay_LoadingScreen,
t_qtDisplay_SetupScreen,
t_qtDisplayCyclicScreens,
t_qtDisplay_AnimateCurrentScreen,
t_qtDisplay_DoLedStuff,
SCREENS_ARRAY_SIZE(t_qtDisplayCyclicScreens),
0,
WIDTH,
HEIGHT};
#endif

View File

@ -11,6 +11,8 @@
#include "devices/lilygoS3Amoled.h" #include "devices/lilygoS3Amoled.h"
#elif defined(NERMINER_S3_DONGLE) #elif defined(NERMINER_S3_DONGLE)
#include "devices/lilygoS3Dongle.h" #include "devices/lilygoS3Dongle.h"
#elif defined(NERMINER_T_QT)
#include "devices/lilygoT_QT.h"
#else #else
#error "No device defined" #error "No device defined"
#endif #endif
@ -44,6 +46,7 @@ extern DisplayDriver noDisplayDriver;
extern DisplayDriver tDisplayDriver; extern DisplayDriver tDisplayDriver;
extern DisplayDriver amoledDisplayDriver; extern DisplayDriver amoledDisplayDriver;
extern DisplayDriver dongleDisplayDriver; extern DisplayDriver dongleDisplayDriver;
extern DisplayDriver t_qtDisplayDriver;
#define SCREENS_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define SCREENS_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

4122
src/media/images_128_128.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -161,6 +161,28 @@ unsigned long mTriggerUpdate = 0;
unsigned long initialMillis = millis(); unsigned long initialMillis = millis();
unsigned long initialTime = 0; unsigned long initialTime = 0;
void getTime(unsigned long* currentHours, unsigned long* currentMinutes, unsigned long* currentSeconds){
//Check if need an NTP call to check current time
if((mTriggerUpdate == 0) || (millis() - mTriggerUpdate > UPDATE_PERIOD_h * 60 * 60 * 1000)){ //60 sec. * 60 min * 1000ms
if(WiFi.status() == WL_CONNECTED) {
timeClient.update(); //NTP call to get current time
mTriggerUpdate = millis();
initialTime = timeClient.getEpochTime(); // Guarda la hora inicial (en segundos desde 1970)
Serial.print("TimeClient NTPupdateTime ");
}
}
unsigned long elapsedTime = (millis() - mTriggerUpdate) / 1000; // Tiempo transcurrido en segundos
unsigned long currentTime = initialTime + elapsedTime; // La hora actual
// convierte la hora actual en horas, minutos y segundos
*currentHours = currentTime % 86400 / 3600;
*currentMinutes = currentTime % 3600 / 60;
*currentSeconds = currentTime % 60;
}
String getTime(void){ String getTime(void){
//Check if need an NTP call to check current time //Check if need an NTP call to check current time
@ -235,6 +257,17 @@ clock_data getClockData(unsigned long mElapsed)
return data; return data;
} }
clock_data_t getClockData_t(unsigned long mElapsed)
{
clock_data_t data;
data.valids = valids;
data.currentHashRate = getCurrentHashRate(mElapsed);
getTime(&data.currentHours, &data.currentMinutes, &data.currentSeconds);
return data;
}
coin_data getCoinData(unsigned long mElapsed) coin_data getCoinData(unsigned long mElapsed)
{ {
coin_data data; coin_data data;

View File

@ -73,6 +73,14 @@ typedef struct {
String currentTime; String currentTime;
}clock_data; }clock_data;
typedef struct {
String currentHashRate;
String valids;
unsigned long currentHours;
unsigned long currentMinutes;
unsigned long currentSeconds;
}clock_data_t;
typedef struct { typedef struct {
String completedShares; String completedShares;
String totalKHashes; String totalKHashes;
@ -92,5 +100,6 @@ void setup_monitor(void);
mining_data getMiningData(unsigned long mElapsed); mining_data getMiningData(unsigned long mElapsed);
clock_data getClockData(unsigned long mElapsed); clock_data getClockData(unsigned long mElapsed);
coin_data getCoinData(unsigned long mElapsed); coin_data getCoinData(unsigned long mElapsed);
clock_data_t getClockData_t(unsigned long mElapsed);
#endif //MONITOR_API_H #endif //MONITOR_API_H