Merge branch 'master' into dev

This commit is contained in:
BitMaker 2024-06-10 21:37:20 +02:00
commit 865bf4f363
41 changed files with 393 additions and 175 deletions

View File

@ -143,9 +143,8 @@ Recommended low difficulty share pools:
| Pool URL | Port | Web URL | Status |
| ----------------- | ----- | -------------------------- | ------------------------------------------------------------------ |
| public-pool.io | 21496 | https://web.public-pool.io | Open Source Solo Bitcoin Mining Pool supporting open source miners |
| nerdminers.org | | https://nerdminers.org | Team domain for future pool - Currently pointing to public-pool.io |
| pool.nerdminers.org | 3333 | https://nerdminers.org | The official Nerdminer pool site - Mantained by @golden-guy |
| pool.nerdminer.io | 3333 | https://nerdminer.io | Mantained by CHMEX |
| pool.vkbit.com | 3333 | https://vkbit.com/ | Mantained by djerfy - public-pool fork |
| pool.pyblock.xyz | 3333 | https://pool.pyblock.xyz/ | Mantained by curly60e |
| pool.sethforprivacy.com | 3333 | https://pool.sethforprivacy.com/ | Mantained by @sethforprivacy - public-pool fork |

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -4,16 +4,16 @@ efuse_err_halt = 1
[DOWNLOAD PATH]
file_sel0 = 1
file_path0 = C:\Users\RogerPC\Desktop\CRYPTO\BITMAKER\Projectes\EN CURSO\SEEDER\Seeder\bin\0xe000_boot_app0.bin
file_offset0 = 0xe000
file_path0 = C:\Users\RogerPC\Desktop\BITMAKER\BITMAKER\Projectes\EN CURSO\NERDMINERv2\NerdMinerV2\bin\bin ESP32-devKit- no pass\0x1000_bootloader.bin
file_offset0 = 0x1000
file_sel1 = 1
file_path1 = C:\Users\RogerPC\Desktop\CRYPTO\BITMAKER\Projectes\EN CURSO\SEEDER\Seeder\bin\0x1000_bootloader_qio_80m.bin
file_offset1 = 0x1000
file_path1 = C:\Users\RogerPC\Desktop\BITMAKER\BITMAKER\Projectes\EN CURSO\NERDMINERv2\NerdMinerV2\bin\bin ESP32-devKit- no pass\0xe000_boot_app0.bin
file_offset1 = 0xe000
file_sel2 = 1
file_path2 = C:\Users\RogerPC\Desktop\CRYPTO\BITMAKER\Projectes\EN CURSO\SEEDER\Seeder\bin\0x8000_Seeder.ino.partitions.bin
file_path2 = C:\Users\RogerPC\Desktop\BITMAKER\BITMAKER\Projectes\EN CURSO\NERDMINERv2\NerdMinerV2\bin\bin ESP32-devKit- no pass\0x8000_partitions.bin
file_offset2 = 0x8000
file_sel3 = 1
file_path3 = C:\Users\RogerPC\Desktop\CRYPTO\BITMAKER\Projectes\EN CURSO\SEEDER\Seeder\bin\0x10000_Seeder.ino.bin
file_path3 = C:\Users\RogerPC\Desktop\BITMAKER\BITMAKER\Projectes\EN CURSO\NERDMINERv2\NerdMinerV2\bin\bin ESP32-devKit- no pass\0x10000_firmware.bin
file_offset3 = 0x10000
file_sel4 = 0
file_path4 =
@ -45,12 +45,12 @@ file_offset12 =
file_sel13 = 0
file_path13 =
file_offset13 =
default_path = C:\Users\RogerPC\Desktop\CRYPTO\BITMAKER\Projectes\EN CURSO\SEEDER\Seeder\bin
default_path = C:\Users\RogerPC\Desktop\BITMAKER\BITMAKER\Projectes\EN CURSO\NERDMINERv2\NerdMinerV2\bin\bin ESP32-devKit- no pass
[FLASH_CRYSTAL]
spicfgdis = 0
spispeed = 3
spimode = 0
spimode = 2
[MAC SAVE]
mac_save_enable = False
@ -84,7 +84,7 @@ flash_write_size = 1024
[DOWNLOAD]
autostart1 = 0
com_port1 = COM4
com_port1 = COM157
baudrate1 = 4
checkmac1 = 1
erase_flash_en = True

View File

@ -462,14 +462,17 @@ monitor_filters =
esp32_exception_decoder
time
log2file
board_build.arduino.memory_type = qio_opi
# Commenting out 'board_build.arduino.memory_type' fixes missing 'sdkconfig.h' errors:
;board_build.arduino.memory_type = qio_opi
monitor_speed = 115200
upload_speed = 115200
# 2 x 4.5MB app, 6.875MB SPIFFS
board_build.partitions = huge_app.csv
build_flags =
;-D DEBUG_MINING=1
-D TDISPLAY=1
# Switching from 'TDISPLAY' to 'NERDMINER_T_DISPLAY_V1' fixes font related compile errors
;-D TDISPLAY=1
-D NERDMINER_T_DISPLAY_V1=1
lib_deps =
https://github.com/takkaO/OpenFontRender#v1.2
bblanchon/ArduinoJson@^6.21.5
@ -685,6 +688,11 @@ platform = espressif32@6.6.0
board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_filters =
esp32_exception_decoder
time
colorize
;debug
upload_speed = 921600
;build_type = debug
board_build.partitions = huge_app.csv
@ -714,6 +722,7 @@ build_flags =
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
lib_deps =
https://github.com/takkaO/OpenFontRender#v1.2
bblanchon/ArduinoJson@^6.21.5

View File

@ -115,8 +115,12 @@ void setup()
/******** CREATE STRATUM TASK *****/
sprintf(name, "(%s)", "Stratum");
#ifdef ESP32_2432S028R
// Free a little bit of the heap to the screen
BaseType_t res2 = xTaskCreatePinnedToCore(runStratumWorker, "Stratum", 13500, (void*)name, 3, NULL,1);
#else
BaseType_t res2 = xTaskCreatePinnedToCore(runStratumWorker, "Stratum", 15000, (void*)name, 3, NULL,1);
#endif
/******** CREATE MINER TASKS *****/
//for (size_t i = 0; i < THREADS; i++) {

View File

@ -3,9 +3,22 @@
#define PIN_BUTTON_1 0
//#define PIN_BUTTON_2 22 // Not used
#define PIN_ENABLE5V 21 // Not used
// #define PIN_ENABLE5V 21 // Not used
#define LED_PIN 4 // Red pin
#define LED_PIN_G 17 // Green pin
#define LED_PIN_G 16 // Green pin
#define LED_PIN_B 17 // Green pin
// Pin defines for the SD card interface
// This is working for both, ESP32 2432S028R and ESP 2432S028_2USB boards
// --------------------------------------
// use SPI interface
// (default SPI unit provided by <SPI.h>)
// setup SPI pins.
#define SDSPI_CS 5
#define SDSPI_CLK 18
#define SDSPI_MOSI 23
#define SDSPI_MISO 19
// Pin defines for the SD card interface
// This is working for both, ESP32 2432S028R and ESP 2432S028_2USB boards

View File

@ -13,10 +13,14 @@
#include "OpenFontRender.h"
#include <SPI.h>
#include "rotation.h"
#include "drivers/storage/nvMemory.h"
#include "drivers/storage/storage.h"
#define WIDTH 130 //320
#define HEIGHT 170
extern nvMemory nvMem;
OpenFontRender render;
TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in platformio.ini
TFT_eSprite background = TFT_eSprite(&tft); // Invoke library sprite
@ -26,25 +30,46 @@ TFT_eTouch<TFT_eSPI> touch(tft, ETOUCH_CS, 0xFF, hSPI);
extern monitor_data mMonitor;
extern pool_data pData;
extern DisplayDriver *currentDisplayDriver;
extern bool invertColors;
extern TSettings Settings;
bool hasChangedScreen = true;
void getChipInfo(void){
Serial.print("Chip: ");
Serial.println(ESP.getChipModel());
Serial.print("ChipRevision: ");
Serial.println(ESP.getChipRevision());
Serial.print("Psram size: ");
Serial.print(ESP.getPsramSize() / 1024);
Serial.println("KB");
Serial.print("Flash size: ");
Serial.print(ESP.getFlashChipSize() / 1024);
Serial.println("KB");
Serial.print("CPU frequency: ");
Serial.print(ESP.getCpuFreqMHz());
Serial.println("MHz");
}
void esp32_2432S028R_Init(void)
{
// getChipInfo();
tft.init();
tft.setRotation(ROTATION_90);
#ifdef ESP32_2432S028_2USB
/*
In addition to TFT_INVERSION this adjusts the gamma curve to have better
picture quality for this type of ESP32_2432S028 TFT with for example two USB connectors
*/
tft.writecommand(ILI9341_GAMMASET); // Gamma curve selected
if (nvMem.loadConfig(&Settings))
{
// Serial.print("Invert Colors: ");
// Serial.println(Settings.invertColors);
invertColors = Settings.invertColors;
}
tft.invertDisplay(invertColors);
tft.setRotation(1);
tft.setSwapBytes(true); // Swap the colour byte order when rendering
if (invertColors) {
tft.writecommand(ILI9341_GAMMASET);
tft.writedata(2);
delay(120);
tft.writecommand(ILI9341_GAMMASET); // Gamma curve selected
tft.writecommand(ILI9341_GAMMASET); //Gamma curve selected
tft.writedata(1);
#endif
tft.setSwapBytes(true); // Swap the colour byte order when rendering
}
hSPI.begin(TOUCH_CLK, TOUCH_MISO, TOUCH_MOSI, ETOUCH_CS);
touch.init();
@ -52,9 +77,9 @@ void esp32_2432S028R_Init(void)
touch.setCalibration(calibation);
//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
//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)))
@ -65,6 +90,11 @@ void esp32_2432S028R_Init(void)
}
pinMode(LED_PIN, OUTPUT);
pinMode(LED_PIN_B, OUTPUT);
pinMode(LED_PIN_G, OUTPUT);
digitalWrite(LED_PIN, LOW);
digitalWrite(LED_PIN_B, HIGH);
digitalWrite(LED_PIN_G, HIGH);
pData.bestDifficulty = "0";
pData.workersHash = "0";
pData.workersCount = 0;
@ -86,68 +116,108 @@ void esp32_2432S028R_AlternateRotation(void)
bool bottomScreenBlue = true;
void printPoolData(){
pData = getPoolData();
background.createSprite(320,70); //Background Sprite
background.setSwapBytes(true);
if (bottomScreenBlue) {
background.pushImage(0, 0, 320, 70, bottonPoolScreen);
//background.fillRect(295,43,25,10,TFT_CYAN);
} else {
background.pushImage(0, 0, 320, 70, bottonPoolScreen_g);
}
//background.setTextDatum(MC_DATUM);
render.setDrawer(background); // Link drawing object to background instance (so font will be rendered on background)
render.setLineSpaceRatio(1);
render.setFontSize(24);
render.cdrawString(String(pData.workersCount).c_str(), 155, 35, TFT_BLACK);
render.setFontSize(18);
render.setAlignment(Align::BottomRight);
render.cdrawString(pData.workersHash.c_str(), 265, 34, TFT_BLACK);
render.setAlignment(Align::BottomLeft);
render.cdrawString(pData.bestDifficulty.c_str(), 54, 34, TFT_BLACK);
background.pushSprite(0,170);
background.deleteSprite();
}
void printheap(){
//Serial.print("============ Free Heap:");
//Serial.println(ESP.getFreeHeap());
Serial.print("$$ Free Heap:");
Serial.println(ESP.getFreeHeap());
// Serial.printf("### stack WMark usage: %d\n", uxTaskGetStackHighWaterMark(NULL));
}
void createBackgroundSprite(int16_t wdt, int16_t hgt){ // Set the background and link the render, used multiple times to fit in heap
bool createBackgroundSprite(int16_t wdt, int16_t hgt){ // Set the background and link the render, used multiple times to fit in heap
background.createSprite(wdt, hgt) ; //Background Sprite
printheap();
// printheap();
if (background.created()) {
background.setColorDepth(16);
background.setSwapBytes(true);
render.setDrawer(background); // Link drawing object to background instance (so font will be rendered on background)
render.setLineSpaceRatio(0.9);
} else {
Serial.println("#### Sprite Error ####");
Serial.printf("Size w:%d h:%d \n", wdt, hgt);
printheap();
}
return background.created();
}
extern unsigned long mPoolUpdate;
void printPoolData(){
if ((hasChangedScreen) || (mPoolUpdate == 0) || (millis() - mPoolUpdate > UPDATE_POOL_min * 60 * 1000)){
if (Settings.PoolAddress != "tn.vkbit.com") {
pData = getPoolData();
background.createSprite(320,50); //Background Sprite
if (!background.created()) {
Serial.println("###### POOL SPRITE ERROR ######");
// Serial.printf("Pool data W:%d H:%s D:%s\n", pData.workersCount, pData.workersHash, pData.bestDifficulty);
printheap();
}
background.setSwapBytes(true);
if (bottomScreenBlue) {
background.pushImage(0, -20, 320, 70, bottonPoolScreen);
tft.pushImage(0,170,320,20,bottonPoolScreen);
} else {
background.pushImage(0, -20, 320, 70, bottonPoolScreen_g);
tft.pushImage(0,170,320,20,bottonPoolScreen_g);
}
render.setDrawer(background); // Link drawing object to background instance (so font will be rendered on background)
render.setLineSpaceRatio(1);
render.setFontSize(24);
render.cdrawString(String(pData.workersCount).c_str(), 157, 16, TFT_BLACK);
render.setFontSize(18);
render.setAlignment(Align::BottomRight);
render.cdrawString(pData.workersHash.c_str(), 265, 14, TFT_BLACK);
render.setAlignment(Align::BottomLeft);
render.cdrawString(pData.bestDifficulty.c_str(), 54, 14, TFT_BLACK);
background.pushSprite(0,190);
background.deleteSprite();
} else {
pData.bestDifficulty = "TESTNET";
pData.workersHash = "TESTNET";
pData.workersCount = 1;
tft.fillRect(0,170,320,70, TFT_DARKGREEN);
background.createSprite(320,40); //Background Sprite
background.fillSprite(TFT_DARKGREEN);
if (!background.created()) {
Serial.println("###### POOL SPRITE ERROR ######");
// Serial.printf("Pool data W:%d H:%s D:%s\n", pData.workersCount, pData.workersHash, pData.bestDifficulty);
printheap();
}
background.setFreeFont(FF24);
background.setTextDatum(TL_DATUM);
background.setTextSize(1);
background.setTextColor(TFT_WHITE, TFT_DARKGREEN);
background.drawString("TESTNET", 50, 0, GFXFF);
background.pushSprite(0,185);
mPoolUpdate = millis();
Serial.println("Testnet");
background.deleteSprite();
}
}
}
void esp32_2432S028R_MinerScreen(unsigned long mElapsed)
{
if (hasChangedScreen) tft.pushImage(0, 0, initWidth, initHeight, MinerScreen);
hasChangedScreen = false;
mining_data data = getMiningData(mElapsed);
//Serial.println("Proximo sprite...");
printPoolData();
if (hasChangedScreen) tft.pushImage(0, 0, initWidth, initHeight, MinerScreen);
hasChangedScreen = false;
int wdtOffset = 190;
// Recreate sprite to the right side of the screen
createBackgroundSprite(WIDTH-5, HEIGHT-7);
//Print background screen
background.pushImage(-190, 0, MinerWidth, MinerHeight, MinerScreen);
// Total hashes
render.setFontSize(18);
render.rdrawString(data.totalMHashes.c_str(), 268-wdtOffset, 138, TFT_BLACK);
// Block templates
render.setFontSize(18);
render.setAlignment(Align::TopLeft);
@ -182,7 +252,7 @@ void esp32_2432S028R_MinerScreen(unsigned long mElapsed)
// Delete sprite to free the memory heap
background.deleteSprite();
printheap();
// printheap();
//Serial.println("=========== Mining Display ==============") ;
// Create background sprite to print data at once
@ -190,9 +260,6 @@ void esp32_2432S028R_MinerScreen(unsigned long mElapsed)
//Print background screen
background.pushImage(0, -90, 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);
@ -204,9 +271,9 @@ void esp32_2432S028R_MinerScreen(unsigned long mElapsed)
// Delete sprite to free the memory heap
background.deleteSprite();
//delay(50);
printPoolData();
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());
#ifdef DEBUG_MEMORY
// Print heap
@ -218,13 +285,13 @@ void esp32_2432S028R_ClockScreen(unsigned long mElapsed)
{
if (hasChangedScreen) tft.pushImage(0, 0, minerClockWidth, minerClockHeight, minerClockScreen);
printPoolData();
hasChangedScreen = false;
clock_data data = getClockData(mElapsed);
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());
// Create background sprite to print data at once
createBackgroundSprite(270,36);
@ -267,9 +334,8 @@ void esp32_2432S028R_ClockScreen(unsigned long mElapsed)
// Delete sprite to free the memory heap
background.deleteSprite();
#ifdef ESP32_2432S028R
printPoolData();
#endif
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());
#ifdef DEBUG_MEMORY
// Print heap
@ -280,17 +346,17 @@ void esp32_2432S028R_ClockScreen(unsigned long mElapsed)
void esp32_2432S028R_GlobalHashScreen(unsigned long mElapsed)
{
if (hasChangedScreen) tft.pushImage(0, 0, globalHashWidth, globalHashHeight, globalHashScreen);
printPoolData();
hasChangedScreen = false;
coin_data data = getCoinData(mElapsed);
// Create background sprite to print data at once
createBackgroundSprite(169,105);
// Print background screen
background.pushImage(-160, -3, minerClockWidth, minerClockHeight, globalHashScreen);
//background.fillScreen(TFT_BLUE);
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);
@ -359,9 +425,9 @@ void esp32_2432S028R_GlobalHashScreen(unsigned long mElapsed)
background.pushSprite(5, 100);
// Delete sprite to free the memory heap
background.deleteSprite();
#ifdef ESP32_2432S028R
printPoolData();
#endif
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());
#ifdef DEBUG_MEMORY
// Print heap
@ -372,13 +438,11 @@ void esp32_2432S028R_BTCprice(unsigned long mElapsed)
{
if (hasChangedScreen) tft.pushImage(0, 0, priceScreenWidth, priceScreenHeight, priceScreen);
printPoolData();
hasChangedScreen = false;
clock_data data = getClockData(mElapsed);
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());
// Create background sprite to print data at once
createBackgroundSprite(270,36);
@ -402,16 +466,17 @@ void esp32_2432S028R_BTCprice(unsigned long mElapsed)
// Print background screen
background.pushImage(-130, -3, priceScreenWidth, priceScreenHeight, priceScreen);
// Print BTC Price
// Print Hour
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 202-130, 0, GFXFF);
// Print Hour
background.setFreeFont(FF22);
background.setTextSize(2);
// Print BTC Price
background.setFreeFont(FF24);
background.setTextDatum(TL_DATUM);
background.setTextSize(1);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 0, 50, GFXFF);
@ -421,9 +486,8 @@ void esp32_2432S028R_BTCprice(unsigned long mElapsed)
// Delete sprite to free the memory heap
background.deleteSprite();
#ifdef ESP32_2432S028R
printPoolData();
#endif
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());
#ifdef DEBUG_MEMORY
// Print heap
@ -437,13 +501,14 @@ void esp32_2432S028R_LoadingScreen(void)
tft.pushImage(0, 33, initWidth, initHeight, initScreen);
tft.setTextColor(TFT_BLACK);
tft.drawString(CURRENT_VERSION, 24, 147, FONT2);
delay(2000);
tft.fillScreen(TFT_BLACK);
tft.pushImage(0, 0, initWidth, initHeight, MinerScreen);
// delay(2000);
// tft.fillScreen(TFT_BLACK);
// tft.pushImage(0, 0, initWidth, initHeight, MinerScreen);
}
void esp32_2432S028R_SetupScreen(void)
{
tft.fillScreen(TFT_BLACK);
tft.pushImage(0, 33, setupModeWidth, setupModeHeight, setupModeScreen);
}
@ -465,24 +530,22 @@ void esp32_2432S028R_DoLedStuff(unsigned long frame)
int16_t t_x , t_y; // To store the touch coordinates
bool pressed = touch.getXY(t_x, t_y);
if (pressed) {
if (((t_x > 109)&&(t_x < 211)) && ((t_y > 185)&&(t_y < 241))) bottomScreenBlue ^= true;
if (((t_x > 109)&&(t_x < 211)) && ((t_y > 185)&&(t_y < 241))) {
bottomScreenBlue ^= true;
hasChangedScreen = true;
}
else
if (t_x > 160) {
// next screen
Serial.print(t_x);
Serial.print(":x Próxima Tela y:");
Serial.println(t_y);
// Serial.printf("Next screen touch( x:%d y:%d )\n", t_x, t_y);
currentDisplayDriver->current_cyclic_screen = (currentDisplayDriver->current_cyclic_screen + 1) % currentDisplayDriver->num_cyclic_screens;
} else if (t_x < 160)
{
// Previus screen
Serial.print(t_x);
Serial.print(":x Tela anterior y:");
Serial.println(t_y);
// Serial.printf("Previus screen touch( x:%d y:%d )\n", t_x, t_y);
/* Serial.println(currentDisplayDriver->current_cyclic_screen); */
currentDisplayDriver->current_cyclic_screen = currentDisplayDriver->current_cyclic_screen - 1;
if (currentDisplayDriver->current_cyclic_screen<0) currentDisplayDriver->current_cyclic_screen = currentDisplayDriver->num_cyclic_screens - 1;
Serial.println(currentDisplayDriver->current_cyclic_screen);
}
}
previousTouchMillis = currentMillis;
@ -494,21 +557,25 @@ void esp32_2432S028R_DoLedStuff(unsigned long frame)
switch (mMonitor.NerdStatus)
{
case NM_waitingConfig:
digitalWrite(LED_PIN, HIGH); // LED encendido de forma continua
digitalWrite(LED_PIN, LOW); // 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
// Serial.print("C");
digitalWrite(LED_PIN, HIGH);
digitalWrite(LED_PIN_B, !digitalRead(LED_PIN)); // Cambia el estado del LED
}
break;
case NM_hashing:
if (currentMillis - previousMillis >= 100)
if (currentMillis - previousMillis >= 500)
{ // 0.1sec blink
// Serial.print("h");
previousMillis = currentMillis;
digitalWrite(LED_PIN_B, HIGH);
digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Cambia el estado del LED
}
break;

View File

@ -20,6 +20,12 @@ TFT_eSprite background = TFT_eSprite(&tft); // Invoke library sprite
void tDisplay_Init(void)
{
//Init pin 15 to eneble 5V external power (LilyGo bug)
#ifdef PIN_ENABLE5V
pinMode(PIN_ENABLE5V, OUTPUT);
digitalWrite(PIN_ENABLE5V, HIGH);
#endif
tft.init();
#ifdef LILYGO_S3_T_EMBED
tft.setRotation(ROTATION_270);

View File

@ -67,14 +67,12 @@ void tDisplay_MinerScreen(unsigned long mElapsed)
render.rdrawString(data.currentHashRate.c_str(), 96, 90, TFT_BLACK);
// Total hashes
render.setFontSize(13);
render.rdrawString(data.totalMHashes.c_str(), 200, 112, TFT_BLACK);
render.rdrawString(data.totalMHashes.c_str(), 200, 106, TFT_BLACK);
// Block templates
render.setFontSize(13);
render.drawString(data.templates.c_str(), 140, 15, 0xDEDB);
// Best diff
render.drawString(data.bestDiff.c_str(), 140, 38, 0xDEDB);
// 32Bit shares
render.setFontSize(13);
render.drawString(data.completedShares.c_str(), 140, 60, 0xDEDB);
// Hores
render.setFontSize(9);

View File

@ -57,6 +57,15 @@ bool SDCard::cardBusy()
return cardBusy_;
}
/// @brief End the card to free heap space.
void SDCard::terminate()
{
iSD_->end();
#ifdef BUILD_SDSPI
ispi_->end();
#endif
}
/// @brief Transfer settings from config file on a SD card to the device.
/// @param nvMemory* where to save
/// @param TSettings* passing a struct is required, to save memory
@ -97,8 +106,12 @@ bool SDCard::loadConfigFile(TSettings* Settings)
{
serializeJsonPretty(json, Serial);
Serial.print('\n');
if (json.containsKey(JSON_KEY_SSID)) {
Settings->WifiSSID = json[JSON_KEY_SSID] | Settings->WifiSSID;
}
if (json.containsKey(JSON_KEY_PASW)) {
Settings->WifiPW = json[JSON_KEY_PASW] | Settings->WifiPW;
}
Settings->PoolAddress = json[JSON_KEY_POOLURL] | Settings->PoolAddress;
strcpy(Settings->PoolPassword, json[JSON_KEY_POOLPASS] | Settings->PoolPassword);
strcpy(Settings->BtcWallet, json[JSON_KEY_WALLETID] | Settings->BtcWallet);
@ -108,6 +121,13 @@ bool SDCard::loadConfigFile(TSettings* Settings)
Settings->Timezone = json[JSON_KEY_TIMEZONE].as<int>();
if (json.containsKey(JSON_KEY_STATS2NV))
Settings->saveStats = json[JSON_KEY_STATS2NV].as<bool>();
if (json.containsKey(JSON_KEY_INVCOLOR)) {
Settings->invertColors = json[JSON_KEY_INVCOLOR].as<bool>();
} else {
Settings->invertColors = false;
}
// Serial.printf("Carteira Lida SD:%s\n", Settings.BtcWallet);
Serial.printf("Carteira Lida SDs:%s\n", Settings->BtcWallet);
return true;
}
else
@ -184,7 +204,6 @@ bool SDCard::initSDcard()
}
#else
SDCard::SDCard(int ID) {}
SDCard::~SDCard() {}
void SDCard::SD2nvMemory(nvMemory* nvMem, TSettings* Settings) {};
@ -192,5 +211,5 @@ bool SDCard::loadConfigFile(TSettings* Settings) { return false; }
bool SDCard::initSDcard() { return false; }
bool SDCard::cardAvailable() { return false; }
bool SDCard::cardBusy() { return false; }
void SDCard::terminate() {}
#endif //BUILD_SDMMC

View File

@ -58,6 +58,7 @@ public:
bool loadConfigFile(TSettings* Settings);
bool cardAvailable();
bool cardBusy();
void terminate();
private:
bool initSDcard();
bool cardInitialized_;

View File

@ -35,6 +35,7 @@ bool nvMemory::saveConfig(TSettings* Settings)
json[JSON_SPIFFS_KEY_WALLETID] = Settings->BtcWallet;
json[JSON_SPIFFS_KEY_TIMEZONE] = Settings->Timezone;
json[JSON_SPIFFS_KEY_STATS2NV] = Settings->saveStats;
json[JSON_SPIFFS_KEY_INVCOLOR] = Settings->invertColors;
// Open config file
File configFile = SPIFFS.open(JSON_CONFIG_FILE, "w");
@ -97,6 +98,11 @@ bool nvMemory::loadConfig(TSettings* Settings)
Settings->Timezone = json[JSON_SPIFFS_KEY_TIMEZONE].as<int>();
if (json.containsKey(JSON_SPIFFS_KEY_STATS2NV))
Settings->saveStats = json[JSON_SPIFFS_KEY_STATS2NV].as<bool>();
if (json.containsKey(JSON_SPIFFS_KEY_INVCOLOR)) {
Settings->invertColors = json[JSON_SPIFFS_KEY_INVCOLOR].as<bool>();
} else {
Settings->invertColors = false;
}
return true;
}
else

View File

@ -18,6 +18,7 @@
#define DEFAULT_POOLPORT 21496
#define DEFAULT_TIMEZONE 2
#define DEFAULT_SAVESTATS false
#define DEFAULT_INVERTCOLORS false
// JSON config files
#define JSON_CONFIG_FILE "/config.json"
@ -31,6 +32,7 @@
#define JSON_KEY_POOLPORT "PoolPort"
#define JSON_KEY_TIMEZONE "Timezone"
#define JSON_KEY_STATS2NV "SaveStats"
#define JSON_KEY_INVCOLOR "invertColors"
// JSON config file SPIFFS (different for backward compatibility with existing devices)
#define JSON_SPIFFS_KEY_POOLURL "poolString"
@ -39,6 +41,7 @@
#define JSON_SPIFFS_KEY_WALLETID "btcString"
#define JSON_SPIFFS_KEY_TIMEZONE "gmtZone"
#define JSON_SPIFFS_KEY_STATS2NV "saveStatsToNVS"
#define JSON_SPIFFS_KEY_INVCOLOR "invertColors"
// settings
struct TSettings
@ -51,6 +54,7 @@ struct TSettings
int PoolPort{ DEFAULT_POOLPORT };
int Timezone{ DEFAULT_TIMEZONE };
bool saveStats{ DEFAULT_SAVESTATS };
bool invertColors{ DEFAULT_INVERTCOLORS };
};
#endif // _STORAGE_H_

View File

@ -142,7 +142,7 @@ const unsigned short setupModeScreen[0xFD20] PROGMEM = {
// Icon width and height
const uint16_t MinerWidth = 240;
const uint16_t MinerHeight = 128;
const uint16_t MinerHeight = 135;
const unsigned short MinerScreen[0x7800] PROGMEM = {

View File

@ -400,6 +400,13 @@ void saveStat() {
nvs_set_u64(stat_handle, "upTime", upTime + (esp_timer_get_time()/1000000));
}
void resetStat() {
Serial.printf("[MONITOR] Resetting NVS stats\n");
templates = hashes = Mhashes = totalKHashes = elapsedKHs = upTime = shares = valids = 0;
best_diff = 0.0;
saveStat();
}
void runMonitor(void *name)
{

View File

@ -17,6 +17,8 @@ void runStratumWorker(void *name);
void runMiner(void *name);
String printLocalTime(void);
void resetStat();
typedef struct{
uint8_t bytearray_target[32];
uint8_t bytearray_pooltarget[32];

View File

@ -25,6 +25,7 @@ extern monitor_data mMonitor;
//from saved config
extern TSettings Settings;
bool invertColors = false;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000);
@ -357,13 +358,12 @@ pool_data getPoolData(void){
//pool_data pData;
if((mPoolUpdate == 0) || (millis() - mPoolUpdate > UPDATE_POOL_min * 60 * 1000)){
if (WiFi.status() != WL_CONNECTED) return pData;
//Make first API call to get global hash and current difficulty
HTTPClient http;
http.setReuse(true);
try {
String btcWallet = Settings.BtcWallet;
Serial.println(btcWallet);
// Serial.println(btcWallet);
if (btcWallet.indexOf(".")>0) btcWallet = btcWallet.substring(0,btcWallet.indexOf("."));
#ifdef NERDMINER_T_HMI
Serial.println("Pool API : " + poolAPIUrl+btcWallet);
@ -405,10 +405,28 @@ pool_data getPoolData(void){
}
doc.clear();
mPoolUpdate = millis();
Serial.println("\n####### Pool Data OK!");
} else {
Serial.println("\n####### Pool Data HTTP Error!");
/* Serial.println(httpCode);
String payload = http.getString();
Serial.println(payload); */
// mPoolUpdate = millis();
pData.bestDifficulty = "P";
pData.workersHash = "E";
pData.workersCount = 0;
http.end();
return pData;
}
http.end();
} catch(...) {
Serial.println("####### Pool Error!");
// mPoolUpdate = millis();
pData.bestDifficulty = "P";
pData.workersHash = "Error";
pData.workersCount = 0;
http.end();
return pData;
}
}
return pData;

View File

@ -12,8 +12,8 @@
//Time update period
#define UPDATE_PERIOD_h 5
//API BTC price
#define getBTCAPI "https://api.blockchain.com/v3/exchange/tickers/BTC-USD"
//API BTC price (Update to USDT cus it's more liquidity and flow price updade)
#define getBTCAPI "https://api.blockchain.com/v3/exchange/tickers/BTC-USDT"
#define UPDATE_BTC_min 1
//API Block height
@ -31,7 +31,7 @@
#define getPublicPool "https://public-pool.io:40557/api/client/" // +btcString
#define UPDATE_POOL_min 1
#define NEXT_HALVING_EVENT 840000
#define NEXT_HALVING_EVENT 1050000 //840000
#define HALVING_BLOCKS 210000
enum NMState {

View File

@ -136,21 +136,37 @@ bool checkValid(unsigned char* hash, unsigned char* target) {
return valid;
}
void getNextExtranonce2(int extranonce2_size, char *extranonce2) {
/**
* get random extranonce2
*/
void getRandomExtranonce2(int extranonce2_size, char *extranonce2) {
uint8_t b0, b1, b2, b3;
b0 = rand() % 256;
b1 = rand() % 256;
b2 = rand() % 256;
b3 = rand() % 256;
unsigned long extranonce2_number = b3 << 24 | b2 << 16 | b1 << 8 | b0;
char format[] = "%00x";
sprintf(&format[1], "%02dx", extranonce2_size * 2);
sprintf(extranonce2, format, extranonce2_number);
}
/**
* get linear extranonce2
*/
void getNextExtranonce2(int extranonce2_size, char *extranonce2) {
unsigned long extranonce2_number = strtoul(extranonce2, NULL, 10);
extranonce2_number++;
memset(extranonce2, '0', 2 * extranonce2_size);
if (extranonce2_number > long(pow(10, 2 * extranonce2_size))) {
return;
}
char format[] = "%00x";
char next_extranounce2[2 * extranonce2_size + 1];
memset(extranonce2, '0', 2 * extranonce2_size);
ultoa(extranonce2_number, next_extranounce2, 10);
memcpy(extranonce2 + (2 * extranonce2_size) - long(log10(extranonce2_number)) - 1 , next_extranounce2, strlen(next_extranounce2));
extranonce2[2 * extranonce2_size] = 0;
sprintf(&format[1], "%02dx", extranonce2_size * 2);
sprintf(extranonce2, format, extranonce2_number);
}
miner_data init_miner_data(void){

View File

@ -13,6 +13,7 @@
#include "drivers/storage/SDCard.h"
#include "drivers/storage/nvMemory.h"
#include "drivers/storage/storage.h"
#include "mining.h"
#include "timeconst.h"
@ -38,11 +39,19 @@ void saveConfigCallback()
//wm.setConfigPortalBlocking(false);
}
/* void saveParamsCallback()
// Callback notifying us of the need to save configuration
{
Serial.println("Should save config");
shouldSaveConfig = true;
nvMem.saveConfig(&Settings);
} */
void configModeCallback(WiFiManager* myWiFiManager)
// Called when config mode launched
{
Serial.println("Entered Configuration Mode");
drawSetupScreen();
Serial.print("Config SSID: ");
Serial.println(myWiFiManager->getConfigPortalSSID());
@ -54,6 +63,7 @@ void reset_configuration()
{
Serial.println("Erasing Config, restarting");
nvMem.deleteConfig();
resetStat();
wm.resetSettings();
ESP.restart();
}
@ -102,6 +112,9 @@ void init_WifiManager()
}
};
// Free the memory from SDCard class
SDCrd.terminate();
// Reset settings (only for development)
//wm.resetSettings();
@ -110,14 +123,15 @@ void init_WifiManager()
// Set config save notify callback
wm.setSaveConfigCallback(saveConfigCallback);
wm.setSaveParamsCallback(saveConfigCallback);
// Set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode
wm.setAPCallback(configModeCallback);
//Advanced settings
wm.setConfigPortalBlocking(false); //Hacemos que el portal no bloquee el firmware
wm.setConnectTimeout(50); // how long to try to connect for before continuing
//wm.setConfigPortalTimeout(30); // auto close configportal after n seconds
wm.setConnectTimeout(40); // how long to try to connect for before continuing
wm.setConfigPortalTimeout(180); // auto close configportal after n seconds
// wm.setCaptivePortalEnable(false); // disable captive portal redirection
// wm.setAPClientCheck(true); // avoid timeout if client connected to softap
//wm.setTimeout(120);
@ -136,7 +150,7 @@ void init_WifiManager()
WiFiManagerParameter port_text_box_num("Poolport", "Pool port", convertedValue, 7);
// Text box (String) - 80 characters maximum
WiFiManagerParameter password_text_box("Poolpassword", "Pool password (Optional)", Settings.PoolPassword, 80);
//WiFiManagerParameter password_text_box("Poolpassword", "Pool password (Optional)", Settings.PoolPassword, 80);
// Text box (String) - 80 characters maximum
WiFiManagerParameter addr_text_box("btcAddress", "Your BTC address", Settings.BtcWallet, 80);
@ -153,7 +167,9 @@ void init_WifiManager()
{
strcat(checkboxParams, " checked");
}
WiFiManagerParameter save_stats_to_nvs("SaveStatsToNVS", "Track Uptime, Best Diff, Total Hashes in device Flash memory. (Experimental)", "T", 2, checkboxParams, WFM_LABEL_AFTER);
WiFiManagerParameter save_stats_to_nvs("SaveStatsToNVS", "Save mining statistics to flash memory.", "T", 2, checkboxParams, WFM_LABEL_AFTER);
// Text box (String) - 80 characters maximum
WiFiManagerParameter password_text_box("Poolpassword - Optional", "Pool password", Settings.PoolPassword, 80);
// Add all defined parameters
wm.addParameter(&pool_text_box);
@ -163,6 +179,15 @@ void init_WifiManager()
wm.addParameter(&time_text_box_num);
wm.addParameter(&features_html);
wm.addParameter(&save_stats_to_nvs);
#ifdef ESP32_2432S028R
char checkboxParams2[24] = "type=\"checkbox\"";
if (Settings.invertColors)
{
strcat(checkboxParams2, " checked");
}
WiFiManagerParameter invertColors("inverColors", "Invert Display Colors (if the colors looks weird)", "T", 2, checkboxParams2, WFM_LABEL_AFTER);
wm.addParameter(&invertColors);
#endif
Serial.println("AllDone: ");
if (forceConfig)
@ -171,8 +196,8 @@ void init_WifiManager()
//No configuramos timeout al modulo
wm.setConfigPortalBlocking(true); //Hacemos que el portal SI bloquee el firmware
drawSetupScreen();
if (wm.startConfigPortal(DEFAULT_SSID, DEFAULT_WIFIPW))
mMonitor.NerdStatus = NM_Connecting;
if (!wm.startConfigPortal(DEFAULT_SSID, DEFAULT_WIFIPW))
{
//Could be break forced after edditing, so save new config
Serial.println("failed to connect and hit timeout");
@ -181,33 +206,48 @@ void init_WifiManager()
strncpy(Settings.PoolPassword, password_text_box.getValue(), sizeof(Settings.PoolPassword));
strncpy(Settings.BtcWallet, addr_text_box.getValue(), sizeof(Settings.BtcWallet));
Settings.Timezone = atoi(time_text_box_num.getValue());
Serial.println(save_stats_to_nvs.getValue());
//Serial.println(save_stats_to_nvs.getValue());
Settings.saveStats = (strncmp(save_stats_to_nvs.getValue(), "T", 1) == 0);
#ifdef ESP32_2432S028R
Settings.invertColors = (strncmp(invertColors.getValue(), "T", 1) == 0);
#endif
nvMem.saveConfig(&Settings);
delay(3*SECOND_MS);
//reset and try again, or maybe put it to deep sleep
ESP.restart();
delay(5*SECOND_MS);
};
}
else
{
//Tratamos de conectar con la configuración inicial ya almacenada
mMonitor.NerdStatus = NM_Connecting;
wm.setCaptivePortalEnable(false); // disable captive portal redirection
if (!wm.autoConnect(Settings.WifiSSID.c_str(), Settings.WifiPW.c_str()))
// disable captive portal redirection
wm.setCaptivePortalEnable(true);
wm.setConfigPortalBlocking(true);
wm.setEnableConfigPortal(true);
// if (!wm.autoConnect(Settings.WifiSSID.c_str(), Settings.WifiPW.c_str()))
if (!wm.autoConnect(DEFAULT_SSID, DEFAULT_WIFIPW))
{
Serial.println("Failed to connect and hit timeout");
//delay(3000);
// if we still have not connected restart and try all over again
//ESP.restart();
//delay(5000);
Serial.println("Failed to connect to configured WIFI, and hit timeout");
if (shouldSaveConfig) {
// Save new config
Settings.PoolAddress = pool_text_box.getValue();
Settings.PoolPort = atoi(port_text_box_num.getValue());
strncpy(Settings.PoolPassword, password_text_box.getValue(), sizeof(Settings.PoolPassword));
strncpy(Settings.BtcWallet, addr_text_box.getValue(), sizeof(Settings.BtcWallet));
Settings.Timezone = atoi(time_text_box_num.getValue());
// Serial.println(save_stats_to_nvs.getValue());
Settings.saveStats = (strncmp(save_stats_to_nvs.getValue(), "T", 1) == 0);
#ifdef ESP32_2432S028R
Settings.invertColors = (strncmp(invertColors.getValue(), "T", 1) == 0);
#endif
nvMem.saveConfig(&Settings);
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
ESP.restart();
}
}
mMonitor.NerdStatus = NM_Connecting;
//Conectado a la red Wifi
if (WiFi.status() == WL_CONNECTED) {
//tft.pushImage(0, 0, MinerWidth, MinerHeight, MinerScreen);
@ -244,12 +284,21 @@ void init_WifiManager()
Serial.print("TimeZone fromUTC: ");
Serial.println(Settings.Timezone);
#ifdef ESP32_2432S028R
Settings.invertColors = (strncmp(invertColors.getValue(), "T", 1) == 0);
Serial.print("Invert Colors: ");
Serial.println(Settings.invertColors);
#endif
}
// Save the custom parameters to FS
if (shouldSaveConfig)
{
nvMem.saveConfig(&Settings);
#ifdef ESP32_2432S028R
if (Settings.invertColors) ESP.restart();
#endif
}
}