Added AM/PM annunciators to clock for 12hr mode
Added last will to MQTT connection Condensed no heater timeouts with default screen
This commit is contained in:
parent
9fbb6e8dfc
commit
583a4881cd
|
@ -1414,6 +1414,20 @@ void checkDebugCommands()
|
|||
bTestBTModule = !bTestBTModule;
|
||||
Bluetooth.test(bTestBTModule ? 0xff : 0x00); // special enter or leave BT test commands
|
||||
}
|
||||
else if(rxVal == ('s' & 0x1f)) { // CTRL-S Stripped back - no heater mode
|
||||
sUserSettings us = NVstore.getUserSettings();
|
||||
us.NoHeater = !us.NoHeater;
|
||||
NVstore.setUserSettings(us);
|
||||
NVstore.save();
|
||||
NVstore.doSave();
|
||||
if(us.NoHeater)
|
||||
DebugPort.println("Restarting ESP to invoke cut back No Heater mode");
|
||||
else
|
||||
DebugPort.println("Restarting ESP to invoke Full control mode");
|
||||
DebugPort.handle();
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
#ifdef PROTOCOL_INVESTIGATION
|
||||
if(bSendVal) {
|
||||
|
@ -1765,6 +1779,7 @@ void setSSID(const char* name)
|
|||
NVstore.save();
|
||||
NVstore.doSave(); // ensure NV storage
|
||||
DebugPort.println("Restarting ESP to invoke new network credentials");
|
||||
DebugPort.handle();
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
@ -1778,6 +1793,7 @@ void setAPpassword(const char* name)
|
|||
NVstore.save();
|
||||
NVstore.doSave(); // ensure NV storage
|
||||
DebugPort.println("Restarting ESP to invoke new network credentials");
|
||||
DebugPort.handle();
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
|
|
@ -191,15 +191,19 @@ CBasicScreen::keyHandler(uint8_t event)
|
|||
if(event & key_Down) {
|
||||
if(repeatCount > 2) {
|
||||
repeatCount = -1; // prevent double handling
|
||||
_showModeTime = millis() + 5000;
|
||||
_nModeSel = getThermostatModeActive() ? 0 : 1;
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
_showModeTime = millis() + 5000;
|
||||
_nModeSel = getThermostatModeActive() ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// hold UP to toggle degC/degF mode selection
|
||||
if(event & key_Up) {
|
||||
if(repeatCount > 2) {
|
||||
repeatCount = -1; // prevent double handling
|
||||
_showModeTime = millis() + 5000;
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
_showModeTime = millis() + 5000;
|
||||
}
|
||||
sUserSettings settings = NVstore.getUserSettings();
|
||||
toggle(settings.degF);
|
||||
NVstore.setUserSettings(settings);
|
||||
|
@ -208,18 +212,20 @@ CBasicScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
// hold CENTRE to turn ON or OFF
|
||||
if(event & key_Centre) {
|
||||
int runstate = getHeaterInfo().getRunStateEx();
|
||||
if(runstate) { // running, including cyclic mode idle
|
||||
if(repeatCount > 5) {
|
||||
repeatCount = -1;
|
||||
requestOff();
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
int runstate = getHeaterInfo().getRunStateEx();
|
||||
if(runstate) { // running, including cyclic mode idle
|
||||
if(repeatCount > 5) {
|
||||
repeatCount = -1;
|
||||
requestOff();
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // standard idle state
|
||||
// standby, request ON
|
||||
if(repeatCount > 3) {
|
||||
repeatCount = -1;
|
||||
requestOn();
|
||||
else { // standard idle state
|
||||
// standby, request ON
|
||||
if(repeatCount > 3) {
|
||||
repeatCount = -1;
|
||||
requestOn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,24 +238,26 @@ CBasicScreen::keyHandler(uint8_t event)
|
|||
if(event & keyReleased) {
|
||||
if(!_showModeTime) {
|
||||
// release DOWN key to reduce set demand, provided we are not in mode select
|
||||
if(event & key_Down) {
|
||||
if(reqDemandDelta(-1)) {
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 0;
|
||||
_ScreenManager.reqUpdate();
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
if(event & key_Down) {
|
||||
if(reqDemandDelta(-1)) {
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 0;
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
else
|
||||
_reqOEMWarning();
|
||||
}
|
||||
else
|
||||
_reqOEMWarning();
|
||||
}
|
||||
// release UP key to increase set demand, provided we are not in mode select
|
||||
if(event & key_Up) {
|
||||
if(reqDemandDelta(+1)) {
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 0;
|
||||
_ScreenManager.reqUpdate();
|
||||
// release UP key to increase set demand, provided we are not in mode select
|
||||
if(event & key_Up) {
|
||||
if(reqDemandDelta(+1)) {
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 0;
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
else
|
||||
_reqOEMWarning();
|
||||
}
|
||||
else
|
||||
_reqOEMWarning();
|
||||
}
|
||||
}
|
||||
if(event & key_Left) {
|
||||
|
@ -289,14 +297,16 @@ CBasicScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
// release CENTRE to accept new mode, and/or show current setting
|
||||
if(event & key_Centre) {
|
||||
if(repeatCount != -2) { // prevent after off commands
|
||||
if(_showModeTime) {
|
||||
_showModeTime = millis(); // force immediate cancellation of showmode (via screen update)
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
if(repeatCount != -2) { // prevent after off commands
|
||||
if(_showModeTime) {
|
||||
_showModeTime = millis(); // force immediate cancellation of showmode (via screen update)
|
||||
}
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 0;
|
||||
}
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 0;
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
|
||||
repeatCount = -1;
|
||||
|
@ -307,6 +317,9 @@ CBasicScreen::keyHandler(uint8_t event)
|
|||
void
|
||||
CBasicScreen::showRunState()
|
||||
{
|
||||
if(NVstore.getUserSettings().NoHeater)
|
||||
return;
|
||||
|
||||
int runstate = getHeaterInfo().getRunStateEx();
|
||||
int errstate = getHeaterInfo().getErrState();
|
||||
|
||||
|
|
|
@ -24,8 +24,10 @@
|
|||
#include "KeyPad.h"
|
||||
#include "../Utility/helpers.h"
|
||||
#include "fonts/Tahoma24.h"
|
||||
#include "fonts/Arial.h"
|
||||
#include "../RTC/Clock.h"
|
||||
#include "../Protocol/Protocol.h"
|
||||
#include "../Utility/NVStorage.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -54,18 +56,40 @@ CClockScreen::show()
|
|||
const BTCDateTime& now = Clock.get();
|
||||
|
||||
char str[32];
|
||||
// if(now.second() & 0x01)
|
||||
int clockcentre = _display.xCentre();
|
||||
int hr = now.hour();
|
||||
if(NVstore.getUserSettings().clock12hr) {
|
||||
if(hr == 0)
|
||||
hr = 12;
|
||||
else if (hr > 12)
|
||||
hr -= 12;
|
||||
clockcentre -= 8; // allow space for AM/PM indicators
|
||||
}
|
||||
|
||||
|
||||
if(_colon)
|
||||
sprintf(str, "%d:%02d", now.hour(), now.minute());
|
||||
sprintf(str, "%d:%02d", hr, now.minute());
|
||||
else
|
||||
sprintf(str, "%d %02d", now.hour(), now.minute());
|
||||
sprintf(str, "%d %02d", hr, now.minute());
|
||||
_colon = !_colon;
|
||||
|
||||
int yPos = 25;
|
||||
int timewidth = 0;
|
||||
{
|
||||
// CTransientFont AF(_display, &tahoma_16ptFontInfo); // temporarily use a large font
|
||||
CTransientFont AF(_display, &tahoma_24ptFontInfo); // temporarily use a large font
|
||||
_printMenuText(_display.xCentre(), yPos, str, false, eCentreJustify);
|
||||
_printMenuText(clockcentre, yPos, str, false, eCentreJustify);
|
||||
CRect extents;
|
||||
extents.xPos = 0;
|
||||
extents.yPos = 0;
|
||||
_display.getTextExtents(str, extents);
|
||||
timewidth = extents.width;
|
||||
}
|
||||
if(NVstore.getUserSettings().clock12hr) {
|
||||
CTransientFont AF(_display, &arial_8ptBoldFontInfo); // temporarily use a large font
|
||||
if(now.hour() >= 12)
|
||||
_printMenuText(clockcentre + timewidth/2 + 5, yPos + 14, "PM");
|
||||
else
|
||||
_printMenuText(clockcentre + timewidth/2 + 5, yPos, "AM");
|
||||
}
|
||||
sprintf(str, "%s %d %s %d", now.dowStr(), now.day(), now.monthStr(), now.year());
|
||||
_printMenuText(_display.xCentre(), 56, str, false, eCentreJustify);
|
||||
|
@ -85,7 +109,9 @@ CClockScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
// press DOWN
|
||||
if(event & key_Down) {
|
||||
_ScreenManager.selectMenu(CScreenManager::TimerMenuLoop); // switch to timer set screen loop
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
_ScreenManager.selectMenu(CScreenManager::TimerMenuLoop); // switch to timer set screen loop
|
||||
}
|
||||
}
|
||||
}
|
||||
if(event & keyRepeat) {
|
||||
|
@ -107,18 +133,20 @@ CClockScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
// hold CENTRE to toggle On/Off state
|
||||
if(event & key_Centre) {
|
||||
int runstate = getHeaterInfo().getRunStateEx();
|
||||
if(runstate) { // running, including cyclic mode idle
|
||||
if(_keyRepeatCount > 5) {
|
||||
_keyRepeatCount = -1;
|
||||
requestOff();
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
int runstate = getHeaterInfo().getRunStateEx();
|
||||
if(runstate) { // running, including cyclic mode idle
|
||||
if(_keyRepeatCount > 5) {
|
||||
_keyRepeatCount = -1;
|
||||
requestOff();
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // standard idle state
|
||||
// standby, request ON
|
||||
if(_keyRepeatCount > 3) {
|
||||
_keyRepeatCount = -1;
|
||||
requestOn();
|
||||
else { // standard idle state
|
||||
// standby, request ON
|
||||
if(_keyRepeatCount > 3) {
|
||||
_keyRepeatCount = -1;
|
||||
requestOn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@ CHomeMenuSelScreen::show()
|
|||
case 3: strcpy(msg, "Clock"); break;
|
||||
}
|
||||
_printMenuText(50, 38, msg, _rowSel == 1);
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -200,3 +199,187 @@ CHomeMenuSelScreen::adjust(int dir)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
CNoHeaterHomeMenuSelScreen::CNoHeaterHomeMenuSelScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CNoHeaterHomeMenuSelScreen::onSelect()
|
||||
{
|
||||
CScreenHeader::onSelect();
|
||||
_rowSel = 0;
|
||||
_action = NVstore.getUserSettings().HomeMenu;
|
||||
_dispTimeout = NVstore.getUserSettings().dimTime;
|
||||
_menuTimeout = NVstore.getUserSettings().menuTimeout;
|
||||
if(_action.onTimeout == 0)
|
||||
_action.onTimeout = 2;
|
||||
}
|
||||
|
||||
void
|
||||
CNoHeaterHomeMenuSelScreen::_initUI()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
CNoHeaterHomeMenuSelScreen::show()
|
||||
{
|
||||
char msg[16];
|
||||
|
||||
_display.clearDisplay();
|
||||
|
||||
if(!CPasswordScreen::show()) { // for showing "saving settings"
|
||||
|
||||
if(_rowSel == 4) {
|
||||
_showConfirmMessage();
|
||||
}
|
||||
else {
|
||||
_showTitle("Home Menu Actions");
|
||||
|
||||
_drawBitmap(22, 14, TimeoutIconInfo);
|
||||
switch(_action.onTimeout) {
|
||||
case 2: strcpy(msg, "Temperature"); break;
|
||||
case 3: strcpy(msg, "Clock"); break;
|
||||
}
|
||||
_printMenuText(40, 14, msg, _rowSel == 3);
|
||||
|
||||
// display timeout
|
||||
_drawBitmap(10, 26, DisplayTimeoutIconInfo);
|
||||
if(_dispTimeout) {
|
||||
float mins = float(abs(_dispTimeout)) / 60000.f;
|
||||
sprintf(msg, "%s %0.1f min%s", (_dispTimeout < 0) ? "Blank" : "Dim", mins, mins < 2 ? "" : "s");
|
||||
_printMenuText(40, 26, msg, _rowSel == 2);
|
||||
}
|
||||
else
|
||||
_printMenuText(40, 26, "Always on", _rowSel == 2);
|
||||
|
||||
// menu timeout
|
||||
_drawBitmap(10, 38, MenuTimeoutIconInfo);
|
||||
if(_menuTimeout) {
|
||||
float mins = float(abs(_menuTimeout)) / 60000.f;
|
||||
sprintf(msg, "Home %0.1f min%s", mins, mins < 2 ? "" : "s");
|
||||
_printMenuText(40, 38, msg, _rowSel == 1);
|
||||
}
|
||||
else
|
||||
_printMenuText(40, 38, "Disabled", _rowSel == 1);
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CNoHeaterHomeMenuSelScreen::animate()
|
||||
{
|
||||
if(!CPasswordScreen::_busy()) {
|
||||
if(_rowSel != 4) {
|
||||
int yPos = 53;
|
||||
int xPos = _display.xCentre();
|
||||
const char* pMsg = NULL;
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_printMenuText(xPos, yPos, " \021 \030Edit Exit \020 ", true, eCentreJustify);
|
||||
break;
|
||||
case 1:
|
||||
_display.drawFastHLine(0, 52, 128, WHITE);
|
||||
pMsg = " No keypad activity returns to the home menu. ";
|
||||
_scrollMessage(56, pMsg, _scrollChar);
|
||||
break;
|
||||
case 2:
|
||||
_display.drawFastHLine(0, 52, 128, WHITE);
|
||||
pMsg = " No keypad activity either dims or blanks the display. Hold Left or Right to toggle Dim/Blank mode. ";
|
||||
_scrollMessage(56, pMsg, _scrollChar);
|
||||
break;
|
||||
case 3:
|
||||
_display.drawFastHLine(0, 52, 128, WHITE);
|
||||
pMsg = " Menu to return to after no keypad activity. ";
|
||||
_scrollMessage(56, pMsg, _scrollChar);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CNoHeaterHomeMenuSelScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
sUserSettings us;
|
||||
if(event & keyPressed) {
|
||||
// UP press
|
||||
if(event & key_Up) {
|
||||
if(_rowSel == 4) {
|
||||
_enableStoringMessage();
|
||||
us = NVstore.getUserSettings();
|
||||
us.HomeMenu = _action;
|
||||
us.menuTimeout = _menuTimeout;
|
||||
us.dimTime = _dispTimeout;
|
||||
NVstore.setUserSettings(us);
|
||||
saveNV();
|
||||
_rowSel = 0;
|
||||
}
|
||||
else {
|
||||
_scrollChar = 0;
|
||||
_rowSel++;
|
||||
UPPERLIMIT(_rowSel, 3);
|
||||
}
|
||||
}
|
||||
// DOWN press
|
||||
if(event & key_Down) {
|
||||
_scrollChar = 0;
|
||||
_rowSel--;
|
||||
LOWERLIMIT(_rowSel, 0);
|
||||
}
|
||||
// CENTRE press
|
||||
if(event & key_Centre) {
|
||||
if(_rowSel == 0) {
|
||||
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // force return to main menu
|
||||
}
|
||||
else {
|
||||
_rowSel = 4;
|
||||
}
|
||||
}
|
||||
// LEFT press
|
||||
if(event & key_Left) {
|
||||
if(_rowSel == 0)
|
||||
_ScreenManager.prevMenu();
|
||||
else
|
||||
adjust(-1);
|
||||
}
|
||||
// RIGHT press
|
||||
if(event & key_Right) {
|
||||
if(_rowSel == 0)
|
||||
_ScreenManager.nextMenu();
|
||||
else
|
||||
adjust(+1);
|
||||
}
|
||||
}
|
||||
|
||||
_ScreenManager.reqUpdate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CNoHeaterHomeMenuSelScreen::adjust(int dir)
|
||||
{
|
||||
switch(_rowSel) {
|
||||
case 1:
|
||||
_menuTimeout += dir * 30000;
|
||||
LOWERLIMIT(_menuTimeout, 0);
|
||||
UPPERLIMIT(_menuTimeout, 300000);
|
||||
break;
|
||||
case 2:
|
||||
_dispTimeout += dir * 30000;
|
||||
LOWERLIMIT(_dispTimeout, -600000);
|
||||
UPPERLIMIT(_dispTimeout, 600000);
|
||||
break;
|
||||
case 3:
|
||||
_action.onTimeout = _action.onTimeout==3 ? 2 : 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,4 +44,21 @@ public:
|
|||
void adjust(int dir);
|
||||
};
|
||||
|
||||
class CNoHeaterHomeMenuSelScreen : public CPasswordScreen
|
||||
{
|
||||
int _rowSel;
|
||||
int _scrollChar;
|
||||
sHomeMenuActions _action;
|
||||
long _dispTimeout;
|
||||
long _menuTimeout;
|
||||
void _initUI();
|
||||
public:
|
||||
CNoHeaterHomeMenuSelScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
bool show();
|
||||
bool animate();
|
||||
bool keyHandler(uint8_t event);
|
||||
void onSelect();
|
||||
void adjust(int dir);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "../Utility/helpers.h"
|
||||
#include "../Utility/macros.h"
|
||||
#include "fonts/Arial.h"
|
||||
#include "../Utility/NVStorage.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -70,7 +71,9 @@ CMenuTrunkScreen::show()
|
|||
|
||||
_printMenuText(_display.xCentre(), yPos[_rowSel], " \021 \020 ", true, eCentreJustify);
|
||||
|
||||
_printMenuText(_display.xCentre(), yPos[3], "Heater Tuning", false, eCentreJustify);
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
_printMenuText(_display.xCentre(), yPos[3], "Heater Tuning", false, eCentreJustify);
|
||||
}
|
||||
_printMenuText(_display.xCentre(), yPos[2], "System Settings", false, eCentreJustify);
|
||||
_printMenuText(_display.xCentre(), yPos[1], "User Settings", false, eCentreJustify);
|
||||
_printMenuText(_display.xCentre(), yPos[0], "Root menu", false, eCentreJustify);
|
||||
|
@ -134,7 +137,8 @@ CMenuTrunkScreen::keyHandler(uint8_t event)
|
|||
// press UP
|
||||
if(event & key_Up) {
|
||||
_rowSel++;
|
||||
UPPERLIMIT(_rowSel, 3);
|
||||
int lim = NVstore.getUserSettings().NoHeater ? 2 : 3;
|
||||
UPPERLIMIT(_rowSel, lim);
|
||||
}
|
||||
// press DOWN
|
||||
if(event & key_Down) {
|
||||
|
|
|
@ -86,14 +86,6 @@ COtherOptionsScreen::show()
|
|||
}
|
||||
else
|
||||
_printMenuText(40, 38, "Disabled", _rowSel == 1);
|
||||
|
||||
/* if(_rowSel == 0)
|
||||
_printMenuText(_display.xCentre(), 53, " \021 Exit \020 ", _rowSel == 0, eCentreJustify);
|
||||
else {
|
||||
_display.drawFastHLine(0, 52, 128, WHITE);
|
||||
_printMenuText(_display.xCentre(), 56, "\030\031Sel \033\032 Adj", false, eCentreJustify);
|
||||
_printMenuText(_display.xCentre(), 56, "Save", false, eCentreJustify);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#define Y_WIFI_ICON 0
|
||||
#define X_CLOCK 50
|
||||
#define Y_CLOCK 0
|
||||
#define X_TIMER_ICON 83
|
||||
#define X_TIMER_ICON 84
|
||||
#define Y_TIMER_ICON 0
|
||||
#define X_BATT_ICON 103
|
||||
#define Y_BATT_ICON 0
|
||||
|
@ -309,19 +309,21 @@ CScreenHeader::showWifiIcon()
|
|||
void
|
||||
CScreenHeader::showBatteryIcon(float voltage)
|
||||
{
|
||||
_drawBitmap(X_BATT_ICON, Y_BATT_ICON, BatteryIconInfo);
|
||||
char msg[16];
|
||||
sprintf(msg, "%.1fV", voltage);
|
||||
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
||||
_display.setCursor(X_BATT_ICON + BatteryIconInfo.width/2,
|
||||
Y_BATT_ICON + BatteryIconInfo.height + 2);
|
||||
_display.printCentreJustified(msg);
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
_drawBitmap(X_BATT_ICON, Y_BATT_ICON, BatteryIconInfo);
|
||||
char msg[16];
|
||||
sprintf(msg, "%.1fV", voltage);
|
||||
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
||||
_display.setCursor(X_BATT_ICON + BatteryIconInfo.width/2,
|
||||
Y_BATT_ICON + BatteryIconInfo.height + 2);
|
||||
_display.printCentreJustified(msg);
|
||||
|
||||
// nominal 10.5 -> 13.5V bargraph
|
||||
int Capacity = (voltage - 10.7) * 4;
|
||||
if(Capacity < 0) Capacity = 0;
|
||||
if(Capacity > 11) Capacity = 11;
|
||||
_display.fillRect(X_BATT_ICON+2 + Capacity, Y_BATT_ICON+2, BatteryIconInfo.width-4-Capacity, 6, BLACK);
|
||||
// nominal 10.5 -> 13.5V bargraph
|
||||
int Capacity = (voltage - 10.7) * 4;
|
||||
if(Capacity < 0) Capacity = 0;
|
||||
if(Capacity > 11) Capacity = 11;
|
||||
_display.fillRect(X_BATT_ICON+2 + Capacity, Y_BATT_ICON+2, BatteryIconInfo.width-4-Capacity, 6, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -372,21 +374,43 @@ CScreenHeader::showTime()
|
|||
sprintf(msg, "No RTC");
|
||||
}
|
||||
else {
|
||||
int hr = now.hour();
|
||||
if(NVstore.getUserSettings().clock12hr) {
|
||||
if(hr == 0)
|
||||
hr = 12;
|
||||
if(hr > 12) {
|
||||
hr -= 12;
|
||||
}
|
||||
}
|
||||
if(_colon)
|
||||
sprintf(msg, "%02d:%02d", now.hour(), now.minute());
|
||||
sprintf(msg, "%02d:%02d", hr, now.minute());
|
||||
else
|
||||
sprintf(msg, "%02d %02d", now.hour(), now.minute());
|
||||
sprintf(msg, "%02d %02d", hr, now.minute());
|
||||
_colon = !_colon;
|
||||
}
|
||||
|
||||
int timewidth = 0;
|
||||
int xPos = X_CLOCK;
|
||||
{
|
||||
CTransientFont AF(_display, &arial_8ptFontInfo);
|
||||
// determine centre position of remaining real estate
|
||||
int xPos = X_WIFI_ICON + WifiIconInfo.width + WifiInIconInfo.width; // rhs of wifi conglomeration
|
||||
if(isWifiAP()) xPos += 4; // add more if an Access Point
|
||||
|
||||
_display.fillRect(xPos - 15, Y_CLOCK, 30, arial_8ptFontInfo.nBitsPerLine, BLACK);
|
||||
_printMenuText(X_CLOCK, Y_CLOCK, msg);
|
||||
if(NVstore.getUserSettings().clock12hr)
|
||||
xPos -= 3;
|
||||
_display.fillRect(xPos, Y_CLOCK, 30, arial_8ptFontInfo.nBitsPerLine, BLACK);
|
||||
_printMenuText(xPos, Y_CLOCK-2, msg);
|
||||
CRect extents;
|
||||
extents.xPos = 0;
|
||||
extents.yPos = 0;
|
||||
_display.getTextExtents(msg, extents);
|
||||
timewidth = extents.width;
|
||||
}
|
||||
if(NVstore.getUserSettings().clock12hr) {
|
||||
CTransientFont AF(_display, &miniFontInfo);
|
||||
xPos += timewidth + 2;
|
||||
_display.fillRect(xPos, Y_CLOCK, 8, 10, BLACK);
|
||||
if(now.hour() >= 12)
|
||||
_printMenuText(xPos, Y_CLOCK+5, "PM");
|
||||
else
|
||||
_printMenuText(xPos, Y_CLOCK, "AM");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -393,14 +393,24 @@ CScreenManager::begin(bool bNoClock)
|
|||
|
||||
std::vector<CScreen*> menuloop;
|
||||
// create root menu loop
|
||||
menuloop.push_back(new CDetailedScreen(*_pDisplay, *this)); // detail control
|
||||
menuloop.push_back(new CBasicScreen(*_pDisplay, *this)); // basic control
|
||||
if(!bNoClock)
|
||||
menuloop.push_back(new CClockScreen(*_pDisplay, *this)); // clock
|
||||
menuloop.push_back(new CPrimingScreen(*_pDisplay, *this)); // mode / priming
|
||||
if(getBoardRevision() != 0 && getBoardRevision() != BRD_V2_NOGPIO) // has GPIO support
|
||||
menuloop.push_back(new CGPIOInfoScreen(*_pDisplay, *this)); // GPIO info
|
||||
menuloop.push_back(new CMenuTrunkScreen(*_pDisplay, *this));
|
||||
if(NVstore.getUserSettings().NoHeater) {
|
||||
menuloop.push_back(new CMenuTrunkScreen(*_pDisplay, *this));
|
||||
menuloop.push_back(new CBasicScreen(*_pDisplay, *this)); // basic control
|
||||
if(!bNoClock)
|
||||
menuloop.push_back(new CClockScreen(*_pDisplay, *this)); // clock
|
||||
if(getBoardRevision() != 0 && getBoardRevision() != BRD_V2_NOGPIO) // has GPIO support
|
||||
menuloop.push_back(new CGPIOInfoScreen(*_pDisplay, *this)); // GPIO info
|
||||
}
|
||||
else {
|
||||
menuloop.push_back(new CDetailedScreen(*_pDisplay, *this)); // detail control
|
||||
menuloop.push_back(new CBasicScreen(*_pDisplay, *this)); // basic control
|
||||
if(!bNoClock)
|
||||
menuloop.push_back(new CClockScreen(*_pDisplay, *this)); // clock
|
||||
menuloop.push_back(new CPrimingScreen(*_pDisplay, *this)); // mode / priming
|
||||
if(getBoardRevision() != 0 && getBoardRevision() != BRD_V2_NOGPIO) // has GPIO support
|
||||
menuloop.push_back(new CGPIOInfoScreen(*_pDisplay, *this)); // GPIO info
|
||||
menuloop.push_back(new CMenuTrunkScreen(*_pDisplay, *this));
|
||||
}
|
||||
_Screens.push_back(menuloop);
|
||||
|
||||
// create timer screens loop
|
||||
|
@ -431,17 +441,26 @@ CScreenManager::begin(bool bNoClock)
|
|||
|
||||
// create User Settings screens loop
|
||||
menuloop.clear();
|
||||
menuloop.push_back(new CThermostatModeScreen(*_pDisplay, *this)); // thermostat settings screen
|
||||
menuloop.push_back(new CHomeMenuSelScreen(*_pDisplay, *this)); // Home menu settings screen
|
||||
menuloop.push_back(new COtherOptionsScreen(*_pDisplay, *this)); // Other options screen
|
||||
if(getBoardRevision() != 0 && getBoardRevision() != BRD_V2_NOGPIO) // has GPIO support ?
|
||||
menuloop.push_back(new CGPIOSetupScreen(*_pDisplay, *this)); // GPIO settings screen
|
||||
if(NVstore.getUserSettings().NoHeater) {
|
||||
menuloop.push_back(new CNoHeaterHomeMenuSelScreen(*_pDisplay, *this)); // No Heater Home menu settings screen
|
||||
if(getBoardRevision() != 0 && getBoardRevision() != BRD_V2_NOGPIO) // has GPIO support ?
|
||||
menuloop.push_back(new CGPIOSetupScreen(*_pDisplay, *this)); // GPIO settings screen
|
||||
}
|
||||
else {
|
||||
menuloop.push_back(new CThermostatModeScreen(*_pDisplay, *this)); // thermostat settings screen
|
||||
menuloop.push_back(new CHomeMenuSelScreen(*_pDisplay, *this)); // Home menu settings screen
|
||||
menuloop.push_back(new COtherOptionsScreen(*_pDisplay, *this)); // Other options screen
|
||||
if(getBoardRevision() != 0 && getBoardRevision() != BRD_V2_NOGPIO) // has GPIO support ?
|
||||
menuloop.push_back(new CGPIOSetupScreen(*_pDisplay, *this)); // GPIO settings screen
|
||||
}
|
||||
_Screens.push_back(menuloop);
|
||||
|
||||
// create System Settings screens loop
|
||||
menuloop.clear();
|
||||
menuloop.push_back(new CVersionInfoScreen(*_pDisplay, *this)); // GPIO settings screen
|
||||
menuloop.push_back(new CHourMeterScreen(*_pDisplay, *this)); // Hour Meter screen
|
||||
if(!NVstore.getUserSettings().NoHeater) {
|
||||
menuloop.push_back(new CHourMeterScreen(*_pDisplay, *this)); // Hour Meter screen
|
||||
}
|
||||
menuloop.push_back(new CWiFiScreen(*_pDisplay, *this));
|
||||
menuloop.push_back(new CMQTTScreen(*_pDisplay, *this));
|
||||
menuloop.push_back(new CBTScreen(*_pDisplay, *this));
|
||||
|
@ -503,7 +522,7 @@ CScreenManager::checkUpdate()
|
|||
// Basic Control
|
||||
// Clock
|
||||
// return to those upon timeout, otherwise return to Basic Control screen
|
||||
if(_rootMenu > 2) {
|
||||
if((_rootMenu > 2) || ((_rootMenu == 0) && NVstore.getUserSettings().NoHeater)) {
|
||||
uint8_t userHomeMenu = NVstore.getUserSettings().HomeMenu.onTimeout;
|
||||
if(userHomeMenu) { // allow user to override defualt screen
|
||||
userHomeMenu--;
|
||||
|
|
|
@ -1,19 +1,28 @@
|
|||
/*
|
||||
* This file is part of the "bluetoothheater" distribution
|
||||
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
||||
*
|
||||
* Copyright (C) 2019 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "NVStorage.h"
|
||||
#include "DebugPort.h"
|
||||
#include "MQTTsetup.h"
|
||||
|
||||
#ifdef newmqttmenu
|
||||
|
||||
/*const char* MQTTsetupmodes[] = {
|
||||
"Enter MQTT broker's IP address",
|
||||
"Enter MQTT broker's port",
|
||||
"Enter MQTT broker's username",
|
||||
"Enter MQTT broker's password",
|
||||
"Enter root topic name",
|
||||
"Enter QoS level",
|
||||
"Enable? (Y)es / (N)o"
|
||||
};*/
|
||||
|
||||
CMQTTsetup::CMQTTsetup()
|
||||
{
|
||||
_active = false;
|
||||
|
@ -171,13 +180,9 @@ CMQTTsetup::getMQTTstring(char rxVal, int maxidx, char* pTargetString)
|
|||
if(rxVal == '\n') {
|
||||
strncpy(pTargetString, _buffer, maxidx);
|
||||
pTargetString[maxidx] = 0;
|
||||
// _mode = 0;
|
||||
// showMQTTmenu();
|
||||
return true;
|
||||
}
|
||||
if(rxVal == 0x1b) {
|
||||
// _mode = 0;
|
||||
// showMQTTmenu();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -188,12 +193,9 @@ CMQTTsetup::getMQTTstring(char rxVal, int maxidx, char* pTargetString)
|
|||
if(_idx == maxidx) {
|
||||
strncpy(pTargetString, _buffer, maxidx);
|
||||
pTargetString[maxidx] = 0;
|
||||
// _mode = 0;
|
||||
// showMQTTmenu();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,3 +1,24 @@
|
|||
/*
|
||||
* This file is part of the "bluetoothheater" distribution
|
||||
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
||||
*
|
||||
* Copyright (C) 2019 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "NVStorage.h"
|
||||
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ sUserSettings::load()
|
|||
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("enableOTA", enableOTA, 0, u8inBounds, 0, 1);
|
||||
validatedLoad("cyclicStop", cyclic.Stop, 0, s8inBounds, 0, 10);
|
||||
validatedLoad("cyclicStart", cyclic.Start, -1, s8inBounds, -20, 0);
|
||||
uint8_t tVal;
|
||||
|
@ -386,6 +386,8 @@ sUserSettings::load()
|
|||
validatedLoad("JSONsingle", JSON.singleElement, 0, u8inBounds, 0, 1);
|
||||
validatedLoad("JSONLF", JSON.LF, 0, u8inBounds, 0, 1);
|
||||
validatedLoad("JSONpad", JSON.padding, 0, u8inBounds, 0, 1);
|
||||
validatedLoad("NoHeater", NoHeater, 0, u8inBounds, 0, 1);
|
||||
validatedLoad("Clock12hr", clock12hr, 0, u8inBounds, 0, 1);
|
||||
preferences.end();
|
||||
}
|
||||
|
||||
|
@ -417,6 +419,8 @@ sUserSettings::save()
|
|||
preferences.putUChar("JSONsingle", JSON.singleElement);
|
||||
preferences.putUChar("JSONLF", JSON.LF);
|
||||
preferences.putUChar("JSONpad", JSON.padding);
|
||||
preferences.putUChar("NoHeater", NoHeater);
|
||||
preferences.putUChar("Clock12hr", clock12hr);
|
||||
preferences.end();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is part of the "bluetoothheater" distribution
|
||||
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
||||
*
|
||||
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
|
||||
* Copyright (C) 2019 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
|
||||
|
@ -264,6 +264,8 @@ struct sUserSettings : public CESP32_NVStorage {
|
|||
sHomeMenuActions HomeMenu;
|
||||
sGPIOparams GPIO;
|
||||
sJSONoptions JSON;
|
||||
uint8_t NoHeater;
|
||||
uint8_t clock12hr;
|
||||
|
||||
bool valid() {
|
||||
bool retval = true;
|
||||
|
@ -295,7 +297,7 @@ struct sUserSettings : public CESP32_NVStorage {
|
|||
ThermostatWindow = 1.0;
|
||||
useThermostat = 1;
|
||||
enableWifi = 1;
|
||||
enableOTA = 1;
|
||||
enableOTA = 0;
|
||||
GPIO.in1Mode = CGPIOin1::Disabled;
|
||||
GPIO.in2Mode = CGPIOin2::Disabled;
|
||||
GPIO.out1Mode = CGPIOout1::Disabled;
|
||||
|
@ -305,6 +307,8 @@ struct sUserSettings : public CESP32_NVStorage {
|
|||
cyclic.init();
|
||||
HomeMenu.init();
|
||||
JSON.init();
|
||||
NoHeater = 0;
|
||||
clock12hr = 0;
|
||||
};
|
||||
void load();
|
||||
void save();
|
||||
|
@ -327,6 +331,8 @@ struct sUserSettings : public CESP32_NVStorage {
|
|||
cyclic = rhs.cyclic;
|
||||
HomeMenu = rhs.HomeMenu;
|
||||
JSON = rhs.JSON;
|
||||
NoHeater = rhs.NoHeater;
|
||||
clock12hr = rhs.clock12hr;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -28,6 +28,7 @@ char mqttHost[128];
|
|||
char mqttUser[32];
|
||||
char mqttPass[32];
|
||||
#endif
|
||||
char statusTopic[128];
|
||||
|
||||
#ifdef USE_RTOS_MQTTTIMER
|
||||
TimerHandle_t mqttReconnectTimer = NULL;
|
||||
|
@ -57,6 +58,8 @@ void onMqttConnect(bool sessionPresent)
|
|||
mqttReconnect = 0;
|
||||
#endif
|
||||
|
||||
sprintf(statusTopic, "%s/status", NVstore.getMQTTinfo().topic);
|
||||
|
||||
DebugPort.println("MQTT: Connected to broker.");
|
||||
// DebugPort.printf("Session present: %d\r\n", sessionPresent);
|
||||
|
||||
|
@ -68,9 +71,9 @@ void onMqttConnect(bool sessionPresent)
|
|||
MQTTclient.subscribe(topicnameJSONin, NVstore.getMQTTinfo().qos);
|
||||
|
||||
// spit out an "I'm here" message
|
||||
char lcltopic[128];
|
||||
sprintf(lcltopic, "%s/Status", NVstore.getMQTTinfo().topic);
|
||||
MQTTclient.publish(lcltopic, NVstore.getMQTTinfo().qos, true, "onMqttConnect");
|
||||
MQTTclient.publish(statusTopic, NVstore.getMQTTinfo().qos, true, "online");
|
||||
// and a will if we die unexpectedly
|
||||
MQTTclient.setWill(statusTopic, NVstore.getMQTTinfo().qos, true, "offline");
|
||||
|
||||
#ifdef MQTT_DBG_LOOPBACK
|
||||
// testo - loopback
|
||||
|
|
Loading…
Reference in a new issue