2018-11-26 11:58:15 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the "bluetoothheater" distribution
|
|
|
|
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-12-16 07:34:39 +00:00
|
|
|
#include <Arduino.h>
|
2018-10-20 07:11:23 +00:00
|
|
|
#include "NVStorage.h"
|
2018-12-12 09:47:20 +00:00
|
|
|
#include "DebugPort.h"
|
2019-04-12 23:18:07 +00:00
|
|
|
#include <driver/adc.h>
|
2018-10-20 07:11:23 +00:00
|
|
|
|
2019-01-11 23:33:45 +00:00
|
|
|
|
2018-12-07 11:16:04 +00:00
|
|
|
bool
|
|
|
|
sNVStore::valid()
|
|
|
|
{
|
|
|
|
bool retval = true;
|
2019-06-06 01:32:43 +00:00
|
|
|
retval &= heaterTuning.valid();
|
|
|
|
retval &= userSettings.valid();
|
2018-12-07 11:16:04 +00:00
|
|
|
for(int i=0; i<2; i++) {
|
2019-01-11 23:33:45 +00:00
|
|
|
retval &= timer[i].valid();
|
2018-12-07 11:16:04 +00:00
|
|
|
}
|
2019-05-16 11:12:29 +00:00
|
|
|
retval &= MQTT.valid();
|
|
|
|
retval &= Credentials.valid();
|
2018-12-07 11:16:04 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sNVStore::init()
|
|
|
|
{
|
2019-06-06 01:32:43 +00:00
|
|
|
heaterTuning.init();
|
|
|
|
userSettings.init();
|
2019-06-16 10:37:25 +00:00
|
|
|
|
|
|
|
for(int i=0; i<14; i++) {
|
|
|
|
timer[i].init(i);
|
2018-12-07 11:16:04 +00:00
|
|
|
}
|
2019-06-16 10:37:25 +00:00
|
|
|
|
2019-05-16 11:12:29 +00:00
|
|
|
MQTT.init();
|
|
|
|
Credentials.init();
|
2019-07-24 20:06:47 +00:00
|
|
|
hourMeter.init();
|
2018-12-07 11:16:04 +00:00
|
|
|
}
|
2018-10-20 07:11:23 +00:00
|
|
|
|
|
|
|
CHeaterStorage::CHeaterStorage()
|
|
|
|
{
|
2019-05-16 11:12:29 +00:00
|
|
|
_calValues.init();
|
2018-10-20 07:11:23 +00:00
|
|
|
}
|
|
|
|
|
2018-11-28 11:15:23 +00:00
|
|
|
float
|
2019-06-06 01:32:43 +00:00
|
|
|
sHeaterTuning::getPmin() const
|
2018-10-20 07:11:23 +00:00
|
|
|
{
|
2019-06-06 01:32:43 +00:00
|
|
|
return float(Pmin) * 0.1f;
|
2018-10-20 07:11:23 +00:00
|
|
|
}
|
|
|
|
|
2018-11-28 11:15:23 +00:00
|
|
|
float
|
2019-06-06 01:32:43 +00:00
|
|
|
sHeaterTuning::getPmax() const
|
2018-10-20 07:11:23 +00:00
|
|
|
{
|
2019-06-06 01:32:43 +00:00
|
|
|
return float(Pmax) * 0.1f;
|
2018-10-20 07:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-03-14 10:52:59 +00:00
|
|
|
|
2018-10-20 07:11:23 +00:00
|
|
|
void
|
2019-06-06 01:32:43 +00:00
|
|
|
sHeaterTuning::setPmin(float val)
|
2018-10-20 07:11:23 +00:00
|
|
|
{
|
2019-07-03 13:01:36 +00:00
|
|
|
BOUNDSLIMIT(val, 0.4, 5.0);
|
2018-11-28 11:15:23 +00:00
|
|
|
uint8_t cVal = (uint8_t)(val * 10.f + 0.5f);
|
2019-06-06 01:32:43 +00:00
|
|
|
Pmin = cVal;
|
2018-10-20 07:11:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-06-06 01:32:43 +00:00
|
|
|
sHeaterTuning::setPmax(float val)
|
2018-10-20 07:11:23 +00:00
|
|
|
{
|
2019-07-03 13:01:36 +00:00
|
|
|
BOUNDSLIMIT(val, 1.0, 10.0);
|
2018-11-28 11:15:23 +00:00
|
|
|
uint8_t cVal = (uint8_t)(val * 10.f + 0.5f);
|
2019-06-06 01:32:43 +00:00
|
|
|
Pmax = cVal;
|
2019-03-14 10:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-11 05:40:25 +00:00
|
|
|
void
|
2019-06-06 01:32:43 +00:00
|
|
|
sHeaterTuning::setSysVoltage(float fVal)
|
2019-01-11 05:40:25 +00:00
|
|
|
{
|
|
|
|
int val = int(fVal * 10.0);
|
|
|
|
if(val == 120 || val == 240) {
|
2019-06-06 01:32:43 +00:00
|
|
|
sysVoltage = val;
|
2019-01-11 05:40:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-21 11:17:54 +00:00
|
|
|
float
|
|
|
|
sHeaterTuning::getLVC() const
|
|
|
|
{
|
|
|
|
return lowVolts * 0.1;
|
|
|
|
}
|
2019-01-19 11:05:14 +00:00
|
|
|
|
2018-12-07 04:18:24 +00:00
|
|
|
void
|
|
|
|
CHeaterStorage::getTimerInfo(int idx, sTimer& timerInfo)
|
|
|
|
{
|
2019-06-15 23:09:29 +00:00
|
|
|
if(INBOUNDS(idx, 0, 13)) {
|
2018-12-07 11:16:04 +00:00
|
|
|
timerInfo = _calValues.timer[idx];
|
2018-12-07 04:18:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CHeaterStorage::setTimerInfo(int idx, const sTimer& timerInfo)
|
|
|
|
{
|
2019-06-15 23:09:29 +00:00
|
|
|
if(INBOUNDS(idx, 0, 13)) {
|
2018-12-07 11:16:04 +00:00
|
|
|
_calValues.timer[idx] = timerInfo;
|
2018-12-07 04:18:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-19 11:38:39 +00:00
|
|
|
|
2019-05-12 10:15:18 +00:00
|
|
|
// MQTT parameter read/save
|
|
|
|
const sMQTTparams&
|
|
|
|
CHeaterStorage::getMQTTinfo() const
|
|
|
|
{
|
|
|
|
return _calValues.MQTT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CHeaterStorage::setMQTTinfo(const sMQTTparams& info)
|
|
|
|
{
|
|
|
|
_calValues.MQTT = info;
|
|
|
|
}
|
|
|
|
|
2019-05-16 11:12:29 +00:00
|
|
|
// credentials read/save
|
|
|
|
const sCredentials&
|
|
|
|
CHeaterStorage::getCredentials() const
|
|
|
|
{
|
|
|
|
return _calValues.Credentials;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CHeaterStorage::setCredentials(const sCredentials& info)
|
|
|
|
{
|
|
|
|
_calValues.Credentials = info;
|
|
|
|
}
|
|
|
|
|
2019-06-06 01:32:43 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-07-24 20:06:47 +00:00
|
|
|
const sHourMeter&
|
|
|
|
CHeaterStorage::getHourMeter() const
|
|
|
|
{
|
|
|
|
return _calValues.hourMeter;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CHeaterStorage::setHourMeter(const sHourMeter& newVals)
|
|
|
|
{
|
|
|
|
// if(_calValues.hourMeter != newVals) {
|
|
|
|
if(newVals != _calValues.hourMeter) {
|
|
|
|
_calValues.hourMeter = newVals;
|
|
|
|
_calValues.hourMeter.save();
|
|
|
|
};
|
|
|
|
}
|
2019-06-06 01:32:43 +00:00
|
|
|
|
2019-05-12 10:15:18 +00:00
|
|
|
|
2018-10-20 07:11:23 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ESP32
|
|
|
|
//
|
2019-05-11 02:18:06 +00:00
|
|
|
//#ifdef ESP32
|
2018-10-20 07:11:23 +00:00
|
|
|
|
|
|
|
CESP32HeaterStorage::CESP32HeaterStorage()
|
|
|
|
{
|
2019-05-16 11:12:29 +00:00
|
|
|
init();
|
2018-10-20 07:11:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CESP32HeaterStorage::~CESP32HeaterStorage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CESP32HeaterStorage::init()
|
|
|
|
{
|
2019-06-29 08:08:37 +00:00
|
|
|
_bShouldSave = false;
|
2019-06-16 10:37:25 +00:00
|
|
|
_calValues.init();
|
2018-10-20 07:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 23:33:45 +00:00
|
|
|
void
|
|
|
|
CESP32HeaterStorage::load()
|
2018-10-20 07:11:23 +00:00
|
|
|
{
|
2018-12-12 09:47:20 +00:00
|
|
|
DebugPort.println("Reading from NV storage");
|
2019-06-06 01:32:43 +00:00
|
|
|
_calValues.heaterTuning.load();
|
2019-02-14 10:20:15 +00:00
|
|
|
for(int i=0; i<14; i++) {
|
2019-05-16 11:12:29 +00:00
|
|
|
_calValues.timer[i].load();
|
2018-12-07 11:16:04 +00:00
|
|
|
}
|
2019-06-06 01:32:43 +00:00
|
|
|
_calValues.userSettings.load();
|
2019-05-16 11:12:29 +00:00
|
|
|
_calValues.MQTT.load();
|
|
|
|
_calValues.Credentials.load();
|
2018-10-20 07:11:23 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 23:33:45 +00:00
|
|
|
void
|
2019-06-29 08:08:37 +00:00
|
|
|
CESP32HeaterStorage::doSave()
|
2018-10-20 07:11:23 +00:00
|
|
|
{
|
2019-06-29 08:08:37 +00:00
|
|
|
if(_bShouldSave) {
|
|
|
|
_bShouldSave = false;
|
2018-12-12 09:47:20 +00:00
|
|
|
DebugPort.println("Saving to NV storage");
|
2019-06-06 01:32:43 +00:00
|
|
|
_calValues.heaterTuning.save();
|
2019-02-14 10:20:15 +00:00
|
|
|
for(int i=0; i<14; i++) {
|
2019-05-16 11:12:29 +00:00
|
|
|
_calValues.timer[i].save();
|
2019-01-11 23:33:45 +00:00
|
|
|
}
|
2019-06-06 01:32:43 +00:00
|
|
|
_calValues.userSettings.save();
|
2019-05-16 11:12:29 +00:00
|
|
|
_calValues.MQTT.save();
|
|
|
|
_calValues.Credentials.save();
|
2019-01-11 23:33:45 +00:00
|
|
|
}
|
2019-06-29 08:08:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CESP32HeaterStorage::save()
|
|
|
|
{
|
|
|
|
_bShouldSave = true; // queue request to save to NV
|
|
|
|
}
|
2019-01-11 23:33:45 +00:00
|
|
|
|
|
|
|
void
|
2019-06-06 01:32:43 +00:00
|
|
|
sHeaterTuning::load()
|
2019-01-11 23:33:45 +00:00
|
|
|
{
|
|
|
|
// section for heater calibration params
|
2019-05-16 11:12:29 +00:00
|
|
|
// **** MAX LENGTH is 15 for names ****
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.begin("Calibration", false);
|
2019-05-16 11:12:29 +00:00
|
|
|
validatedLoad("minPump", Pmin, 14, u8inBounds, 4, 100);
|
|
|
|
validatedLoad("maxPump", Pmax, 45, u8inBounds, 4, 150);
|
|
|
|
validatedLoad("minFan", Fmin, 1500, u16inBounds, 100, 5000);
|
|
|
|
validatedLoad("maxFan", Fmax, 4500, u16inBounds, 100, 6000);
|
|
|
|
validatedLoad("systemVoltage", sysVoltage, 120, u8Match2, 120, 240);
|
|
|
|
validatedLoad("fanSensor", fanSensor, 1, u8inBounds, 1, 2);
|
|
|
|
validatedLoad("glowDrive", glowDrive, 5, u8inBounds, 1, 6);
|
2019-07-21 11:17:54 +00:00
|
|
|
if(sysVoltage == 120)
|
2019-07-22 20:15:18 +00:00
|
|
|
validatedLoad("lowVolts", lowVolts, 115, u8inBoundsOrZero, 100, 125);
|
2019-07-21 11:17:54 +00:00
|
|
|
else
|
2019-07-22 20:15:18 +00:00
|
|
|
validatedLoad("lowVolts", lowVolts, 230, u8inBoundsOrZero, 200, 250);
|
2019-07-18 12:28:40 +00:00
|
|
|
validatedLoad("pumpCal", pumpCal, 0.02, 0.001, 1);
|
2019-07-21 11:17:54 +00:00
|
|
|
validatedLoad("tempOfs", tempOfs, 0.0, -10.0, +10.0);
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-06-06 01:32:43 +00:00
|
|
|
sHeaterTuning::save()
|
2019-01-11 23:33:45 +00:00
|
|
|
{
|
|
|
|
// section for heater calibration params
|
2019-05-16 11:12:29 +00:00
|
|
|
// **** MAX LENGTH is 15 for names ****
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.begin("Calibration", false);
|
2019-05-16 11:12:29 +00:00
|
|
|
preferences.putUChar("minPump", Pmin);
|
|
|
|
preferences.putUChar("maxPump", Pmax);
|
|
|
|
preferences.putUShort("minFan", Fmin);
|
|
|
|
preferences.putUShort("maxFan", Fmax);
|
|
|
|
preferences.putUChar("systemVoltage", sysVoltage);
|
|
|
|
preferences.putUChar("fanSensor", fanSensor);
|
|
|
|
preferences.putUChar("glowDrive", glowDrive);
|
2019-07-21 11:17:54 +00:00
|
|
|
preferences.putUChar("lowVolts", lowVolts);
|
2019-07-18 12:28:40 +00:00
|
|
|
preferences.putFloat("pumpCal", pumpCal);
|
2019-07-21 11:17:54 +00:00
|
|
|
preferences.putFloat("tempOfs", tempOfs);
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-05-16 11:12:29 +00:00
|
|
|
sTimer::load()
|
2019-01-12 01:19:55 +00:00
|
|
|
{
|
2019-05-16 11:12:29 +00:00
|
|
|
// **** MAX LENGTH is 15 for names ****
|
2019-01-11 23:33:45 +00:00
|
|
|
char SectionName[16];
|
2019-05-16 11:12:29 +00:00
|
|
|
sprintf(SectionName, "timer%d", timerID+1);
|
2019-01-12 01:19:55 +00:00
|
|
|
preferences.begin(SectionName, false);
|
2019-05-16 11:12:29 +00:00
|
|
|
validatedLoad("startHour", start.hour, 0, s8inBounds, 0, 23);
|
|
|
|
validatedLoad("startMin", start.min, 0, s8inBounds, 0, 59);
|
|
|
|
validatedLoad("stopHour", stop.hour, 0, s8inBounds, 0, 23);
|
|
|
|
validatedLoad("stopMin", stop.min, 0, s8inBounds, 0, 59);
|
|
|
|
validatedLoad("enabled", enabled, 0, u8inBounds, 0, 255); // all 8 bits used!
|
|
|
|
validatedLoad("repeat", repeat, 0, u8inBounds, 0, 1);
|
|
|
|
validatedLoad("temperature", temperature, 22, u8inBounds, 8, 35);
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-05-16 11:12:29 +00:00
|
|
|
sTimer::save()
|
2019-01-11 23:33:45 +00:00
|
|
|
{
|
2019-05-16 11:12:29 +00:00
|
|
|
// **** MAX LENGTH is 15 for names ****
|
2019-01-11 23:33:45 +00:00
|
|
|
char SectionName[16];
|
2019-05-16 11:12:29 +00:00
|
|
|
sprintf(SectionName, "timer%d", timerID+1);
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.begin(SectionName, false);
|
2019-05-16 11:12:29 +00:00
|
|
|
preferences.putChar("startHour", start.hour);
|
|
|
|
preferences.putChar("startMin", start.min);
|
|
|
|
preferences.putChar("stopHour", stop.hour);
|
|
|
|
preferences.putChar("stopMin", stop.min);
|
|
|
|
preferences.putUChar("enabled", enabled);
|
|
|
|
preferences.putUChar("repeat", repeat);
|
|
|
|
preferences.putUChar("temperature", temperature);
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-06-06 01:32:43 +00:00
|
|
|
sUserSettings::load()
|
2019-01-11 23:33:45 +00:00
|
|
|
{
|
2019-05-16 11:12:29 +00:00
|
|
|
// **** MAX LENGTH is 15 for names ****
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.begin("user", false);
|
2019-06-06 01:32:43 +00:00
|
|
|
validatedLoad("dimTime", dimTime, 60000, -600000, 600000);
|
|
|
|
validatedLoad("menuTimeout", menuTimeout, 60000, 0, 300000);
|
2019-05-16 11:12:29 +00:00
|
|
|
validatedLoad("degF", degF, 0, u8inBounds, 0, 1);
|
2019-06-06 01:32:43 +00:00
|
|
|
validatedLoad("thermostat", useThermostat, 1, u8inBounds, 0, 1);
|
|
|
|
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);
|
2019-05-16 11:12:29 +00:00
|
|
|
validatedLoad("enableWifi", enableWifi, 1, u8inBounds, 0, 1);
|
|
|
|
validatedLoad("enableOTA", enableOTA, 1, u8inBounds, 0, 1);
|
|
|
|
validatedLoad("cyclicStop", cyclic.Stop, 0, s8inBounds, 0, 10);
|
|
|
|
validatedLoad("cyclicStart", cyclic.Start, -1, s8inBounds, -20, 0);
|
2019-06-02 12:47:35 +00:00
|
|
|
uint8_t tVal;
|
|
|
|
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;
|
2019-06-06 01:32:43 +00:00
|
|
|
validatedLoad("MenuOnTimeout", HomeMenu.onTimeout, 0, u8inBounds, 0, 3);
|
2019-05-16 11:12:29 +00:00
|
|
|
validatedLoad("MenuonStart", HomeMenu.onStart, 0, u8inBounds, 0, 3);
|
|
|
|
validatedLoad("MenuonStop", HomeMenu.onStop, 0, u8inBounds, 0, 3);
|
|
|
|
validatedLoad("FrameRate", FrameRate, 1000, u16inBounds, 300, 1500);
|
2019-06-15 23:09:29 +00:00
|
|
|
validatedLoad("JSONsingle", JSON.singleElement, 0, u8inBounds, 0, 1);
|
|
|
|
validatedLoad("JSONLF", JSON.LF, 0, u8inBounds, 0, 1);
|
|
|
|
validatedLoad("JSONpad", JSON.padding, 0, u8inBounds, 0, 1);
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-06-06 01:32:43 +00:00
|
|
|
sUserSettings::save()
|
2019-01-11 23:33:45 +00:00
|
|
|
{
|
2019-05-16 11:12:29 +00:00
|
|
|
// **** MAX LENGTH is 15 for names ****
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.begin("user", false);
|
2019-05-16 11:12:29 +00:00
|
|
|
preferences.putLong("dimTime", dimTime);
|
|
|
|
preferences.putLong("menuTimeout", menuTimeout);
|
2019-06-06 01:32:43 +00:00
|
|
|
preferences.putUChar("thermostat", useThermostat);
|
2019-05-16 11:12:29 +00:00
|
|
|
preferences.putUChar("degF", degF);
|
|
|
|
preferences.putUChar("thermoMethod", ThermostatMethod);
|
2019-06-06 01:32:43 +00:00
|
|
|
preferences.putFloat("thermoWindow", ThermostatWindow);
|
2019-05-16 11:12:29 +00:00
|
|
|
preferences.putUChar("enableWifi", enableWifi);
|
|
|
|
preferences.putUChar("enableOTA", enableOTA);
|
|
|
|
preferences.putChar("cyclicStop", cyclic.Stop);
|
|
|
|
preferences.putChar("cyclicStart",cyclic.Start);
|
2019-06-02 12:47:35 +00:00
|
|
|
preferences.putUChar("GPIOinMode", GPIO.inMode);
|
|
|
|
preferences.putUChar("GPIOoutMode", GPIO.outMode);
|
|
|
|
preferences.putUChar("GPIOalgMode", GPIO.algMode);
|
2019-05-16 11:12:29 +00:00
|
|
|
preferences.putUChar("MenuOnTimeout", HomeMenu.onTimeout);
|
|
|
|
preferences.putUChar("MenuonStart", HomeMenu.onStart);
|
|
|
|
preferences.putUChar("MenuonStop", HomeMenu.onStop);
|
|
|
|
preferences.putUShort("FrameRate", FrameRate);
|
2019-06-15 23:09:29 +00:00
|
|
|
preferences.putUChar("JSONsingle", JSON.singleElement);
|
|
|
|
preferences.putUChar("JSONLF", JSON.LF);
|
|
|
|
preferences.putUChar("JSONpad", JSON.padding);
|
2019-01-11 23:33:45 +00:00
|
|
|
preferences.end();
|
|
|
|
}
|
|
|
|
|
2019-05-12 10:15:18 +00:00
|
|
|
void
|
2019-05-16 11:12:29 +00:00
|
|
|
sMQTTparams::load()
|
2019-05-12 10:15:18 +00:00
|
|
|
{
|
2019-05-16 11:12:29 +00:00
|
|
|
// **** MAX LENGTH is 15 for names ****
|
2019-05-12 10:15:18 +00:00
|
|
|
preferences.begin("mqtt", false);
|
2019-05-16 11:12:29 +00:00
|
|
|
validatedLoad("enabled", enabled, 0, u8inBounds, 0, 1);
|
|
|
|
validatedLoad("port", port, 0, u16inBounds, 0, 0xffff);
|
|
|
|
validatedLoad("host", host, 127, "hostIP");
|
|
|
|
validatedLoad("username", username, 31, "username");
|
|
|
|
validatedLoad("password", password, 31, "password");
|
2019-05-12 10:15:18 +00:00
|
|
|
preferences.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-05-16 11:12:29 +00:00
|
|
|
sMQTTparams::save()
|
2019-05-12 10:15:18 +00:00
|
|
|
{
|
2019-05-16 11:12:29 +00:00
|
|
|
// **** MAX LENGTH is 15 for names ****
|
2019-05-12 10:15:18 +00:00
|
|
|
preferences.begin("mqtt", false);
|
2019-05-16 11:12:29 +00:00
|
|
|
preferences.putUChar("enabled", enabled);
|
|
|
|
preferences.putUShort("port", port);
|
|
|
|
preferences.putString("host", host);
|
|
|
|
preferences.putString("username", username);
|
|
|
|
preferences.putString("password", password);
|
2019-05-12 10:15:18 +00:00
|
|
|
preferences.end();
|
|
|
|
}
|
|
|
|
|
2019-05-16 11:12:29 +00:00
|
|
|
bool
|
|
|
|
sMQTTparams::valid()
|
2019-01-12 01:19:55 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-16 11:12:29 +00:00
|
|
|
void
|
|
|
|
sCredentials::load()
|
|
|
|
{
|
|
|
|
// **** MAX LENGTH is 15 for names ****
|
|
|
|
preferences.begin("credentials", false);
|
|
|
|
validatedLoad("SSID", SSID, 31, "Afterburner");
|
|
|
|
validatedLoad("APpassword", APpassword, 31, "thereisnospoon");
|
|
|
|
validatedLoad("webUpdateUser", webUpdateUsername, 31, "Afterburner");
|
|
|
|
validatedLoad("webUpdatePass", webUpdatePassword, 31, "BurnBabyBurn");
|
|
|
|
preferences.end();
|
2019-01-18 20:15:02 +00:00
|
|
|
}
|
|
|
|
|
2019-05-16 11:12:29 +00:00
|
|
|
void
|
|
|
|
sCredentials::save()
|
|
|
|
{
|
|
|
|
// **** MAX LENGTH is 15 for names ****
|
|
|
|
preferences.begin("credentials", false);
|
|
|
|
preferences.putString("SSID", SSID);
|
|
|
|
preferences.putString("APpassword", APpassword);
|
|
|
|
preferences.putString("webUpdateUser", webUpdateUsername);
|
|
|
|
preferences.putString("webUpdatePass", webUpdatePassword);
|
|
|
|
preferences.end();
|
2019-01-12 01:19:55 +00:00
|
|
|
}
|
|
|
|
|
2019-05-16 11:12:29 +00:00
|
|
|
bool
|
|
|
|
sCredentials::valid()
|
2019-01-12 01:19:55 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-06-06 01:32:43 +00:00
|
|
|
void toggle(bool& ref)
|
|
|
|
{
|
|
|
|
ref = !ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
void toggle(uint8_t& ref)
|
|
|
|
{
|
|
|
|
ref = ref ? 0 : 1;
|
|
|
|
}
|
2019-07-24 20:06:47 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
sHourMeter::save()
|
|
|
|
{
|
|
|
|
// **** MAX LENGTH is 15 for names ****
|
|
|
|
preferences.begin("hourmeter", false);
|
|
|
|
preferences.putULong("RunTime", RunTime);
|
|
|
|
preferences.putULong("GlowTime", GlowTime);
|
|
|
|
preferences.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sHourMeter::load()
|
|
|
|
{
|
|
|
|
// **** MAX LENGTH is 15 for names ****
|
|
|
|
preferences.begin("hourmeter", false);
|
|
|
|
validatedLoad("RunTime", RunTime, 0, 0, 0xffffffffL);
|
|
|
|
validatedLoad("GlowTime", GlowTime, 0, 0, 0xffffffffL);
|
|
|
|
preferences.end();
|
|
|
|
}
|