Condensed NV GPIO params into a struct. Improved GPIO info screen, showing disabled modes
This commit is contained in:
parent
200b928af6
commit
f4a3ce45bb
|
@ -1236,12 +1236,12 @@ void setupGPIO()
|
|||
// V2.0+ PCBs use an input transistor buffer. Active state into ESP32 is HIGH (inverted).
|
||||
int activePinState = (BoardRevision == 10) ? LOW : HIGH;
|
||||
int Input1 = BoardRevision == 20 ? GPIOin1_pinV20 : GPIOin1_pinV21V10;
|
||||
GPIOin.begin(Input1, GPIOin2_pin, NVstore.getGPIOinMode(), activePinState);
|
||||
GPIOin.begin(Input1, GPIOin2_pin, NVstore.getGPIOparams().inMode, activePinState);
|
||||
|
||||
// GPIO out is always active high from ESP32
|
||||
// V1.0 PCBs only expose the bare pins
|
||||
// V2.0+ PCBs provide an open collector output that conducts when active
|
||||
GPIOout.begin(GPIOout1_pin, GPIOout2_pin, NVstore.getGPIOoutMode());
|
||||
GPIOout.begin(GPIOout1_pin, GPIOout2_pin, NVstore.getGPIOparams().outMode);
|
||||
|
||||
// ### MAJOR ISSUE WITH ADC INPUTS ###
|
||||
//
|
||||
|
@ -1257,7 +1257,7 @@ void setupGPIO()
|
|||
// This will be properly fixed in V2.1 PCBs
|
||||
//
|
||||
// As V1.0 PCBS expose the bare pins, the correct GPIO33 input can be readily chosen.
|
||||
GPIOalgModes algMode = NVstore.getGPIOalgMode();
|
||||
GPIOalgModes algMode = NVstore.getGPIOparams().algMode;
|
||||
if(BoardRevision == 20)
|
||||
algMode = GPIOalgNone; // force off analogue support in V2.0 PCBs
|
||||
GPIOalg.begin(GPIOalg_pin, algMode);
|
||||
|
@ -1270,13 +1270,22 @@ void setupGPIO()
|
|||
}
|
||||
}
|
||||
|
||||
void setGPIO(int channel, bool state)
|
||||
bool toggleGPIOout(int channel)
|
||||
{
|
||||
if(NVstore.getGPIOparams().outMode == GPIOoutUser) {
|
||||
setGPIOout(channel, !getGPIOout(channel)); // toggle selected GPIO output
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void setGPIOout(int channel, bool state)
|
||||
{
|
||||
DebugPort.printf("setGPIO: Output #%d = %d\r\n", channel+1, state);
|
||||
GPIOout.setState(channel, state);
|
||||
}
|
||||
|
||||
bool getGPIO(int channel)
|
||||
bool getGPIOout(int channel)
|
||||
{
|
||||
bool retval = GPIOout.getState(channel);
|
||||
DebugPort.printf("getGPIO: Output #%d = %d\r\n", channel+1, retval);
|
||||
|
|
|
@ -135,7 +135,7 @@ CBasicScreen::show()
|
|||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
sprintf(msg, "GPIO output #%d %s", _feedbackType, getGPIO(_feedbackType-1) ? "ON" : "OFF");
|
||||
sprintf(msg, "GPIO output #%d %s", _feedbackType, getGPIOout(_feedbackType-1) ? "ON" : "OFF");
|
||||
break;
|
||||
}
|
||||
// centre message at bottom of screen
|
||||
|
@ -170,21 +170,23 @@ CBasicScreen::keyHandler(uint8_t event)
|
|||
// hold LEFT to toggle GPIO output #1
|
||||
if(event & key_Left) {
|
||||
if(repeatCount > 2) {
|
||||
repeatCount = -1; // prevent double handling
|
||||
setGPIO(0, !getGPIO(0)); // toggle GPIO output #1
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 1;
|
||||
_ScreenManager.reqUpdate();
|
||||
repeatCount = -1; // prevent double handling
|
||||
if(toggleGPIOout(0)) { // toggle GPIO output #1
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 1;
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
// hold RIGHT to toggle GPIO output #2
|
||||
if(event & key_Right) {
|
||||
if(repeatCount > 2) {
|
||||
repeatCount = -1; // prevent double handling
|
||||
setGPIO(1, !getGPIO(1)); // toggle GPIO output #2
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 2;
|
||||
_ScreenManager.reqUpdate();
|
||||
if(toggleGPIOout(1)) { // toggle GPIO output #2
|
||||
_showSetModeTime = millis() + 2000;
|
||||
_feedbackType = 2;
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
// hold DOWN to enter thermostat / fixed mode selection
|
||||
|
|
|
@ -91,14 +91,14 @@ CClockScreen::keyHandler(uint8_t event)
|
|||
if(event & key_Left) {
|
||||
if(_keyRepeatCount > 2) {
|
||||
_keyRepeatCount = -1; // prevent double handling
|
||||
setGPIO(0, !getGPIO(0)); // toggle GPIO output #1
|
||||
toggleGPIOout(0); // toggle GPIO output #1
|
||||
}
|
||||
}
|
||||
// hold RIGHT to toggle GPIO output #2
|
||||
if(event & key_Right) {
|
||||
if(_keyRepeatCount > 2) {
|
||||
_keyRepeatCount = -1; // prevent double handling
|
||||
setGPIO(1, !getGPIO(1)); // toggle GPIO output #2
|
||||
toggleGPIOout(1); // toggle GPIO output #2
|
||||
}
|
||||
}
|
||||
// hold CENTRE to toggle On/Off state
|
||||
|
|
|
@ -185,14 +185,14 @@ CDetailedScreen::keyHandler(uint8_t event)
|
|||
if(event & key_Left) {
|
||||
if(_keyRepeatCount > 2) {
|
||||
_keyRepeatCount = -1; // prevent double handling
|
||||
setGPIO(0, !getGPIO(0)); // toggle GPIO output #1
|
||||
toggleGPIOout(0); // toggle GPIO output #1
|
||||
}
|
||||
}
|
||||
// hold RIGHT to toggle GPIO output #2
|
||||
if(event & key_Right) {
|
||||
if(_keyRepeatCount > 2) {
|
||||
_keyRepeatCount = -1; // prevent double handling
|
||||
setGPIO(1, !getGPIO(1)); // toggle GPIO output #2
|
||||
toggleGPIOout(1); // toggle GPIO output #2
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ static const int Column = 38;
|
|||
CGPIOScreen::CGPIOScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr)
|
||||
{
|
||||
_initUI();
|
||||
_GPIOinMode = 0;
|
||||
_GPIOoutMode = 0;
|
||||
_GPIOalgMode = 0;
|
||||
_GPIOparams.inMode = GPIOinNone;
|
||||
_GPIOparams.outMode = GPIOoutNone;
|
||||
_GPIOparams.algMode = GPIOalgNone;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -59,9 +59,7 @@ CGPIOScreen::onSelect()
|
|||
{
|
||||
CPasswordScreen::onSelect();
|
||||
_initUI();
|
||||
_GPIOinMode = NVstore.getGPIOinMode();
|
||||
_GPIOoutMode = NVstore.getGPIOoutMode();
|
||||
_GPIOalgMode = NVstore.getGPIOalgMode();
|
||||
_GPIOparams = NVstore.getGPIOparams();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -88,11 +86,11 @@ CGPIOScreen::show()
|
|||
_drawBitmap(10, 14, GPIOIconInfo);
|
||||
{
|
||||
const char* msgText = NULL;
|
||||
switch(_GPIOinMode) {
|
||||
case 0: msgText = "Disabled"; break;
|
||||
case 1: msgText = "1-On 2-Off"; break;
|
||||
case 2: msgText = "1-On 2-\352T"; break;
|
||||
case 3: msgText = "1-On/Off"; break;
|
||||
switch(_GPIOparams.inMode) {
|
||||
case GPIOinNone: msgText = "Disabled"; break;
|
||||
case GPIOinOn1Off2: msgText = "1-On 2-Off"; break;
|
||||
case GPIOinOnHold1: msgText = "1-On 2-\352T"; break;
|
||||
case GPIOinOn1Off1: msgText = "1-On/Off"; break;
|
||||
}
|
||||
if(msgText)
|
||||
_printMenuText(Column, Line3, msgText, _rowSel == 3);
|
||||
|
@ -100,10 +98,10 @@ CGPIOScreen::show()
|
|||
|
||||
{
|
||||
const char* msgText = NULL;
|
||||
switch(_GPIOoutMode) {
|
||||
case 0: msgText = "Disabled"; break;
|
||||
case 1: msgText = "1: Status LED"; break;
|
||||
case 2: msgText = "1&2 User"; break;
|
||||
switch(_GPIOparams.outMode) {
|
||||
case GPIOoutNone: msgText = "Disabled"; break;
|
||||
case GPIOoutStatus: msgText = "1: Status LED"; break;
|
||||
case GPIOoutUser: msgText = "1&2 User"; break;
|
||||
}
|
||||
if(msgText)
|
||||
_printMenuText(Column, Line2, msgText, _rowSel == 2);
|
||||
|
@ -111,9 +109,9 @@ CGPIOScreen::show()
|
|||
|
||||
{
|
||||
const char* msgText = NULL;
|
||||
switch(_GPIOalgMode) {
|
||||
case 0: msgText = "Disabled"; break;
|
||||
case 1: msgText = "Ip1 allows"; break;
|
||||
switch(_GPIOparams.algMode) {
|
||||
case GPIOalgNone: msgText = "Disabled"; break;
|
||||
case GPIOalgHeatDemand: msgText = "Ip1 allows"; break;
|
||||
}
|
||||
if(msgText)
|
||||
_printMenuText(Column, Line1, msgText, _rowSel == 1);
|
||||
|
@ -139,9 +137,9 @@ CGPIOScreen::animate()
|
|||
break;
|
||||
case 1:
|
||||
_display.drawFastHLine(0, 52, 128, WHITE);
|
||||
switch(_GPIOalgMode) {
|
||||
case 0: pMsg = " Analogue input is ignored. "; break;
|
||||
case 1: pMsg = " Input 1 enables reading of analogue input to set temperature. "; break;
|
||||
switch(_GPIOparams.algMode) {
|
||||
case GPIOalgNone: pMsg = " Analogue input is ignored. "; break;
|
||||
case GPIOalgHeatDemand: pMsg = " Input 1 enables reading of analogue input to set temperature. "; break;
|
||||
}
|
||||
if(pMsg)
|
||||
_scrollMessage(56, pMsg, _scrollChar);
|
||||
|
@ -149,10 +147,10 @@ CGPIOScreen::animate()
|
|||
|
||||
case 2:
|
||||
_display.drawFastHLine(0, 52, 128, WHITE);
|
||||
switch(_GPIOoutMode) {
|
||||
case 0: pMsg = " Digital outputs are disabled. "; break;
|
||||
case 1: pMsg = " Output1: LED status indicator. "; break;
|
||||
case 2: pMsg = " Output 1&2: User controlled. "; break;
|
||||
switch(_GPIOparams.outMode) {
|
||||
case GPIOoutNone: pMsg = " Digital outputs are disabled. "; break;
|
||||
case GPIOoutStatus: pMsg = " Output1: LED status indicator. "; break;
|
||||
case GPIOoutUser: pMsg = " Output 1&2: User controlled. "; break;
|
||||
}
|
||||
if(pMsg)
|
||||
_scrollMessage(56, pMsg, _scrollChar);
|
||||
|
@ -160,11 +158,11 @@ CGPIOScreen::animate()
|
|||
|
||||
case 3:
|
||||
_display.drawFastHLine(0, 52, 128, WHITE);
|
||||
switch(_GPIOinMode) {
|
||||
case 0: pMsg = " Digital inputs are disabled. "; break;
|
||||
case 1: pMsg = " Input 1: Starts upon closure. Input 2: Stops upon closure. "; break;
|
||||
case 2: pMsg = " Input 1: Starts when held closed, stops when opened. Input2: Max fuel when closed, min fuel when open. "; break;
|
||||
case 3: pMsg = " Input 1: Starts or Stops upon closure. "; break;
|
||||
switch(_GPIOparams.inMode) {
|
||||
case GPIOinNone: pMsg = " Digital inputs are disabled. "; break;
|
||||
case GPIOinOn1Off2: pMsg = " Input 1: Starts upon closure. Input 2: Stops upon closure. "; break;
|
||||
case GPIOinOnHold1: pMsg = " Input 1: Starts when held closed, stops when opened. Input2: Max fuel when closed, min fuel when open. "; break;
|
||||
case GPIOinOn1Off1: pMsg = " Input 1: Starts or Stops upon closure. "; break;
|
||||
}
|
||||
if(pMsg)
|
||||
_scrollMessage(56, pMsg, _scrollChar);
|
||||
|
@ -231,9 +229,7 @@ CGPIOScreen::keyHandler(uint8_t event)
|
|||
break;
|
||||
case 4: // confirmed save
|
||||
_showStoringMessage();
|
||||
NVstore.setGPIOinMode(_GPIOinMode);
|
||||
NVstore.setGPIOoutMode(_GPIOoutMode);
|
||||
NVstore.setGPIOalgMode(_GPIOalgMode);
|
||||
NVstore.setGPIOparams(_GPIOparams);
|
||||
saveNV();
|
||||
|
||||
setupGPIO();
|
||||
|
@ -264,21 +260,25 @@ CGPIOScreen::keyHandler(uint8_t event)
|
|||
void
|
||||
CGPIOScreen::_adjust(int dir)
|
||||
{
|
||||
int tVal;
|
||||
switch(_rowSel) {
|
||||
case 1: // analogue mode
|
||||
_GPIOalgMode += dir;
|
||||
UPPERLIMIT(_GPIOalgMode, 1);
|
||||
LOWERLIMIT(_GPIOalgMode, 0);
|
||||
tVal = _GPIOparams.algMode;
|
||||
tVal += dir;
|
||||
WRAPLIMITS(tVal, 0, 1);
|
||||
_GPIOparams.algMode = (GPIOalgModes)tVal;
|
||||
break;
|
||||
case 2: // outputs mode
|
||||
_GPIOoutMode += dir;
|
||||
ROLLLOWERLIMIT(_GPIOoutMode, 0, 2);
|
||||
ROLLUPPERLIMIT(_GPIOoutMode, 2, 0);
|
||||
tVal = _GPIOparams.outMode;
|
||||
tVal += dir;
|
||||
WRAPLIMITS(tVal, 0, 2);
|
||||
_GPIOparams.outMode = (GPIOoutModes)tVal;
|
||||
break;
|
||||
case 3:
|
||||
_GPIOinMode += dir;
|
||||
ROLLUPPERLIMIT(_GPIOinMode, 3, 0);
|
||||
ROLLLOWERLIMIT(_GPIOinMode, 0, 3);
|
||||
tVal = _GPIOparams.inMode;
|
||||
tVal += dir;
|
||||
WRAPLIMITS(tVal, 0, 3);
|
||||
_GPIOparams.inMode = (GPIOinModes)tVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -318,14 +318,38 @@ CGPIOInfoScreen::show()
|
|||
|
||||
_printMenuText(55, Line1, "Analogue:", false, eRightJustify);
|
||||
|
||||
_drawBitmap(4, 29, GPIOin.getState(0) ? CloseIconInfo : OpenIconInfo);
|
||||
_drawBitmap(27, 29, GPIOin.getState(1) ? CloseIconInfo : OpenIconInfo);
|
||||
|
||||
_drawBitmap(86, 29, GPIOout.getState(0) ? BulbOnIconInfo : BulbOffIconInfo);
|
||||
_drawBitmap(113, 29, GPIOout.getState(1) ? BulbOnIconInfo : BulbOffIconInfo);
|
||||
if(NVstore.getGPIOparams().inMode == GPIOinNone) {
|
||||
_drawBitmap(7, 28, CrossLgIconInfo);
|
||||
_drawBitmap(30, 28, CrossLgIconInfo);
|
||||
}
|
||||
else {
|
||||
_drawBitmap(4, 29, GPIOin.getState(0) ? CloseIconInfo : OpenIconInfo);
|
||||
if(NVstore.getGPIOparams().inMode == GPIOinOn1Off1)
|
||||
_drawBitmap(30, 28, CrossLgIconInfo);
|
||||
else
|
||||
_drawBitmap(27, 29, GPIOin.getState(1) ? CloseIconInfo : OpenIconInfo);
|
||||
}
|
||||
|
||||
sprintf(msg, "%d", GPIOalg.getValue());
|
||||
_printMenuText(58, Line1, msg);
|
||||
|
||||
if(NVstore.getGPIOparams().outMode == GPIOoutNone) {
|
||||
_drawBitmap(87, 28, CrossLgIconInfo);
|
||||
_drawBitmap(114, 28, CrossLgIconInfo);
|
||||
}
|
||||
else {
|
||||
_drawBitmap(86, 29, GPIOout.getState(0) ? BulbOnIconInfo : BulbOffIconInfo);
|
||||
if(NVstore.getGPIOparams().outMode == GPIOoutStatus)
|
||||
_drawBitmap(114, 28, CrossLgIconInfo);
|
||||
else
|
||||
_drawBitmap(113, 29, GPIOout.getState(1) ? BulbOnIconInfo : BulbOffIconInfo);
|
||||
}
|
||||
|
||||
if(NVstore.getGPIOparams().algMode == GPIOalgNone) {
|
||||
_drawBitmap(58, Line1, CrossLgIconInfo);
|
||||
}
|
||||
else {
|
||||
sprintf(msg, "%d%%", GPIOalg.getValue() * 100 / 4096);
|
||||
_printMenuText(58, Line1, msg);
|
||||
}
|
||||
|
||||
_printMenuText(_display.xCentre(), 53, " \021 \020 ", true, eCentreJustify);
|
||||
return true;
|
||||
|
@ -354,14 +378,14 @@ CGPIOInfoScreen::keyHandler(uint8_t event)
|
|||
if(event & key_Left) {
|
||||
if(_keyRepeatCount > 2) {
|
||||
_keyRepeatCount = -1; // prevent double handling
|
||||
setGPIO(0, !getGPIO(0)); // toggle GPIO output #1
|
||||
toggleGPIOout(0); // toggle GPIO output #1
|
||||
}
|
||||
}
|
||||
// hold RIGHT to toggle GPIO output #2
|
||||
if(event & key_Right) {
|
||||
if(_keyRepeatCount > 2) {
|
||||
_keyRepeatCount = -1; // prevent double handling
|
||||
setGPIO(1, !getGPIO(1)); // toggle GPIO output #2
|
||||
toggleGPIOout(1); // toggle GPIO output #2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include "PasswordScreen.h"
|
||||
#include "../Utility/GPIO.h"
|
||||
|
||||
class C128x64_OLED;
|
||||
class CScreenManager;
|
||||
|
@ -32,9 +33,7 @@ class CGPIOScreen : public CPasswordScreen
|
|||
{
|
||||
int _rowSel;
|
||||
void _adjust(int dir);
|
||||
int _GPIOinMode;
|
||||
int _GPIOoutMode;
|
||||
int _GPIOalgMode;
|
||||
sGPIOparams _GPIOparams;
|
||||
int _animateCount;
|
||||
int _scrollChar;
|
||||
void _initUI();
|
||||
|
|
|
@ -119,7 +119,7 @@ CHeaterSettingsScreen::animate()
|
|||
}
|
||||
else {
|
||||
_animateCount++;
|
||||
ROLLUPPERLIMIT(_animateCount, 9, 0);
|
||||
WRAPUPPERLIMIT(_animateCount, 9, 0);
|
||||
|
||||
if(_rowSel == 1) {
|
||||
_display.drawRect(Column-border, Line1-border, 34, 8+2*border, BLACK);
|
||||
|
|
|
@ -199,18 +199,15 @@ CHomeMenuSelScreen::adjust(int dir)
|
|||
switch(_rowSel) {
|
||||
case 1:
|
||||
_action.onStop += dir;
|
||||
ROLLLOWERLIMIT(_action.onStop, 0, 3);
|
||||
ROLLUPPERLIMIT(_action.onStop, 3, 0);
|
||||
WRAPLIMITS(_action.onStop, 0, 3);
|
||||
break;
|
||||
case 2:
|
||||
_action.onStart += dir;
|
||||
ROLLLOWERLIMIT(_action.onStart, 0, 3);
|
||||
ROLLUPPERLIMIT(_action.onStart, 3, 0);
|
||||
WRAPLIMITS(_action.onStart, 0, 3);
|
||||
break;
|
||||
case 3:
|
||||
_action.onTimeout += dir;
|
||||
ROLLLOWERLIMIT(_action.onTimeout, 0, 3);
|
||||
ROLLUPPERLIMIT(_action.onTimeout, 3, 0);
|
||||
WRAPLIMITS(_action.onTimeout, 0, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,13 +129,13 @@ CPasswordScreen::keyHandler(uint8_t event)
|
|||
// press UP
|
||||
if(event & key_Up) {
|
||||
_PWdig[_PWcol]++;
|
||||
ROLLUPPERLIMIT(_PWdig[_PWcol], 9, 0);
|
||||
WRAPUPPERLIMIT(_PWdig[_PWcol], 9, 0);
|
||||
}
|
||||
|
||||
// press DOWN
|
||||
if(event & key_Down) {
|
||||
_PWdig[_PWcol]--;
|
||||
ROLLLOWERLIMIT(_PWdig[_PWcol], 0, 9);
|
||||
WRAPLOWERLIMIT(_PWdig[_PWcol], 0, 9);
|
||||
}
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ CScreenHeader::animate()
|
|||
// animate timer icon,
|
||||
// inserting an update icon if new firmware available from internet web server
|
||||
_animateCount++;
|
||||
ROLLUPPERLIMIT(_animateCount, 10, 0);
|
||||
WRAPUPPERLIMIT(_animateCount, 10, 0);
|
||||
if(isUpdateAvailable(true)) {
|
||||
int xPos = X_TIMER_ICON - 3;
|
||||
int yPos = Y_TIMER_ICON;
|
||||
|
|
|
@ -411,8 +411,7 @@ CScreenManager::_changeSubMenu(int dir)
|
|||
_leaveScreen();
|
||||
_subMenu += dir;
|
||||
int bounds = _Screens[_menu].size() - 1;
|
||||
ROLLUPPERLIMIT(_subMenu, bounds, 0);
|
||||
ROLLLOWERLIMIT(_subMenu, 0, bounds);
|
||||
WRAPLIMITS(_subMenu, 0, bounds);
|
||||
if(_menu == 0)
|
||||
_rootMenu = _subMenu; // track the root menu for when we branch then return
|
||||
_enterScreen();
|
||||
|
|
|
@ -173,7 +173,7 @@ CSetClockScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
else {
|
||||
_rowSel--;
|
||||
ROLLLOWERLIMIT(_rowSel, 1, 7);
|
||||
WRAPLOWERLIMIT(_rowSel, 1, 7);
|
||||
}
|
||||
}
|
||||
// press RIGHT
|
||||
|
@ -183,7 +183,7 @@ CSetClockScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
else {
|
||||
_rowSel++;
|
||||
ROLLUPPERLIMIT(_rowSel, 7, 1);
|
||||
WRAPUPPERLIMIT(_rowSel, 7, 1);
|
||||
}
|
||||
}
|
||||
// press UP
|
||||
|
|
|
@ -206,12 +206,12 @@ CSetTimerScreen::keyHandler(uint8_t event)
|
|||
case 1:
|
||||
// select previous field
|
||||
_colSel--;
|
||||
ROLLLOWERLIMIT(_colSel, 0, 5);
|
||||
WRAPLOWERLIMIT(_colSel, 0, 5);
|
||||
break;
|
||||
case 2:
|
||||
// select previous day
|
||||
_colSel--;
|
||||
ROLLLOWERLIMIT(_colSel, 0, 6);
|
||||
WRAPLOWERLIMIT(_colSel, 0, 6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -224,12 +224,12 @@ CSetTimerScreen::keyHandler(uint8_t event)
|
|||
case 1:
|
||||
// select next field
|
||||
_colSel++;
|
||||
ROLLUPPERLIMIT(_colSel, 5, 0);
|
||||
WRAPUPPERLIMIT(_colSel, 5, 0);
|
||||
break;
|
||||
case 2:
|
||||
// select next day
|
||||
_colSel++;
|
||||
ROLLUPPERLIMIT(_colSel, 6, 0);
|
||||
WRAPUPPERLIMIT(_colSel, 6, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -322,23 +322,19 @@ CSetTimerScreen::_adjust(int dir)
|
|||
switch(_colSel) {
|
||||
case 0:
|
||||
_timerInfo.start.hour += dir;
|
||||
ROLLUPPERLIMIT(_timerInfo.start.hour, 23, 0);
|
||||
ROLLLOWERLIMIT(_timerInfo.start.hour, 0, 23);
|
||||
WRAPLIMITS(_timerInfo.start.hour, 0, 23);
|
||||
break;
|
||||
case 1:
|
||||
_timerInfo.start.min += dir;
|
||||
ROLLUPPERLIMIT(_timerInfo.start.min, 59, 0);
|
||||
ROLLLOWERLIMIT(_timerInfo.start.min, 0, 59);
|
||||
WRAPLIMITS(_timerInfo.start.min, 0, 59);
|
||||
break;
|
||||
case 2:
|
||||
_timerInfo.stop.hour += dir;
|
||||
ROLLUPPERLIMIT(_timerInfo.stop.hour, 23, 0);
|
||||
ROLLLOWERLIMIT(_timerInfo.stop.hour, 0, 23);
|
||||
WRAPLIMITS(_timerInfo.stop.hour, 0, 23);
|
||||
break;
|
||||
case 3:
|
||||
_timerInfo.stop.min += dir;
|
||||
ROLLUPPERLIMIT(_timerInfo.stop.min, 59, 0);
|
||||
ROLLLOWERLIMIT(_timerInfo.stop.min, 0, 59);
|
||||
WRAPLIMITS(_timerInfo.stop.min, 0, 59);
|
||||
break;
|
||||
case 4:
|
||||
if(_rowSel == 1) {
|
||||
|
|
|
@ -103,7 +103,7 @@ CSettingsScreen::animate()
|
|||
}
|
||||
else {
|
||||
_animateCount++;
|
||||
ROLLUPPERLIMIT(_animateCount, 9, 0);
|
||||
WRAPUPPERLIMIT(_animateCount, 9, 0);
|
||||
|
||||
int glowDrive = getHeaterInfo().getGlow_Drive();
|
||||
_printMenuText(Column, Line1, " ");
|
||||
|
|
|
@ -311,8 +311,7 @@ CThermostatModeScreen::_adjust(int dir)
|
|||
break;
|
||||
case 4: // thermostat mode
|
||||
_thermoMode += dir;
|
||||
ROLLLOWERLIMIT(_thermoMode, 0, 2);
|
||||
ROLLUPPERLIMIT(_thermoMode, 2, 0);
|
||||
WRAPLIMITS(_thermoMode, 0, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ CTimerChartScreen::show()
|
|||
if(pixel > 4) {
|
||||
pixel = 0;
|
||||
subpixel++;
|
||||
ROLLUPPERLIMIT(subpixel, 2, 0);
|
||||
WRAPUPPERLIMIT(subpixel, 2, 0);
|
||||
}
|
||||
if((interval == 119) && blockStart >=0) { // timer ran up until midnight
|
||||
IDcentre = hour0 + (blockStart + 120) / 2;
|
||||
|
@ -158,8 +158,8 @@ CTimerChartScreen::keyHandler(uint8_t event)
|
|||
// handle initial key press
|
||||
if(event & keyPressed) {
|
||||
bHeld = false;
|
||||
// press CENTRE
|
||||
if(event & key_Centre) {
|
||||
// press CENTRE, UP or DOWN
|
||||
if(event & (key_Centre | key_Down | key_Up)) {
|
||||
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // exit: return to clock screen
|
||||
}
|
||||
// press LEFT - navigate fields, or screens
|
||||
|
@ -170,12 +170,6 @@ CTimerChartScreen::keyHandler(uint8_t event)
|
|||
if(event & key_Right) {
|
||||
_ScreenManager.nextMenu();
|
||||
}
|
||||
// press UP
|
||||
if(event & key_Up) {
|
||||
}
|
||||
// press DOWN
|
||||
if(event & key_Down) {
|
||||
}
|
||||
}
|
||||
|
||||
// handle held down keys
|
||||
|
|
|
@ -149,7 +149,7 @@ CVersionInfoScreen::animate()
|
|||
if(_rowSel <= 1 && isUpdateAvailable()) {
|
||||
// show ascending up arrow if firmware update is available on web server
|
||||
_animateCount++;
|
||||
ROLLUPPERLIMIT(_animateCount, 5, 0);
|
||||
WRAPUPPERLIMIT(_animateCount, 5, 0);
|
||||
int ypos = 11 + 15 - 7 - _animateCount;
|
||||
_display.fillRect(0, 11, 10, 21, BLACK);
|
||||
_display.drawBitmap(2, ypos, WifiOutIconInfo.pBitmap, WifiOutIconInfo.width, 7, WHITE); // upload arrow - from web to afterburner
|
||||
|
|
|
@ -574,6 +574,19 @@ const uint8_t PROGMEM OpenIcon[] =
|
|||
};
|
||||
const BITMAP_INFO OpenIconInfo(13, 7, OpenIcon);
|
||||
|
||||
const uint8_t PROGMEM CrossLgIcon[] =
|
||||
{
|
||||
0x82, // # #
|
||||
0x44, // # #
|
||||
0x28, // # #
|
||||
0x10, // #
|
||||
0x28, // # #
|
||||
0x44, // # #
|
||||
0x82, // # #
|
||||
};
|
||||
const BITMAP_INFO CrossLgIconInfo(7, 7, CrossLgIcon);
|
||||
|
||||
|
||||
const uint8_t PROGMEM CloseIcon[] =
|
||||
{
|
||||
0x00, 0x00, //
|
||||
|
|
|
@ -73,6 +73,7 @@ extern const BITMAP_INFO TimerIconInfo;
|
|||
extern const BITMAP_INFO LargeTimerIconInfo;
|
||||
extern const BITMAP_INFO VerticalRepeatIconInfo;
|
||||
|
||||
extern const BITMAP_INFO CrossLgIconInfo;
|
||||
|
||||
// Bitmap for open
|
||||
extern const BITMAP_INFO OpenIconInfo;
|
||||
|
|
|
@ -64,19 +64,21 @@ const char* getVersionStr();
|
|||
extern const char* getVersionDate();
|
||||
extern int getBoardRevision();
|
||||
extern void setupGPIO();
|
||||
extern void setGPIO(int channel, bool state);
|
||||
extern bool getGPIO(int channel);
|
||||
extern void setGPIOout(int channel, bool state);
|
||||
extern bool getGPIOout(int channel);
|
||||
extern bool toggleGPIOout(int channel);
|
||||
extern void feedWatchdog();
|
||||
extern bool isUpdateAvailable(bool test=true);
|
||||
extern void checkFOTA();
|
||||
extern void setUploadSize(long val);
|
||||
extern void setUploadSize(long val);
|
||||
|
||||
|
||||
|
||||
|
||||
#define LOWERLIMIT(A, B) if((A) < (B)) (A) = (B)
|
||||
#define UPPERLIMIT(A, B) if((A) > (B)) (A) = (B)
|
||||
#define ROLLUPPERLIMIT(A, B, C) if((A) > (B)) (A) = (C)
|
||||
#define ROLLLOWERLIMIT(A, B, C) if((A) < (B)) (A) = (C)
|
||||
#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)
|
||||
|
||||
#endif
|
|
@ -292,7 +292,7 @@ CTimerManager::findNextTimer(int hour, int minute, int dow)
|
|||
if(dayMinute == _dayMinutes) {
|
||||
dayMinute = 0;
|
||||
dow++;
|
||||
ROLLUPPERLIMIT(dow, 6, 0);
|
||||
WRAPUPPERLIMIT(dow, 6, 0);
|
||||
}
|
||||
}
|
||||
nextTimer = 0;
|
||||
|
|
|
@ -44,6 +44,12 @@ enum GPIOalgModes {
|
|||
GPIOalgHeatDemand,
|
||||
};
|
||||
|
||||
struct sGPIOparams {
|
||||
GPIOinModes inMode;
|
||||
GPIOoutModes outMode;
|
||||
GPIOalgModes algMode;
|
||||
};
|
||||
|
||||
|
||||
class CGPIOin {
|
||||
GPIOinModes _Mode;
|
||||
|
|
|
@ -295,59 +295,18 @@ CHeaterStorage::setCyclicMode(const sCyclicThermostat& val)
|
|||
save();
|
||||
}
|
||||
|
||||
GPIOinModes
|
||||
CHeaterStorage::getGPIOinMode()
|
||||
const sGPIOparams&
|
||||
CHeaterStorage::getGPIOparams() const
|
||||
{
|
||||
GPIOinModes inMode = GPIOinNone;
|
||||
switch(_calValues.Options.GPIOinMode) {
|
||||
case 0: inMode = GPIOinNone; break;
|
||||
case 1: inMode = GPIOinOn1Off2; break;
|
||||
case 2: inMode = GPIOinOnHold1; break;
|
||||
case 3: inMode = GPIOinOn1Off1; break;
|
||||
}
|
||||
return inMode;
|
||||
return _calValues.Options.GPIO;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setGPIOinMode(unsigned char val)
|
||||
void
|
||||
CHeaterStorage::setGPIOparams(const sGPIOparams& params)
|
||||
{
|
||||
_calValues.Options.GPIOinMode = val;
|
||||
_calValues.Options.GPIO = params;
|
||||
}
|
||||
|
||||
GPIOoutModes
|
||||
CHeaterStorage::getGPIOoutMode()
|
||||
{
|
||||
GPIOoutModes outMode = GPIOoutNone;
|
||||
switch(_calValues.Options.GPIOoutMode) {
|
||||
case 0: outMode = GPIOoutNone; break;
|
||||
case 1: outMode = GPIOoutStatus; break;
|
||||
case 2: outMode = GPIOoutUser; break;
|
||||
}
|
||||
return outMode;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setGPIOoutMode(unsigned char val)
|
||||
{
|
||||
_calValues.Options.GPIOoutMode = val;
|
||||
}
|
||||
|
||||
GPIOalgModes
|
||||
CHeaterStorage::getGPIOalgMode()
|
||||
{
|
||||
GPIOalgModes algMode = GPIOalgNone;
|
||||
switch (_calValues.Options.GPIOalgMode) {
|
||||
case 0: algMode = GPIOalgNone; break;
|
||||
case 1: algMode = GPIOalgHeatDemand; break;
|
||||
}
|
||||
return algMode;
|
||||
}
|
||||
|
||||
void
|
||||
CHeaterStorage::setGPIOalgMode(unsigned char val)
|
||||
{
|
||||
_calValues.Options.GPIOalgMode = val;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
CHeaterStorage::getFrameRate()
|
||||
|
@ -531,9 +490,10 @@ sBTCoptions::load()
|
|||
validatedLoad("enableOTA", enableOTA, 1, u8inBounds, 0, 1);
|
||||
validatedLoad("cyclicStop", cyclic.Stop, 0, s8inBounds, 0, 10);
|
||||
validatedLoad("cyclicStart", cyclic.Start, -1, s8inBounds, -20, 0);
|
||||
validatedLoad("GPIOinMode", GPIOinMode, 0, u8inBounds, 0, 3);
|
||||
validatedLoad("GPIOoutMode", GPIOoutMode, 0, u8inBounds, 0, 2);
|
||||
validatedLoad("GPIOalgMode", GPIOalgMode, 0, u8inBounds, 0, 2);
|
||||
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;
|
||||
validatedLoad("MenuonTimeout", HomeMenu.onTimeout, 0, u8inBounds, 0, 3);
|
||||
validatedLoad("MenuonStart", HomeMenu.onStart, 0, u8inBounds, 0, 3);
|
||||
validatedLoad("MenuonStop", HomeMenu.onStop, 0, u8inBounds, 0, 3);
|
||||
|
@ -554,9 +514,9 @@ sBTCoptions::save()
|
|||
preferences.putUChar("enableOTA", enableOTA);
|
||||
preferences.putChar("cyclicStop", cyclic.Stop);
|
||||
preferences.putChar("cyclicStart",cyclic.Start);
|
||||
preferences.putUChar("GPIOinMode", GPIOinMode);
|
||||
preferences.putUChar("GPIOoutMode", GPIOoutMode);
|
||||
preferences.putUChar("GPIOalgMode", GPIOalgMode);
|
||||
preferences.putUChar("GPIOinMode", GPIO.inMode);
|
||||
preferences.putUChar("GPIOoutMode", GPIO.outMode);
|
||||
preferences.putUChar("GPIOalgMode", GPIO.algMode);
|
||||
preferences.putUChar("MenuOnTimeout", HomeMenu.onTimeout);
|
||||
preferences.putUChar("MenuonStart", HomeMenu.onStart);
|
||||
preferences.putUChar("MenuonStop", HomeMenu.onStop);
|
||||
|
|
|
@ -159,12 +159,10 @@ struct sBTCoptions : public CESP32_NVStorage {
|
|||
uint8_t ThermostatMethod; // 0: standard heater, 1: Narrow Hysterisis, 2:Managed Hz mode
|
||||
uint8_t enableWifi;
|
||||
uint8_t enableOTA;
|
||||
uint8_t GPIOinMode;
|
||||
uint8_t GPIOoutMode;
|
||||
uint8_t GPIOalgMode;
|
||||
uint16_t FrameRate;
|
||||
sCyclicThermostat cyclic;
|
||||
sHomeMenuActions HomeMenu;
|
||||
sGPIOparams GPIO;
|
||||
|
||||
bool valid() {
|
||||
bool retval = true;
|
||||
|
@ -174,8 +172,8 @@ struct sBTCoptions : public CESP32_NVStorage {
|
|||
retval &= (ThermostatMethod & 0x03) < 3; // only modes 0, 1 or 2
|
||||
retval &= (enableWifi == 0) || (enableWifi == 1);
|
||||
retval &= (enableOTA == 0) || (enableOTA == 1);
|
||||
retval &= GPIOinMode < 4;
|
||||
retval &= GPIOoutMode < 3;
|
||||
retval &= GPIO.inMode < 4;
|
||||
retval &= GPIO.outMode < 3;
|
||||
retval &= (FrameRate >= 300) && (FrameRate <= 1500);
|
||||
retval &= cyclic.valid();
|
||||
retval &= HomeMenu.valid();
|
||||
|
@ -188,9 +186,9 @@ struct sBTCoptions : public CESP32_NVStorage {
|
|||
ThermostatMethod = 0;
|
||||
enableWifi = 1;
|
||||
enableOTA = 1;
|
||||
GPIOinMode = 0;
|
||||
GPIOoutMode = 0;
|
||||
GPIOalgMode = 0;
|
||||
GPIO.inMode = GPIOinNone;
|
||||
GPIO.outMode = GPIOoutNone;
|
||||
GPIO.algMode = GPIOalgNone;
|
||||
FrameRate = 1000;
|
||||
cyclic.init();
|
||||
HomeMenu.init();
|
||||
|
@ -245,9 +243,7 @@ public:
|
|||
unsigned char getOTAEnabled();
|
||||
const sCyclicThermostat& getCyclicMode() const;
|
||||
const sMQTTparams& getMQTTinfo() const;
|
||||
GPIOinModes getGPIOinMode();
|
||||
GPIOoutModes getGPIOoutMode();
|
||||
GPIOalgModes getGPIOalgMode();
|
||||
const sGPIOparams& getGPIOparams() const;
|
||||
uint16_t getFrameRate();
|
||||
const sHomeMenuActions& getHomeMenu() const;
|
||||
const sCredentials& getCredentials() const;
|
||||
|
@ -269,9 +265,7 @@ public:
|
|||
void setWifiEnabled(unsigned char val);
|
||||
void setOTAEnabled(unsigned char val);
|
||||
void setCyclicMode(const sCyclicThermostat& val);
|
||||
void setGPIOinMode(unsigned char val);
|
||||
void setGPIOoutMode(unsigned char val);
|
||||
void setGPIOalgMode(unsigned char val);
|
||||
void setGPIOparams(const sGPIOparams& params);
|
||||
void setFrameRate(uint16_t val);
|
||||
void setHomeMenu(sHomeMenuActions val);
|
||||
|
||||
|
|
Loading…
Reference in a new issue