added timeconsts to make delay times more obvious and less error prone

This commit is contained in:
dwightmulcahy 2024-03-14 11:48:14 -05:00
parent 009c7941a3
commit 02cb5aaa95
4 changed files with 28 additions and 8 deletions

View File

@ -12,6 +12,7 @@
#include "monitor.h"
#include "drivers/displays/display.h"
#include "drivers/storage/SDCard.h"
#include "timeconst.h"
//3 seconds WDT
#define WDT_TIMEOUT 3
@ -53,7 +54,7 @@ void setup()
#endif //MONITOR_SPEED
Serial.setTimeout(0);
delay(100);
delay(SECOND_MS/10);
esp_task_wdt_init(WDT_MINER_TIMEOUT, true);
// Idle task that would reset WDT never runs, because core 0 gets fully utilized
@ -62,7 +63,7 @@ void setup()
// Setup the buttons
#if defined(PIN_BUTTON_1) && !defined(PIN_BUTTON_2) //One button device
button1.setPressTicks(5000);
button1.setPressMs(5*SECOND_MS);
button1.attachClick(switchToNextScreen);
button1.attachDoubleClick(alternateScreenRotation);
button1.attachLongPressStart(reset_configuration);
@ -70,13 +71,13 @@ void setup()
#endif
#if defined(PIN_BUTTON_1) && defined(PIN_BUTTON_2) //Button 1 of two button device
button1.setPressTicks(5000);
button1.setPressMs(5*SECOND_MS);
button1.attachClick(alternateScreenState);
button1.attachDoubleClick(alternateScreenRotation);
#endif
#if defined(PIN_BUTTON_2) //Button 2 of two button device
button2.setPressTicks(5000);
button2.setPressMs(5*SECOND_MS);
button2.attachClick(switchToNextScreen);
button2.attachLongPressStart(reset_configuration);
#endif
@ -89,7 +90,7 @@ void setup()
/******** PRINT INIT SCREEN *****/
drawLoadingScreen();
delay(2000);
delay(2*SECOND_MS);
/******** SHOW LED INIT STATUS (devices without screen) *****/
mMonitor.NerdStatus = NM_waitingConfig;

View File

@ -10,6 +10,7 @@
#include "mining.h"
#include "utils.h"
#include "monitor.h"
#include "timeconst.h"
#include "drivers/displays/display.h"
#include "drivers/storage/storage.h"
@ -43,7 +44,7 @@ monitor_data mMonitor;
bool isMinerSuscribed = false;
unsigned long mLastTXtoPool = millis();
int saveIntervals[7] = {5 * 60, 15 * 60, 30 * 60, 1 * 360, 3 * 360, 6 * 360, 12 * 360};
int saveIntervals[7] = {5 * MINUTE, 15 * MINUTE, 30 * MINUTE, 1 * HOUR, 3 * HOUR, 6 * HOUR, 12 * HOUR};
int saveIntervalsSize = sizeof(saveIntervals)/sizeof(saveIntervals[0]);
int currentIntervalIndex = 0;

17
src/timeconst.h Normal file
View File

@ -0,0 +1,17 @@
//
// Created by dwight on 3/14/24.
//
#ifndef NERDMINER_V2_TIMECONST_H
#define NERDMINER_V2_TIMECONST_H
#define SECOND_MS 1000
#define SECOND 1
#define MINUTE 60*SECOND // 60 Seconds
#define HOUR 60*MINUTE // 3,600 Seconds
#define DAY 24*HOUR // 86,400 Seconds
#define WEEK 7*DAY // 604,800 Seconds
#define MONTH 30*DAY // 2,592,000 Seconds
#define YEAR 365*DAY // 31,536,000 Seconds
#endif //NERDMINER_V2_TIMECONST_H

View File

@ -13,6 +13,7 @@
#include "drivers/storage/SDCard.h"
#include "drivers/storage/nvMemory.h"
#include "drivers/storage/storage.h"
#include "timeconst.h"
// Flag for saving data
@ -183,10 +184,10 @@ void init_WifiManager()
Settings.saveStats = (strncmp(save_stats_to_nvs.getValue(), "T", 1) == 0);
nvMem.saveConfig(&Settings);
delay(3000);
delay(3*SECOND_MS);
//reset and try again, or maybe put it to deep sleep
ESP.restart();
delay(5000);
delay(5*SECOND_MS);
};
}
else