Using CPasswordScreen for Fuel and heater settings
This commit is contained in:
parent
033d2f4c27
commit
7ddc2c16ef
|
@ -45,7 +45,7 @@ CBasicScreen::CBasicScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreen
|
|||
_nModeSel = 0;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
CBasicScreen::show()
|
||||
{
|
||||
CScreenHeader::show();
|
||||
|
@ -118,10 +118,11 @@ CBasicScreen::show()
|
|||
if((_showMode == 0) && (_showSetMode == 0)) {
|
||||
showRunState();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CBasicScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
static int repeatCount = -1;
|
||||
|
@ -227,6 +228,7 @@ CBasicScreen::keyHandler(uint8_t event)
|
|||
|
||||
repeatCount = -1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -34,7 +34,7 @@ class CBasicScreen : public CScreenHeader
|
|||
void showRunState();
|
||||
public:
|
||||
CBasicScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
void keyHandler(uint8_t event);
|
||||
bool show();
|
||||
bool keyHandler(uint8_t event);
|
||||
bool animate() { return CScreen::animate(); };
|
||||
};
|
||||
|
|
|
@ -46,7 +46,7 @@ CClockScreen::showTime(int)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CClockScreen::show()
|
||||
{
|
||||
CScreenHeader::show();
|
||||
|
@ -68,17 +68,15 @@ CClockScreen::show()
|
|||
}
|
||||
sprintf(str, "%s %d %s %d", now.dowStr(), now.day(), now.monthStr(), now.year());
|
||||
_printMenuText(_display.xCentre(), 56, str, false, eCentreJustify);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CClockScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
if(event & keyPressed) {
|
||||
// press CENTRE
|
||||
if(event & key_Centre) {
|
||||
return;
|
||||
}
|
||||
// press LEFT
|
||||
if(event & key_Left) {
|
||||
_ScreenManager.prevScreen();
|
||||
|
@ -96,5 +94,6 @@ CClockScreen::keyHandler(uint8_t event)
|
|||
_ScreenManager.selectTimerScreen(true); // switch to timer set screen loop
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,6 @@ protected:
|
|||
bool _colon;
|
||||
public:
|
||||
CClockScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
void keyHandler(uint8_t event);
|
||||
bool show();
|
||||
bool keyHandler(uint8_t event);
|
||||
};
|
||||
|
|
|
@ -73,7 +73,7 @@ CDetailedScreen::CDetailedScreen(C128x64_OLED& display, CScreenManager& mgr) : C
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CDetailedScreen::show()
|
||||
{
|
||||
CScreenHeader::show();
|
||||
|
@ -119,6 +119,7 @@ CDetailedScreen::show()
|
|||
}
|
||||
|
||||
showRunState(runstate, errstate);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -165,7 +166,7 @@ CDetailedScreen::animate()
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CDetailedScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
|
||||
|
@ -214,6 +215,7 @@ CDetailedScreen::keyHandler(uint8_t event)
|
|||
if(event & keyReleased) {
|
||||
_keyRepeatCount = -1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class CDetailedScreen : public CScreenHeader
|
|||
void showRunState(int state, int errstate);
|
||||
public:
|
||||
CDetailedScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
bool show();
|
||||
bool animate();
|
||||
void keyHandler(uint8_t event);
|
||||
bool keyHandler(uint8_t event);
|
||||
};
|
||||
|
|
|
@ -32,20 +32,16 @@
|
|||
#include "KeyPad.h"
|
||||
#include "../Protocol/helpers.h"
|
||||
#include "../Wifi/BTCWifi.h"
|
||||
#include "fonts/Arial.h"
|
||||
|
||||
|
||||
CFuelMixtureScreen::CFuelMixtureScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreenHeader(display, mgr)
|
||||
CFuelMixtureScreen::CFuelMixtureScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr)
|
||||
{
|
||||
_rowSel = 0;
|
||||
_colSel = 0;
|
||||
_SaveTime = 0;
|
||||
for(int i= 0; i < 4; i++)
|
||||
_PWdig[i] = -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CFuelMixtureScreen::show()
|
||||
{
|
||||
CScreenHeader::show();
|
||||
|
@ -56,15 +52,7 @@ CFuelMixtureScreen::show()
|
|||
const int col3 = _display.width() - border;
|
||||
_printInverted(0, 16, " Fuel Settings ", true);
|
||||
|
||||
if(_SaveTime) {
|
||||
long tDelta = millis() - _SaveTime;
|
||||
if(tDelta > 0)
|
||||
_SaveTime = 0;
|
||||
_printInverted(_display.xCentre(), 28, " ", true, eCentreJustify);
|
||||
_printInverted(_display.xCentre(), 39, " ", true, eCentreJustify);
|
||||
_printInverted(_display.xCentre(), 34, " STORING ", true, eCentreJustify);
|
||||
}
|
||||
else {
|
||||
if(!CPasswordScreen::show()) {
|
||||
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
|
@ -90,249 +78,193 @@ CFuelMixtureScreen::show()
|
|||
break;
|
||||
|
||||
case 1:
|
||||
_printMenuText(_display.xCentre(), 34, "Enter password...", false, eCentreJustify);
|
||||
_showPassword();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
_display.clearDisplay();
|
||||
// Pump Minimum adjustment
|
||||
yPos = border + 36;
|
||||
_printMenuText(80, yPos, "Min", false, eRightJustify);
|
||||
sprintf(str, "%.1f", adjPump[0]);
|
||||
_printMenuText(col3, yPos, str, _rowSel == 2, eRightJustify);
|
||||
_printMenuText(col3, yPos, str, _rowSel == 1, eRightJustify);
|
||||
// Pump Maximum adjustment
|
||||
yPos = border + 24;
|
||||
_printMenuText(80, yPos, "Pump Hz Max", false, eRightJustify);
|
||||
sprintf(str, "%.1f", adjPump[1]);
|
||||
_printMenuText(col3, yPos, str, _rowSel == 3, eRightJustify);
|
||||
_printMenuText(col3, yPos, str, _rowSel == 2, eRightJustify);
|
||||
// Fan Minimum adjustment
|
||||
yPos = border + 12;
|
||||
_printMenuText(80, yPos, "Min", false, eRightJustify);
|
||||
sprintf(str, "%d", adjFan[0]);
|
||||
_printMenuText(col3, yPos, str, _rowSel == 4, eRightJustify);
|
||||
_printMenuText(col3, yPos, str, _rowSel == 3, eRightJustify);
|
||||
// Fan Maximum adjustment
|
||||
yPos = border;
|
||||
_printMenuText(80, yPos, "Fan RPM Max", false, eRightJustify);
|
||||
sprintf(str, "%d", adjFan[1]);
|
||||
_printMenuText(col3, yPos, str, _rowSel == 5, eRightJustify);
|
||||
_printMenuText(col3, yPos, str, _rowSel == 4, eRightJustify);
|
||||
// navigation line
|
||||
yPos = 53;
|
||||
_printMenuText(_display.xCentre(), yPos, "<- ->", false, eCentreJustify);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 5:
|
||||
_printMenuText(_display.xCentre(), 35, "Press UP to", false, eCentreJustify);
|
||||
_printMenuText(_display.xCentre(), 43, "confirm save", false, eCentreJustify);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// _display.display();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CFuelMixtureScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
if(CPasswordScreen::keyHandler(event)) {
|
||||
if(_isPasswordOK()) {
|
||||
_rowSel = 1;
|
||||
_colSel = 0;
|
||||
// grab current settings upon entry to edit mode
|
||||
adjPump[0] = getHeaterInfo().getPump_Min();
|
||||
adjPump[1] = getHeaterInfo().getPump_Max();
|
||||
adjFan[0] = getHeaterInfo().getFan_Min();
|
||||
adjFan[1] = getHeaterInfo().getFan_Max();
|
||||
}
|
||||
}
|
||||
|
||||
if(event & keyPressed) {
|
||||
// press CENTRE
|
||||
if(event & key_Centre) {
|
||||
switch(_rowSel) {
|
||||
case 1:
|
||||
// match "1688"
|
||||
if((_PWdig[0] == 1) &&
|
||||
(_PWdig[1] == 6) &&
|
||||
(_PWdig[2] == 8) &&
|
||||
(_PWdig[3] == 8)) {
|
||||
_rowSel = 2;
|
||||
_colSel = 0;
|
||||
// grab current settings upon entry to edit mode
|
||||
adjPump[0] = getHeaterInfo().getPump_Min();
|
||||
adjPump[1] = getHeaterInfo().getPump_Max();
|
||||
adjFan[0] = getHeaterInfo().getFan_Min();
|
||||
adjFan[1] = getHeaterInfo().getFan_Max();
|
||||
}
|
||||
// reset PW digits
|
||||
for(int i= 0; i < 4; i++)
|
||||
_PWdig[i] = -1;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
_rowSel = 6; // enter save confirm mode
|
||||
break;
|
||||
case 6:
|
||||
_rowSel = 0;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// press LEFT
|
||||
if(event & key_Left) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_ScreenManager.prevScreen();
|
||||
break;
|
||||
case 1:
|
||||
_colSel--;
|
||||
LOWERLIMIT(_colSel, 0);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
_adjustSetting(-1);
|
||||
break;
|
||||
case 6:
|
||||
_rowSel = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// press RIGHT
|
||||
if(event & key_Right) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_ScreenManager.nextScreen();
|
||||
break;
|
||||
case 1:
|
||||
_colSel++;
|
||||
UPPERLIMIT(_colSel, 5);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
_adjustSetting(+1);
|
||||
break;
|
||||
case 6:
|
||||
_rowSel = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// press UP
|
||||
if(event & key_Up) {
|
||||
if(hasOEMcontroller())
|
||||
_reqOEMWarning();
|
||||
else {
|
||||
else {
|
||||
|
||||
if(event & keyPressed) {
|
||||
// press CENTRE
|
||||
if(event & key_Centre) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
_rowSel++;
|
||||
_colSel = 0;
|
||||
UPPERLIMIT(_rowSel, 5);
|
||||
_rowSel = 5; // enter save confirm mode
|
||||
break;
|
||||
case 1: // password entry
|
||||
_PWdig[_colSel]++;
|
||||
ROLLUPPERLIMIT(_PWdig[_colSel], 9, 0);
|
||||
break;
|
||||
case 6:
|
||||
_SaveTime = millis() + 1500;
|
||||
setPumpMin(adjPump[0]);
|
||||
setPumpMax(adjPump[1]);
|
||||
setFanMin(adjFan[0]);
|
||||
setFanMax(adjFan[1]);
|
||||
saveNV();
|
||||
case 5:
|
||||
_rowSel = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// press LEFT
|
||||
if(event & key_Left) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_ScreenManager.prevScreen();
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
_adjustSetting(-1);
|
||||
break;
|
||||
case 5:
|
||||
_rowSel = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// press RIGHT
|
||||
if(event & key_Right) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_ScreenManager.nextScreen();
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
_adjustSetting(+1);
|
||||
break;
|
||||
case 5:
|
||||
_rowSel = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// press UP
|
||||
if(event & key_Up) {
|
||||
if(hasOEMcontroller())
|
||||
_reqOEMWarning();
|
||||
else {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_getPassword();
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
_rowSel++;
|
||||
_colSel = 0;
|
||||
UPPERLIMIT(_rowSel, 4);
|
||||
break;
|
||||
case 5:
|
||||
_showStoringMessage();
|
||||
setPumpMin(adjPump[0]);
|
||||
setPumpMax(adjPump[1]);
|
||||
setFanMin(adjFan[0]);
|
||||
setFanMax(adjFan[1]);
|
||||
saveNV();
|
||||
_rowSel = 0;
|
||||
_ScreenManager.reqUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// press DOWN
|
||||
if(event & key_Down) {
|
||||
switch(_rowSel) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
_rowSel--;
|
||||
_colSel = 0;
|
||||
break;
|
||||
case 5:
|
||||
_rowSel = 0;
|
||||
_ScreenManager.reqUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// press DOWN
|
||||
if(event & key_Down) {
|
||||
|
||||
|
||||
if(event & keyRepeat) {
|
||||
switch(_rowSel) {
|
||||
case 1: // password entry
|
||||
_PWdig[_colSel]--;
|
||||
ROLLLOWERLIMIT(_PWdig[_colSel], 0, 9);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
_rowSel = 0;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
_rowSel--;
|
||||
_colSel = 0;
|
||||
break;
|
||||
case 6:
|
||||
_rowSel = 0;
|
||||
int adj = 0;
|
||||
if(event & key_Right) adj = +1;
|
||||
if(event & key_Left) adj = -1;
|
||||
if(adj) {
|
||||
_adjustSetting(adj);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(event & keyRepeat) {
|
||||
switch(_rowSel) {
|
||||
case 1:
|
||||
if(event & key_Centre)
|
||||
_rowSel = 0; // escape PW entry by holding centre button
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
int adj = 0;
|
||||
if(event & key_Right) adj = +1;
|
||||
if(event & key_Left) adj = -1;
|
||||
if(adj) {
|
||||
_adjustSetting(adj);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
|
||||
void
|
||||
CFuelMixtureScreen::_showPassword()
|
||||
{
|
||||
// determine metrics of character sizing
|
||||
CRect extents;
|
||||
_display.getTextExtents("X", extents);
|
||||
int charWidth = extents.width;
|
||||
_display.getTextExtents(" ", extents);
|
||||
int spaceWidth = extents.width;
|
||||
|
||||
for(int idx =0 ; idx < 4; idx++) {
|
||||
|
||||
extents.xPos = _display.xCentre() - (2 - idx) * (charWidth * 1.5);
|
||||
extents.yPos = 50;
|
||||
|
||||
char str[8];
|
||||
|
||||
if(_PWdig[idx] < 0) {
|
||||
strcpy(str, "-");
|
||||
}
|
||||
else {
|
||||
sprintf(str, "%d", _PWdig[idx]);
|
||||
}
|
||||
_printMenuText(extents.xPos, extents.yPos, str, _colSel == idx);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CFuelMixtureScreen::_adjustSetting(int dir)
|
||||
{
|
||||
switch(_rowSel) {
|
||||
case 2:
|
||||
case 1:
|
||||
adjPump[0] += (float(dir) * 0.1f);
|
||||
break;
|
||||
case 3:
|
||||
case 2:
|
||||
adjPump[1] += (float(dir) * 0.1f);
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
adjFan[0] += dir * 10;
|
||||
break;
|
||||
case 5:
|
||||
case 4:
|
||||
adjFan[1] += dir * 10;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -20,25 +20,25 @@
|
|||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ScreenHeader.h"
|
||||
#include "PasswordScreen.h"
|
||||
|
||||
class C128x64_OLED;
|
||||
class CScreenManager;
|
||||
class CProtocol;
|
||||
//class CProtocol;
|
||||
|
||||
class CFuelMixtureScreen : public CScreenHeader {
|
||||
int _PWdig[4];
|
||||
class CFuelMixtureScreen : public CPasswordScreen {
|
||||
// int _PWdig[4];
|
||||
float adjPump[2];
|
||||
short adjFan[2];
|
||||
int _rowSel;
|
||||
int _colSel;
|
||||
unsigned long _SaveTime;
|
||||
void _showPassword();
|
||||
// unsigned long _SaveTime;
|
||||
// void _showPassword();
|
||||
void _adjustSetting(int dir);
|
||||
|
||||
public:
|
||||
CFuelMixtureScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
void keyHandler(uint8_t event);
|
||||
bool show();
|
||||
bool keyHandler(uint8_t event);
|
||||
bool animate() { return CScreen::animate(); };
|
||||
};
|
||||
|
|
|
@ -34,16 +34,15 @@
|
|||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CHeaterSettingsScreen::CHeaterSettingsScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreenHeader(display, mgr)
|
||||
CHeaterSettingsScreen::CHeaterSettingsScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr)
|
||||
{
|
||||
_rowSel = 0;
|
||||
_SaveTime = 0;
|
||||
_fanSensor = 1;
|
||||
_glowPower = 5;
|
||||
_sysVoltage = 12;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
CHeaterSettingsScreen::show()
|
||||
{
|
||||
char msg[20];
|
||||
|
@ -52,71 +51,111 @@ CHeaterSettingsScreen::show()
|
|||
|
||||
_printInverted(0, 0, " Heater Settings ", true);
|
||||
|
||||
if(_SaveTime) {
|
||||
long tDelta = millis() - _SaveTime;
|
||||
if(tDelta > 0)
|
||||
_SaveTime = 0;
|
||||
_printInverted(_display.xCentre(), 28, " ", true, eCentreJustify);
|
||||
_printInverted(_display.xCentre(), 39, " ", true, eCentreJustify);
|
||||
_printInverted(_display.xCentre(), 34, " STORING ", true, eCentreJustify);
|
||||
}
|
||||
else {
|
||||
if(!CPasswordScreen::show()) {
|
||||
yPos = 14;
|
||||
_printMenuText(98, yPos, "Glow plug power:", false, eRightJustify);
|
||||
sprintf(msg, "PF-%d", _glowPower);
|
||||
_printMenuText(100, yPos, msg, _rowSel == 3);
|
||||
yPos = 27;
|
||||
_printMenuText(98, yPos, "Fan sensor:", false, eRightJustify);
|
||||
sprintf(msg, "SN-%d", _fanSensor);
|
||||
_printMenuText(100, yPos, msg, _rowSel == 2);
|
||||
yPos = 40;
|
||||
_printMenuText(98, yPos, "System voltage:", false, eRightJustify);
|
||||
sprintf(msg, "%dV", _sysVoltage);
|
||||
_printMenuText(100, yPos, msg, _rowSel == 1);
|
||||
|
||||
if(_rowSel == 4) {
|
||||
_printMenuText(_display.xCentre(), 35, "Press UP to", false, eCentreJustify);
|
||||
_printMenuText(_display.xCentre(), 43, "confirm save", false, eCentreJustify);
|
||||
}
|
||||
else {
|
||||
_printMenuText(98, yPos, "Glow plug power:", false, eRightJustify);
|
||||
sprintf(msg, "PF-%d", _glowPower);
|
||||
_printMenuText(100, yPos, msg, _rowSel == 3);
|
||||
yPos = 27;
|
||||
_printMenuText(98, yPos, "Fan sensor:", false, eRightJustify);
|
||||
sprintf(msg, "SN-%d", _fanSensor);
|
||||
_printMenuText(100, yPos, msg, _rowSel == 2);
|
||||
yPos = 40;
|
||||
_printMenuText(98, yPos, "System voltage:", false, eRightJustify);
|
||||
sprintf(msg, "%dV", _sysVoltage);
|
||||
_printMenuText(100, yPos, msg, _rowSel == 1);
|
||||
}
|
||||
// navigation line
|
||||
yPos = 53;
|
||||
xPos = _display.xCentre();
|
||||
_printMenuText(xPos, yPos, "<- ->", _rowSel == 0, eCentreJustify);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CHeaterSettingsScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
if(event & keyPressed) {
|
||||
// press LEFT to select previous screen, or Fixed Hz mode when in mode select
|
||||
if(event & key_Left) {
|
||||
if(_rowSel == 0)
|
||||
_ScreenManager.prevScreen();
|
||||
else {
|
||||
_adjust(-1);
|
||||
}
|
||||
}
|
||||
// press RIGHT to selecxt next screen, or Thermostat mode when in mode select
|
||||
if(event & key_Right) {
|
||||
if(_rowSel == 0)
|
||||
_ScreenManager.nextScreen();
|
||||
else {
|
||||
_adjust(+1);
|
||||
}
|
||||
}
|
||||
if(event & key_Down) {
|
||||
_rowSel--;
|
||||
LOWERLIMIT(_rowSel, 1);
|
||||
}
|
||||
if(event & key_Up) {
|
||||
if(CPasswordScreen::keyHandler(event)) {
|
||||
if(_isPasswordOK()) {
|
||||
_rowSel++;
|
||||
UPPERLIMIT(_rowSel, 3);
|
||||
}
|
||||
if(event & key_Centre) {
|
||||
if(_rowSel) {
|
||||
_SaveTime = millis() + 1500;
|
||||
_ScreenManager.reqUpdate();
|
||||
_rowSel = 0;
|
||||
}
|
||||
else {
|
||||
if(event & keyPressed) {
|
||||
// press LEFT to select previous screen
|
||||
if(event & key_Left) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_ScreenManager.prevScreen();
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
_adjust(-1);
|
||||
break;
|
||||
case 4:
|
||||
_rowSel = 0; // abort save
|
||||
break;
|
||||
}
|
||||
}
|
||||
// press RIGHT to select next screen
|
||||
if(event & key_Right) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_ScreenManager.nextScreen();
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
_adjust(+1);
|
||||
break;
|
||||
case 4:
|
||||
_rowSel = 0; // abort save
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(event & key_Down) {
|
||||
_rowSel--;
|
||||
LOWERLIMIT(_rowSel, 0);
|
||||
}
|
||||
// UP press
|
||||
if(event & key_Up) {
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
_getPassword(); // nav line ,request password
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
_rowSel++;
|
||||
UPPERLIMIT(_rowSel, 3);
|
||||
break;
|
||||
case 4: // confirmed save
|
||||
_showStoringMessage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
// CENTRE press
|
||||
if(event & key_Centre) {
|
||||
switch(_rowSel) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
_rowSel = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -20,21 +20,20 @@
|
|||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ScreenHeader.h"
|
||||
#include "PasswordScreen.h"
|
||||
|
||||
class C128x64_OLED;
|
||||
class CScreenManager;
|
||||
|
||||
class CHeaterSettingsScreen : public CScreenHeader
|
||||
class CHeaterSettingsScreen : public CPasswordScreen
|
||||
{
|
||||
int _rowSel;
|
||||
unsigned long _SaveTime;
|
||||
void _adjust(int dir);
|
||||
int _sysVoltage;
|
||||
int _fanSensor;
|
||||
int _glowPower;
|
||||
public:
|
||||
CHeaterSettingsScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
void keyHandler(uint8_t event);
|
||||
bool show();
|
||||
bool keyHandler(uint8_t event);
|
||||
};
|
||||
|
|
|
@ -46,16 +46,9 @@ CPasswordScreen::CPasswordScreen(C128x64_OLED& display, CScreenManager& mgr) : C
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CPasswordScreen::show()
|
||||
{
|
||||
CScreenHeader::show();
|
||||
|
||||
char str[16];
|
||||
int xPos, yPos;
|
||||
const int col2 = 90;
|
||||
const int col3 = _display.width() - border;
|
||||
_printInverted(0, 16, _Title, true);
|
||||
|
||||
if(_SaveTime) {
|
||||
long tDelta = millis() - _SaveTime;
|
||||
|
@ -64,18 +57,20 @@ CPasswordScreen::show()
|
|||
_printInverted(_display.xCentre(), 28, " ", true, eCentreJustify);
|
||||
_printInverted(_display.xCentre(), 39, " ", true, eCentreJustify);
|
||||
_printInverted(_display.xCentre(), 34, " STORING ", true, eCentreJustify);
|
||||
return true;
|
||||
}
|
||||
else if(_bGetPassword) {
|
||||
_printMenuText(_display.xCentre(), 34, "Enter password...", false, eCentreJustify);
|
||||
_showPassword();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
if(_bGetPassword) {
|
||||
_printMenuText(_display.xCentre(), 34, "Enter password...", false, eCentreJustify);
|
||||
_showPassword();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CPasswordScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
if(_bGetPassword) {
|
||||
|
@ -90,11 +85,12 @@ CPasswordScreen::keyHandler(uint8_t event)
|
|||
(_PWdig[3] == 8)) {
|
||||
_bPasswordOK = true;
|
||||
}
|
||||
|
||||
_bGetPassword = false;
|
||||
// reset PW digits
|
||||
for(int i= 0; i < 4; i++)
|
||||
_PWdig[i] = -1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// press LEFT
|
||||
|
@ -122,7 +118,9 @@ CPasswordScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -158,26 +156,21 @@ CPasswordScreen::_showPassword()
|
|||
}
|
||||
|
||||
void
|
||||
CPasswordScreen::_setGetPassword(bool state)
|
||||
CPasswordScreen::_getPassword()
|
||||
{
|
||||
_bGetPassword = state;
|
||||
if(state) {
|
||||
_bPasswordOK = false;
|
||||
_PWcol = 0;
|
||||
// reset PW digits
|
||||
for(int i= 0; i < 4; i++)
|
||||
_PWdig[i] = -1;
|
||||
}
|
||||
_bGetPassword = true;
|
||||
_bPasswordOK = false;
|
||||
_PWcol = 0;
|
||||
// reset PW digits
|
||||
for(int i= 0; i < 4; i++)
|
||||
_PWdig[i] = -1;
|
||||
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
|
||||
void
|
||||
CPasswordScreen::_setTitle(const char* title)
|
||||
CPasswordScreen::_showStoringMessage()
|
||||
{
|
||||
strcpy(_Title, title);
|
||||
}
|
||||
|
||||
bool
|
||||
CPasswordScreen::_isPasswordOK()
|
||||
{
|
||||
return _bPasswordOK;
|
||||
_SaveTime = millis() + 1500;
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
|
|
|
@ -18,13 +18,14 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef __PASSWORDSCREEN_H__
|
||||
#define __PASSWORDSCREEN_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ScreenHeader.h"
|
||||
|
||||
class C128x64_OLED;
|
||||
class CScreenManager;
|
||||
class CProtocol;
|
||||
|
||||
class CPasswordScreen : public CScreenHeader {
|
||||
int _PWdig[4];
|
||||
|
@ -32,15 +33,16 @@ class CPasswordScreen : public CScreenHeader {
|
|||
bool _bPasswordOK;
|
||||
int _PWcol;
|
||||
unsigned long _SaveTime;
|
||||
char _Title[20];
|
||||
protected:
|
||||
bool _showPassword();
|
||||
void _setGetPassword(bool state);
|
||||
void _setTitle(const char* title);
|
||||
bool _isPasswordOK();
|
||||
void _getPassword();
|
||||
bool _isPasswordOK() { return _bPasswordOK; };
|
||||
void _showStoringMessage();
|
||||
public:
|
||||
CPasswordScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
void keyHandler(uint8_t event);
|
||||
bool show();
|
||||
bool keyHandler(uint8_t event);
|
||||
bool animate() { return CScreen::animate(); };
|
||||
};
|
||||
|
||||
#endif
|
|
@ -42,7 +42,7 @@ CPrimingScreen::CPrimingScreen(C128x64_OLED& display, CScreenManager& mgr) : CSc
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CPrimingScreen::show()
|
||||
{
|
||||
CScreenHeader::show();
|
||||
|
@ -97,20 +97,15 @@ CPrimingScreen::show()
|
|||
}
|
||||
}
|
||||
|
||||
// _display.display();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CPrimingScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
|
||||
if(event & keyPressed) {
|
||||
// press CENTRE
|
||||
if(event & key_Centre) {
|
||||
return;
|
||||
}
|
||||
// press LEFT
|
||||
if(event & key_Left) {
|
||||
switch(_rowSel) {
|
||||
|
@ -178,6 +173,7 @@ CPrimingScreen::keyHandler(uint8_t event)
|
|||
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -33,7 +33,7 @@ class CPrimingScreen : public CScreenHeader {
|
|||
void stopPump();
|
||||
public:
|
||||
CPrimingScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
void keyHandler(uint8_t event);
|
||||
bool show();
|
||||
bool keyHandler(uint8_t event);
|
||||
bool animate() { return CScreen::animate(); };
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ CRebootScreen::CRebootScreen(C128x64_OLED& display, CScreenManager& mgr) : CScre
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CRebootScreen::show()
|
||||
{
|
||||
int yPos = 0;
|
||||
|
@ -69,13 +69,14 @@ CRebootScreen::show()
|
|||
yPos += _display.textHeight() + 10;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CRebootScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -28,8 +28,8 @@ class CScreenManager;
|
|||
class CRebootScreen : public CScreen {
|
||||
public:
|
||||
CRebootScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
void keyHandler(uint8_t event);
|
||||
bool show();
|
||||
bool keyHandler(uint8_t event);
|
||||
void setMessage(const char* content[2], long delayTime);
|
||||
private:
|
||||
String _rebootMessage[2];
|
||||
|
|
|
@ -33,9 +33,10 @@ CScreen::animate()
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CScreen::show()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
#include "fonts/FontTypes.h"
|
||||
#include "../Utility/UtilClasses.h"
|
||||
|
||||
class CProtocol;
|
||||
|
||||
enum eJUSTIFY {
|
||||
eLeftJustify, eCentreJustify, eRightJustify
|
||||
};
|
||||
|
@ -52,8 +50,8 @@ public:
|
|||
virtual ~CScreen();
|
||||
virtual void onSelect();
|
||||
virtual bool animate();
|
||||
virtual void show();
|
||||
virtual void keyHandler(uint8_t event) {};
|
||||
virtual bool show();
|
||||
virtual bool keyHandler(uint8_t event) { return false; };
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ CScreenHeader::CScreenHeader(C128x64_OLED& disp, CScreenManager& mgr) : CScreen(
|
|||
_colon = false;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
CScreenHeader::show()
|
||||
{
|
||||
_display.clearDisplay();
|
||||
|
@ -53,6 +53,8 @@ CScreenHeader::show()
|
|||
|
||||
// clock
|
||||
showTime(numTimers);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Animate IN/OUT arrows against the WiFi icon, according to actual web server traffic:
|
||||
|
|
|
@ -40,8 +40,8 @@ protected:
|
|||
virtual void showTime(int numTimers); // x location depends upon how many timers are active
|
||||
public:
|
||||
CScreenHeader(C128x64_OLED& disp, CScreenManager& mgr);
|
||||
virtual void show();
|
||||
virtual bool animate();
|
||||
bool show();
|
||||
bool animate();
|
||||
};
|
||||
|
||||
#endif // __SCREEN_HEADER_H__
|
||||
|
|
|
@ -48,7 +48,7 @@ CSetClockScreen::showTime(int)
|
|||
// override and DO NOTHING!
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
CSetClockScreen::show()
|
||||
{
|
||||
long deltaT = millis() - _nextT;
|
||||
|
@ -120,10 +120,11 @@ CSetClockScreen::show()
|
|||
_printMenuText(xPos, yPos, " return ", _rowSel==0, eCentreJustify);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CSetClockScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
|
||||
|
@ -140,7 +141,6 @@ CSetClockScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
_rowSel = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// press LEFT
|
||||
if(event & key_Left) {
|
||||
|
@ -190,6 +190,7 @@ CSetClockScreen::keyHandler(uint8_t event)
|
|||
|
||||
_nextT = millis();
|
||||
_ScreenManager.reqUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -37,7 +37,7 @@ class CSetClockScreen : public CScreenHeader {
|
|||
|
||||
public:
|
||||
CSetClockScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
bool show();
|
||||
void showTime(int);
|
||||
void keyHandler(uint8_t event);
|
||||
bool keyHandler(uint8_t event);
|
||||
};
|
||||
|
|
|
@ -50,7 +50,7 @@ CSetTimerScreen::onSelect()
|
|||
NVstore.getTimerInfo(_instance, _timer);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
CSetTimerScreen::show()
|
||||
{
|
||||
CScreenHeader::show();
|
||||
|
@ -117,10 +117,12 @@ CSetTimerScreen::show()
|
|||
xPos = _display.xCentre();
|
||||
//_printMenuText(xPos, yPos, "<- ->", _rowSel==0, eCentreJustify);
|
||||
_printMenuText(xPos, yPos, "<- return ->", _rowSel==0, eCentreJustify);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CSetTimerScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
static bool bHeld = false;
|
||||
|
@ -142,7 +144,6 @@ CSetTimerScreen::keyHandler(uint8_t event)
|
|||
_rowSel = 0;
|
||||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
// press LEFT - navigate fields, or screens
|
||||
if(event & key_Left) {
|
||||
|
@ -269,6 +270,7 @@ CSetTimerScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
|
||||
_ScreenManager.reqUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,6 @@ class CSetTimerScreen : public CScreenHeader {
|
|||
public:
|
||||
CSetTimerScreen(C128x64_OLED& display, CScreenManager& mgr, int instance);
|
||||
void onSelect();
|
||||
void show();
|
||||
void keyHandler(uint8_t event);
|
||||
bool show();
|
||||
bool keyHandler(uint8_t event);
|
||||
};
|
||||
|
|
|
@ -46,7 +46,7 @@ CWiFiScreen::CWiFiScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreenHe
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CWiFiScreen::show()
|
||||
{
|
||||
CScreenHeader::show();
|
||||
|
@ -90,16 +90,11 @@ CWiFiScreen::show()
|
|||
// show next/prev screen navigation line
|
||||
_printMenuText(_display.xCentre(), 52, "<- ->", _rowSel == 0, eCentreJustify);
|
||||
|
||||
|
||||
/* yPos += _display.textHeight() + 2;
|
||||
char msg[32];
|
||||
int mins = NVstore.getDimTime() / 60000;
|
||||
sprintf(msg, "Display Dim: %d min%c", mins, (mins > 1) ? 's' : ' ');
|
||||
_printMenuText(0, yPos, msg);*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
CWiFiScreen::keyHandler(uint8_t event)
|
||||
{
|
||||
if(event & keyPressed) {
|
||||
|
@ -154,5 +149,6 @@ CWiFiScreen::keyHandler(uint8_t event)
|
|||
}
|
||||
_repeatCount = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ class CScreenManager;
|
|||
class CWiFiScreen : public CScreenHeader {
|
||||
public:
|
||||
CWiFiScreen(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
void keyHandler(uint8_t event);
|
||||
bool show();
|
||||
bool keyHandler(uint8_t event);
|
||||
private:
|
||||
int _rowSel;
|
||||
int _repeatCount;
|
||||
|
|
Loading…
Reference in a new issue