commit
5573aaf321
@ -61,7 +61,11 @@ Optional you can select other pool:
|
||||
| btc.zsolo.bid | 6057 | https://zsolo.bid/en/btc-solo-mining-pool |
|
||||
| eu.stratum.slushpool.com | 3333 | https://braiins.com/pool |
|
||||
|
||||
**If you need to reboot your currentConfig**, hold right top button during 5 seconds and config will be deleted.
|
||||
### Buttons
|
||||
With the USB-C port to the right:
|
||||
- The top button allows you to **reset the configurations and reboot** your NerdMiner. Just hold it for 5 seconds.
|
||||
- Click the bottom button once to turn the screen off and on again
|
||||
- Double click to change the orientation (default is USB-C to the right)
|
||||
|
||||
#### Build video
|
||||
[![Ver video aquí](https://img.youtube.com/vi/POUT2R_opDs/0.jpg)](https://youtu.be/POUT2R_opDs)
|
||||
|
@ -38,3 +38,4 @@ lib_deps =
|
||||
https://github.com/takkaO/OpenFontRender
|
||||
bblanchon/ArduinoJson@^6.21.2
|
||||
https://github.com/tzapu/WiFiManager.git
|
||||
mathertel/OneButton @ ^2.0.3
|
||||
|
@ -1,8 +1,11 @@
|
||||
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
#include <esp_task_wdt.h>
|
||||
#include <TFT_eSPI.h> // Graphics and font library
|
||||
#include <OneButton.h>
|
||||
|
||||
#include "mbedtls/md.h"
|
||||
#include "media/images.h"
|
||||
@ -13,6 +16,9 @@
|
||||
|
||||
//3 seconds WDT
|
||||
#define WDT_TIMEOUT 3
|
||||
OneButton button1(PIN_BUTTON_1);
|
||||
OneButton button2(PIN_BUTTON_2);
|
||||
|
||||
|
||||
OpenFontRender render;
|
||||
|
||||
@ -32,6 +38,20 @@ const char* ntpServer = "pool.ntp.org";
|
||||
|
||||
//void runMonitor(void *name);
|
||||
|
||||
void alternate_screen_state() {
|
||||
int screen_state= digitalRead(TFT_BL);
|
||||
//Serial.printf("Screen state is '%s', switching to '%s'", screen_state, !screen_state);
|
||||
Serial.println("Switching display state");
|
||||
digitalWrite(TFT_BL, !screen_state);
|
||||
}
|
||||
|
||||
void alternate_screen_rotation() {
|
||||
tft.getRotation() == 1 ? tft.setRotation(3) : tft.setRotation(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********* INIT *****/
|
||||
void setup()
|
||||
{
|
||||
@ -43,12 +63,27 @@ void setup()
|
||||
disableCore0WDT();
|
||||
disableCore1WDT();
|
||||
|
||||
// Setup the buttons
|
||||
// Button 1 (Boot)
|
||||
button1.setPressTicks(5000);
|
||||
button1.attachClick(alternate_screen_state);
|
||||
button1.attachDoubleClick(alternate_screen_rotation);
|
||||
// button1.attachLongPressStart([]{Serial.println("Button 1 started a long press");});
|
||||
// button1.attachLongPressStop([]{Serial.println("Button 1 stopped a long press");});
|
||||
// button1.attachDuringLongPress([]{Serial.println("Button 1 is being held down");});
|
||||
|
||||
// Button 2 (GPIO14)
|
||||
button2.setPressTicks(5000);
|
||||
// button2.attachClick();
|
||||
// button2.attachDoubleClick([]{Serial.println("Button 2 was double clicked");});
|
||||
button2.attachLongPressStart(reset_configurations);
|
||||
// button2.attachLongPressStop(reset_configurations);
|
||||
// button2.attachDuringLongPress([]{Serial.println("Button 2 is being held down");});
|
||||
|
||||
|
||||
/******** INIT NERDMINER ************/
|
||||
Serial.println("NerdMiner v2 starting......");
|
||||
|
||||
// Setup the button
|
||||
pinMode(PIN_BUTTON_1, INPUT);
|
||||
attachInterrupt(PIN_BUTTON_1, checkResetConfigButton, FALLING);
|
||||
|
||||
/******** INIT DISPLAY ************/
|
||||
tft.init();
|
||||
@ -109,6 +144,9 @@ void app_error_fault_handler(void *arg) {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// keep watching the push buttons:
|
||||
button1.tick();
|
||||
button2.tick();
|
||||
|
||||
wifiManagerProcess(); // avoid delays() in loop when non-blocking and other long running code
|
||||
|
||||
@ -123,8 +161,6 @@ void loop() {
|
||||
oldStatus = newStatus;
|
||||
}
|
||||
|
||||
checkResetConfigButton();
|
||||
|
||||
//Run miner on main core when there is time --Currently on test
|
||||
// runMiner();
|
||||
|
||||
|
@ -27,10 +27,6 @@ char btcString[80] = "yourBtcAddress";
|
||||
// Define WiFiManager Object
|
||||
WiFiManager wm;
|
||||
|
||||
static int buttonReset = 1;
|
||||
static unsigned long lastButtonPress = 0; // Última vez que se pulsó el botón
|
||||
|
||||
volatile bool buttonPressed = false;
|
||||
|
||||
extern TFT_eSPI tft; // tft variable declared on main
|
||||
|
||||
@ -140,8 +136,6 @@ void init_WifiManager()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
//Serial.setTxTimeoutMs(10);
|
||||
//Init config pin
|
||||
pinMode(PIN_BUTTON_2, INPUT);
|
||||
|
||||
//Init pin 15 to eneble 5V external power (LilyGo bug)
|
||||
pinMode(PIN_ENABLE5V, OUTPUT);
|
||||
@ -271,46 +265,12 @@ void init_WifiManager()
|
||||
}
|
||||
}
|
||||
|
||||
/*void checkResetConfigButton(){
|
||||
|
||||
// Leer el estado del botón
|
||||
int buttonState = digitalRead(PIN_BUTTON_0);
|
||||
unsigned int last_time = (millis() - lastButtonPress);
|
||||
Serial.printf("button pressed %i - %u\n", buttonReset, last_time);
|
||||
|
||||
buttonReset++;
|
||||
lastButtonPress = millis();
|
||||
|
||||
if ( last_time > 1000) {
|
||||
buttonReset = 1;
|
||||
}
|
||||
|
||||
// Si el botón está pulsado y ha pasado suficiente tiempo desde la última pulsación
|
||||
if (last_time < 1000 && buttonReset == 4) {
|
||||
buttonPressed = true;
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
void checkResetConfigButton() {
|
||||
// check for button press
|
||||
if ( digitalRead(PIN_BUTTON_2) == LOW ) {
|
||||
// poor mans debounce/press-hold, code not ideal for production
|
||||
delay(50);
|
||||
if( digitalRead(PIN_BUTTON_2) == LOW ){
|
||||
Serial.println("Button Pressed");
|
||||
// still holding button for 3000 ms, reset settings, code not ideaa for production
|
||||
delay(3000); // reset delay hold
|
||||
if( digitalRead(PIN_BUTTON_2) == LOW ){
|
||||
Serial.println("Button Held");
|
||||
void reset_configurations() {
|
||||
Serial.println("Erasing Config, restarting");
|
||||
wm.resetSettings();
|
||||
SPIFFS.remove(JSON_CONFIG_FILE); //Borramos fichero
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wifiManagerProcess() {
|
||||
|
@ -5,6 +5,4 @@
|
||||
|
||||
void init_WifiManager();
|
||||
void wifiManagerProcess();
|
||||
void checkResetConfigButton();
|
||||
void checkRemoveConfiguration();
|
||||
|
||||
void reset_configurations();
|
Loading…
Reference in New Issue
Block a user