Multi device support refactoring

This commit is contained in:
Roman Mashta 2023-09-02 02:01:42 +03:00
parent 7a574d1b47
commit fc23e9797e
33 changed files with 43990 additions and 1124 deletions

View File

@ -126,7 +126,7 @@
//#include <User_Setups/Setup204_ESP32_TouchDown.h> // Setup file for the ESP32 TouchDown based on ILI9488 480 x 320 TFT //#include <User_Setups/Setup204_ESP32_TouchDown.h> // Setup file for the ESP32 TouchDown based on ILI9488 480 x 320 TFT
//#include <User_Setups/Setup205_ESP32_TouchDown_S3.h> // Setup file for the ESP32 TouchDown S3 based on ILI9488 480 x 320 TFT //#include <User_Setups/Setup205_ESP32_TouchDown_S3.h> // Setup file for the ESP32 TouchDown S3 based on ILI9488 480 x 320 TFT
#ifdef NERDMINERV2 #ifdef NERDMINERV2
#include <User_Setups/Setup206_LilyGo_T_Display_S3.h> #include <User_Setups/Setup206_LilyGo_T_Display_S3.h>
#endif #endif
@ -136,10 +136,9 @@
#endif #endif
#ifdef NERMINER_S3_DONGLE #ifdef NERMINER_S3_DONGLE
#include <User_Setups/Setup300_TTGO_T_Dongle.h> //Just a stub. No driver implementation for S3 AMOLED in TFT_eSPI #include <User_Setups/Setup300_TTGO_T_Dongle.h>
#endif #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

@ -2,35 +2,34 @@
#define ST7735_DRIVER #define ST7735_DRIVER
#define TFT_WIDTH 80 #define TFT_WIDTH 80
#define TFT_HEIGHT 160 #define TFT_HEIGHT 160
#define TFT_RST 1
#define TFT_RST 1 #define TFT_MISO -1
#define TFT_MISO -1 #define TFT_MOSI 3
#define TFT_MOSI 3 #define TFT_SCLK 5
#define TFT_SCLK 5 #define TFT_CS 4
#define TFT_CS 4 #define TFT_DC 2
#define TFT_DC 2
// #define TFT_BL 38 // #define TFT_BL 38
// #define TFT_BACKLIGHT_ON LOW // #define TFT_BACKLIGHT_ON LOW
#define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset) #define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset)
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH #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_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_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_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_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_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_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 LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded // Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
// this will save ~20kbytes of FLASH // this will save ~20kbytes of FLASH
#define SMOOTH_FONT #define SMOOTH_FONT
#define SPI_FREQUENCY 50000000 // Actually sets it to 26.67MHz = 80/3 #define SPI_FREQUENCY 50000000 // Actually sets it to 26.67MHz = 80/3
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS // #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
// #define SPI_FREQUENCY 80000000 // #define SPI_FREQUENCY 80000000

View File

@ -1,41 +1,41 @@
#pragma once #pragma once
/***********************config*************************/ /***********************config*************************/
#define LCD_USB_QSPI_DREVER 1 #define LCD_USB_QSPI_DREVER 1
#define SPI_FREQUENCY 75000000 #define SPI_FREQUENCY 75000000
#define TFT_SPI_MODE SPI_MODE0 #define TFT_SPI_MODE SPI_MODE0
#define TFT_SPI_HOST SPI2_HOST #define TFT_SPI_HOST SPI2_HOST
#define EXAMPLE_LCD_H_RES 536 #define EXAMPLE_LCD_H_RES 536
#define EXAMPLE_LCD_V_RES 240 #define EXAMPLE_LCD_V_RES 240
#define LVGL_LCD_BUF_SIZE (EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES) #define LVGL_LCD_BUF_SIZE (EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES)
/***********************config*************************/ /***********************config*************************/
#define TFT_WIDTH 240 #define TFT_WIDTH 240
#define TFT_HEIGHT 536 #define TFT_HEIGHT 536
#define SEND_BUF_SIZE (0x4000) //(LCD_WIDTH * LCD_HEIGHT + 8) / 10 #define SEND_BUF_SIZE (0x4000) //(LCD_WIDTH * LCD_HEIGHT + 8) / 10
#define TFT_TE 9 #define TFT_TE 9
#define TFT_SDO 8 #define TFT_SDO 8
#define TFT_DC 7 #define TFT_DC 7
#define TFT_RES 17 #define TFT_RES 17
#define TFT_CS 6 #define TFT_CS 6
#define TFT_MOSI 18 #define TFT_MOSI 18
#define TFT_SCK 47 #define TFT_SCK 47
#define TFT_QSPI_CS 6 #define TFT_QSPI_CS 6
#define TFT_QSPI_SCK 47 #define TFT_QSPI_SCK 47
#define TFT_QSPI_D0 18 #define TFT_QSPI_D0 18
#define TFT_QSPI_D1 7 #define TFT_QSPI_D1 7
#define TFT_QSPI_D2 48 #define TFT_QSPI_D2 48
#define TFT_QSPI_D3 5 #define TFT_QSPI_D3 5
#define TFT_QSPI_RST 17 #define TFT_QSPI_RST 17
#define PIN_LED 38 #define PIN_LED 38
#define PIN_BAT_VOLT 4 #define PIN_BAT_VOLT 4
#define PIN_BUTTON_1 0 #define PIN_BUTTON_1 0
#define PIN_BUTTON_2 21 #define PIN_BUTTON_2 21

View File

@ -5,7 +5,7 @@
const static lcd_cmd_t rm67162_spi_init[] = { const static lcd_cmd_t rm67162_spi_init[] = {
{0xFE, {0x00}, 0x01}, // PAGE {0xFE, {0x00}, 0x01}, // PAGE
{0x35, {0x00}, 0x00}, //TE ON {0x35, {0x00}, 0x00}, // TE ON
// {0x34, {0x00}, 0x00}, //TE OFF // {0x34, {0x00}, 0x00}, //TE OFF
{0x36, {0x00}, 0x01}, // Scan Direction Control {0x36, {0x00}, 0x01}, // Scan Direction Control
{0x3A, {0x75}, 0x01}, // Interface Pixel Format 16bit/pixel {0x3A, {0x75}, 0x01}, // Interface Pixel Format 16bit/pixel
@ -35,161 +35,167 @@ static spi_device_handle_t spi;
static void WriteComm(uint8_t data) static void WriteComm(uint8_t data)
{ {
TFT_CS_L; TFT_CS_L;
SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE)); SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE));
TFT_DC_L; TFT_DC_L;
SPI.write(data); SPI.write(data);
TFT_DC_H; TFT_DC_H;
SPI.endTransaction(); SPI.endTransaction();
TFT_CS_H; TFT_CS_H;
} }
static void WriteData(uint8_t data) static void WriteData(uint8_t data)
{ {
TFT_CS_L; TFT_CS_L;
SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE)); SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE));
TFT_DC_H; TFT_DC_H;
SPI.write(data); SPI.write(data);
SPI.endTransaction(); SPI.endTransaction();
TFT_CS_H; TFT_CS_H;
} }
static void WriteData16(uint16_t data) static void WriteData16(uint16_t data)
{ {
TFT_CS_L; TFT_CS_L;
SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE)); SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE));
TFT_DC_H; TFT_DC_H;
SPI.write16(data); SPI.write16(data);
SPI.endTransaction(); SPI.endTransaction();
TFT_CS_H; TFT_CS_H;
} }
static void lcd_send_cmd(uint32_t cmd, uint8_t *dat, uint32_t len) static void lcd_send_cmd(uint32_t cmd, uint8_t *dat, uint32_t len)
{ {
#if LCD_USB_QSPI_DREVER == 1 #if LCD_USB_QSPI_DREVER == 1
TFT_CS_L; TFT_CS_L;
spi_transaction_t t; spi_transaction_t t;
memset(&t, 0, sizeof(t)); memset(&t, 0, sizeof(t));
t.flags = (SPI_TRANS_MULTILINE_CMD | SPI_TRANS_MULTILINE_ADDR); t.flags = (SPI_TRANS_MULTILINE_CMD | SPI_TRANS_MULTILINE_ADDR);
t.cmd = 0x02; t.cmd = 0x02;
t.addr = cmd << 8; t.addr = cmd << 8;
// Serial.printf("t.addr:0x%X\r\n", t.addr); // Serial.printf("t.addr:0x%X\r\n", t.addr);
if (len != 0) { if (len != 0)
t.tx_buffer = dat; {
t.length = 8 * len; t.tx_buffer = dat;
} else { t.length = 8 * len;
t.tx_buffer = NULL; }
t.length = 0; else
} {
spi_device_polling_transmit(spi, &t); t.tx_buffer = NULL;
TFT_CS_H; t.length = 0;
}
spi_device_polling_transmit(spi, &t);
TFT_CS_H;
#else #else
WriteComm(cmd); WriteComm(cmd);
if (len != 0) { if (len != 0)
for (int i = 0; i < len; i++) {
WriteData(dat[i]); for (int i = 0; i < len; i++)
} WriteData(dat[i]);
}
#endif #endif
} }
void rm67162_init(void) void rm67162_init(void)
{ {
pinMode(TFT_CS, OUTPUT); pinMode(TFT_CS, OUTPUT);
pinMode(TFT_RES, OUTPUT); pinMode(TFT_RES, OUTPUT);
TFT_RES_L; TFT_RES_L;
delay(300); delay(300);
TFT_RES_H; TFT_RES_H;
delay(200); delay(200);
#if LCD_USB_QSPI_DREVER == 1 #if LCD_USB_QSPI_DREVER == 1
esp_err_t ret; esp_err_t ret;
spi_bus_config_t buscfg = { spi_bus_config_t buscfg = {
.data0_io_num = TFT_QSPI_D0, .data0_io_num = TFT_QSPI_D0,
.data1_io_num = TFT_QSPI_D1, .data1_io_num = TFT_QSPI_D1,
.sclk_io_num = TFT_QSPI_SCK, .sclk_io_num = TFT_QSPI_SCK,
.data2_io_num = TFT_QSPI_D2, .data2_io_num = TFT_QSPI_D2,
.data3_io_num = TFT_QSPI_D3, .data3_io_num = TFT_QSPI_D3,
.max_transfer_sz = (SEND_BUF_SIZE * 16) + 8, .max_transfer_sz = (SEND_BUF_SIZE * 16) + 8,
.flags = SPICOMMON_BUSFLAG_MASTER | SPICOMMON_BUSFLAG_GPIO_PINS /* | .flags = SPICOMMON_BUSFLAG_MASTER | SPICOMMON_BUSFLAG_GPIO_PINS /* |
SPICOMMON_BUSFLAG_QUAD */ SPICOMMON_BUSFLAG_QUAD */
, ,
}; };
spi_device_interface_config_t devcfg = { spi_device_interface_config_t devcfg = {
.command_bits = 8, .command_bits = 8,
.address_bits = 24, .address_bits = 24,
.mode = TFT_SPI_MODE, .mode = TFT_SPI_MODE,
.clock_speed_hz = SPI_FREQUENCY, .clock_speed_hz = SPI_FREQUENCY,
.spics_io_num = -1, .spics_io_num = -1,
// .spics_io_num = TFT_QSPI_CS, // .spics_io_num = TFT_QSPI_CS,
.flags = SPI_DEVICE_HALFDUPLEX, .flags = SPI_DEVICE_HALFDUPLEX,
.queue_size = 17, .queue_size = 17,
}; };
ret = spi_bus_initialize(TFT_SPI_HOST, &buscfg, SPI_DMA_CH_AUTO); ret = spi_bus_initialize(TFT_SPI_HOST, &buscfg, SPI_DMA_CH_AUTO);
ESP_ERROR_CHECK(ret); ESP_ERROR_CHECK(ret);
ret = spi_bus_add_device(TFT_SPI_HOST, &devcfg, &spi); ret = spi_bus_add_device(TFT_SPI_HOST, &devcfg, &spi);
ESP_ERROR_CHECK(ret); ESP_ERROR_CHECK(ret);
#else #else
SPI.begin(TFT_SCK, -1, TFT_MOSI, TFT_CS); SPI.begin(TFT_SCK, -1, TFT_MOSI, TFT_CS);
SPI.setFrequency(SPI_FREQUENCY); SPI.setFrequency(SPI_FREQUENCY);
pinMode(TFT_DC, OUTPUT); pinMode(TFT_DC, OUTPUT);
#endif #endif
// Initialize the screen multiple times to prevent initialization failure // Initialize the screen multiple times to prevent initialization failure
int i = 3; int i = 3;
while (i--) { while (i--)
{
#if LCD_USB_QSPI_DREVER == 1 #if LCD_USB_QSPI_DREVER == 1
const lcd_cmd_t *lcd_init = rm67162_qspi_init; const lcd_cmd_t *lcd_init = rm67162_qspi_init;
for (int i = 0; i < sizeof(rm67162_qspi_init) / sizeof(lcd_cmd_t); i++) for (int i = 0; i < sizeof(rm67162_qspi_init) / sizeof(lcd_cmd_t); i++)
#else #else
const lcd_cmd_t *lcd_init = rm67162_spi_init; const lcd_cmd_t *lcd_init = rm67162_spi_init;
for (int i = 0; i < sizeof(rm67162_spi_init) / sizeof(lcd_cmd_t); i++) for (int i = 0; i < sizeof(rm67162_spi_init) / sizeof(lcd_cmd_t); i++)
#endif #endif
{ {
lcd_send_cmd(lcd_init[i].cmd, lcd_send_cmd(lcd_init[i].cmd,
(uint8_t *)lcd_init[i].data, (uint8_t *)lcd_init[i].data,
lcd_init[i].len & 0x7f); lcd_init[i].len & 0x7f);
if (lcd_init[i].len & 0x80) if (lcd_init[i].len & 0x80)
delay(120); delay(120);
}
} }
}
} }
void lcd_setRotation(uint8_t r) void lcd_setRotation(uint8_t r)
{ {
uint8_t gbr = TFT_MAD_RGB; uint8_t gbr = TFT_MAD_RGB;
switch (r) { switch (r)
case 0: // Portrait {
// WriteData(gbr); case 0: // Portrait
break; // WriteData(gbr);
case 1: // Landscape (Portrait + 90) break;
gbr = TFT_MAD_MX | TFT_MAD_MV | gbr; case 1: // Landscape (Portrait + 90)
break; gbr = TFT_MAD_MX | TFT_MAD_MV | gbr;
case 2: // Inverter portrait break;
gbr = TFT_MAD_MX | TFT_MAD_MY | gbr; case 2: // Inverter portrait
break; gbr = TFT_MAD_MX | TFT_MAD_MY | gbr;
case 3: // Inverted landscape break;
gbr = TFT_MAD_MV | TFT_MAD_MY | gbr; case 3: // Inverted landscape
break; gbr = TFT_MAD_MV | TFT_MAD_MY | gbr;
} break;
lcd_send_cmd(TFT_MADCTL, &gbr, 1); }
lcd_send_cmd(TFT_MADCTL, &gbr, 1);
} }
void lcd_address_set(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) void lcd_address_set(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
{ {
lcd_cmd_t t[3] = { lcd_cmd_t t[3] = {
{0x2a, {uint8_t(x1 >> 8), (uint8_t)x1, (uint8_t)(x2 >> 8), (uint8_t) x2}, 0x04}, {0x2a, {uint8_t(x1 >> 8), (uint8_t)x1, (uint8_t)(x2 >> 8), (uint8_t)x2}, 0x04},
{0x2b, {uint8_t(y1 >> 8), (uint8_t)y1, (uint8_t)(y2 >> 8), (uint8_t) y2}, 0x04}, {0x2b, {uint8_t(y1 >> 8), (uint8_t)y1, (uint8_t)(y2 >> 8), (uint8_t)y2}, 0x04},
{0x2c, {0x00}, 0x00}, {0x2c, {0x00}, 0x00},
}; };
for (uint32_t i = 0; i < 3; i++) { for (uint32_t i = 0; i < 3; i++)
lcd_send_cmd(t[i].cmd, t[i].data, t[i].len); {
} lcd_send_cmd(t[i].cmd, t[i].data, t[i].len);
}
} }
void lcd_fill(uint16_t xsta, void lcd_fill(uint16_t xsta,
@ -199,21 +205,22 @@ void lcd_fill(uint16_t xsta,
uint16_t color) uint16_t color)
{ {
uint16_t w = xend - xsta; uint16_t w = xend - xsta;
uint16_t h = yend - ysta; uint16_t h = yend - ysta;
uint16_t *color_p = (uint16_t *)ps_malloc(w * h * 2); uint16_t *color_p = (uint16_t *)ps_malloc(w * h * 2);
if (!color_p) { if (!color_p)
return; {
} return;
memset(color_p, color, w * h * 2); }
lcd_PushColors(xsta, ysta, w, h, color_p); memset(color_p, color, w * h * 2);
free(color_p); lcd_PushColors(xsta, ysta, w, h, color_p);
free(color_p);
} }
void lcd_DrawPoint(uint16_t x, uint16_t y, uint16_t color) void lcd_DrawPoint(uint16_t x, uint16_t y, uint16_t color)
{ {
lcd_address_set(x, y, x + 1, y + 1); lcd_address_set(x, y, x + 1, y + 1);
lcd_PushColors(&color, 1); lcd_PushColors(&color, 1);
} }
void lcd_PushColors(uint16_t x, void lcd_PushColors(uint16_t x,
@ -223,110 +230,120 @@ void lcd_PushColors(uint16_t x,
uint16_t *data) uint16_t *data)
{ {
#if LCD_USB_QSPI_DREVER == 1 #if LCD_USB_QSPI_DREVER == 1
bool first_send = 1; bool first_send = 1;
size_t len = width * high; size_t len = width * high;
uint16_t *p = (uint16_t *)data; uint16_t *p = (uint16_t *)data;
lcd_address_set(x, y, x + width - 1, y + high - 1); lcd_address_set(x, y, x + width - 1, y + high - 1);
TFT_CS_L; TFT_CS_L;
do { do
size_t chunk_size = len; {
spi_transaction_ext_t t = {0}; size_t chunk_size = len;
memset(&t, 0, sizeof(t)); spi_transaction_ext_t t = {0};
if (first_send) { memset(&t, 0, sizeof(t));
t.base.flags = if (first_send)
SPI_TRANS_MODE_QIO /* | SPI_TRANS_MODE_DIOQIO_ADDR */; {
t.base.cmd = 0x32 /* 0x12 */; t.base.flags =
t.base.addr = 0x002C00; SPI_TRANS_MODE_QIO /* | SPI_TRANS_MODE_DIOQIO_ADDR */;
first_send = 0; t.base.cmd = 0x32 /* 0x12 */;
} else { t.base.addr = 0x002C00;
t.base.flags = SPI_TRANS_MODE_QIO | SPI_TRANS_VARIABLE_CMD | first_send = 0;
SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY; }
t.command_bits = 0; else
t.address_bits = 0; {
t.dummy_bits = 0; t.base.flags = SPI_TRANS_MODE_QIO | SPI_TRANS_VARIABLE_CMD |
} SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY;
if (chunk_size > SEND_BUF_SIZE) { t.command_bits = 0;
chunk_size = SEND_BUF_SIZE; t.address_bits = 0;
} t.dummy_bits = 0;
t.base.tx_buffer = p; }
t.base.length = chunk_size * 16; if (chunk_size > SEND_BUF_SIZE)
{
chunk_size = SEND_BUF_SIZE;
}
t.base.tx_buffer = p;
t.base.length = chunk_size * 16;
// spi_device_queue_trans(spi, (spi_transaction_t *)&t, portMAX_DELAY); // spi_device_queue_trans(spi, (spi_transaction_t *)&t, portMAX_DELAY);
spi_device_polling_transmit(spi, (spi_transaction_t *)&t); spi_device_polling_transmit(spi, (spi_transaction_t *)&t);
len -= chunk_size; len -= chunk_size;
p += chunk_size; p += chunk_size;
} while (len > 0); } while (len > 0);
TFT_CS_H; TFT_CS_H;
#else #else
lcd_address_set(x, y, x + width - 1, y + high - 1); lcd_address_set(x, y, x + width - 1, y + high - 1);
TFT_CS_L; TFT_CS_L;
SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE)); SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE));
TFT_DC_H; TFT_DC_H;
SPI.writeBytes((uint8_t *)data, width * high * 2); SPI.writeBytes((uint8_t *)data, width * high * 2);
SPI.endTransaction(); SPI.endTransaction();
TFT_CS_H; TFT_CS_H;
#endif #endif
} }
void lcd_PushColors(uint16_t *data, uint32_t len) void lcd_PushColors(uint16_t *data, uint32_t len)
{ {
#if LCD_USB_QSPI_DREVER == 1 #if LCD_USB_QSPI_DREVER == 1
bool first_send = 1; bool first_send = 1;
uint16_t *p = (uint16_t *)data; uint16_t *p = (uint16_t *)data;
TFT_CS_L; TFT_CS_L;
do { do
size_t chunk_size = len; {
spi_transaction_ext_t t = {0}; size_t chunk_size = len;
memset(&t, 0, sizeof(t)); spi_transaction_ext_t t = {0};
if (first_send) { memset(&t, 0, sizeof(t));
t.base.flags = if (first_send)
SPI_TRANS_MODE_QIO /* | SPI_TRANS_MODE_DIOQIO_ADDR */; {
t.base.cmd = 0x32 /* 0x12 */; t.base.flags =
t.base.addr = 0x002C00; SPI_TRANS_MODE_QIO /* | SPI_TRANS_MODE_DIOQIO_ADDR */;
first_send = 0; t.base.cmd = 0x32 /* 0x12 */;
} else { t.base.addr = 0x002C00;
t.base.flags = SPI_TRANS_MODE_QIO | SPI_TRANS_VARIABLE_CMD | first_send = 0;
SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY; }
t.command_bits = 0; else
t.address_bits = 0; {
t.dummy_bits = 0; t.base.flags = SPI_TRANS_MODE_QIO | SPI_TRANS_VARIABLE_CMD |
} SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY;
if (chunk_size > SEND_BUF_SIZE) { t.command_bits = 0;
chunk_size = SEND_BUF_SIZE; t.address_bits = 0;
} t.dummy_bits = 0;
t.base.tx_buffer = p; }
t.base.length = chunk_size * 16; if (chunk_size > SEND_BUF_SIZE)
{
chunk_size = SEND_BUF_SIZE;
}
t.base.tx_buffer = p;
t.base.length = chunk_size * 16;
// spi_device_queue_trans(spi, (spi_transaction_t *)&t, portMAX_DELAY); // spi_device_queue_trans(spi, (spi_transaction_t *)&t, portMAX_DELAY);
spi_device_polling_transmit(spi, (spi_transaction_t *)&t); spi_device_polling_transmit(spi, (spi_transaction_t *)&t);
len -= chunk_size; len -= chunk_size;
p += chunk_size; p += chunk_size;
} while (len > 0); } while (len > 0);
TFT_CS_H; TFT_CS_H;
#else #else
TFT_CS_L; TFT_CS_L;
SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE)); SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, TFT_SPI_MODE));
TFT_DC_H; TFT_DC_H;
SPI.writeBytes((uint8_t *)data, len * 2); SPI.writeBytes((uint8_t *)data, len * 2);
SPI.endTransaction(); SPI.endTransaction();
TFT_CS_H; TFT_CS_H;
#endif #endif
} }
void lcd_sleep() void lcd_sleep()
{ {
lcd_send_cmd(0x10, NULL, 0); lcd_send_cmd(0x10, NULL, 0);
} }
void lcd_on() void lcd_on()
{ {
lcd_send_cmd(0x29, NULL, 0x00); lcd_send_cmd(0x29, NULL, 0x00);
} }
void lcd_off() void lcd_off()
{ {
lcd_send_cmd(0x28, NULL, 0x00); lcd_send_cmd(0x28, NULL, 0x00);
} }

View File

@ -29,9 +29,9 @@
typedef struct typedef struct
{ {
uint8_t cmd; uint8_t cmd;
uint8_t data[4]; uint8_t data[4];
uint8_t len; uint8_t len;
} lcd_cmd_t; } lcd_cmd_t;
void rm67162_init(void); void rm67162_init(void);

View File

@ -136,3 +136,4 @@ lib_deps =
mathertel/OneButton @ ^2.0.3 mathertel/OneButton @ ^2.0.3
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

View File

@ -10,14 +10,20 @@
#include "wManager.h" #include "wManager.h"
#include "mining.h" #include "mining.h"
#include "monitor.h" #include "monitor.h"
#include "display/display.h" #include "drivers/display.h"
//3 seconds WDT //3 seconds WDT
#define WDT_TIMEOUT 3 #define WDT_TIMEOUT 3
//15 minutes WDT for miner task //15 minutes WDT for miner task
#define WDT_MINER_TIMEOUT 900 #define WDT_MINER_TIMEOUT 900
OneButton button1(PIN_BUTTON_1);
OneButton button2(PIN_BUTTON_2); #ifdef PIN_BUTTON_1
OneButton button1(PIN_BUTTON_1);
#endif
#ifdef PIN_BUTTON_2
OneButton button2(PIN_BUTTON_2);
#endif
extern monitor_data mMonitor; extern monitor_data mMonitor;
@ -42,29 +48,24 @@ void setup()
//disableCore1WDT(); //disableCore1WDT();
// Setup the buttons // Setup the buttons
#if defined(NERDMINERV2) || defined(NERMINER_S3_AMOLED) #if defined(PIN_BUTTON_1) && !defined(PIN_BUTTON_2) //One button device
// Button 1 (Boot) button1.setPressTicks(5000);
button1.setPressTicks(5000); button1.attachClick(switchToNextScreen);
button1.attachClick(alternateScreenState); button1.attachDoubleClick(alternateScreenRotation);
button1.attachDoubleClick(alternateScreenRotation); button1.attachLongPressStart(reset_configurations);
// Button 2 (GPIO14)
button2.setPressTicks(5000);
button2.attachClick(switchToNextScreen);
button2.attachLongPressStart(reset_configurations);
#elif defined(DEVKITV1)
//Standard ESP32-devKit
button1.setPressTicks(5000);
button1.attachLongPressStart(reset_configurations);
pinMode(LED_PIN, OUTPUT);
#elif defined(NERMINER_S3_DONGLE)
button1.setPressTicks(5000);
button1.attachClick(switchToNextScreen);
button1.attachDoubleClick(alternateScreenRotation);
button1.attachLongPressStart(reset_configurations);
#endif #endif
#if defined(PIN_BUTTON_1) && defined(PIN_BUTTON_2) //Button 1 of two button device
button1.setPressTicks(5000);
button1.attachClick(alternateScreenState);
button1.attachDoubleClick(alternateScreenRotation);
#endif
#if defined(PIN_BUTTON_2) //Button 2 of two button device
button2.setPressTicks(5000);
button2.attachClick(switchToNextScreen);
button2.attachLongPressStart(reset_configurations);
#endif
/******** INIT NERDMINER ************/ /******** INIT NERDMINER ************/
Serial.println("NerdMiner v2 starting......"); Serial.println("NerdMiner v2 starting......");
@ -78,10 +79,8 @@ void setup()
/******** SHOW LED INIT STATUS (devices without screen) *****/ /******** SHOW LED INIT STATUS (devices without screen) *****/
mMonitor.NerdStatus = NM_waitingConfig; mMonitor.NerdStatus = NM_waitingConfig;
#ifdef DEVKITV1 doLedStuff(0);
doLedStuff(LED_PIN);
#endif
/******** INIT WIFI ************/ /******** INIT WIFI ************/
init_WifiManager(); init_WifiManager();
@ -131,14 +130,15 @@ void app_error_fault_handler(void *arg) {
void loop() { void loop() {
// keep watching the push buttons: // keep watching the push buttons:
button1.tick(); #ifdef PIN_BUTTON_1
button2.tick(); button1.tick();
#endif
#ifdef PIN_BUTTON_2
button2.tick();
#endif
wifiManagerProcess(); // avoid delays() in loop when non-blocking and other long running code wifiManagerProcess(); // avoid delays() in loop when non-blocking and other long running code
#ifdef DEVKITV1
doLedStuff(LED_PIN);
#endif
vTaskDelay(50 / portTICK_PERIOD_MS); vTaskDelay(50 / portTICK_PERIOD_MS);
} }

View File

@ -1,63 +0,0 @@
#include "display.h"
#ifdef NO_DISPLAY
DisplayDriver *currentDisplayDriver = &noDisplayDriver;
#endif
#ifdef T_DISPLAY
DisplayDriver *currentDisplayDriver = &tDisplayDriver;
#endif
#ifdef AMOLED_DISPLAY
DisplayDriver *currentDisplayDriver = &amoledDisplayDriver;
#endif
#ifdef DONGLE_DISPLAY
DisplayDriver *currentDisplayDriver = &dongleDisplayDriver;
#endif
// Initialize the display
void initDisplay() {
currentDisplayDriver->initDisplay();
}
// Alternate screen state
void alternateScreenState() {
currentDisplayDriver->alternateScreenState();
}
// Alternate screen rotation
void alternateScreenRotation() {
currentDisplayDriver->alternateScreenRotation();
}
// Draw the loading screen
void drawLoadingScreen() {
currentDisplayDriver->loadingScreen();
}
// Draw the setup screen
void drawSetupScreen() {
currentDisplayDriver->setupScreen();
}
// Reset the current cyclic screen to the first one
void resetToFirstScreen() {
currentDisplayDriver->current_cyclic_screen = 0;
}
// Switches to the next cyclic screen without drawing it
void switchToNextScreen() {
currentDisplayDriver->current_cyclic_screen = (currentDisplayDriver->current_cyclic_screen + 1) % currentDisplayDriver->num_cyclic_screens;
}
// Draw the current cyclic screen
void drawCurrentScreen(unsigned long mElapsed) {
currentDisplayDriver->cyclic_screens[currentDisplayDriver->current_cyclic_screen](mElapsed);
}
// Animate the current cyclic screen
void animateCurrentScreen(unsigned long frame) {
currentDisplayDriver->animateCurrentScreen(frame);
}

View File

@ -1,43 +0,0 @@
#ifndef DRIVERS_H
#define DRIVERS_H
#if defined(DEVKITV1)
#define NO_DISPLAY
#elif defined(NERMINER_S3_AMOLED)
#define AMOLED_DISPLAY
#elif defined(NERMINER_S3_DONGLE)
#define DONGLE_DISPLAY
#else
#define T_DISPLAY
#endif
typedef void (*AlternateFunction)(void);
typedef void (*DriverInitFunction)(void);
typedef void (*ScreenFunction)(void);
typedef void (*CyclicScreenFunction)(unsigned long mElapsed);
typedef void (*AnimateCurrentScreenFunction)(unsigned long frame);
typedef struct {
DriverInitFunction initDisplay; // Initialize the display
AlternateFunction alternateScreenState; // Alternate screen state
AlternateFunction alternateScreenRotation; // Alternate screen rotation
ScreenFunction loadingScreen; // Explicit loading screen
ScreenFunction setupScreen; // Explicit setup screen
CyclicScreenFunction *cyclic_screens; // Array of cyclic screens
AnimateCurrentScreenFunction animateCurrentScreen; // Animate the current cyclic screen
int num_cyclic_screens; // Number of cyclic screens
int current_cyclic_screen; // Current cyclic screen being displayed
int screenWidth; // Screen width
int screenHeight; // Screen height
} DisplayDriver;
extern DisplayDriver *currentDisplayDriver;
extern DisplayDriver noDisplayDriver;
extern DisplayDriver tDisplayDriver;
extern DisplayDriver amoledDisplayDriver;
extern DisplayDriver dongleDisplayDriver;
#define SCREENS_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif // DRIVERS_H

View File

@ -1,225 +0,0 @@
#include "../drivers.h"
#ifdef AMOLED_DISPLAY
#include <rm67162.h>
#include <TFT_eSPI.h>
#include "media/images.h"
#include "media/myFonts.h"
#include "media/Free_Fonts.h"
#include "version.h"
#include "monitor.h"
#include "OpenFontRender.h"
#define WIDTH 536
#define HEIGHT 240
OpenFontRender render;
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite background = TFT_eSprite(&tft);
void amoledDisplay_Init(void) {
rm67162_init();
lcd_setRotation(1);
background.createSprite(WIDTH, HEIGHT);
background.setSwapBytes(true);
render.setDrawer(background);
render.setLineSpaceRatio(0.9);
if (render.loadFont(DigitalNumbers, sizeof(DigitalNumbers))){
Serial.println("Initialise error");
return;
}
}
int screen_state= 1;
void amoledDisplay_AlternateScreenState(void) {
screen_state == 1 ? lcd_off() : lcd_on();
screen_state ^= 1;
}
int screen_rotation = 1;
void amoledDisplay_AlternateRotation(void) {
screen_rotation == 1 ? lcd_setRotation(3) : lcd_setRotation(1);
screen_rotation ^= 1;
}
void amoledDisplay_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(35);
render.setCursor(19, 118);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 118, 114, TFT_BLACK);
//Total hashes
render.setFontSize(18);
render.rdrawString(data.totalMHashes.c_str(), 268, 138, TFT_BLACK);
//Block templates
render.setFontSize(18);
render.drawString(data.templates.c_str(), 186, 20, 0xDEDB);
//Best diff
render.drawString(data.bestDiff.c_str(), 186, 48, 0xDEDB);
//32Bit shares
render.setFontSize(18);
render.drawString(data.completedShares.c_str(), 186, 76, 0xDEDB);
//Hores
render.setFontSize(14);
render.rdrawString(data.timeMining.c_str(), 315, 104, 0xDEDB);
//Valid Blocks
render.setFontSize(24);
render.drawString(data.valids.c_str(), 285, 56, 0xDEDB);
//Print Temp
render.setFontSize(10);
render.rdrawString(data.temp.c_str(), 239, 1, TFT_BLACK);
render.setFontSize(4);
render.rdrawString(String(0).c_str(), 244, 3, TFT_BLACK);
//Print Hour
render.setFontSize(10);
render.rdrawString(data.currentTime.c_str(), 286, 1, TFT_BLACK);
//Push prepared background to screen
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_ClockScreen(unsigned long mElapsed) {
clock_data data = getClockData(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());
//Hashrate
render.setFontSize(25);
render.setCursor(19, 122);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 94, 129, TFT_BLACK);
//Print BTC Price
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 202, 3, GFXFF);
//Print BlockHeight
render.setFontSize(18);
render.rdrawString(data.blockHeight.c_str(), 254, 140, TFT_BLACK);
//Print Hour
background.setFreeFont(FF23);
background.setTextSize(2);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.currentTime.c_str(), 130, 50, GFXFF);
//Push prepared background to screen
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_GlobalHashScreen(unsigned long mElapsed) {
coin_data data = getCoinData(mElapsed);
//Print background screen
background.pushImage(0, 0, globalHashWidth, globalHashHeight, globalHashScreen);
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 BTC Price
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 198, 3, GFXFF);
//Print Hour
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 268, 3, GFXFF);
//Print Last Pool Block
background.setFreeFont(FSS9);
background.setTextDatum(TR_DATUM);
background.setTextColor(0x9C92);
background.drawString(data.halfHourFee.c_str(), 302, 52, GFXFF);
//Print Difficulty
background.setFreeFont(FSS9);
background.setTextDatum(TR_DATUM);
background.setTextColor(0x9C92);
background.drawString(data.netwrokDifficulty.c_str(), 302, 88, GFXFF);
//Print Global Hashrate
render.setFontSize(17);
render.rdrawString(data.globalHashRate.c_str(), 274, 145, TFT_BLACK);
//Print BlockHeight
render.setFontSize(28);
render.rdrawString(data.blockHeight.c_str(), 140, 104, 0xDEDB);
//Draw percentage rectangle
int x2 = 2 + (138*data.progressPercent/100);
background.fillRect(2, 149, x2, 168, 0xDEDB);
//Print Remaining BLocks
background.setTextFont(FONT2);
background.setTextSize(1);
background.setTextDatum(MC_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.remainingBlocks.c_str(), 72, 159, FONT2);
//Push prepared background to screen
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_LoadingScreen(void) {
background.fillScreen(TFT_BLACK);
background.pushImage(0, 0, initWidth, initHeight, initScreen);
background.setTextColor(TFT_BLACK);
background.drawString(CURRENT_VERSION, 24, 147, FONT2);
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_SetupScreen(void) {
background.pushImage(0, 0, setupModeWidth, setupModeHeight, setupModeScreen);
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_AnimateCurrentScreen(unsigned long frame) {
}
CyclicScreenFunction amoledDisplayCyclicScreens[] = { amoledDisplay_MinerScreen, amoledDisplay_ClockScreen, amoledDisplay_GlobalHashScreen };
DisplayDriver amoledDisplayDriver = {
amoledDisplay_Init,
amoledDisplay_AlternateScreenState,
amoledDisplay_AlternateRotation,
amoledDisplay_LoadingScreen,
amoledDisplay_SetupScreen,
amoledDisplayCyclicScreens,
amoledDisplay_AnimateCurrentScreen,
SCREENS_ARRAY_SIZE(amoledDisplayCyclicScreens),
0,
WIDTH,
HEIGHT
};
#endif

View File

@ -1,135 +0,0 @@
#include "../drivers.h"
#ifdef DONGLE_DISPLAY
#include <TFT_eSPI.h>
#include "media/images.h"
#include "media/myFonts.h"
#include "media/Free_Fonts.h"
#include "version.h"
#include "monitor.h"
#include "OpenFontRender.h"
#define WIDTH 160
#define HEIGHT 80
#define BUFFER_WIDTH WIDTH
#define BUFFER_HEIGHT HEIGHT * 4
#define SCROLL_SPEED 1
int pos_y = 0;
int delta_y = SCROLL_SPEED;
int max_y = BUFFER_HEIGHT - HEIGHT;
OpenFontRender render;
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite background = TFT_eSprite(&tft);
#define BACK_COLOR TFT_BLACK
#define VALUE_COLOR TFT_WHITE
#define KEY_COLOR TFT_WHITE
#define CLEAR_SCREEN() \
int32_t x = 4, y = 8; \
background.setTextSize(1);\
background.setTextFont(FONT2);\
background.setTextColor(KEY_COLOR);\
background.fillRect(0, 0, BUFFER_WIDTH, BUFFER_HEIGHT, BACK_COLOR);\
render.setFontSize(24);\
#define PRINT_STR(key, value, x, y)\
{\
background.drawString(String(key).c_str(), x, y);\
y -= 8;\
render.rdrawString(String(value).c_str(), WIDTH - 4, y, VALUE_COLOR);\
y += 40;\
max_y = y;\
}
#define PUSH_SCREEN() \
background.pushSprite(0,0);
void dongleDisplay_Init(void) {
tft.init();
tft.setRotation(3);
tft.setSwapBytes(true);
tft.fillScreen(TFT_RED);
background.createSprite(BUFFER_WIDTH, BUFFER_HEIGHT);
background.setSwapBytes(true);
render.setDrawer(background);
render.setLineSpaceRatio(0.9);
// 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 dongleDisplay_AlternateScreenState(void) {
}
void dongleDisplay_AlternateRotation(void) {
tft.getRotation() == 1 ? tft.setRotation(3) : tft.setRotation(1);
}
void dongleDisplay_MinerScreen(unsigned long mElapsed) {
mining_data data = getMiningData(mElapsed);
//Print background screen
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());
CLEAR_SCREEN();
PRINT_STR("M.Hashes", data.totalMHashes, x, y)
PRINT_STR("Templates", data.templates, x, y)
PRINT_STR("Best Diff", data.bestDiff, x, y)
PRINT_STR("Shares", data.completedShares, x, y)
PRINT_STR("Hash rate", data.currentHashRate, x, y)
PRINT_STR("Valids", data.valids, x, y)
PRINT_STR("Temp", data.temp, x, y)
PRINT_STR("Time", data.currentTime, x, y)
}
void dongleDisplay_LoadingScreen(void) {
CLEAR_SCREEN();
PRINT_STR("Initializing...","", x, y);
PUSH_SCREEN();
}
void dongleDisplay_SetupScreen(void) {
CLEAR_SCREEN();
PRINT_STR("Use WiFi for setup...","", x, y);
PUSH_SCREEN();
}
void dongleDisplay_AnimateCurrentScreen(unsigned long frame) {
if(pos_y >= max_y - HEIGHT) {
delta_y = -SCROLL_SPEED;
pos_y = max_y - HEIGHT;
} else if(pos_y <= 0) {
delta_y = SCROLL_SPEED;
pos_y = 0;
}
pos_y += delta_y;
background.pushSprite(0, -pos_y);
}
CyclicScreenFunction dongleDisplayCyclicScreens[] = { dongleDisplay_MinerScreen };
DisplayDriver dongleDisplayDriver = {
dongleDisplay_Init,
dongleDisplay_AlternateScreenState,
dongleDisplay_AlternateRotation,
dongleDisplay_LoadingScreen,
dongleDisplay_SetupScreen,
dongleDisplayCyclicScreens,
dongleDisplay_AnimateCurrentScreen,
SCREENS_ARRAY_SIZE(dongleDisplayCyclicScreens),
0,
WIDTH,
HEIGHT
};
#endif

View File

@ -1,60 +0,0 @@
#include "../drivers.h"
#ifdef NO_DISPLAY
#include <Arduino.h>
#include "monitor.h"
void noDisplay_Init(void) {
Serial.println("No display driver initialized");
}
void noDisplay_AlternateScreenState(void) {
}
void noDisplay_AlternateRotation(void) {
}
void noDisplay_NoScreen(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 noDisplay_LoadingScreen(void) {
Serial.println("Initializing...");
}
void noDisplay_SetupScreen(void) {
Serial.println("Setup...");
}
void tDisplay_AnimateCurrentScreen(unsigned long frame) {
}
CyclicScreenFunction noDisplayCyclicScreens[] = { noDisplay_NoScreen };
DisplayDriver noDisplayDriver = {
noDisplay_Init,
noDisplay_AlternateScreenState,
noDisplay_AlternateRotation,
noDisplay_LoadingScreen,
noDisplay_SetupScreen,
noDisplayCyclicScreens,
noDisplay_AnimateCurrentScreen,
SCREENS_ARRAY_SIZE(noDisplayCyclicScreens),
0,
0,
0,
};
#endif

View File

@ -1,220 +0,0 @@
#include "../drivers.h"
#ifdef T_DISPLAY
#include <TFT_eSPI.h>
#include "media/images.h"
#include "media/myFonts.h"
#include "media/Free_Fonts.h"
#include "version.h"
#include "monitor.h"
#include "OpenFontRender.h"
#define WIDTH 340
#define HEIGHT 170
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 tDisplay_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 tDisplay_AlternateScreenState(void) {
int screen_state= digitalRead(TFT_BL);
Serial.println("Switching display state");
digitalWrite(TFT_BL, !screen_state);
}
void tDisplay_AlternateRotation(void) {
tft.getRotation() == 1 ? tft.setRotation(3) : tft.setRotation(1);
}
void tDisplay_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(35);
render.setCursor(19, 118);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 118, 114, TFT_BLACK);
//Total hashes
render.setFontSize(18);
render.rdrawString(data.totalMHashes.c_str(), 268, 138, TFT_BLACK);
//Block templates
render.setFontSize(18);
render.drawString(data.templates.c_str(), 186, 20, 0xDEDB);
//Best diff
render.drawString(data.bestDiff.c_str(), 186, 48, 0xDEDB);
//32Bit shares
render.setFontSize(18);
render.drawString(data.completedShares.c_str(), 186, 76, 0xDEDB);
//Hores
render.setFontSize(14);
render.rdrawString(data.timeMining.c_str(), 315, 104, 0xDEDB);
//Valid Blocks
render.setFontSize(24);
render.drawString(data.valids.c_str(), 285, 56, 0xDEDB);
//Print Temp
render.setFontSize(10);
render.rdrawString(data.temp.c_str(), 239, 1, TFT_BLACK);
render.setFontSize(4);
render.rdrawString(String(0).c_str(), 244, 3, TFT_BLACK);
//Print Hour
render.setFontSize(10);
render.rdrawString(data.currentTime.c_str(), 286, 1, TFT_BLACK);
//Push prepared background to screen
background.pushSprite(0,0);
}
void tDisplay_ClockScreen(unsigned long mElapsed) {
clock_data data = getClockData(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());
//Hashrate
render.setFontSize(25);
render.setCursor(19, 122);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 94, 129, TFT_BLACK);
//Print BTC Price
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 202, 3, GFXFF);
//Print BlockHeight
render.setFontSize(18);
render.rdrawString(data.blockHeight.c_str(), 254, 140, TFT_BLACK);
//Print Hour
background.setFreeFont(FF23);
background.setTextSize(2);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.currentTime.c_str(), 130, 50, GFXFF);
//Push prepared background to screen
background.pushSprite(0,0);
}
void tDisplay_GlobalHashScreen(unsigned long mElapsed) {
coin_data data = getCoinData(mElapsed);
//Print background screen
background.pushImage(0, 0, globalHashWidth, globalHashHeight, globalHashScreen);
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 BTC Price
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 198, 3, GFXFF);
//Print Hour
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 268, 3, GFXFF);
//Print Last Pool Block
background.setFreeFont(FSS9);
background.setTextDatum(TR_DATUM);
background.setTextColor(0x9C92);
background.drawString(data.halfHourFee.c_str(), 302, 52, GFXFF);
//Print Difficulty
background.setFreeFont(FSS9);
background.setTextDatum(TR_DATUM);
background.setTextColor(0x9C92);
background.drawString(data.netwrokDifficulty.c_str(), 302, 88, GFXFF);
//Print Global Hashrate
render.setFontSize(17);
render.rdrawString(data.globalHashRate.c_str(), 274, 145, TFT_BLACK);
//Print BlockHeight
render.setFontSize(28);
render.rdrawString(data.blockHeight.c_str(), 140, 104, 0xDEDB);
//Draw percentage rectangle
int x2 = 2 + (138*data.progressPercent/100);
background.fillRect(2, 149, x2, 168, 0xDEDB);
//Print Remaining BLocks
background.setTextFont(FONT2);
background.setTextSize(1);
background.setTextDatum(MC_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.remainingBlocks.c_str(), 72, 159, FONT2);
//Push prepared background to screen
background.pushSprite(0,0);
}
void tDisplay_LoadingScreen(void) {
tft.fillScreen(TFT_BLACK);
tft.pushImage(0, 0, initWidth, initHeight, initScreen);
tft.setTextColor(TFT_BLACK);
tft.drawString(CURRENT_VERSION, 24, 147, FONT2);
}
void tDisplay_SetupScreen(void) {
tft.pushImage(0, 0, setupModeWidth, setupModeHeight, setupModeScreen);
}
void tDisplay_AnimateCurrentScreen(unsigned long frame) {
}
CyclicScreenFunction tDisplayCyclicScreens[] = { tDisplay_MinerScreen, tDisplay_ClockScreen, tDisplay_GlobalHashScreen };
DisplayDriver tDisplayDriver = {
tDisplay_Init,
tDisplay_AlternateScreenState,
tDisplay_AlternateRotation,
tDisplay_LoadingScreen,
tDisplay_SetupScreen,
tDisplayCyclicScreens,
tDisplay_AnimateCurrentScreen,
SCREENS_ARRAY_SIZE(tDisplayCyclicScreens),
0,
WIDTH,
HEIGHT
};
#endif

View File

@ -0,0 +1,9 @@
#ifndef _ESP32_DEV_KIT_H
#define _ESP32_DEV_KIT_H
#define PIN_BUTTON_1 0
#define LED_PIN 2
#define NO_DISPLAY
#endif

View File

@ -0,0 +1,9 @@
#ifndef _LILYGO_S3_AMOLED_H
#define _LILYGO_S3_AMOLED_H
#define PIN_BUTTON_1 0
#define PIN_BUTTON_2 21
#define AMOLED_DISPLAY
#endif

View File

@ -0,0 +1,11 @@
#ifndef _LILYGO_S3_DONGLE_H
#define _LILYGO_S3_DONGLE_H
#define PIN_BUTTON_1 0
#define LED_DI_PIN 40
#define LED_CI_PIN 39
#define USE_LED
#define DONGLE_DISPLAY
#endif

View File

@ -0,0 +1,10 @@
#ifndef _LILYGO_S3_T_DISPLAY_H
#define _LILYGO_S3_T_DISPLAY_H
#define PIN_BUTTON_1 0
#define PIN_BUTTON_2 14
#define PIN_ENABLE5V 15
#define T_DISPLAY
#endif

View File

@ -0,0 +1,10 @@
#ifndef _NERD_MINER_V2_H
#define _NERD_MINER_V2_H
#define PIN_BUTTON_1 0
#define PIN_BUTTON_2 14
#define PIN_ENABLE5V 15
#define T_DISPLAY
#endif

77
src/drivers/display.cpp Normal file
View File

@ -0,0 +1,77 @@
#include "display.h"
#ifdef NO_DISPLAY
DisplayDriver *currentDisplayDriver = &noDisplayDriver;
#endif
#ifdef T_DISPLAY
DisplayDriver *currentDisplayDriver = &tDisplayDriver;
#endif
#ifdef AMOLED_DISPLAY
DisplayDriver *currentDisplayDriver = &amoledDisplayDriver;
#endif
#ifdef DONGLE_DISPLAY
DisplayDriver *currentDisplayDriver = &dongleDisplayDriver;
#endif
// Initialize the display
void initDisplay()
{
currentDisplayDriver->initDisplay();
}
// Alternate screen state
void alternateScreenState()
{
currentDisplayDriver->alternateScreenState();
}
// Alternate screen rotation
void alternateScreenRotation()
{
currentDisplayDriver->alternateScreenRotation();
}
// Draw the loading screen
void drawLoadingScreen()
{
currentDisplayDriver->loadingScreen();
}
// Draw the setup screen
void drawSetupScreen()
{
currentDisplayDriver->setupScreen();
}
// Reset the current cyclic screen to the first one
void resetToFirstScreen()
{
currentDisplayDriver->current_cyclic_screen = 0;
}
// Switches to the next cyclic screen without drawing it
void switchToNextScreen()
{
currentDisplayDriver->current_cyclic_screen = (currentDisplayDriver->current_cyclic_screen + 1) % currentDisplayDriver->num_cyclic_screens;
}
// Draw the current cyclic screen
void drawCurrentScreen(unsigned long mElapsed)
{
currentDisplayDriver->cyclic_screens[currentDisplayDriver->current_cyclic_screen](mElapsed);
}
// Animate the current cyclic screen
void animateCurrentScreen(unsigned long frame)
{
currentDisplayDriver->animateCurrentScreen(frame);
}
// Do LED stuff
void doLedStuff(unsigned long frame)
{
currentDisplayDriver->doLedStuff(frame);
}

View File

@ -14,5 +14,6 @@ void drawLoadingScreen();
void drawSetupScreen(); void drawSetupScreen();
void drawCurrentScreen(unsigned long mElapsed); void drawCurrentScreen(unsigned long mElapsed);
void animateCurrentScreen(unsigned long frame); void animateCurrentScreen(unsigned long frame);
void doLedStuff(unsigned long frame);
#endif // DISPLAY_H #endif // DISPLAY_H

View File

@ -0,0 +1,246 @@
#include "../drivers.h"
#ifdef AMOLED_DISPLAY
#include <rm67162.h>
#include <TFT_eSPI.h>
#include "media/images_536_240.h"
#include "media/myFonts.h"
#include "media/Free_Fonts.h"
#include "version.h"
#include "monitor.h"
#include "OpenFontRender.h"
#define WIDTH 536
#define HEIGHT 240
#define SOURCE_HEIGHT 170
#define MARGIN_LEFT 42
#define SCALE HEIGHT / SOURCE_HEIGHT
#define X(x) (MARGIN_LEFT + (x * SCALE))
#define Y(y) (y * SCALE)
#define FS(S) (S * SCALE)
OpenFontRender render;
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite background = TFT_eSprite(&tft);
void amoledDisplay_Init(void)
{
rm67162_init();
lcd_setRotation(1);
background.createSprite(WIDTH, HEIGHT);
background.setSwapBytes(true);
render.setDrawer(background);
render.setLineSpaceRatio(0.9);
if (render.loadFont(DigitalNumbers, sizeof(DigitalNumbers)))
{
Serial.println("Initialise error");
return;
}
}
int screen_state = 1;
void amoledDisplay_AlternateScreenState(void)
{
screen_state == 1 ? lcd_off() : lcd_on();
screen_state ^= 1;
}
int screen_rotation = 1;
void amoledDisplay_AlternateRotation(void)
{
screen_rotation == 1 ? lcd_setRotation(3) : lcd_setRotation(1);
screen_rotation ^= 1;
}
void amoledDisplay_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(FS(35));
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), X(118), Y(114), TFT_BLACK);
// Total hashes
render.setFontSize(FS(18));
render.rdrawString(data.totalMHashes.c_str(), X(268), Y(138), TFT_BLACK);
// Block templates
render.setFontSize(FS(18));
render.drawString(data.templates.c_str(), X(186), Y(20), 0xDEDB);
// Best diff
render.drawString(data.bestDiff.c_str(), X(186), Y(48), 0xDEDB);
// 32Bit shares
render.setFontSize(FS(18));
render.drawString(data.completedShares.c_str(), X(186), Y(76), 0xDEDB);
// Hores
render.setFontSize(FS(14));
render.rdrawString(data.timeMining.c_str(), X(315), Y(104), 0xDEDB);
// Valid Blocks
render.setFontSize(FS(24));
render.drawString(data.valids.c_str(), X(285), Y(56), 0xDEDB);
// Print Temp
render.setFontSize(FS(10));
render.rdrawString(data.temp.c_str(), X(239), Y(1), TFT_BLACK);
render.setFontSize(FS(4));
render.rdrawString(String(0).c_str(), X(244), Y(3), TFT_BLACK);
// Print Hour
render.setFontSize(FS(10));
render.rdrawString(data.currentTime.c_str(), X(286), Y(1), TFT_BLACK);
// Push prepared background to screen
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_ClockScreen(unsigned long mElapsed)
{
clock_data data = getClockData(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());
// Hashrate
render.setFontSize(FS(25));
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), X(94), Y(129), TFT_BLACK);
// Print BTC Price
background.setFreeFont(FSSB12);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.btcPrice.c_str(), X(202), Y(3), GFXFF);
// Print BlockHeight
render.setFontSize(FS(18));
render.rdrawString(data.blockHeight.c_str(), X(254), Y(140), TFT_BLACK);
// Print Hour
background.setFreeFont(FF24);
background.setTextSize(2);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.currentTime.c_str(), X(130), Y(50), GFXFF);
// Push prepared background to screen
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_GlobalHashScreen(unsigned long mElapsed)
{
coin_data data = getCoinData(mElapsed);
// Print background screen
background.pushImage(0, 0, globalHashWidth, globalHashHeight, globalHashScreen);
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 BTC Price
background.setFreeFont(FSSB12);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.btcPrice.c_str(), X(198), Y(3), GFXFF);
// Print Hour
background.setFreeFont(FSSB12);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), X(268), Y(3), GFXFF);
// Print Last Pool Block
background.setFreeFont(FSS12);
background.setTextDatum(TR_DATUM);
background.setTextColor(0x9C92);
background.drawString(data.halfHourFee.c_str(), X(302), Y(52), GFXFF);
// Print Difficulty
background.setFreeFont(FSS12);
background.setTextDatum(TR_DATUM);
background.setTextColor(0x9C92);
background.drawString(data.netwrokDifficulty.c_str(), X(302), Y(88), GFXFF);
// Print Global Hashrate
render.setFontSize(FS(17));
render.rdrawString(data.globalHashRate.c_str(), X(274), Y(145), TFT_BLACK);
// Print BlockHeight
render.setFontSize(FS(28));
render.rdrawString(data.blockHeight.c_str(), X(140), Y(104), 0xDEDB);
// Draw percentage rectangle
int x2 = 2 + (138 * data.progressPercent / 100);
background.fillRect(2, Y(149), X(x2), Y(238), 0xDEDB);
// Print Remaining BLocks
background.setTextFont(FONT4);
background.setTextSize(1);
background.setTextDatum(MC_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.remainingBlocks.c_str(), X(72), Y(159), FONT2);
// Push prepared background to screen
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_LoadingScreen(void)
{
background.fillScreen(TFT_BLACK);
background.pushImage(0, 0, initWidth, initHeight, initScreen);
background.setTextColor(TFT_BLACK);
background.drawString(CURRENT_VERSION, X(24), Y(147), FONT2);
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_SetupScreen(void)
{
background.pushImage(0, 0, setupModeWidth, setupModeHeight, setupModeScreen);
lcd_PushColors(0, 0, WIDTH, HEIGHT, (uint16_t *)background.getPointer());
}
void amoledDisplay_AnimateCurrentScreen(unsigned long frame)
{
}
void amoledDisplay_DoLedStuff(unsigned long frame)
{
}
CyclicScreenFunction amoledDisplayCyclicScreens[] = {amoledDisplay_MinerScreen, amoledDisplay_ClockScreen, amoledDisplay_GlobalHashScreen};
DisplayDriver amoledDisplayDriver = {
amoledDisplay_Init,
amoledDisplay_AlternateScreenState,
amoledDisplay_AlternateRotation,
amoledDisplay_LoadingScreen,
amoledDisplay_SetupScreen,
amoledDisplayCyclicScreens,
amoledDisplay_AnimateCurrentScreen,
amoledDisplay_DoLedStuff,
SCREENS_ARRAY_SIZE(amoledDisplayCyclicScreens),
0,
WIDTH,
HEIGHT};
#endif

View File

@ -0,0 +1,212 @@
#include "../drivers.h"
#ifdef DONGLE_DISPLAY
#include <TFT_eSPI.h>
#include "media/images_160_80.h"
#include "media/myFonts.h"
#include "media/Free_Fonts.h"
#include "version.h"
#include "monitor.h"
#include "OpenFontRender.h"
#include <FastLED.h>
#define WIDTH 160
#define HEIGHT 80
#define BUFFER_WIDTH MinerWidth
#define BUFFER_HEIGHT MinerHeight
#define SCROLL_SPEED 2
int pos_y = 0;
int delta_y = SCROLL_SPEED;
int max_y = BUFFER_HEIGHT - HEIGHT;
OpenFontRender render;
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite background = TFT_eSprite(&tft);
#define MAX_BRIGHTNESS 16
#define SLOW_FADE 1;
#define FAST_FADE 4;
CRGB leds(0, 0, 0);
int brightness = 0;
int fadeDirection = 1;
int fadeAmount = 0;
extern monitor_data mMonitor;
#define BACK_COLOR TFT_BLACK
#define VALUE_COLOR TFT_WHITE
#define KEY_COLOR TFT_WHITE
#define RESET_SCREEN() \
int32_t x = 8, y = 8; \
background.setTextSize(1); \
background.setTextFont(FONT2); \
\
background.setTextColor(KEY_COLOR); \
\
render.setFontSize(18);
#define CLEAR_SCREEN() \
RESET_SCREEN(); \
background.fillRect(0, 0, BUFFER_WIDTH, BUFFER_HEIGHT, BACK_COLOR); \
\
#define PRINT_STR(str) \
{ \
background.drawString(String(str).c_str(), x, y); \
y += 32; \
max_y = y; \
}
#define PRINT_VALUE(value) \
{ \
render.drawString(String(value).c_str(), x, y, VALUE_COLOR); \
y += 27; \
}
#define PUSH_SCREEN() \
background.pushSprite(0, 0);
void dongleDisplay_Init(void)
{
FastLED.addLeds<APA102, LED_DI_PIN, LED_CI_PIN, BGR>(&leds, 1);
FastLED.show();
tft.init();
tft.setRotation(3);
tft.setSwapBytes(true);
background.createSprite(BUFFER_WIDTH, BUFFER_HEIGHT);
background.setSwapBytes(true);
render.setDrawer(background);
render.setLineSpaceRatio(0.9);
// 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 dongleDisplay_AlternateScreenState(void)
{
}
void dongleDisplay_AlternateRotation(void)
{
tft.getRotation() == 1 ? tft.setRotation(3) : tft.setRotation(1);
}
void dongleDisplay_MinerScreen(unsigned long mElapsed)
{
max_y = BUFFER_HEIGHT;
mining_data data = getMiningData(mElapsed);
// Print background screen
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());
background.pushImage(0, 0, MinerWidth, MinerHeight, MinerScreen);
RESET_SCREEN();
x = 74;
y = 15;
render.setFontSize(20);
PRINT_VALUE(data.currentTime);
render.setFontSize(18);
x = 68;
y = 51;
PRINT_VALUE(data.currentHashRate);
PRINT_VALUE(data.valids);
PRINT_VALUE(data.templates);
PRINT_VALUE(data.bestDiff);
PRINT_VALUE(data.completedShares);
PRINT_VALUE(data.totalMHashes);
PRINT_VALUE(data.temp);
}
void dongleDisplay_LoadingScreen(void)
{
CLEAR_SCREEN();
PRINT_STR("Initializing...");
PUSH_SCREEN();
}
void dongleDisplay_SetupScreen(void)
{
CLEAR_SCREEN();
PRINT_STR("Use WiFi for setup...");
PUSH_SCREEN();
}
void dongleDisplay_AnimateCurrentScreen(unsigned long frame)
{
if (pos_y > max_y)
{
pos_y = 0;
}
if (pos_y > max_y - HEIGHT)
{
background.pushSprite(0, max_y - pos_y);
}
pos_y += delta_y;
background.pushSprite(0, -pos_y);
}
void dongleDisplay_DoLedStuff(unsigned long frame)
{
#ifdef USE_LED
switch (mMonitor.NerdStatus)
{
case NM_waitingConfig:
brightness = MAX_BRIGHTNESS;
leds.setRGB(255, 255, 0);
fadeAmount = 0;
break;
case NM_Connecting:
leds.setRGB(0, 0, 255);
fadeAmount = SLOW_FADE;
break;
case NM_hashing:
leds.setRGB(0, 0, 255);
fadeAmount = FAST_FADE;
break;
}
leds.fadeLightBy(0xFF - brightness);
FastLED.show();
brightness = brightness + (fadeDirection * fadeAmount);
if (brightness <= 0 || brightness >= MAX_BRIGHTNESS)
{
fadeDirection = -fadeDirection;
}
brightness = constrain(brightness, 0, MAX_BRIGHTNESS);
#endif
}
CyclicScreenFunction dongleDisplayCyclicScreens[] = {dongleDisplay_MinerScreen};
DisplayDriver dongleDisplayDriver = {
dongleDisplay_Init,
dongleDisplay_AlternateScreenState,
dongleDisplay_AlternateRotation,
dongleDisplay_LoadingScreen,
dongleDisplay_SetupScreen,
dongleDisplayCyclicScreens,
dongleDisplay_AnimateCurrentScreen,
dongleDisplay_DoLedStuff,
SCREENS_ARRAY_SIZE(dongleDisplayCyclicScreens),
0,
WIDTH,
HEIGHT};
#endif

View File

@ -0,0 +1,104 @@
#include "../drivers.h"
#ifdef NO_DISPLAY
#include <Arduino.h>
#include "monitor.h"
#include "wManager.h"
extern monitor_data mMonitor;
void noDisplay_Init(void)
{
Serial.println("No display driver initialized");
pinMode(LED_PIN, OUTPUT);
}
void noDisplay_AlternateScreenState(void)
{
}
void noDisplay_AlternateRotation(void)
{
}
void noDisplay_NoScreen(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 noDisplay_LoadingScreen(void)
{
Serial.println("Initializing...");
}
void noDisplay_SetupScreen(void)
{
Serial.println("Setup...");
}
// Variables para controlar el parpadeo con millis()
unsigned long previousMillis = 0;
void noDisplay_DoLedStuff(unsigned long frame)
{
unsigned long currentMillis = millis();
switch (mMonitor.NerdStatus)
{
case NM_waitingConfig:
digitalWrite(LED_PIN, HIGH); // LED encendido de forma continua
break;
case NM_Connecting:
if (currentMillis - previousMillis >= 500)
{ // 0.5sec blink
previousMillis = currentMillis;
digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Cambia el estado del LED
}
break;
case NM_hashing:
if (currentMillis - previousMillis >= 100)
{ // 0.1sec blink
previousMillis = currentMillis;
digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Cambia el estado del LED
}
break;
}
}
void noDisplay_AnimateCurrentScreen(unsigned long frame)
{
}
CyclicScreenFunction noDisplayCyclicScreens[] = {noDisplay_NoScreen};
DisplayDriver noDisplayDriver = {
noDisplay_Init,
noDisplay_AlternateScreenState,
noDisplay_AlternateRotation,
noDisplay_LoadingScreen,
noDisplay_SetupScreen,
noDisplayCyclicScreens,
noDisplay_AnimateCurrentScreen,
noDisplay_DoLedStuff,
SCREENS_ARRAY_SIZE(noDisplayCyclicScreens),
0,
0,
0,
};
#endif

View File

@ -0,0 +1,234 @@
#include "../drivers.h"
#ifdef T_DISPLAY
#include <TFT_eSPI.h>
#include "media/images_320_170.h"
#include "media/myFonts.h"
#include "media/Free_Fonts.h"
#include "version.h"
#include "monitor.h"
#include "OpenFontRender.h"
#define WIDTH 340
#define HEIGHT 170
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 tDisplay_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 tDisplay_AlternateScreenState(void)
{
int screen_state = digitalRead(TFT_BL);
Serial.println("Switching display state");
digitalWrite(TFT_BL, !screen_state);
}
void tDisplay_AlternateRotation(void)
{
tft.getRotation() == 1 ? tft.setRotation(3) : tft.setRotation(1);
}
void tDisplay_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(35);
render.setCursor(19, 118);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 118, 114, TFT_BLACK);
// Total hashes
render.setFontSize(18);
render.rdrawString(data.totalMHashes.c_str(), 268, 138, TFT_BLACK);
// Block templates
render.setFontSize(18);
render.drawString(data.templates.c_str(), 186, 20, 0xDEDB);
// Best diff
render.drawString(data.bestDiff.c_str(), 186, 48, 0xDEDB);
// 32Bit shares
render.setFontSize(18);
render.drawString(data.completedShares.c_str(), 186, 76, 0xDEDB);
// Hores
render.setFontSize(14);
render.rdrawString(data.timeMining.c_str(), 315, 104, 0xDEDB);
// Valid Blocks
render.setFontSize(24);
render.drawString(data.valids.c_str(), 285, 56, 0xDEDB);
// Print Temp
render.setFontSize(10);
render.rdrawString(data.temp.c_str(), 239, 1, TFT_BLACK);
render.setFontSize(4);
render.rdrawString(String(0).c_str(), 244, 3, TFT_BLACK);
// Print Hour
render.setFontSize(10);
render.rdrawString(data.currentTime.c_str(), 286, 1, TFT_BLACK);
// Push prepared background to screen
background.pushSprite(0, 0);
}
void tDisplay_ClockScreen(unsigned long mElapsed)
{
clock_data data = getClockData(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());
// Hashrate
render.setFontSize(25);
render.setCursor(19, 122);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 94, 129, TFT_BLACK);
// Print BTC Price
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 202, 3, GFXFF);
// Print BlockHeight
render.setFontSize(18);
render.rdrawString(data.blockHeight.c_str(), 254, 140, TFT_BLACK);
// Print Hour
background.setFreeFont(FF23);
background.setTextSize(2);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.currentTime.c_str(), 130, 50, GFXFF);
// Push prepared background to screen
background.pushSprite(0, 0);
}
void tDisplay_GlobalHashScreen(unsigned long mElapsed)
{
coin_data data = getCoinData(mElapsed);
// Print background screen
background.pushImage(0, 0, globalHashWidth, globalHashHeight, globalHashScreen);
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 BTC Price
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 198, 3, GFXFF);
// Print Hour
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 268, 3, GFXFF);
// Print Last Pool Block
background.setFreeFont(FSS9);
background.setTextDatum(TR_DATUM);
background.setTextColor(0x9C92);
background.drawString(data.halfHourFee.c_str(), 302, 52, GFXFF);
// Print Difficulty
background.setFreeFont(FSS9);
background.setTextDatum(TR_DATUM);
background.setTextColor(0x9C92);
background.drawString(data.netwrokDifficulty.c_str(), 302, 88, GFXFF);
// Print Global Hashrate
render.setFontSize(17);
render.rdrawString(data.globalHashRate.c_str(), 274, 145, TFT_BLACK);
// Print BlockHeight
render.setFontSize(28);
render.rdrawString(data.blockHeight.c_str(), 140, 104, 0xDEDB);
// Draw percentage rectangle
int x2 = 2 + (138 * data.progressPercent / 100);
background.fillRect(2, 149, x2, 168, 0xDEDB);
// Print Remaining BLocks
background.setTextFont(FONT2);
background.setTextSize(1);
background.setTextDatum(MC_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.remainingBlocks.c_str(), 72, 159, FONT2);
// Push prepared background to screen
background.pushSprite(0, 0);
}
void tDisplay_LoadingScreen(void)
{
tft.fillScreen(TFT_BLACK);
tft.pushImage(0, 0, initWidth, initHeight, initScreen);
tft.setTextColor(TFT_BLACK);
tft.drawString(CURRENT_VERSION, 24, 147, FONT2);
}
void tDisplay_SetupScreen(void)
{
tft.pushImage(0, 0, setupModeWidth, setupModeHeight, setupModeScreen);
}
void tDisplay_AnimateCurrentScreen(unsigned long frame)
{
}
void tDisplay_DoLedStuff(unsigned long frame)
{
}
CyclicScreenFunction tDisplayCyclicScreens[] = {tDisplay_MinerScreen, tDisplay_ClockScreen, tDisplay_GlobalHashScreen};
DisplayDriver tDisplayDriver = {
tDisplay_Init,
tDisplay_AlternateScreenState,
tDisplay_AlternateRotation,
tDisplay_LoadingScreen,
tDisplay_SetupScreen,
tDisplayCyclicScreens,
tDisplay_AnimateCurrentScreen,
tDisplay_DoLedStuff,
SCREENS_ARRAY_SIZE(tDisplayCyclicScreens),
0,
WIDTH,
HEIGHT};
#endif

50
src/drivers/drivers.h Normal file
View File

@ -0,0 +1,50 @@
#ifndef DRIVERS_H
#define DRIVERS_H
#if defined(NERDMINERV2)
#include "devices/nerdMinerV2.h"
#elif defined(DEVKITV1)
#include "devices/esp32DevKit.h"
#elif defined(TDISPLAY)
#include "devices/lilygoS3TDisplay.h"
#elif defined(NERMINER_S3_AMOLED)
#include "devices/lilygoS3Amoled.h"
#elif defined(NERMINER_S3_DONGLE)
#include "devices/lilygoS3Dongle.h"
#else
#error "No device defined"
#endif
typedef void (*AlternateFunction)(void);
typedef void (*DriverInitFunction)(void);
typedef void (*ScreenFunction)(void);
typedef void (*CyclicScreenFunction)(unsigned long mElapsed);
typedef void (*AnimateCurrentScreenFunction)(unsigned long frame);
typedef void (*DoLedStuff)(unsigned long frame);
typedef struct
{
DriverInitFunction initDisplay; // Initialize the display
AlternateFunction alternateScreenState; // Alternate screen state
AlternateFunction alternateScreenRotation; // Alternate screen rotation
ScreenFunction loadingScreen; // Explicit loading screen
ScreenFunction setupScreen; // Explicit setup screen
CyclicScreenFunction *cyclic_screens; // Array of cyclic screens
AnimateCurrentScreenFunction animateCurrentScreen; // Animate the current cyclic screen
DoLedStuff doLedStuff; // Do LED stuff
int num_cyclic_screens; // Number of cyclic screens
int current_cyclic_screen; // Current cyclic screen being displayed
int screenWidth; // Screen width
int screenHeight; // Screen height
} DisplayDriver;
extern DisplayDriver *currentDisplayDriver;
extern DisplayDriver noDisplayDriver;
extern DisplayDriver tDisplayDriver;
extern DisplayDriver amoledDisplayDriver;
extern DisplayDriver dongleDisplayDriver;
#define SCREENS_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif // DRIVERS_H

2427
src/media/images_160_80.h Normal file

File diff suppressed because it is too large Load Diff

40235
src/media/images_536_240.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
#include "mining.h" #include "mining.h"
#include "utils.h" #include "utils.h"
#include "monitor.h" #include "monitor.h"
#include "display/display.h" #include "drivers/display.h"
unsigned long templates = 0; unsigned long templates = 0;
unsigned long hashes= 0; unsigned long hashes= 0;
@ -375,38 +375,42 @@ void runMiner(void * task_id) {
#define DELAY 100 #define DELAY 100
#define REDRAW_EVERY 10 #define REDRAW_EVERY 10
void runMonitor(void *name){ void runMonitor(void *name)
{
Serial.println("[MONITOR] started"); Serial.println("[MONITOR] started");
unsigned long mLastCheck = 0; unsigned long mLastCheck = 0;
resetToFirstScreen(); resetToFirstScreen();
unsigned long frame = 0; unsigned long frame = 0;
while(1){ while (1)
if((frame % REDRAW_EVERY) == 0){ {
unsigned long mElapsed = millis()-mLastCheck; if ((frame % REDRAW_EVERY) == 0)
{
unsigned long mElapsed = millis() - mLastCheck;
mLastCheck = millis(); mLastCheck = millis();
unsigned long currentKHashes = (Mhashes*1000) + hashes/1000; unsigned long currentKHashes = (Mhashes * 1000) + hashes / 1000;
elapsedKHs = currentKHashes - totalKHashes; elapsedKHs = currentKHashes - totalKHashes;
totalKHashes = currentKHashes; totalKHashes = currentKHashes;
drawCurrentScreen(mElapsed); drawCurrentScreen(mElapsed);
//Monitor state when hashrate is 0.0 // Monitor state when hashrate is 0.0
if(elapsedKHs == 0) { if (elapsedKHs == 0)
{
Serial.printf(">>> [i] Miner: newJob>%s / inRun>%s) - Client: connected>%s / subscribed>%s / wificonnected>%s\n", Serial.printf(">>> [i] Miner: newJob>%s / inRun>%s) - Client: connected>%s / subscribed>%s / wificonnected>%s\n",
mMiner.newJob ? "true" : "false", mMiner.inRun ? "true" : "false", mMiner.newJob ? "true" : "false", mMiner.inRun ? "true" : "false",
client.connected() ? "true" : "false", isMinerSuscribed ? "true" : "false", WiFi.status() == WL_CONNECTED ? "true" : "false"); client.connected() ? "true" : "false", isMinerSuscribed ? "true" : "false", WiFi.status() == WL_CONNECTED ? "true" : "false");
} }
} }
animateCurrentScreen(frame); animateCurrentScreen(frame);
doLedStuff(frame);
// Pause the task for 1000ms // Pause the task for 1000ms
vTaskDelay(DELAY / portTICK_PERIOD_MS); vTaskDelay(DELAY / portTICK_PERIOD_MS);
frame++; frame++;
} }
} }

View File

@ -209,49 +209,25 @@ String getTime(void){
return LocalHour; return LocalHour;
} }
// Variables para controlar el parpadeo con millis() String getCurrentHashRate(unsigned long mElapsed)
unsigned long previousMillis = 0; {
void doLedStuff(int ledPin){
unsigned long currentMillis = millis();
switch (mMonitor.NerdStatus) {
case NM_waitingConfig: digitalWrite(ledPin, HIGH); // LED encendido de forma continua
break;
case NM_Connecting: if (currentMillis - previousMillis >= 500) { //0.5sec blink
previousMillis = currentMillis;
digitalWrite(ledPin, !digitalRead(ledPin)); // Cambia el estado del LED
}
break;
case NM_hashing: if (currentMillis - previousMillis >= 100) { //0.1sec blink
previousMillis = currentMillis;
digitalWrite(ledPin, !digitalRead(ledPin)); // Cambia el estado del LED
}
break;
}
}
String getCurrentHashRate(unsigned long mElapsed){
return String((1.0 * (elapsedKHs * 1000)) / mElapsed, 2); return String((1.0 * (elapsedKHs * 1000)) / mElapsed, 2);
} }
mining_data getMiningData(unsigned long mElapsed){ mining_data getMiningData(unsigned long mElapsed)
{
mining_data data; mining_data data;
char best_diff_string[16] = {0}; char best_diff_string[16] = {0};
suffix_string(best_diff, best_diff_string, 16, 0); suffix_string(best_diff, best_diff_string, 16, 0);
char timeMining[15] = {0}; char timeMining[15] = {0};
unsigned long secElapsed = millis() / 1000; unsigned long secElapsed = millis() / 1000;
int days = secElapsed / 86400; int days = secElapsed / 86400;
int hours = (secElapsed - (days * 86400)) / 3600; //Number of seconds in an hour 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 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); int secs = secElapsed - (days * 86400) - (hours * 3600) - (mins * 60);
sprintf(timeMining, "%01d %02d:%02d:%02d", days, hours, mins, secs); sprintf(timeMining, "%01d %02d:%02d:%02d", days, hours, mins, secs);
data.completedShares = shares; data.completedShares = shares;
data.totalMHashes = Mhashes; data.totalMHashes = Mhashes;
@ -263,11 +239,12 @@ mining_data getMiningData(unsigned long mElapsed){
data.valids = valids; data.valids = valids;
data.temp = String(temperatureRead(), 0); data.temp = String(temperatureRead(), 0);
data.currentTime = getTime(); data.currentTime = getTime();
return data; return data;
} }
clock_data getClockData(unsigned long mElapsed){ clock_data getClockData(unsigned long mElapsed)
{
clock_data data; clock_data data;
data.completedShares = shares; data.completedShares = shares;
@ -280,10 +257,11 @@ clock_data getClockData(unsigned long mElapsed){
return data; return data;
} }
coin_data getCoinData(unsigned long mElapsed){ coin_data getCoinData(unsigned long mElapsed)
{
coin_data data; coin_data data;
updateGlobalData(); //Update gData vars asking mempool APIs updateGlobalData(); // Update gData vars asking mempool APIs
data.completedShares = shares; data.completedShares = shares;
data.totalKHashes = totalKHashes; data.totalKHashes = totalKHashes;
@ -296,7 +274,7 @@ coin_data getCoinData(unsigned long mElapsed){
data.blockHeight = getBlockHeight(); data.blockHeight = getBlockHeight();
unsigned long currentBlock = data.blockHeight.toInt(); unsigned long currentBlock = data.blockHeight.toInt();
unsigned long remainingBlocks = (((currentBlock / HALVING_BLOCKS)+1) * HALVING_BLOCKS) - currentBlock; unsigned long remainingBlocks = (((currentBlock / HALVING_BLOCKS) + 1) * HALVING_BLOCKS) - currentBlock;
data.progressPercent = (HALVING_BLOCKS - remainingBlocks) * 100 / HALVING_BLOCKS; data.progressPercent = (HALVING_BLOCKS - remainingBlocks) * 100 / HALVING_BLOCKS;
data.remainingBlocks = String(remainingBlocks) + " BLOCKS"; data.remainingBlocks = String(remainingBlocks) + " BLOCKS";

View File

@ -88,7 +88,6 @@ typedef struct {
}coin_data; }coin_data;
void setup_monitor(void); void setup_monitor(void);
void doLedStuff(int ledPin);
mining_data getMiningData(unsigned long mElapsed); mining_data getMiningData(unsigned long mElapsed);
clock_data getClockData(unsigned long mElapsed); clock_data getClockData(unsigned long mElapsed);

View File

@ -10,7 +10,7 @@
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include "wManager.h" #include "wManager.h"
#include "monitor.h" #include "monitor.h"
#include "display/display.h" #include "drivers/display.h"
// JSON configuration file // JSON configuration file
#define JSON_CONFIG_FILE "/config.json" #define JSON_CONFIG_FILE "/config.json"
@ -139,19 +139,21 @@ void init_WifiManager()
//Serial.setTxTimeoutMs(10); //Serial.setTxTimeoutMs(10);
//Init pin 15 to eneble 5V external power (LilyGo bug) //Init pin 15 to eneble 5V external power (LilyGo bug)
pinMode(PIN_ENABLE5V, OUTPUT); #ifdef PIN_ENABLE5V
digitalWrite(PIN_ENABLE5V, HIGH); pinMode(PIN_ENABLE5V, OUTPUT);
digitalWrite(PIN_ENABLE5V, HIGH);
#endif
// Change to true when testing to force configuration every time we run // Change to true when testing to force configuration every time we run
bool forceConfig = false; bool forceConfig = false;
#if !defined(DEVKITV1) & !defined(NERMINER_S3_DONGLE) #if defined(PIN_BUTTON_2)
// Check if button2 is pressed to enter configMode with actual configuration // Check if button2 is pressed to enter configMode with actual configuration
if(!digitalRead(PIN_BUTTON_2)){ if(!digitalRead(PIN_BUTTON_2)){
Serial.println(F("Button pressed to force start config mode")); Serial.println(F("Button pressed to force start config mode"));
forceConfig = true; forceConfig = true;
wm.setBreakAfterConfig(true); //Set to detect config edition and save wm.setBreakAfterConfig(true); //Set to detect config edition and save
} }
#endif #endif
bool spiffsSetup = loadConfigFile(); bool spiffsSetup = loadConfigFile();

View File

@ -1,25 +1,3 @@
#ifdef NERDMINERV2
//Define config buttons for TTGO-TDisplay-s3
#define PIN_BUTTON_1 0
#define PIN_BUTTON_2 14
#define PIN_ENABLE5V 15
#elif defined(DEVKITV1)
//Standard ESP32-devKit
#define PIN_BUTTON_1 0
#define PIN_BUTTON_2 19 //Not used
#define PIN_ENABLE5V 21 //Not used
#define LED_PIN 2
#elif defined(NERMINER_S3_AMOLED)
#define PIN_BUTTON_1 0
#define PIN_BUTTON_2 21
#define PIN_ENABLE5V 15
#elif defined(NERMINER_S3_DONGLE)
#define PIN_BUTTON_1 0
#define PIN_BUTTON_2 -1
#define PIN_ENABLE5V -1
#endif
void init_WifiManager(); void init_WifiManager();
void wifiManagerProcess(); void wifiManagerProcess();
void reset_configurations(); void reset_configurations();