removed most helper functions from NVstore, now pass in/out cal structures. Fixed some bad NV stores
This commit is contained in:
parent
cfdedc0d7c
commit
a53d6eabd0
|
@ -118,8 +118,8 @@
|
|||
#define RX_DATA_TIMOUT 50
|
||||
|
||||
const int FirmwareRevision = 23;
|
||||
const int FirmwareSubRevision = 0;
|
||||
const char* FirmwareDate = "1 Jun 2019";
|
||||
const int FirmwareSubRevision = 1;
|
||||
const char* FirmwareDate = "6 Jun 2019";
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
|
@ -397,10 +397,10 @@ void setup() {
|
|||
|
||||
sCredentials creds = NVstore.getCredentials();
|
||||
|
||||
if(NVstore.getWifiEnabled()) {
|
||||
if(NVstore.getUserSettings().enableWifi) {
|
||||
initWifi(WiFi_TriggerPin, creds.SSID, creds.APpassword);
|
||||
#if USE_OTA == 1
|
||||
if(NVstore.getOTAEnabled()) {
|
||||
if(NVstore.getUserSettings().enableOTA) {
|
||||
initOTA();
|
||||
}
|
||||
#endif // USE_OTA
|
||||
|
@ -545,7 +545,7 @@ void loop()
|
|||
// This will be the first activity for considerable period on the blue wire
|
||||
// The heater always responds to a controller frame, but otherwise never by itself
|
||||
|
||||
if(RxTimeElapsed >= (NVstore.getFrameRate() - 60)) { // compensate for the time spent just doing things in this state machine
|
||||
if(RxTimeElapsed >= (NVstore.getUserSettings().FrameRate - 60)) { // compensate for the time spent just doing things in this state machine
|
||||
// have not seen any receive data for a second.
|
||||
// OEM controller is probably not connected.
|
||||
// Skip state machine immediately to BTC_Tx, sending our own settings.
|
||||
|
@ -922,8 +922,12 @@ bool reqTemp(unsigned char newTemp)
|
|||
newTemp = max;
|
||||
if(newTemp <= min)
|
||||
newTemp = min;
|
||||
|
||||
NVstore.setDesiredTemperature(newTemp);
|
||||
|
||||
// seta nd save the temperature to NV storage
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
settings.desiredTemperature = newTemp;
|
||||
NVstore.setUserSettings(settings);
|
||||
NVstore.save();
|
||||
|
||||
ScreenManager.reqUpdate();
|
||||
return true;
|
||||
|
@ -938,7 +942,7 @@ bool reqTempDelta(int delta)
|
|||
|
||||
int getSetTemp()
|
||||
{
|
||||
return NVstore.getDesiredTemperature();
|
||||
return NVstore.getUserSettings().desiredTemperature;
|
||||
}
|
||||
|
||||
bool reqThermoToggle()
|
||||
|
@ -951,10 +955,19 @@ bool setThermostatMode(unsigned char val)
|
|||
if(bHasOEMController)
|
||||
return false;
|
||||
|
||||
NVstore.setThermostatMode(val);
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
settings.useThermostat = val;
|
||||
NVstore.setUserSettings(settings);
|
||||
return true;
|
||||
}
|
||||
|
||||
void setDegFMode(bool state)
|
||||
{
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
settings.degF = state ? 0x01 : 0x00;
|
||||
NVstore.setUserSettings(settings);
|
||||
}
|
||||
|
||||
|
||||
bool getThermostatModeActive()
|
||||
{
|
||||
|
@ -962,7 +975,7 @@ bool getThermostatModeActive()
|
|||
return getHeaterInfo().isThermostat();
|
||||
}
|
||||
else {
|
||||
return NVstore.getThermostatMode() != 0;
|
||||
return NVstore.getUserSettings().useThermostat != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -995,7 +1008,7 @@ float getTemperatureDesired()
|
|||
return getHeaterInfo().getTemperature_Desired();
|
||||
}
|
||||
else {
|
||||
return NVstore.getDesiredTemperature();
|
||||
return NVstore.getUserSettings().desiredTemperature;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1006,35 +1019,49 @@ float getTemperatureSensor()
|
|||
|
||||
void setPumpMin(float val)
|
||||
{
|
||||
NVstore.setPmin(val);
|
||||
sHeaterTuning tuning = NVstore.getHeaterTuning();
|
||||
tuning.setPmin(val);
|
||||
NVstore.setHeaterTuning(tuning);
|
||||
}
|
||||
|
||||
void setPumpMax(float val)
|
||||
{
|
||||
NVstore.setPmax(val);
|
||||
sHeaterTuning tuning = NVstore.getHeaterTuning();
|
||||
tuning.setPmax(val);
|
||||
NVstore.setHeaterTuning(tuning);
|
||||
}
|
||||
|
||||
void setFanMin(short cVal)
|
||||
{
|
||||
NVstore.setFmin(cVal);
|
||||
sHeaterTuning tuning = NVstore.getHeaterTuning();
|
||||
tuning.Fmin = cVal;
|
||||
NVstore.setHeaterTuning(tuning);
|
||||
}
|
||||
|
||||
void setFanMax(short cVal)
|
||||
{
|
||||
NVstore.setFmax(cVal);
|
||||
sHeaterTuning tuning = NVstore.getHeaterTuning();
|
||||
tuning.Fmax = cVal;
|
||||
NVstore.setHeaterTuning(tuning);
|
||||
}
|
||||
|
||||
void setFanSensor(unsigned char cVal)
|
||||
{
|
||||
NVstore.setFanSensor(cVal);
|
||||
sHeaterTuning tuning = NVstore.getHeaterTuning();
|
||||
tuning.fanSensor = cVal;
|
||||
NVstore.setHeaterTuning(tuning);
|
||||
}
|
||||
|
||||
void setSystemVoltage(float val) {
|
||||
NVstore.setSystemVoltage(val);
|
||||
sHeaterTuning tuning = NVstore.getHeaterTuning();
|
||||
tuning.setSysVoltage(val);
|
||||
NVstore.setHeaterTuning(tuning);
|
||||
}
|
||||
|
||||
void setGlowDrive(unsigned char val) {
|
||||
NVstore.setGlowDrive(val);
|
||||
sHeaterTuning tuning = NVstore.getHeaterTuning();
|
||||
tuning.glowDrive = val;
|
||||
NVstore.setHeaterTuning(tuning);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -205,7 +205,6 @@ bool esp32FOTA::execHTTPcheck()
|
|||
|
||||
if (httpCode == 200)
|
||||
{ //Check is a file was returned
|
||||
|
||||
String payload = http.getString();
|
||||
|
||||
int str_len = payload.length() + 1;
|
||||
|
@ -247,6 +246,7 @@ bool esp32FOTA::execHTTPcheck()
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -59,7 +59,7 @@ CBasicScreen::show()
|
|||
|
||||
float fTemp = getTemperatureSensor();
|
||||
if(fTemp > -80) {
|
||||
if(NVstore.getDegFMode()) {
|
||||
if(NVstore.getUserSettings().degF) {
|
||||
fTemp = fTemp * 9 / 5 + 32;
|
||||
sprintf(msg, "%.1f`F", fTemp);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ CBasicScreen::show()
|
|||
|
||||
if(getThermostatModeActive()) {
|
||||
float fTemp = getTemperatureDesired();
|
||||
if(NVstore.getDegFMode()) {
|
||||
if(NVstore.getUserSettings().degF) {
|
||||
fTemp = fTemp * 9 / 5 + 32;
|
||||
sprintf(msg, "Setpoint = %.0f`F", fTemp);
|
||||
}
|
||||
|
@ -202,7 +202,10 @@ CBasicScreen::keyHandler(uint8_t event)
|
|||
if(repeatCount > 2) {
|
||||
repeatCount = -1; // prevent double handling
|
||||
_showModeTime = millis() + 5000;
|
||||
NVstore.setDegFMode(NVstore.getDegFMode() ? 0 : 1);
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
toggle(settings.degF);
|
||||
NVstore.setUserSettings(settings);
|
||||
NVstore.save();
|
||||
}
|
||||
}
|
||||
// hold CENTRE to turn ON or OFF
|
||||
|
|
|
@ -224,7 +224,10 @@ CDetailedScreen::keyHandler(uint8_t event)
|
|||
if(event & key_Up) {
|
||||
if(_keyRepeatCount > 1) { // held Down - togle thermo/fixed mode
|
||||
_keyRepeatCount = -1; // prevent double handling
|
||||
NVstore.setDegFMode(NVstore.getDegFMode() ? 0 : 1);
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
toggle(settings.degF);
|
||||
NVstore.setUserSettings(settings);
|
||||
NVstore.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +279,7 @@ CDetailedScreen::showThermometer(float desired, float actual)
|
|||
if(actual > -80) {
|
||||
#ifdef MINI_TEMPLABEL
|
||||
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
||||
if(NVstore.getDegFMode()) {
|
||||
if(NVstore.getUserSettings().degF) {
|
||||
actual = actual * 9 / 5 + 32;
|
||||
sprintf(msg, "%.1f`F", actual);
|
||||
}
|
||||
|
@ -299,7 +302,7 @@ CDetailedScreen::showThermometer(float desired, float actual)
|
|||
if(desired > 0) {
|
||||
int yPos = Y_BULB + TEMP_YPOS(desired) - 2;
|
||||
_drawBitmap(X_BULB-1, yPos, ThermoPtrIconInfo); // set indicator against bulb
|
||||
if(NVstore.getDegFMode()) {
|
||||
if(NVstore.getUserSettings().degF) {
|
||||
desired = desired * 9 / 5 + 32;
|
||||
sprintf(msg, "%.0f`F", desired);
|
||||
}
|
||||
|
@ -333,7 +336,7 @@ CDetailedScreen::showBodyThermometer(int actual)
|
|||
// determine width and position right justified
|
||||
#ifdef MINI_BODYLABEL
|
||||
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
||||
if(NVstore.getDegFMode()) {
|
||||
if(NVstore.getUserSettings().degF) {
|
||||
actual = actual * 9 / 5 + 32;
|
||||
sprintf(label, "%d`F", actual);
|
||||
}
|
||||
|
|
|
@ -40,9 +40,9 @@ COtherOptionsScreen::onSelect()
|
|||
CScreenHeader::onSelect();
|
||||
_rowSel = 0;
|
||||
_repeatCount = -1;
|
||||
_frameRate = NVstore.getFrameRate();
|
||||
_dispTimeout = NVstore.getDimTime();
|
||||
_menuTimeout = 60000;
|
||||
_frameRate = NVstore.getUserSettings().FrameRate;
|
||||
_dispTimeout = NVstore.getUserSettings().dimTime;
|
||||
_menuTimeout = NVstore.getUserSettings().menuTimeout;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -144,10 +144,13 @@ COtherOptionsScreen::keyHandler(uint8_t event)
|
|||
// UP press
|
||||
if(event & key_Up) {
|
||||
if(_rowSel == 4) {
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
settings.dimTime = _dispTimeout;
|
||||
settings.menuTimeout = _menuTimeout;
|
||||
settings.FrameRate = _frameRate;
|
||||
NVstore.setUserSettings(settings);
|
||||
NVstore.save();
|
||||
_showStoringMessage();
|
||||
NVstore.setFrameRate(_frameRate);
|
||||
NVstore.setDimTime(_dispTimeout);
|
||||
saveNV();
|
||||
_rowSel = 0;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -110,7 +110,7 @@ CPrimingScreen::show()
|
|||
_printMenuText(_display.width()-border, yPos, "degF", _colSel == 1, eRightJustify);
|
||||
}
|
||||
else {
|
||||
int col = NVstore.getDegFMode();
|
||||
int col = NVstore.getUserSettings().degF ? 1 : 0;
|
||||
_printInverted(border, yPos, "degC", col == 0);
|
||||
_printInverted(_display.width()-border, yPos, "degF", col == 1, eRightJustify);
|
||||
}
|
||||
|
@ -168,7 +168,8 @@ CPrimingScreen::keyHandler(uint8_t event)
|
|||
break;
|
||||
case 2:
|
||||
_colSel = 0;
|
||||
NVstore.setDegFMode(0);
|
||||
setDegFMode(false);
|
||||
saveNV();
|
||||
break;
|
||||
case 3:
|
||||
_colSel = 1;
|
||||
|
@ -189,7 +190,8 @@ CPrimingScreen::keyHandler(uint8_t event)
|
|||
break;
|
||||
case 2:
|
||||
_colSel = 1;
|
||||
NVstore.setDegFMode(1);
|
||||
setDegFMode(true);
|
||||
saveNV();
|
||||
break;
|
||||
case 3:
|
||||
if(!getHeaterInfo().getRunState())
|
||||
|
@ -208,9 +210,8 @@ CPrimingScreen::keyHandler(uint8_t event)
|
|||
if(_rowSel == 3)
|
||||
_colSel = 1; // select OFF upon entry to priming menu
|
||||
if(_rowSel == 2)
|
||||
_colSel = NVstore.getDegFMode();
|
||||
_colSel = NVstore.getUserSettings().degF ? 1 : 0;
|
||||
if(_rowSel == 1)
|
||||
// _colSel = getHeaterInfo().isThermostat() ? 0 : 1;
|
||||
_colSel = getThermostatModeActive() ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +228,7 @@ CPrimingScreen::keyHandler(uint8_t event)
|
|||
// _colSel = getHeaterInfo().isThermostat() ? 0 : 1;
|
||||
_colSel = getThermostatModeActive() ? 0 : 1;
|
||||
if(_rowSel == 2)
|
||||
_colSel = NVstore.getDegFMode();
|
||||
_colSel = NVstore.getUserSettings().degF ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ CScreenHeader::showWifiIcon()
|
|||
_UpAnnotation.holdoff--; // animation of arrow is now cleared
|
||||
}
|
||||
else {
|
||||
if(NVstore.getOTAEnabled()) {
|
||||
if(NVstore.getUserSettings().enableOTA) {
|
||||
// OTA is enabled, show OTA
|
||||
// erase top right portion of wifi icon
|
||||
_display.fillRect(X_WIFI_ICON+11, Y_WIFI_ICON, 2, 6, BLACK);
|
||||
|
|
|
@ -251,7 +251,7 @@ CScreenManager::begin(bool bNoClock)
|
|||
bool
|
||||
CScreenManager::checkUpdate()
|
||||
{
|
||||
long dimTimeout = NVstore.getDimTime();
|
||||
long dimTimeout = NVstore.getUserSettings().dimTime;
|
||||
|
||||
// manage dimming or blanking the display, according to user defined inactivity interval
|
||||
if(dimTimeout && _DimTime_ms) {
|
||||
|
@ -268,7 +268,7 @@ CScreenManager::checkUpdate()
|
|||
}
|
||||
}
|
||||
|
||||
if(NVstore.getMenuTimeout() && _MenuTimeout) {
|
||||
if(NVstore.getUserSettings().menuTimeout && _MenuTimeout) {
|
||||
long tDelta = millis() - _MenuTimeout;
|
||||
if(tDelta > 0) {
|
||||
_MenuTimeout = 0;
|
||||
|
@ -373,12 +373,16 @@ CScreenManager::reqUpdate()
|
|||
bool
|
||||
CScreenManager::animate()
|
||||
{
|
||||
if((NVstore.getDimTime() < 0) && (_DimTime_ms == 0)) {
|
||||
if(_pRebootScreen)
|
||||
return false;
|
||||
|
||||
if((NVstore.getUserSettings().dimTime < 0) && (_DimTime_ms == 0))
|
||||
// no screen updates, we should be blanked!
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_menu >= 0)
|
||||
return _Screens[_menu][_subMenu]->animate();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -436,20 +440,20 @@ CScreenManager::prevMenu()
|
|||
void
|
||||
CScreenManager::keyHandler(uint8_t event)
|
||||
{
|
||||
long dimTime = NVstore.getDimTime();
|
||||
long dimTime = NVstore.getUserSettings().dimTime;
|
||||
|
||||
if(_bDimmed) {
|
||||
if(event & keyReleased) {
|
||||
_dim(false);
|
||||
_DimTime_ms = (millis() + abs(dimTime)) | 1;
|
||||
_MenuTimeout = millis() + NVstore.getMenuTimeout();
|
||||
_MenuTimeout = millis() + NVstore.getUserSettings().menuTimeout;
|
||||
}
|
||||
return; // initial press when dimmed is always thrown away
|
||||
}
|
||||
|
||||
// _dim(false);
|
||||
_DimTime_ms = (millis() + abs(dimTime)) | 1;
|
||||
_MenuTimeout = millis() + NVstore.getMenuTimeout();
|
||||
_MenuTimeout = millis() + NVstore.getUserSettings().menuTimeout;
|
||||
|
||||
// call key handler for active screen
|
||||
if(_menu >= 0)
|
||||
|
|
|
@ -54,8 +54,8 @@ CThermostatModeScreen::onSelect()
|
|||
{
|
||||
CPasswordScreen::onSelect();
|
||||
_initUI();
|
||||
_window = NVstore.getThermostatMethodWindow();
|
||||
_thermoMode = NVstore.getThermostatMethodMode();
|
||||
_window = NVstore.getUserSettings().ThermostatWindow;
|
||||
_thermoMode = NVstore.getUserSettings().ThermostatMethod;
|
||||
_cyclicMode = NVstore.getCyclicMode();
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ CThermostatModeScreen::show()
|
|||
_printInverted(_display.xCentre(), 0, " Thermostat Mode ", true, eCentreJustify);
|
||||
_drawBitmap(3, 14, ThermostatIconInfo);
|
||||
float fTemp = _window;
|
||||
if(NVstore.getDegFMode()) {
|
||||
if(NVstore.getUserSettings().degF) {
|
||||
fTemp = fTemp * 9 / 5;
|
||||
sprintf(msg, "%.1f\367F", fTemp);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ CThermostatModeScreen::show()
|
|||
}
|
||||
if(_cyclicMode.isEnabled()) {
|
||||
float fTemp = _cyclicMode.Stop+1;
|
||||
if(NVstore.getDegFMode()) {
|
||||
if(NVstore.getUserSettings().degF) {
|
||||
fTemp = fTemp * 9 / 5;
|
||||
sprintf(msg, "\352>%.0f\367F", fTemp);
|
||||
}
|
||||
|
@ -119,7 +119,8 @@ CThermostatModeScreen::show()
|
|||
_printMenuText(Column, Line1, msg, _rowSel == 1);
|
||||
if(_cyclicMode.isEnabled()) {
|
||||
float fTemp = _cyclicMode.Start;
|
||||
if(NVstore.getDegFMode()) {
|
||||
// if(NVstore.getDegFMode()) {
|
||||
if(NVstore.getUserSettings().degF) {
|
||||
fTemp = fTemp * 9 / 5;
|
||||
sprintf(msg, "\352<%.0f\367F", fTemp);
|
||||
}
|
||||
|
@ -188,6 +189,7 @@ CThermostatModeScreen::animate()
|
|||
bool
|
||||
CThermostatModeScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
sUserSettings settings;
|
||||
if(event & keyPressed) {
|
||||
_keyRepeat = 0; // unlock hold function
|
||||
// press LEFT to select previous screen
|
||||
|
@ -250,8 +252,10 @@ CThermostatModeScreen::keyHandler(uint8_t event)
|
|||
break;
|
||||
case 10: // confirmed save
|
||||
_showStoringMessage();
|
||||
NVstore.setThermostatMethodMode(_thermoMode);
|
||||
NVstore.setThermostatMethodWindow(_window);
|
||||
settings = NVstore.getUserSettings();
|
||||
settings.ThermostatMethod = _thermoMode;
|
||||
settings.ThermostatWindow = _window;
|
||||
NVstore.setUserSettings(settings);
|
||||
NVstore.setCyclicMode(_cyclicMode);
|
||||
saveNV();
|
||||
_rowSel = 0;
|
||||
|
@ -282,6 +286,16 @@ CThermostatModeScreen::keyHandler(uint8_t event)
|
|||
_ScreenManager.selectMenu(CScreenManager::BranchMenu, CScreenManager::FontDumpUI);
|
||||
}
|
||||
}
|
||||
if(_rowSel == 3) {
|
||||
if(event & key_Right) {
|
||||
_adjust(+1);
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
if(event & key_Left) {
|
||||
_adjust(-1);
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(event & keyReleased) {
|
||||
_keyRepeat = -1;
|
||||
|
@ -306,7 +320,7 @@ CThermostatModeScreen::_adjust(int dir)
|
|||
break;
|
||||
case 3: // window
|
||||
_window += (dir * 0.1);
|
||||
UPPERLIMIT(_window, 6.3);
|
||||
UPPERLIMIT(_window, 10.0);
|
||||
LOWERLIMIT(_window, 0.2);
|
||||
break;
|
||||
case 4: // thermostat mode
|
||||
|
|
|
@ -56,11 +56,11 @@ CWiFiScreen::_initUI()
|
|||
{
|
||||
_rowSel = 0;
|
||||
_colSel = 0;
|
||||
_OTAsel = NVstore.getOTAEnabled();
|
||||
_OTAsel = NVstore.getUserSettings().enableOTA;
|
||||
_colLimit = LIMIT_LEFT; // left most selection
|
||||
_bShowMAC = false;
|
||||
|
||||
if(NVstore.getWifiEnabled()) {
|
||||
if(NVstore.getUserSettings().enableWifi) {
|
||||
if(isWifiAP()) {
|
||||
if(isWifiConfigPortal()) {
|
||||
_colSel = 1; // " WiFi: CFG AP only "
|
||||
|
@ -297,7 +297,9 @@ CWiFiScreen::keyHandler(uint8_t event)
|
|||
_rowSel = 3; // stop ticker display
|
||||
}
|
||||
if(_rowSel == 2) {
|
||||
NVstore.setOTAEnabled(_OTAsel);
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
settings.enableOTA = _OTAsel;
|
||||
NVstore.setUserSettings(settings);
|
||||
NVstore.save();
|
||||
const char* content[2];
|
||||
if(_OTAsel)
|
||||
|
|
|
@ -119,21 +119,21 @@ CTxManage::PrepareFrame(const CProtocol& basisFrame, bool isBTCmaster)
|
|||
// heater is happy either way, the OEM controller has set the max/min stuff already
|
||||
if(isBTCmaster) {
|
||||
m_TxFrame.setActiveMode(); // this allows heater to save the tuning params to EEPROM
|
||||
m_TxFrame.setFan_Min(NVstore.getFmin());
|
||||
m_TxFrame.setFan_Max(NVstore.getFmax());
|
||||
m_TxFrame.setPump_Min(NVstore.getPmin());
|
||||
m_TxFrame.setPump_Max(NVstore.getPmax());
|
||||
m_TxFrame.setFan_Min(NVstore.getHeaterTuning().Fmin);
|
||||
m_TxFrame.setFan_Max(NVstore.getHeaterTuning().Fmax);
|
||||
m_TxFrame.setPump_Min(NVstore.getHeaterTuning().getPmin());
|
||||
m_TxFrame.setPump_Max(NVstore.getHeaterTuning().getPmax());
|
||||
|
||||
float tActual = getTemperatureSensor();
|
||||
uint8_t u8Temp = (uint8_t)(tActual);
|
||||
m_TxFrame.setTemperature_Actual(u8Temp); // use current temp, for now
|
||||
m_TxFrame.setTemperature_Desired(NVstore.getDesiredTemperature());
|
||||
m_TxFrame.setTemperature_Desired(NVstore.getUserSettings().desiredTemperature);
|
||||
|
||||
if(NVstore.getThermostatMode()) {
|
||||
uint8_t ThermoMode = NVstore.getThermostatMethodMode(); // get the METHOD of thermostat control
|
||||
float Window = NVstore.getThermostatMethodWindow();
|
||||
if(NVstore.getUserSettings().ThermostatMethod) {
|
||||
uint8_t ThermoMode = NVstore.getUserSettings().ThermostatMethod; // get the METHOD of thermostat control
|
||||
float Window = NVstore.getUserSettings().ThermostatWindow;
|
||||
float tCurrent = getTemperatureSensor();
|
||||
float tDesired = float(NVstore.getDesiredTemperature());
|
||||
float tDesired = float(NVstore.getUserSettings().desiredTemperature);
|
||||
float tDelta = tCurrent - tDesired;
|
||||
float fTemp;
|
||||
#ifdef DEBUG_THERMOSTAT
|
||||
|
@ -157,11 +157,11 @@ CTxManage::PrepareFrame(const CProtocol& basisFrame, bool isBTCmaster)
|
|||
u8Temp = (uint8_t)(tActual + 0.5); // use rounded actual unless within window
|
||||
if(fabs(tDelta) < Window) {
|
||||
// hold at desired if inside window
|
||||
u8Temp = NVstore.getDesiredTemperature();
|
||||
u8Temp = NVstore.getUserSettings().desiredTemperature;
|
||||
}
|
||||
else if(fabs(tDelta) <= 1.0) {
|
||||
// force outside if delta is <= 1 but greater than window
|
||||
u8Temp = NVstore.getDesiredTemperature() + ((tDelta > 0) ? 1 : -1);
|
||||
u8Temp = NVstore.getUserSettings().desiredTemperature + ((tDelta > 0) ? 1 : -1);
|
||||
}
|
||||
m_TxFrame.setTemperature_Actual(u8Temp);
|
||||
#ifdef DEBUG_THERMOSTAT
|
||||
|
@ -200,9 +200,9 @@ CTxManage::PrepareFrame(const CProtocol& basisFrame, bool isBTCmaster)
|
|||
}
|
||||
// m_TxFrame.setThermostatMode(NVstore.getThermostatMode());
|
||||
|
||||
m_TxFrame.Controller.OperatingVoltage = NVstore.getSysVoltage();
|
||||
m_TxFrame.Controller.FanSensor = NVstore.getFanSensor();
|
||||
m_TxFrame.Controller.GlowDrive = NVstore.getGlowDrive();
|
||||
m_TxFrame.Controller.OperatingVoltage = NVstore.getHeaterTuning().sysVoltage;
|
||||
m_TxFrame.Controller.FanSensor = NVstore.getHeaterTuning().fanSensor;
|
||||
m_TxFrame.Controller.GlowDrive = NVstore.getHeaterTuning().glowDrive;
|
||||
}
|
||||
else {
|
||||
m_TxFrame.setPassiveMode(); // this prevents the tuning parameters being saved by heater
|
||||
|
|
|
@ -76,6 +76,7 @@ extern void checkFOTA();
|
|||
extern void setUploadSize(long val);
|
||||
extern void getGPIOinfo(sGPIO& info);
|
||||
extern void simulateGPIOin(uint8_t newKey);
|
||||
extern void setDegFMode(bool state);
|
||||
|
||||
|
||||
extern void ShowOTAScreen(int percent=0, eOTAmodes updateType=eOTAnormal);
|
||||
|
@ -88,5 +89,6 @@ extern void ShowOTAScreen(int percent=0, eOTAmodes updateType=eOTAnormal);
|
|||
#define WRAPUPPERLIMIT(A, B, C) if((A) > (B)) (A) = (C)
|
||||
#define WRAPLOWERLIMIT(A, B, C) if((A) < (B)) (A) = (C)
|
||||
#define WRAPLIMITS(A, B, C) if((A) < (B)) (A) = (C) ; if((A) > (C)) (A) = (B)
|
||||
#define INBOUNDS(TST, MIN, MAX) (((TST) >= (MIN)) && ((tst) <= (MAX)))
|
||||
|
||||
#endif
|
|
@ -39,6 +39,7 @@ CModerator MQTTmoderator;
|
|||
CModerator GPIOmoderator;
|
||||
|
||||
void validateTimer(int ID);
|
||||
void Expand(std::string& str);
|
||||
|
||||
void interpretJsonCommand(char* pLine)
|
||||
{
|
||||
|
@ -94,10 +95,18 @@ void interpretJsonCommand(char* pLine)
|
|||
NVstore.setCyclicMode(cyclic);
|
||||
}
|
||||
else if(strcmp("ThermostatMethod", it->key) == 0) {
|
||||
NVstore.setThermostatMethodMode(it->value.as<unsigned char>());
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
uint8_t val = it->value.as<uint8_t>();
|
||||
if(val <= 2)
|
||||
settings.ThermostatMethod = val;
|
||||
NVstore.setUserSettings(settings);
|
||||
}
|
||||
else if(strcmp("ThermostatWindow", it->key) == 0) {
|
||||
NVstore.setThermostatMethodWindow(it->value.as<float>());
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
float val = it->value.as<float>();
|
||||
if(val >= 0.2f && val <= 10.f)
|
||||
settings.ThermostatWindow = val;
|
||||
NVstore.setUserSettings(settings);
|
||||
}
|
||||
else if(strcmp("Thermostat", it->key) == 0) {
|
||||
if(!setThermostatMode(it->value.as<unsigned char>())) { // this request is blocked if OEM controller active
|
||||
|
@ -256,7 +265,7 @@ bool makeJSONString(CModerator& moderator, char* opStr, int len)
|
|||
bSend |= moderator.addJson("GlowVoltage", getHeaterInfo().getGlow_Voltage(), root );
|
||||
bSend |= moderator.addJson("GlowCurrent", getHeaterInfo().getGlow_Current(), root );
|
||||
bSend |= moderator.addJson("BluewireStat", getBlueWireStatStr(), root );
|
||||
bSend |= moderator.addJson("TempMode", NVstore.getDegFMode(), root);
|
||||
bSend |= moderator.addJson("TempMode", NVstore.getUserSettings().degF, root);
|
||||
|
||||
if(bSend) {
|
||||
root.printTo(opStr, len);
|
||||
|
@ -272,8 +281,8 @@ bool makeJSONStringEx(CModerator& moderator, char* opStr, int len)
|
|||
|
||||
bool bSend = false; // reset should send flag
|
||||
|
||||
bSend |= moderator.addJson("ThermostatMethod", NVstore.getThermostatMethodMode(), root);
|
||||
bSend |= moderator.addJson("ThermostatWindow", NVstore.getThermostatMethodWindow(), root);
|
||||
bSend |= moderator.addJson("ThermostatMethod", NVstore.getUserSettings().ThermostatMethod, root);
|
||||
bSend |= moderator.addJson("ThermostatWindow", NVstore.getUserSettings().ThermostatWindow, root);
|
||||
bSend |= moderator.addJson("ThermostatOvertemp", NVstore.getCyclicMode().Stop, root);
|
||||
bSend |= moderator.addJson("ThermostatUndertemp", NVstore.getCyclicMode().Start, root);
|
||||
|
||||
|
@ -379,7 +388,9 @@ void updateJSONclients(bool report)
|
|||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
}
|
||||
sendWebServerString( jsonStr );
|
||||
getBluetoothClient().send( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
}
|
||||
}
|
||||
// update extended params
|
||||
|
@ -389,7 +400,9 @@ void updateJSONclients(bool report)
|
|||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
}
|
||||
sendWebServerString( jsonStr );
|
||||
getBluetoothClient().send( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
}
|
||||
}
|
||||
// update timer parameters
|
||||
|
@ -406,7 +419,9 @@ void updateJSONclients(bool report)
|
|||
sendWebServerString( jsonStr );
|
||||
unsigned long tWF = millis() - tStart;
|
||||
tStart = millis();
|
||||
getBluetoothClient().send( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
unsigned long tBT = millis() - tStart;
|
||||
bNewTimerInfo = true;
|
||||
DebugPort.printf("JSON times : %ld,%ld,%ld\r\n", tJSON, tBT, tWF);
|
||||
|
@ -426,7 +441,9 @@ void updateJSONclients(bool report)
|
|||
|
||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
sendWebServerString( jsonStr );
|
||||
getBluetoothClient().send( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
}
|
||||
|
||||
// report MQTT params
|
||||
|
@ -436,7 +453,9 @@ void updateJSONclients(bool report)
|
|||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
}
|
||||
sendWebServerString( jsonStr );
|
||||
getBluetoothClient().send( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,7 +465,9 @@ void updateJSONclients(bool report)
|
|||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
||||
}
|
||||
sendWebServerString( jsonStr );
|
||||
getBluetoothClient().send( jsonStr );
|
||||
std::string expand = jsonStr;
|
||||
Expand(expand);
|
||||
getBluetoothClient().send( expand.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,3 +499,14 @@ void initTimerJSONmoderator()
|
|||
makeJSONTimerString(tmr, jsonStr, sizeof(jsonStr));
|
||||
}
|
||||
|
||||
|
||||
void Expand(std::string& str)
|
||||
{
|
||||
size_t pos = str.find(",\"");
|
||||
while(pos != std::string::npos) {
|
||||
str.replace(pos, 2, "}\n{\"");
|
||||
pos = str.find(",\"");
|
||||
}
|
||||
str.append("\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ const int ONFLASHINTERVAL = 50;
|
|||
|
||||
const char* GPIOinNames[4] = {
|
||||
"Disabled",
|
||||
"On1Off1",
|
||||
"On1Off2",
|
||||
"Hold1",
|
||||
"On1Off1"
|
||||
};
|
||||
|
|
|
@ -142,67 +142,3 @@ CStringModerator::reset(const char* name)
|
|||
Memory.erase(it);
|
||||
}
|
||||
}
|
||||
/*
|
||||
CGPIOModerator::CGPIOModerator()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
void
|
||||
CGPIOModerator::reset()
|
||||
{
|
||||
Memory.inState[0] = !Memory.inState[0];
|
||||
Memory.inState[1] = !Memory.inState[1];
|
||||
Memory.outState[0] = !Memory.outState[0];
|
||||
Memory.outState[1] = !Memory.outState[1];
|
||||
Memory.algVal = Memory.algVal+10000;
|
||||
Memory.inMode = (GPIOinModes)-1;
|
||||
Memory.outMode = (GPIOoutModes)-1;
|
||||
Memory.algMode = (GPIOalgModes)-1;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CGPIOModerator::addJson(const sGPIO& toSend, JsonObject& root)
|
||||
{
|
||||
bool retval = false;
|
||||
|
||||
char msgs[5][16];
|
||||
if(Memory.inState[0] != toSend.inState[0]) {
|
||||
root.set("GPin1", toSend.inState[0] ? 1 : 0);
|
||||
retval = true;
|
||||
}
|
||||
if(Memory.inState[1] != toSend.inState[1]) {
|
||||
root.set("GPin2", toSend.inState[1] ? 1 : 0);
|
||||
retval = true;
|
||||
}
|
||||
if(Memory.outState[0] != toSend.outState[0]) {
|
||||
root.set("GPout1", toSend.outState[0] ? 1 : 0);
|
||||
retval = true;
|
||||
}
|
||||
if(Memory.outState[1] != toSend.outState[1]) {
|
||||
root.set("GPout2", toSend.outState[1] ? 1 : 0);
|
||||
retval = true;
|
||||
}
|
||||
if(Memory.algVal != toSend.algVal) {
|
||||
root.set("GPalg", toSend.algVal);
|
||||
retval = true;
|
||||
}
|
||||
if(Memory.inMode != toSend.inMode) {
|
||||
root.set("GPinMode", GPIOinNames[toSend.inMode]);
|
||||
retval = true;
|
||||
}
|
||||
if(Memory.outMode != toSend.outMode) {
|
||||
root.set("GPoutMode", GPIOoutNames[toSend.outMode]);
|
||||
retval = true;
|
||||
}
|
||||
if(Memory.algMode != toSend.algMode) {
|
||||
root.set("GPalgMode", GPIOalgNames[toSend.algMode]);
|
||||
retval = true;
|
||||
}
|
||||
|
||||
Memory = toSend;
|
||||
|
||||
return retval;
|
||||
}
|
||||
*/
|
|
@ -24,6 +24,8 @@
|
|||
#include "DebugPort.h"
|
||||
#include <functional>
|
||||
|
||||
#define INBOUNDS(TST, MIN, MAX) (((TST) >= (MIN)) && ((TST) <= (MAX)))
|
||||
|
||||
|
||||
bool
|
||||
CESP32_NVStorage::validatedLoad(const char* key, char* val, int maxlen, const char* defVal)
|
||||
|
@ -91,10 +93,10 @@ CESP32_NVStorage::validatedLoad(const char* key, uint16_t& val, int defVal, std:
|
|||
}
|
||||
|
||||
bool
|
||||
CESP32_NVStorage::validatedLoad(const char* key, long& val, long defVal, std::function<bool(long, long, long)> validator, long min, long max)
|
||||
CESP32_NVStorage::validatedLoad(const char* key, long& val, long defVal, long min, long max)
|
||||
{
|
||||
val = preferences.getLong(key, defVal);
|
||||
if(!validator(val, min, max)) {
|
||||
if(!INBOUNDS(val, min, max)) {
|
||||
|
||||
DebugPort.printf("CESP32HeaterStorage::validatedLoad<long> invalid read %s=%ld", key, val);
|
||||
DebugPort.printf(" validator(%ld,%ld) reset to %ld\r\n", min, max, defVal);
|
||||
|
@ -106,6 +108,22 @@ CESP32_NVStorage::validatedLoad(const char* key, long& val, long defVal, std::fu
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CESP32_NVStorage::validatedLoad(const char* key, float& val, float defVal, float min, float max)
|
||||
{
|
||||
val = preferences.getFloat(key, defVal);
|
||||
if(!INBOUNDS(val, min, max)) {
|
||||
|
||||
DebugPort.printf("CESP32HeaterStorage::validatedLoad<float> invalid read %s=%f", key, val);
|
||||
DebugPort.printf(" validator(%f,%f) reset to %f\r\n", min, max, defVal);
|
||||
|
||||
val = defVal;
|
||||
preferences.putFloat(key, val);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool u8inBounds(uint8_t test, uint8_t minLim, uint8_t maxLim)
|
||||
{
|
||||
return (test >= minLim) && (test <= maxLim);
|
||||
|
@ -126,9 +144,3 @@ bool u16inBounds(uint16_t test, uint16_t minLim, uint16_t maxLim)
|
|||
return (test >= minLim) && (test <= maxLim);
|
||||
}
|
||||
|
||||
bool s32inBounds(long test, long minLim, long maxLim)
|
||||
{
|
||||
return (test >= minLim) && (test <= maxLim);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ bool u8inBounds(uint8_t test, uint8_t minLim, uint8_t maxLim);
|
|||
bool s8inBounds(int8_t test, int8_t minLim, int8_t maxLim);
|
||||
bool u8Match2(uint8_t test, uint8_t test1, uint8_t test2);
|
||||
bool u16inBounds(uint16_t test, uint16_t minLim, uint16_t maxLim);
|
||||
bool s32inBounds(long test, long minLim, long maxLim);
|
||||
bool thermoMethodinBounds(uint8_t test, uint8_t minLim, uint8_t maxLim);
|
||||
|
||||
class CNVStorage {
|
||||
|
@ -50,8 +49,9 @@ protected:
|
|||
bool validatedLoad(const char* key, int8_t& val, int defVal, std::function<bool(int8_t, int8_t, int8_t)> validator, int min, int max);
|
||||
bool validatedLoad(const char* key, uint8_t& val, int defVal, std::function<bool(uint8_t, uint8_t, uint8_t)> validator, int min, int max, uint8_t mask=0xff);
|
||||
bool validatedLoad(const char* key, uint16_t& val, int defVal, std::function<bool(uint16_t, uint16_t, uint16_t)> validator, int min, int max);
|
||||
bool validatedLoad(const char* key, long& val, long defVal, std::function<bool(long, long, long)> validator, long min, long max);
|
||||
bool validatedLoad(const char* key, long& val, long defVal, long min, long max);
|
||||
bool validatedLoad(const char* key, char* val, int maxlen, const char* defVal);
|
||||
bool validatedLoad(const char* key, float& val, float defVal, float min, float max);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ bool
|
|||
sNVStore::valid()
|
||||
{
|
||||
bool retval = true;
|
||||
retval &= Heater.valid();
|
||||
retval &= Options.valid();
|
||||
retval &= heaterTuning.valid();
|
||||
retval &= userSettings.valid();
|
||||
for(int i=0; i<2; i++) {
|
||||
retval &= timer[i].valid();
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ sNVStore::valid()
|
|||
void
|
||||
sNVStore::init()
|
||||
{
|
||||
Heater.init();
|
||||
Options.init();
|
||||
heaterTuning.init();
|
||||
userSettings.init();
|
||||
for(int i=0; i<2; i++) {
|
||||
timer[i].init();
|
||||
}
|
||||
|
@ -57,151 +57,42 @@ CHeaterStorage::CHeaterStorage()
|
|||
}
|
||||
|
||||
float
|
||||
CHeaterStorage::getPmin()
|
||||
sHeaterTuning::getPmin() const
|
||||
{
|
||||
return float(_calValues.Heater.Pmin) * 0.1f;
|
||||
return float(Pmin) * 0.1f;
|
||||
}
|
||||
|
||||
float
|
||||
CHeaterStorage::getPmax()
|
||||
sHeaterTuning::getPmax() const
|
||||
{
|
||||
return float(_calValues.Heater.Pmax) * 0.1f;
|
||||
return float(Pmax) * 0.1f;
|
||||
}
|
||||
|
||||
unsigned short
|
||||
CHeaterStorage::getFmin()
|
||||
{
|
||||
return _calValues.Heater.Fmin;
|
||||
}
|
||||
|
||||
unsigned short
|
||||
CHeaterStorage::getFmax()
|
||||
{
|
||||
return _calValues.Heater.Fmax;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
CHeaterStorage::getDesiredTemperature()
|
||||
{
|
||||
return _calValues.Heater.setTemperature;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
CHeaterStorage::getThermostatMode()
|
||||
{
|
||||
return _calValues.Heater.ThermostatMode;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
CHeaterStorage::getThermostatMethodMode()
|
||||
{
|
||||
return _calValues.Options.ThermostatMethod & 0x03;
|
||||
}
|
||||
|
||||
float
|
||||
CHeaterStorage::getThermostatMethodWindow()
|
||||
{
|
||||
return float((_calValues.Options.ThermostatMethod >> 2) & 0x3f) * 0.1f; // top 5 bits / 10, then / 2
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setPmin(float val)
|
||||
sHeaterTuning::setPmin(float val)
|
||||
{
|
||||
uint8_t cVal = (uint8_t)(val * 10.f + 0.5f);
|
||||
_calValues.Heater.Pmin = cVal;
|
||||
Pmin = cVal;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setPmax(float val)
|
||||
sHeaterTuning::setPmax(float val)
|
||||
{
|
||||
uint8_t cVal = (uint8_t)(val * 10.f + 0.5f);
|
||||
_calValues.Heater.Pmax = cVal;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setFmin(unsigned short val)
|
||||
{
|
||||
_calValues.Heater.Fmin = val;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setFmax(unsigned short val)
|
||||
{
|
||||
_calValues.Heater.Fmax = val;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setDesiredTemperature(unsigned char val)
|
||||
{
|
||||
_calValues.Heater.setTemperature = val;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setThermostatMode(unsigned char val)
|
||||
{
|
||||
_calValues.Heater.ThermostatMode = val;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setThermostatMethodMode(unsigned char val)
|
||||
{
|
||||
_calValues.Options.ThermostatMethod &= ~0x03;
|
||||
_calValues.Options.ThermostatMethod |= (val & 0x03);
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setThermostatMethodWindow(float val)
|
||||
{
|
||||
_calValues.Options.ThermostatMethod &= 0x03;
|
||||
int nVal = int(val * 10 + 0.5);
|
||||
_calValues.Options.ThermostatMethod |= ((nVal & 0x3F) << 2);
|
||||
Pmax = cVal;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CHeaterStorage::setSystemVoltage(float fVal)
|
||||
sHeaterTuning::setSysVoltage(float fVal)
|
||||
{
|
||||
int val = int(fVal * 10.0);
|
||||
if(val == 120 || val == 240) {
|
||||
_calValues.Heater.sysVoltage = val;
|
||||
sysVoltage = val;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char
|
||||
CHeaterStorage::getSysVoltage()
|
||||
{
|
||||
return _calValues.Heater.sysVoltage;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setFanSensor(unsigned char val)
|
||||
{
|
||||
if(val == 2)
|
||||
_calValues.Heater.fanSensor = 2;
|
||||
else
|
||||
_calValues.Heater.fanSensor = 1;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
CHeaterStorage::getFanSensor()
|
||||
{
|
||||
return _calValues.Heater.fanSensor;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setGlowDrive(unsigned char val)
|
||||
{
|
||||
if(val >=1 && val <= 6)
|
||||
_calValues.Heater.glowDrive = val;
|
||||
else
|
||||
_calValues.Heater.glowDrive = 5;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
CHeaterStorage::getGlowDrive()
|
||||
{
|
||||
return _calValues.Heater.glowDrive;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::getTimerInfo(int idx, sTimer& timerInfo)
|
||||
|
@ -219,117 +110,42 @@ CHeaterStorage::setTimerInfo(int idx, const sTimer& timerInfo)
|
|||
}
|
||||
}
|
||||
|
||||
long
|
||||
CHeaterStorage::getDimTime()
|
||||
{
|
||||
return _calValues.Options.dimTime;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setDimTime(long val)
|
||||
{
|
||||
_calValues.Options.dimTime = val;
|
||||
}
|
||||
|
||||
long
|
||||
CHeaterStorage::getMenuTimeout()
|
||||
{
|
||||
return _calValues.Options.menuTimeout;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setMenuTimeout(long val)
|
||||
{
|
||||
_calValues.Options.menuTimeout = val;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
CHeaterStorage::getDegFMode()
|
||||
{
|
||||
return _calValues.Options.degF;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setDegFMode(unsigned char val)
|
||||
{
|
||||
_calValues.Options.degF = val;
|
||||
save();
|
||||
}
|
||||
|
||||
unsigned char
|
||||
CHeaterStorage::getWifiEnabled()
|
||||
{
|
||||
return _calValues.Options.enableWifi;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setWifiEnabled(unsigned char val)
|
||||
{
|
||||
_calValues.Options.enableWifi = val;
|
||||
save();
|
||||
}
|
||||
|
||||
unsigned char
|
||||
CHeaterStorage::getOTAEnabled()
|
||||
{
|
||||
return _calValues.Options.enableOTA;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setOTAEnabled(unsigned char val)
|
||||
{
|
||||
_calValues.Options.enableOTA = val;
|
||||
save();
|
||||
}
|
||||
|
||||
const sCyclicThermostat&
|
||||
CHeaterStorage::getCyclicMode() const
|
||||
{
|
||||
return _calValues.Options.cyclic;
|
||||
return _calValues.userSettings.cyclic;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setCyclicMode(const sCyclicThermostat& val)
|
||||
{
|
||||
_calValues.Options.cyclic = val;
|
||||
_calValues.userSettings.cyclic = val;
|
||||
save();
|
||||
}
|
||||
|
||||
const sGPIOparams&
|
||||
CHeaterStorage::getGPIOparams() const
|
||||
{
|
||||
return _calValues.Options.GPIO;
|
||||
return _calValues.userSettings.GPIO;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setGPIOparams(const sGPIOparams& params)
|
||||
{
|
||||
_calValues.Options.GPIO = params;
|
||||
_calValues.userSettings.GPIO = params;
|
||||
}
|
||||
|
||||
|
||||
uint16_t
|
||||
CHeaterStorage::getFrameRate()
|
||||
{
|
||||
return _calValues.Options.FrameRate;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setFrameRate(uint16_t val)
|
||||
{
|
||||
_calValues.Options.FrameRate = val;
|
||||
}
|
||||
|
||||
const sHomeMenuActions&
|
||||
CHeaterStorage::getHomeMenu() const
|
||||
{
|
||||
return _calValues.Options.HomeMenu;
|
||||
return _calValues.userSettings.HomeMenu;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setHomeMenu(const sHomeMenuActions& val)
|
||||
{
|
||||
_calValues.Options.HomeMenu = val;
|
||||
_calValues.userSettings.HomeMenu = val;
|
||||
}
|
||||
|
||||
// MQTT parameter read/save
|
||||
|
@ -358,6 +174,30 @@ CHeaterStorage::setCredentials(const sCredentials& info)
|
|||
_calValues.Credentials = info;
|
||||
}
|
||||
|
||||
const sUserSettings&
|
||||
CHeaterStorage::getUserSettings() const
|
||||
{
|
||||
return _calValues.userSettings;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setUserSettings(const sUserSettings& info) {
|
||||
_calValues.userSettings = info;
|
||||
}
|
||||
|
||||
const sHeaterTuning&
|
||||
CHeaterStorage::getHeaterTuning() const
|
||||
{
|
||||
return _calValues.heaterTuning;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setHeaterTuning(const sHeaterTuning& info)
|
||||
{
|
||||
_calValues.heaterTuning = info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// ESP32
|
||||
|
@ -385,11 +225,11 @@ void
|
|||
CESP32HeaterStorage::load()
|
||||
{
|
||||
DebugPort.println("Reading from NV storage");
|
||||
_calValues.Heater.load();
|
||||
_calValues.heaterTuning.load();
|
||||
for(int i=0; i<14; i++) {
|
||||
_calValues.timer[i].load();
|
||||
}
|
||||
_calValues.Options.load();
|
||||
_calValues.userSettings.load();
|
||||
_calValues.MQTT.load();
|
||||
_calValues.Credentials.load();
|
||||
}
|
||||
|
@ -398,17 +238,17 @@ void
|
|||
CESP32HeaterStorage::save()
|
||||
{
|
||||
DebugPort.println("Saving to NV storage");
|
||||
_calValues.Heater.save();
|
||||
_calValues.heaterTuning.save();
|
||||
for(int i=0; i<14; i++) {
|
||||
_calValues.timer[i].save();
|
||||
}
|
||||
_calValues.Options.save();
|
||||
_calValues.userSettings.save();
|
||||
_calValues.MQTT.save();
|
||||
_calValues.Credentials.save();
|
||||
}
|
||||
|
||||
void
|
||||
sHeater::load()
|
||||
sHeaterTuning::load()
|
||||
{
|
||||
// section for heater calibration params
|
||||
// **** MAX LENGTH is 15 for names ****
|
||||
|
@ -417,8 +257,6 @@ sHeater::load()
|
|||
validatedLoad("maxPump", Pmax, 45, u8inBounds, 4, 150);
|
||||
validatedLoad("minFan", Fmin, 1500, u16inBounds, 100, 5000);
|
||||
validatedLoad("maxFan", Fmax, 4500, u16inBounds, 100, 6000);
|
||||
validatedLoad("thermostat", ThermostatMode, 1, u8inBounds, 0, 1);
|
||||
validatedLoad("setTemperature", setTemperature, 22, u8inBounds, 0, 40);
|
||||
validatedLoad("systemVoltage", sysVoltage, 120, u8Match2, 120, 240);
|
||||
validatedLoad("fanSensor", fanSensor, 1, u8inBounds, 1, 2);
|
||||
validatedLoad("glowDrive", glowDrive, 5, u8inBounds, 1, 6);
|
||||
|
@ -426,7 +264,7 @@ sHeater::load()
|
|||
}
|
||||
|
||||
void
|
||||
sHeater::save()
|
||||
sHeaterTuning::save()
|
||||
{
|
||||
// section for heater calibration params
|
||||
// **** MAX LENGTH is 15 for names ****
|
||||
|
@ -435,8 +273,6 @@ sHeater::save()
|
|||
preferences.putUChar("maxPump", Pmax);
|
||||
preferences.putUShort("minFan", Fmin);
|
||||
preferences.putUShort("maxFan", Fmax);
|
||||
preferences.putUChar("thermostat", ThermostatMode);
|
||||
preferences.putUChar("setTemperature", setTemperature);
|
||||
preferences.putUChar("systemVoltage", sysVoltage);
|
||||
preferences.putUChar("fanSensor", fanSensor);
|
||||
preferences.putUChar("glowDrive", glowDrive);
|
||||
|
@ -478,14 +314,24 @@ sTimer::save()
|
|||
}
|
||||
|
||||
void
|
||||
sBTCoptions::load()
|
||||
sUserSettings::load()
|
||||
{
|
||||
// **** MAX LENGTH is 15 for names ****
|
||||
preferences.begin("user", false);
|
||||
validatedLoad("dimTime", dimTime, 60000, s32inBounds, -600000, 600000);
|
||||
validatedLoad("menuTimeout", menuTimeout, 60000, s32inBounds, 0, 300000);
|
||||
validatedLoad("dimTime", dimTime, 60000, -600000, 600000);
|
||||
validatedLoad("menuTimeout", menuTimeout, 60000, 0, 300000);
|
||||
validatedLoad("degF", degF, 0, u8inBounds, 0, 1);
|
||||
validatedLoad("thermoMethod", ThermostatMethod, (10 << 2), u8inBounds, 0, 2, 0x03);
|
||||
validatedLoad("thermostat", useThermostat, 1, u8inBounds, 0, 1);
|
||||
validatedLoad("setTemperature", desiredTemperature, 22, u8inBounds, 0, 40);
|
||||
validatedLoad("thermoMethod", ThermostatMethod, 0, u8inBounds, 0, 255);
|
||||
// catch and migrate old combined method & window
|
||||
if(ThermostatMethod & 0xFC) {
|
||||
float defVal = float(ThermostatMethod>>2) * 0.1f;
|
||||
validatedLoad("thermoWindow", ThermostatWindow, defVal, 0.2f, 10.0f);
|
||||
preferences.putUChar("thermoMethod", ThermostatMethod & 0x03); // strip old window
|
||||
}
|
||||
validatedLoad("thermoWindow", ThermostatWindow, 1.0f, 0.2f, 10.f);
|
||||
DebugPort.printf("2) Window = %f\r\n", ThermostatWindow);
|
||||
validatedLoad("enableWifi", enableWifi, 1, u8inBounds, 0, 1);
|
||||
validatedLoad("enableOTA", enableOTA, 1, u8inBounds, 0, 1);
|
||||
validatedLoad("cyclicStop", cyclic.Stop, 0, s8inBounds, 0, 10);
|
||||
|
@ -494,7 +340,7 @@ sBTCoptions::load()
|
|||
validatedLoad("GPIOinMode", tVal, 0, u8inBounds, 0, 3); GPIO.inMode = (GPIOinModes)tVal;
|
||||
validatedLoad("GPIOoutMode", tVal, 0, u8inBounds, 0, 2); GPIO.outMode = (GPIOoutModes)tVal;
|
||||
validatedLoad("GPIOalgMode", tVal, 0, u8inBounds, 0, 2); GPIO.algMode = (GPIOalgModes)tVal;
|
||||
validatedLoad("MenuonTimeout", HomeMenu.onTimeout, 0, u8inBounds, 0, 3);
|
||||
validatedLoad("MenuOnTimeout", HomeMenu.onTimeout, 0, u8inBounds, 0, 3);
|
||||
validatedLoad("MenuonStart", HomeMenu.onStart, 0, u8inBounds, 0, 3);
|
||||
validatedLoad("MenuonStop", HomeMenu.onStop, 0, u8inBounds, 0, 3);
|
||||
validatedLoad("FrameRate", FrameRate, 1000, u16inBounds, 300, 1500);
|
||||
|
@ -502,14 +348,17 @@ sBTCoptions::load()
|
|||
}
|
||||
|
||||
void
|
||||
sBTCoptions::save()
|
||||
sUserSettings::save()
|
||||
{
|
||||
// **** MAX LENGTH is 15 for names ****
|
||||
preferences.begin("user", false);
|
||||
preferences.putLong("dimTime", dimTime);
|
||||
preferences.putLong("menuTimeout", menuTimeout);
|
||||
preferences.putUChar("thermostat", useThermostat);
|
||||
preferences.putUChar("setTemperature", desiredTemperature);
|
||||
preferences.putUChar("degF", degF);
|
||||
preferences.putUChar("thermoMethod", ThermostatMethod);
|
||||
preferences.putFloat("thermoWindow", ThermostatWindow);
|
||||
preferences.putUChar("enableWifi", enableWifi);
|
||||
preferences.putUChar("enableOTA", enableOTA);
|
||||
preferences.putChar("cyclicStop", cyclic.Stop);
|
||||
|
@ -586,3 +435,12 @@ sCredentials::valid()
|
|||
return true;
|
||||
}
|
||||
|
||||
void toggle(bool& ref)
|
||||
{
|
||||
ref = !ref;
|
||||
}
|
||||
|
||||
void toggle(uint8_t& ref)
|
||||
{
|
||||
ref = ref ? 0 : 1;
|
||||
}
|
||||
|
|
|
@ -27,14 +27,15 @@
|
|||
|
||||
#include "../RTC/Timers.h" // for sTimer
|
||||
|
||||
void toggle(bool& ref);
|
||||
void toggle(uint8_t& ref);
|
||||
|
||||
struct sHeater : public CESP32_NVStorage {
|
||||
|
||||
struct sHeaterTuning : public CESP32_NVStorage {
|
||||
uint8_t Pmin;
|
||||
uint8_t Pmax;
|
||||
uint16_t Fmin;
|
||||
uint16_t Fmax;
|
||||
uint8_t ThermostatMode;
|
||||
uint8_t setTemperature;
|
||||
uint8_t sysVoltage;
|
||||
uint8_t fanSensor;
|
||||
uint8_t glowDrive;
|
||||
|
@ -45,8 +46,6 @@ struct sHeater : public CESP32_NVStorage {
|
|||
retval &= Pmax < 150;
|
||||
retval &= Fmin < 5000;
|
||||
retval &= Fmax < 6000;
|
||||
retval &= ThermostatMode < 2;
|
||||
retval &= setTemperature < 40;
|
||||
retval &= sysVoltage == 120 || sysVoltage == 240;
|
||||
retval &= fanSensor == 1 || fanSensor == 2;
|
||||
retval &= glowDrive >= 1 && glowDrive <= 6;
|
||||
|
@ -57,26 +56,27 @@ struct sHeater : public CESP32_NVStorage {
|
|||
Pmax = 45;
|
||||
Fmin = 1500;
|
||||
Fmax = 4500;
|
||||
ThermostatMode = 1;
|
||||
setTemperature = 23;
|
||||
sysVoltage = 120;
|
||||
fanSensor = 1;
|
||||
glowDrive = 5;
|
||||
};
|
||||
void load();
|
||||
void save();
|
||||
sHeater& operator=(const sHeater& rhs) {
|
||||
sHeaterTuning& operator=(const sHeaterTuning& rhs) {
|
||||
Pmin = rhs.Pmin;
|
||||
Pmax = rhs.Pmax;
|
||||
Fmin = rhs.Fmin;
|
||||
Fmax = rhs.Fmax;
|
||||
ThermostatMode = rhs.ThermostatMode;
|
||||
setTemperature = rhs.setTemperature;
|
||||
sysVoltage = rhs.sysVoltage;
|
||||
fanSensor = rhs.fanSensor;
|
||||
glowDrive = rhs.glowDrive;
|
||||
return *this;
|
||||
}
|
||||
float getPmin() const;
|
||||
float getPmax() const;
|
||||
void setPmin(float val);
|
||||
void setPmax(float val);
|
||||
void setSysVoltage(float val);
|
||||
};
|
||||
|
||||
struct sHomeMenuActions {
|
||||
|
@ -178,11 +178,14 @@ struct sMQTTparams : public CESP32_NVStorage {
|
|||
bool valid();
|
||||
};
|
||||
|
||||
struct sBTCoptions : public CESP32_NVStorage {
|
||||
struct sUserSettings : public CESP32_NVStorage {
|
||||
long dimTime;
|
||||
long menuTimeout;
|
||||
uint8_t desiredTemperature;
|
||||
uint8_t degF;
|
||||
uint8_t ThermostatMethod; // 0: standard heater, 1: Narrow Hysterisis, 2:Managed Hz mode
|
||||
float ThermostatWindow;
|
||||
uint8_t useThermostat;
|
||||
uint8_t enableWifi;
|
||||
uint8_t enableOTA;
|
||||
uint16_t FrameRate;
|
||||
|
@ -194,8 +197,11 @@ struct sBTCoptions : public CESP32_NVStorage {
|
|||
bool retval = true;
|
||||
retval &= (dimTime >= -600000) && (dimTime < 600000); // +/- 10 mins
|
||||
retval &= (menuTimeout >= 0) && (menuTimeout < 300000); // 5 mins
|
||||
retval &= desiredTemperature < 40;
|
||||
retval &= (degF == 0) || (degF == 1);
|
||||
retval &= (ThermostatMethod & 0x03) < 3; // only modes 0, 1 or 2
|
||||
retval &= (ThermostatWindow >= 0.2f) && (ThermostatWindow <= 10.f);
|
||||
retval &= useThermostat < 2;
|
||||
retval &= (enableWifi == 0) || (enableWifi == 1);
|
||||
retval &= (enableOTA == 0) || (enableOTA == 1);
|
||||
retval &= GPIO.inMode < 4;
|
||||
|
@ -208,8 +214,11 @@ struct sBTCoptions : public CESP32_NVStorage {
|
|||
void init() {
|
||||
dimTime = 60000;
|
||||
menuTimeout = 60000;
|
||||
desiredTemperature = 23;
|
||||
degF = 0;
|
||||
ThermostatMethod = 0;
|
||||
ThermostatWindow = 1.0;
|
||||
useThermostat = 1;
|
||||
enableWifi = 1;
|
||||
enableOTA = 1;
|
||||
GPIO.inMode = GPIOinNone;
|
||||
|
@ -221,11 +230,14 @@ struct sBTCoptions : public CESP32_NVStorage {
|
|||
};
|
||||
void load();
|
||||
void save();
|
||||
sBTCoptions& operator=(const sBTCoptions& rhs) {
|
||||
sUserSettings& operator=(const sUserSettings& rhs) {
|
||||
dimTime = rhs.dimTime;
|
||||
menuTimeout = rhs.menuTimeout;
|
||||
desiredTemperature = rhs.desiredTemperature;
|
||||
degF = rhs.degF;
|
||||
ThermostatMethod = rhs.ThermostatMethod;
|
||||
ThermostatWindow = rhs.ThermostatWindow;
|
||||
useThermostat = rhs.useThermostat;
|
||||
enableWifi = rhs.enableWifi;
|
||||
enableOTA = rhs.enableOTA;
|
||||
GPIO.inMode = rhs.GPIO.inMode;
|
||||
|
@ -238,19 +250,18 @@ struct sBTCoptions : public CESP32_NVStorage {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// the actual data stored to NV memory
|
||||
struct sNVStore {
|
||||
sHeater Heater;
|
||||
sBTCoptions Options;
|
||||
sHeaterTuning heaterTuning;
|
||||
sUserSettings userSettings;
|
||||
sTimer timer[14];
|
||||
sMQTTparams MQTT;
|
||||
sCredentials Credentials;
|
||||
bool valid();
|
||||
void init();
|
||||
sNVStore& operator=(const sNVStore& rhs) {
|
||||
Heater = rhs.Heater;
|
||||
Options = rhs.Options;
|
||||
heaterTuning = rhs.heaterTuning;
|
||||
userSettings = rhs.userSettings;
|
||||
for(int i = 0; i < 14; i++)
|
||||
timer[i] = rhs.timer[i];
|
||||
MQTT = rhs.MQTT;
|
||||
|
@ -264,68 +275,38 @@ class CHeaterStorage /*: public CESP32_NVStorage*/ {
|
|||
protected:
|
||||
sNVStore _calValues;
|
||||
public:
|
||||
CHeaterStorage();
|
||||
virtual ~CHeaterStorage() {};
|
||||
CHeaterStorage();
|
||||
virtual ~CHeaterStorage() {};
|
||||
|
||||
// TODO: These are only here to allow building without fully
|
||||
// fleshing out NV storage for Due, Mega etc
|
||||
// these should be removed once complete (pure virtual)
|
||||
virtual void init() {};
|
||||
virtual void load() {};
|
||||
virtual void save() {};
|
||||
// TODO: These are only here to allow building without fully
|
||||
// fleshing out NV storage for Due, Mega etc
|
||||
// these should be removed once complete (pure virtual)
|
||||
virtual void init() {};
|
||||
virtual void load() {};
|
||||
virtual void save() {};
|
||||
|
||||
|
||||
float getPmin();
|
||||
float getPmax();
|
||||
unsigned short getFmin();
|
||||
unsigned short getFmax();
|
||||
unsigned char getDesiredTemperature();
|
||||
unsigned char getThermostatMode();
|
||||
unsigned char getThermostatMethodMode();
|
||||
float getThermostatMethodWindow();
|
||||
unsigned char getSysVoltage();
|
||||
unsigned char getFanSensor();
|
||||
unsigned char getGlowDrive();
|
||||
long getDimTime();
|
||||
long getMenuTimeout();
|
||||
unsigned char getDegFMode();
|
||||
unsigned char getWifiEnabled();
|
||||
unsigned char getOTAEnabled();
|
||||
const sCyclicThermostat& getCyclicMode() const;
|
||||
const sMQTTparams& getMQTTinfo() const;
|
||||
const sGPIOparams& getGPIOparams() const;
|
||||
uint16_t getFrameRate();
|
||||
const sHomeMenuActions& getHomeMenu() const;
|
||||
const sCredentials& getCredentials() const;
|
||||
const sCyclicThermostat& getCyclicMode() const;
|
||||
const sMQTTparams& getMQTTinfo() const;
|
||||
const sGPIOparams& getGPIOparams() const;
|
||||
const sHomeMenuActions& getHomeMenu() const;
|
||||
const sCredentials& getCredentials() const;
|
||||
const sUserSettings& getUserSettings() const;
|
||||
const sHeaterTuning& getHeaterTuning() const;
|
||||
|
||||
void setPmin(float);
|
||||
void setPmax(float);
|
||||
void setFmin(unsigned short val);
|
||||
void setFmax(unsigned short val);
|
||||
void setDesiredTemperature(unsigned char val);
|
||||
void setThermostatMode(unsigned char val);
|
||||
void setThermostatMethodMode(unsigned char val);
|
||||
void setThermostatMethodWindow(float val);
|
||||
void setSystemVoltage(float fVal);
|
||||
void setFanSensor(unsigned char val);
|
||||
void setGlowDrive(unsigned char val);
|
||||
void setDimTime(long val);
|
||||
void setMenuTimeout(long val);
|
||||
void setDegFMode(unsigned char val);
|
||||
void setWifiEnabled(unsigned char val);
|
||||
void setOTAEnabled(unsigned char val);
|
||||
void setCyclicMode(const sCyclicThermostat& val);
|
||||
void setGPIOparams(const sGPIOparams& params);
|
||||
void setFrameRate(uint16_t val);
|
||||
void setHomeMenu(const sHomeMenuActions& val);
|
||||
void setCyclicMode(const sCyclicThermostat& val);
|
||||
void setGPIOparams(const sGPIOparams& params);
|
||||
void setHomeMenu(const sHomeMenuActions& val);
|
||||
|
||||
void getTimerInfo(int idx, sTimer& timerInfo);
|
||||
void setTimerInfo(int idx, const sTimer& timerInfo);
|
||||
void setMQTTinfo(const sMQTTparams& info);
|
||||
void setCredentials(const sCredentials& info);
|
||||
CHeaterStorage& operator=(const CHeaterStorage& rhs) {
|
||||
_calValues = rhs._calValues;
|
||||
}
|
||||
void getTimerInfo(int idx, sTimer& timerInfo);
|
||||
void setTimerInfo(int idx, const sTimer& timerInfo);
|
||||
void setMQTTinfo(const sMQTTparams& info);
|
||||
void setCredentials(const sCredentials& info);
|
||||
CHeaterStorage& operator=(const CHeaterStorage& rhs) {
|
||||
_calValues = rhs._calValues;
|
||||
}
|
||||
void setUserSettings(const sUserSettings& info);
|
||||
void setHeaterTuning(const sHeaterTuning& info);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -194,7 +194,9 @@ void doWiFiManager()
|
|||
|
||||
void wifiDisable(long rebootDelay)
|
||||
{
|
||||
NVstore.setWifiEnabled(0);
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
settings.enableWifi = 0;
|
||||
NVstore.setUserSettings(settings);
|
||||
NVstore.save();
|
||||
|
||||
DebugPort.println("*** Disabling WiFi ***");
|
||||
|
@ -211,7 +213,9 @@ void wifiEnterConfigPortal(bool state, bool erase, long rebootDelay)
|
|||
{
|
||||
wm.disconnect();
|
||||
|
||||
NVstore.setWifiEnabled(1);
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
settings.enableWifi = 1;
|
||||
NVstore.setUserSettings(settings);
|
||||
NVstore.save();
|
||||
|
||||
prepBootIntoConfigPortal(state);
|
||||
|
@ -246,7 +250,10 @@ void wifiFactoryDefault()
|
|||
{
|
||||
wm.resetSettings();
|
||||
prepBootIntoConfigPortal(false);
|
||||
NVstore.setWifiEnabled(1);
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
settings.enableWifi = 1;
|
||||
NVstore.setUserSettings(settings);
|
||||
NVstore.save();
|
||||
}
|
||||
|
||||
// callback is invoked by WiFiManager after new credentials are saved and verified
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
|
||||
esp32FOTA FOTA("afterburner-fota-http", int(getVersion()*1000));
|
||||
unsigned long FOTAtime = millis() + 60000; // initially check in a minutes time
|
||||
unsigned long FOTAtime = millis() + 60000; // initial check in a minutes time
|
||||
int FOTAauth = 0;
|
||||
|
||||
#include <esp_int_wdt.h>
|
||||
|
@ -42,7 +42,6 @@ void hard_restart() {
|
|||
}
|
||||
|
||||
void initOTA(){
|
||||
FOTA.checkURL = "http://www.mrjones.id.au/afterburner/fota/fota.json";
|
||||
ArduinoOTA.setHostname("AfterburnerOTA");
|
||||
|
||||
ArduinoOTA
|
||||
|
@ -96,9 +95,12 @@ void DoOTA()
|
|||
// if so, it can download and implant using OTA and become effective next reboot!
|
||||
long tDelta = millis() - FOTAtime;
|
||||
if(tDelta > 0) {
|
||||
// FOTAtime = millis() + 600000; // 10 minutes
|
||||
FOTAtime = millis() + 3600000; // 1 hour
|
||||
// FOTAtime = millis() + 6000; // 6 seconds
|
||||
// FOTAtime = millis() + 60000; // 60 seconds
|
||||
FOTAtime = millis() + 600000; // 10 minutes
|
||||
// FOTAtime = millis() + 3600000; // 1 hour
|
||||
if ((WiFi.status() == WL_CONNECTED)) { // bug workaround in FOTA where execHTTPcheck does not return false in this condition
|
||||
FOTA.checkURL = "http://www.mrjones.id.au/afterburner/fota/fota.json";
|
||||
DebugPort.println("Checking for new firmware...");
|
||||
if(FOTA.execHTTPcheck()) {
|
||||
DebugPort.println("New firmware available on web server!");
|
||||
|
@ -109,6 +111,9 @@ void DoOTA()
|
|||
else
|
||||
FOTAauth = 1; // flag that new firmware is available
|
||||
}
|
||||
else {
|
||||
FOTAauth = 0; // cancel
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue