Wifi enable & OTA enable in NVram. Bug fix thermostat mode in priming menu.
OTA now shows in screen header against Wifi icon.
This commit is contained in:
parent
f4d6c3dccc
commit
a8744fdf22
|
@ -369,13 +369,17 @@ void setup() {
|
||||||
|
|
||||||
#if USE_WIFI == 1
|
#if USE_WIFI == 1
|
||||||
|
|
||||||
initWifi(WiFi_TriggerPin, FAILEDSSID, FAILEDPASSWORD);
|
if(NVstore.getWifiEnabled()) {
|
||||||
|
initWifi(WiFi_TriggerPin, FAILEDSSID, FAILEDPASSWORD);
|
||||||
#if USE_OTA == 1
|
#if USE_OTA == 1
|
||||||
initOTA();
|
if(NVstore.getOTAEnabled()) {
|
||||||
|
initOTA();
|
||||||
|
}
|
||||||
#endif // USE_OTA
|
#endif // USE_OTA
|
||||||
#if USE_WEBSERVER == 1
|
#if USE_WEBSERVER == 1
|
||||||
initWebServer();
|
initWebServer();
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
}
|
||||||
|
|
||||||
#endif // USE_WIFI
|
#endif // USE_WIFI
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,8 @@ CPrimingScreen::show()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// follow actual heater settings
|
// follow actual heater settings
|
||||||
int col = getHeaterInfo().isThermostat() ? 0 : 1;
|
// int col = getHeaterInfo().isThermostat() ? 0 : 1;
|
||||||
|
int col = getThermostatModeActive() ? 0 : 1;
|
||||||
_printInverted(border, yPos, "Thermostat", col == 0);
|
_printInverted(border, yPos, "Thermostat", col == 0);
|
||||||
_printInverted(_display.width()-border, yPos, "Fixed Hz", col == 1, eRightJustify);
|
_printInverted(_display.width()-border, yPos, "Fixed Hz", col == 1, eRightJustify);
|
||||||
}
|
}
|
||||||
|
@ -163,6 +164,7 @@ CPrimingScreen::keyHandler(uint8_t event)
|
||||||
case 1:
|
case 1:
|
||||||
_colSel = 0;
|
_colSel = 0;
|
||||||
setThermostatMode(1);
|
setThermostatMode(1);
|
||||||
|
saveNV();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
_colSel = 0;
|
_colSel = 0;
|
||||||
|
@ -183,6 +185,7 @@ CPrimingScreen::keyHandler(uint8_t event)
|
||||||
case 1:
|
case 1:
|
||||||
_colSel = 1;
|
_colSel = 1;
|
||||||
setThermostatMode(0);
|
setThermostatMode(0);
|
||||||
|
saveNV();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
_colSel = 1;
|
_colSel = 1;
|
||||||
|
@ -207,7 +210,8 @@ CPrimingScreen::keyHandler(uint8_t event)
|
||||||
if(_rowSel == 2)
|
if(_rowSel == 2)
|
||||||
_colSel = NVstore.getDegFMode();
|
_colSel = NVstore.getDegFMode();
|
||||||
if(_rowSel == 1)
|
if(_rowSel == 1)
|
||||||
_colSel = getHeaterInfo().isThermostat() ? 0 : 1;
|
// _colSel = getHeaterInfo().isThermostat() ? 0 : 1;
|
||||||
|
_colSel = getThermostatModeActive() ? 0 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// press DOWN
|
// press DOWN
|
||||||
|
@ -216,7 +220,8 @@ CPrimingScreen::keyHandler(uint8_t event)
|
||||||
LOWERLIMIT(_rowSel, 0);
|
LOWERLIMIT(_rowSel, 0);
|
||||||
_colSel = 0;
|
_colSel = 0;
|
||||||
if(_rowSel == 1)
|
if(_rowSel == 1)
|
||||||
_colSel = getHeaterInfo().isThermostat() ? 0 : 1;
|
// _colSel = getHeaterInfo().isThermostat() ? 0 : 1;
|
||||||
|
_colSel = getThermostatModeActive() ? 0 : 1;
|
||||||
if(_rowSel == 2)
|
if(_rowSel == 2)
|
||||||
_colSel = NVstore.getDegFMode();
|
_colSel = NVstore.getDegFMode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,12 @@ CScreenHeader::showWifiIcon()
|
||||||
_display.setCursor(X_WIFI_ICON+9, Y_WIFI_ICON+6);
|
_display.setCursor(X_WIFI_ICON+9, Y_WIFI_ICON+6);
|
||||||
_display.print("AP");
|
_display.print("AP");
|
||||||
}
|
}
|
||||||
|
if(NVstore.getOTAEnabled()) {
|
||||||
|
_display.fillRect(X_WIFI_ICON +11, Y_WIFI_ICON, 14, 6, BLACK);
|
||||||
|
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
||||||
|
_display.setCursor(X_WIFI_ICON+12, Y_WIFI_ICON);
|
||||||
|
_display.print("OTA");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,26 +55,31 @@ void
|
||||||
CWiFiScreen::_initUI()
|
CWiFiScreen::_initUI()
|
||||||
{
|
{
|
||||||
_rowSel = 0;
|
_rowSel = 0;
|
||||||
|
_colSel = 0;
|
||||||
|
_OTAsel = NVstore.getOTAEnabled();
|
||||||
|
_colLimit = LIMIT_LEFT; // left most selection
|
||||||
_bShowMAC = false;
|
_bShowMAC = false;
|
||||||
|
|
||||||
if(isWifiAP()) {
|
if(NVstore.getWifiEnabled()) {
|
||||||
if(isWifiConfigPortal()) {
|
if(isWifiAP()) {
|
||||||
_colSel = 0; // " WiFi: CFG AP only "
|
if(isWifiConfigPortal()) {
|
||||||
_colLimit = LIMIT_LEFT; // left most selection
|
_colSel = 0; // " WiFi: CFG AP only "
|
||||||
|
_colLimit = LIMIT_LEFT; // left most selection
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_colSel = 1; // " WiFi: AP only ";
|
||||||
|
_colLimit = LIMIT_RIGHT; // right most selection
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_colSel = 1; // " WiFi: AP only ";
|
if(isWifiConfigPortal()) {
|
||||||
_colLimit = LIMIT_RIGHT; // right most selection
|
_colSel = 2; // " WiFi: CFG STA+AP "
|
||||||
}
|
_colLimit = LIMIT_AWAY; // away from menu limits
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(isWifiConfigPortal()) {
|
_colSel = 3; // " WiFi: STA+AP ";
|
||||||
_colSel = 2; // " WiFi: CFG STA+AP "
|
_colLimit = LIMIT_RIGHT; // right most selection
|
||||||
_colLimit = LIMIT_AWAY; // away from menu limits
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
_colSel = 3; // " WiFi: STA+AP ";
|
|
||||||
_colLimit = LIMIT_RIGHT; // right most selection
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,30 +90,39 @@ CWiFiScreen::show()
|
||||||
CScreenHeader::show();
|
CScreenHeader::show();
|
||||||
|
|
||||||
int yPos = 18;
|
int yPos = 18;
|
||||||
if(isWifiConnected() || isWifiAP()) {
|
|
||||||
|
|
||||||
const char* pTitle = NULL;
|
const char* pTitle = NULL;
|
||||||
switch(_colSel) {
|
switch(_colSel) {
|
||||||
case 0:
|
case 0:
|
||||||
pTitle = " WiFi: CFG AP only ";
|
pTitle = " WiFi: DISABLED ";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
pTitle = " WiFi: AP only ";
|
pTitle = " WiFi: CFG AP only ";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
pTitle = " WiFi: CFG STA+AP ";
|
pTitle = " WiFi: AP only ";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
pTitle = " WiFi: STA+AP ";
|
pTitle = " WiFi: CFG STA+AP ";
|
||||||
break;
|
break;
|
||||||
}
|
case 4:
|
||||||
|
pTitle = " WiFi: STA+AP ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(_rowSel == 0)
|
if(_rowSel == 0)
|
||||||
_printInverted(3, yPos, pTitle, true); // inverted title bar
|
_printInverted(3, yPos, pTitle, true); // inverted title bar
|
||||||
if(_rowSel == 1)
|
if(_rowSel == 1)
|
||||||
_printMenuText(3, yPos, pTitle, true); // selection box
|
_printMenuText(3, yPos, pTitle, true); // selection box
|
||||||
yPos += 3;
|
if(_rowSel == 2) {
|
||||||
|
if(_OTAsel == 0)
|
||||||
|
_printMenuText(3, yPos, " OTA: DISABLED ", true); // selection box
|
||||||
|
else
|
||||||
|
_printMenuText(3, yPos, " OTA: ENABLED ", true); // selection box
|
||||||
|
}
|
||||||
|
yPos += 3;
|
||||||
|
|
||||||
|
if(_colSel) {
|
||||||
// only show STA IP address if available!
|
// only show STA IP address if available!
|
||||||
if(isWifiSTA() && _repeatCount <= STA_HOLD_TIME) {
|
if(isWifiSTA() && _repeatCount <= STA_HOLD_TIME) {
|
||||||
yPos += _display.textHeight() + 2;
|
yPos += _display.textHeight() + 2;
|
||||||
|
@ -126,9 +140,6 @@ CWiFiScreen::show()
|
||||||
else
|
else
|
||||||
_printMenuText(25, yPos, getWifiAPAddrStr());
|
_printMenuText(25, yPos, getWifiAPAddrStr());
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
_printInverted(0, yPos, " WiFi Inactive ", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -162,6 +173,20 @@ CWiFiScreen::animate()
|
||||||
if(pMsg)
|
if(pMsg)
|
||||||
_printMenuText(_display.xCentre(), 56, pMsg, false, eCentreJustify);
|
_printMenuText(_display.xCentre(), 56, pMsg, false, eCentreJustify);
|
||||||
}
|
}
|
||||||
|
if(_rowSel == 2) {
|
||||||
|
_display.drawFastHLine(0, 52, 128, WHITE);
|
||||||
|
const char* pMsg = NULL;
|
||||||
|
switch(_OTAsel) {
|
||||||
|
case 0:
|
||||||
|
pMsg = "\031 ESC Set \032 Enable"; // only right Sel arrow
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
pMsg = "\031 ESC Set \033 Disable"; // only left Sel arrow
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(pMsg)
|
||||||
|
_printMenuText(_display.xCentre(), 56, pMsg, false, eCentreJustify);
|
||||||
|
}
|
||||||
CScreen::animate();
|
CScreen::animate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -176,48 +201,68 @@ CWiFiScreen::keyHandler(uint8_t event)
|
||||||
}
|
}
|
||||||
// press LEFT
|
// press LEFT
|
||||||
if(event & key_Left) {
|
if(event & key_Left) {
|
||||||
if(_rowSel == 0) {
|
switch(_rowSel) {
|
||||||
_ScreenManager.prevMenu();
|
case 0:
|
||||||
}
|
_ScreenManager.prevMenu();
|
||||||
else {
|
break;
|
||||||
if(isWifiAP()) {
|
case 1:
|
||||||
_colSel = 0;
|
if(isWifiAP()) {
|
||||||
_colLimit = LIMIT_LEFT;
|
// _colSel = 0;
|
||||||
}
|
// _colLimit = LIMIT_LEFT;
|
||||||
else {
|
_colSel--;
|
||||||
_colSel--;
|
LOWERLIMIT(_colSel, 0);
|
||||||
LOWERLIMIT(_colSel, 0);
|
_colLimit = (_colSel == 0) ? LIMIT_LEFT : LIMIT_AWAY;
|
||||||
_colLimit = (_colSel == 0) ? LIMIT_LEFT : LIMIT_AWAY;
|
}
|
||||||
}
|
else {
|
||||||
|
_colSel--;
|
||||||
|
LOWERLIMIT(_colSel, 0);
|
||||||
|
_colLimit = (_colSel == 0) ? LIMIT_LEFT : LIMIT_AWAY;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
_OTAsel = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// press RIGHT
|
// press RIGHT
|
||||||
if(event & key_Right) {
|
if(event & key_Right) {
|
||||||
if(_rowSel == 0) {
|
switch(_rowSel) {
|
||||||
_ScreenManager.nextMenu();
|
case 0:
|
||||||
}
|
_ScreenManager.nextMenu();
|
||||||
else {
|
break;
|
||||||
if(isWifiAP()) {
|
case 1:
|
||||||
_colSel = 1;
|
if(isWifiAP()) {
|
||||||
_colLimit = LIMIT_RIGHT;
|
// _colSel = 1;
|
||||||
}
|
// _colLimit = LIMIT_RIGHT;
|
||||||
else {
|
_colSel++;
|
||||||
_colSel++;
|
UPPERLIMIT(_colSel, 2);
|
||||||
UPPERLIMIT(_colSel, 3);
|
_colLimit = (_colSel == 3) ? LIMIT_RIGHT : LIMIT_AWAY;
|
||||||
_colLimit = (_colSel == 3) ? LIMIT_RIGHT : LIMIT_AWAY;
|
}
|
||||||
}
|
else {
|
||||||
|
_colSel++;
|
||||||
|
UPPERLIMIT(_colSel, 4);
|
||||||
|
_colLimit = (_colSel == 4) ? LIMIT_RIGHT : LIMIT_AWAY;
|
||||||
|
// UPPERLIMIT(_colSel, 3);
|
||||||
|
// _colLimit = (_colSel == 3) ? LIMIT_RIGHT : LIMIT_AWAY;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
_OTAsel = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// press UP
|
// press UP
|
||||||
if(event & key_Up) {
|
if(event & key_Up) {
|
||||||
_rowSel = 1;
|
_rowSel++;
|
||||||
|
UPPERLIMIT(_rowSel, 2);
|
||||||
}
|
}
|
||||||
// press DOWN
|
// press DOWN
|
||||||
if(event & key_Down) {
|
if(event & key_Down) {
|
||||||
if(_rowSel == 0) {
|
if(_rowSel == 0) {
|
||||||
_bShowMAC = !_bShowMAC; // toogle MAC/IP address if on navigation row
|
_bShowMAC = !_bShowMAC; // toogle MAC/IP address if on navigation row
|
||||||
}
|
}
|
||||||
_rowSel = 0;
|
_rowSel--;
|
||||||
|
LOWERLIMIT(_rowSel, 0);
|
||||||
}
|
}
|
||||||
_ScreenManager.reqUpdate();
|
_ScreenManager.reqUpdate();
|
||||||
}
|
}
|
||||||
|
@ -230,23 +275,38 @@ CWiFiScreen::keyHandler(uint8_t event)
|
||||||
|
|
||||||
if(event & keyReleased) {
|
if(event & keyReleased) {
|
||||||
if(event & key_Centre) {
|
if(event & key_Centre) {
|
||||||
if(_rowSel) {
|
if(_rowSel == 1) {
|
||||||
|
|
||||||
switch(_colSel) {
|
switch(_colSel) {
|
||||||
case 0:
|
case 0:
|
||||||
wifiEnterConfigPortal(true, true, 5000); // CFG AP: erase credentials, reboot into portal
|
wifiDisable(5000);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
wifiEnterConfigPortal(false, true, 5000); // AP Only: erase credentials, reboot into webserver
|
wifiEnterConfigPortal(true, true, 5000); // CFG AP: erase credentials, reboot into portal
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
wifiEnterConfigPortal(true, false, 5000); // CFG STA+AP: keep credentials, reboot into portal
|
wifiEnterConfigPortal(false, true, 5000); // AP Only: erase credentials, reboot into webserver
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
wifiEnterConfigPortal(true, false, 5000); // CFG STA+AP: keep credentials, reboot into portal
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
wifiEnterConfigPortal(false, false, 5000); // STA+AP: keep credentials, reboot into webserver
|
wifiEnterConfigPortal(false, false, 5000); // STA+AP: keep credentials, reboot into webserver
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_rowSel = 2; // stop ticker display
|
_rowSel = 3; // stop ticker display
|
||||||
|
}
|
||||||
|
if(_rowSel == 2) {
|
||||||
|
NVstore.setOTAEnabled(_OTAsel);
|
||||||
|
NVstore.save();
|
||||||
|
const char* content[2];
|
||||||
|
if(_OTAsel)
|
||||||
|
content[0] = "Enabling OTA";
|
||||||
|
else
|
||||||
|
content[0] = "Disabling OTA";
|
||||||
|
content[1] = "";
|
||||||
|
|
||||||
|
_ScreenManager.showRebootMsg(content, 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_repeatCount = 0;
|
_repeatCount = 0;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
bool keyHandler(uint8_t event);
|
bool keyHandler(uint8_t event);
|
||||||
private:
|
private:
|
||||||
int _colLimit;
|
int _colLimit;
|
||||||
int _rowSel, _colSel;
|
int _rowSel, _colSel, _OTAsel;
|
||||||
int _repeatCount;
|
int _repeatCount;
|
||||||
bool _bShowMAC;
|
bool _bShowMAC;
|
||||||
void _initUI();
|
void _initUI();
|
||||||
|
|
|
@ -86,9 +86,9 @@ const uint8_t miniFontBitmaps[] PROGMEM =
|
||||||
0xC0, // ##
|
0xC0, // ##
|
||||||
|
|
||||||
// @33 'A' (3 pixels wide)
|
// @33 'A' (3 pixels wide)
|
||||||
0xf8, // #####
|
0x78, // ####
|
||||||
0xa0, // # #
|
0xa0, // # #
|
||||||
0xf8, // #####
|
0x78, // ####
|
||||||
|
|
||||||
// @36 'C' (3 pixels wide)
|
// @36 'C' (3 pixels wide)
|
||||||
0x70, // ###
|
0x70, // ###
|
||||||
|
@ -160,6 +160,11 @@ const uint8_t miniFontBitmaps[] PROGMEM =
|
||||||
0x40, // #
|
0x40, // #
|
||||||
0xf8, // #####
|
0xf8, // #####
|
||||||
|
|
||||||
|
// @78 'O' (3 pixels wide)
|
||||||
|
0x70, // ###
|
||||||
|
0x88, // # #
|
||||||
|
0x70, // ###
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Character descriptors for a 3x5 font
|
// Character descriptors for a 3x5 font
|
||||||
|
@ -199,7 +204,7 @@ const FONT_CHAR_INFO miniFontDescriptors[] PROGMEM =
|
||||||
{3, 5, 48}, // 'L'
|
{3, 5, 48}, // 'L'
|
||||||
{3, 5, 75}, // 'M'
|
{3, 5, 75}, // 'M'
|
||||||
{0, 0, 0}, // 'N'
|
{0, 0, 0}, // 'N'
|
||||||
{0, 0, 0}, // 'O'
|
{3, 5, 78}, // 'O'
|
||||||
{3, 5, 51}, // 'P'
|
{3, 5, 51}, // 'P'
|
||||||
{0, 0, 0}, // 'Q'
|
{0, 0, 0}, // 'Q'
|
||||||
{3, 5, 66}, // 'R'
|
{3, 5, 66}, // 'R'
|
||||||
|
|
|
@ -34,8 +34,7 @@ bool
|
||||||
sNVStore::valid()
|
sNVStore::valid()
|
||||||
{
|
{
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
retval &= (DimTime >= 0) && (DimTime < 300000); // 5 mins
|
retval &= Options.valid();
|
||||||
retval &= (ThermostatMethod & 0x03) < 3; // only modes 0, 1 or 2
|
|
||||||
for(int i=0; i<2; i++) {
|
for(int i=0; i<2; i++) {
|
||||||
retval &= timer[i].valid();
|
retval &= timer[i].valid();
|
||||||
}
|
}
|
||||||
|
@ -49,8 +48,7 @@ sNVStore::init()
|
||||||
for(int i=0; i<2; i++) {
|
for(int i=0; i<2; i++) {
|
||||||
timer[i].init();
|
timer[i].init();
|
||||||
}
|
}
|
||||||
DimTime = 60000; // 1 minute
|
Options.init();
|
||||||
ThermostatMethod = 10 << 2; // 1 degree window, normal thermostat
|
|
||||||
Heater.init();
|
Heater.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,13 +96,13 @@ CHeaterStorage::getThermostatMode()
|
||||||
unsigned char
|
unsigned char
|
||||||
CHeaterStorage::getThermostatMethodMode()
|
CHeaterStorage::getThermostatMethodMode()
|
||||||
{
|
{
|
||||||
return _calValues.ThermostatMethod & 0x03;
|
return _calValues.Options.ThermostatMethod & 0x03;
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
CHeaterStorage::getThermostatMethodWindow()
|
CHeaterStorage::getThermostatMethodWindow()
|
||||||
{
|
{
|
||||||
return float((_calValues.ThermostatMethod >> 2) & 0x3f) * 0.1f; // top 5 bits / 10, then / 2
|
return float((_calValues.Options.ThermostatMethod >> 2) & 0x3f) * 0.1f; // top 5 bits / 10, then / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -148,16 +146,16 @@ CHeaterStorage::setThermostatMode(unsigned char val)
|
||||||
void
|
void
|
||||||
CHeaterStorage::setThermostatMethodMode(unsigned char val)
|
CHeaterStorage::setThermostatMethodMode(unsigned char val)
|
||||||
{
|
{
|
||||||
_calValues.ThermostatMethod &= ~0x03;
|
_calValues.Options.ThermostatMethod &= ~0x03;
|
||||||
_calValues.ThermostatMethod |= (val & 0x03);
|
_calValues.Options.ThermostatMethod |= (val & 0x03);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CHeaterStorage::setThermostatMethodWindow(float val)
|
CHeaterStorage::setThermostatMethodWindow(float val)
|
||||||
{
|
{
|
||||||
_calValues.ThermostatMethod &= 0x03;
|
_calValues.Options.ThermostatMethod &= 0x03;
|
||||||
int nVal = int(val * 10 + 0.5);
|
int nVal = int(val * 10 + 0.5);
|
||||||
_calValues.ThermostatMethod |= ((nVal & 0x3F) << 2);
|
_calValues.Options.ThermostatMethod |= ((nVal & 0x3F) << 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -225,25 +223,51 @@ CHeaterStorage::setTimerInfo(int idx, const sTimer& timerInfo)
|
||||||
unsigned long
|
unsigned long
|
||||||
CHeaterStorage::getDimTime()
|
CHeaterStorage::getDimTime()
|
||||||
{
|
{
|
||||||
return _calValues.DimTime;
|
return _calValues.Options.DimTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CHeaterStorage::setDimTime(unsigned long val)
|
CHeaterStorage::setDimTime(unsigned long val)
|
||||||
{
|
{
|
||||||
_calValues.DimTime = val;
|
_calValues.Options.DimTime = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char
|
unsigned char
|
||||||
CHeaterStorage::getDegFMode()
|
CHeaterStorage::getDegFMode()
|
||||||
{
|
{
|
||||||
return _calValues.degF;
|
return _calValues.Options.degF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CHeaterStorage::setDegFMode(unsigned char val)
|
CHeaterStorage::setDegFMode(unsigned char val)
|
||||||
{
|
{
|
||||||
_calValues.degF = 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();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,9 +384,11 @@ void
|
||||||
CESP32HeaterStorage::loadUI()
|
CESP32HeaterStorage::loadUI()
|
||||||
{
|
{
|
||||||
preferences.begin("user", false);
|
preferences.begin("user", false);
|
||||||
validatedLoad("dimTime", _calValues.DimTime, 60000, s32inBounds, 0, 600000);
|
validatedLoad("dimTime", _calValues.Options.DimTime, 60000, s32inBounds, 0, 600000);
|
||||||
validatedLoad("degF", _calValues.degF, 0, u8inBounds, 0, 1);
|
validatedLoad("degF", _calValues.Options.degF, 0, u8inBounds, 0, 1);
|
||||||
validatedLoad("thermoMethod", _calValues.ThermostatMethod, (10 << 2), u8inBounds, 0, 2, 0x03);
|
validatedLoad("thermoMethod", _calValues.Options.ThermostatMethod, (10 << 2), u8inBounds, 0, 2, 0x03);
|
||||||
|
validatedLoad("enableWifi", _calValues.Options.enableWifi, 1, u8inBounds, 0, 1);
|
||||||
|
validatedLoad("enableOTA", _calValues.Options.enableOTA, 1, u8inBounds, 0, 1);
|
||||||
preferences.end();
|
preferences.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,9 +396,11 @@ void
|
||||||
CESP32HeaterStorage::saveUI()
|
CESP32HeaterStorage::saveUI()
|
||||||
{
|
{
|
||||||
preferences.begin("user", false);
|
preferences.begin("user", false);
|
||||||
preferences.putULong("dimTime", _calValues.DimTime);
|
preferences.putULong("dimTime", _calValues.Options.DimTime);
|
||||||
preferences.putUChar("degF", _calValues.degF);
|
preferences.putUChar("degF", _calValues.Options.degF);
|
||||||
preferences.putUChar("thermoMethod", _calValues.ThermostatMethod);
|
preferences.putUChar("thermoMethod", _calValues.Options.ThermostatMethod);
|
||||||
|
preferences.putUChar("enableWifi", _calValues.Options.enableWifi);
|
||||||
|
preferences.putUChar("enableOTA", _calValues.Options.enableOTA);
|
||||||
preferences.end();
|
preferences.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,13 +61,35 @@ struct sHeater {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct sBTCoptions {
|
||||||
|
long DimTime;
|
||||||
|
uint8_t degF;
|
||||||
|
uint8_t ThermostatMethod; // 0: standard heater, 1: Narrow Hysterisis, 2:Managed Hz mode
|
||||||
|
uint8_t enableWifi;
|
||||||
|
uint8_t enableOTA;
|
||||||
|
bool valid() {
|
||||||
|
bool retval = true;
|
||||||
|
retval &= (DimTime >= 0) && (DimTime < 300000); // 5 mins
|
||||||
|
retval &= (degF == 0) || (degF == 1);
|
||||||
|
retval &= (ThermostatMethod & 0x03) < 3; // only modes 0, 1 or 2
|
||||||
|
retval &= (enableWifi == 0) || (enableWifi == 1);
|
||||||
|
retval &= (enableOTA == 0) || (enableOTA == 1);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
void init() {
|
||||||
|
DimTime = 60000;
|
||||||
|
degF = 0;
|
||||||
|
ThermostatMethod = 0;
|
||||||
|
enableWifi = 1;
|
||||||
|
enableOTA = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// the actual data stored to NV memory
|
// the actual data stored to NV memory
|
||||||
struct sNVStore {
|
struct sNVStore {
|
||||||
sHeater Heater;
|
sHeater Heater;
|
||||||
long DimTime;
|
sBTCoptions Options;
|
||||||
uint8_t degF;
|
|
||||||
uint8_t ThermostatMethod; // 0: standard heater, 1: Narrow Hysterisis, 2:Managed Hz mode
|
|
||||||
sTimer timer[14];
|
sTimer timer[14];
|
||||||
bool valid();
|
bool valid();
|
||||||
void init();
|
void init();
|
||||||
|
@ -111,6 +133,8 @@ public:
|
||||||
unsigned char getGlowDrive();
|
unsigned char getGlowDrive();
|
||||||
unsigned long getDimTime();
|
unsigned long getDimTime();
|
||||||
unsigned char getDegFMode();
|
unsigned char getDegFMode();
|
||||||
|
unsigned char getWifiEnabled();
|
||||||
|
unsigned char getOTAEnabled();
|
||||||
|
|
||||||
void setPmin(float);
|
void setPmin(float);
|
||||||
void setPmax(float);
|
void setPmax(float);
|
||||||
|
@ -125,6 +149,8 @@ public:
|
||||||
void setGlowDrive(unsigned char val);
|
void setGlowDrive(unsigned char val);
|
||||||
void setDimTime(unsigned long val);
|
void setDimTime(unsigned long val);
|
||||||
void setDegFMode(unsigned char val);
|
void setDegFMode(unsigned char val);
|
||||||
|
void setWifiEnabled(unsigned char val);
|
||||||
|
void setOTAEnabled(unsigned char val);
|
||||||
|
|
||||||
void getTimerInfo(int idx, sTimer& timerInfo);
|
void getTimerInfo(int idx, sTimer& timerInfo);
|
||||||
void setTimerInfo(int idx, const sTimer& timerInfo);
|
void setTimerInfo(int idx, const sTimer& timerInfo);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
|
#include "../Utility/NVStorage.h"
|
||||||
|
|
||||||
#define USE_AP
|
#define USE_AP
|
||||||
|
|
||||||
|
@ -193,9 +194,28 @@ void doWiFiManager()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wifiDisable(long rebootDelay)
|
||||||
|
{
|
||||||
|
NVstore.setWifiEnabled(0);
|
||||||
|
NVstore.save();
|
||||||
|
|
||||||
|
DebugPort.println("*** Disabling WiFi ***");
|
||||||
|
|
||||||
|
restartServer = (millis() + rebootDelay) | 1; // prepare to reboot in the future - ensure non zero!
|
||||||
|
|
||||||
|
const char* content[2];
|
||||||
|
content[0] = "WiFi Mode \032 DISABLED";
|
||||||
|
content[1] = "";
|
||||||
|
ScreenManager.showRebootMsg(content, rebootDelay);
|
||||||
|
}
|
||||||
|
|
||||||
void wifiEnterConfigPortal(bool state, bool erase, long rebootDelay)
|
void wifiEnterConfigPortal(bool state, bool erase, long rebootDelay)
|
||||||
{
|
{
|
||||||
wm.disconnect();
|
wm.disconnect();
|
||||||
|
|
||||||
|
NVstore.setWifiEnabled(1);
|
||||||
|
NVstore.save();
|
||||||
|
|
||||||
prepBootIntoConfigPortal(state);
|
prepBootIntoConfigPortal(state);
|
||||||
|
|
||||||
const char* content[2];
|
const char* content[2];
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
bool hasWebClientSpoken(bool reset = false);
|
bool hasWebClientSpoken(bool reset = false);
|
||||||
bool hasWebServerSpoken(bool reset = false);
|
bool hasWebServerSpoken(bool reset = false);
|
||||||
void wifiEnterConfigPortal(bool state, bool erase = false, long timeout = 7000);
|
void wifiEnterConfigPortal(bool state, bool erase = false, long timeout = 7000);
|
||||||
|
void wifiDisable(long rebootDelay = 7000);
|
||||||
int isWifiButton();
|
int isWifiButton();
|
||||||
|
|
||||||
#endif __BTCWIFI_H__
|
#endif __BTCWIFI_H__
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
const uint8_t UART_Tx = 1;
|
||||||
const uint8_t LED_Pin = 2;
|
const uint8_t LED_Pin = 2;
|
||||||
|
const uint8_t UART_Rx = 3;
|
||||||
const uint8_t HC05_KeyPin = 4;
|
const uint8_t HC05_KeyPin = 4;
|
||||||
const uint8_t TxEnbPin = 5;
|
const uint8_t TxEnbPin = 5;
|
||||||
const uint8_t GPIO12_pin = 12; // HSPI std pins
|
const uint8_t GPIO12_pin = 12; // HSPI std pins
|
||||||
|
|
Loading…
Reference in a new issue