Added descriptions of key pad functions in setup menus. Made key pad presses more consistent.

This commit is contained in:
rljonesau 2019-03-17 18:10:01 +11:00
parent 1cfd82c32f
commit f4d6c3dccc
14 changed files with 359 additions and 187 deletions

View file

@ -93,17 +93,50 @@ CExperimentalSettingsScreen::show()
_printMenuText(Column, Line2, "Standard", _rowSel == 2);
break;
}
// navigation line
int yPos = 53;
int xPos = _display.xCentre();
_printMenuText(xPos, yPos, "exit", _rowSel == 0, eCentreJustify);
}
}
return true;
}
bool
CExperimentalSettingsScreen::animate()
{
if(_rowSel != 4) {
int yPos = 53;
int xPos = _display.xCentre();
const char* pMsg = NULL;
switch(_rowSel) {
case 0:
_printMenuText(xPos, yPos, " Exit ", true, eCentreJustify);
_printMenuText(_display.width(), yPos, "\030Edit", false, eRightJustify);
break;
case 1:
_display.drawFastHLine(0, 52, 128, WHITE);
pMsg = " User defined window for custom thermostat modes. ";
_scrollMessage(56, pMsg, _startChar);
break;
case 2:
_display.drawFastHLine(0, 52, 128, WHITE);
switch(_thermoMode) {
case 1:
pMsg = " Controller holds measured temperature at the set point whilst within the window. ";
break;
case 2:
pMsg = " Controller uses Fixed Hz mode, adjusting pump rate linearly across the set point window. ";
break;
default:
pMsg = " Use heater's standard thermostat control. ";
break;
}
if(pMsg)
_scrollMessage(56, pMsg, _startChar);
break;
}
return true;
}
return false;
}
bool
CExperimentalSettingsScreen::keyHandler(uint8_t event)
@ -116,6 +149,7 @@ CExperimentalSettingsScreen::keyHandler(uint8_t event)
case 2:
case 3:
_adjust(-1);
_startChar = 0;
break;
case 4:
_rowSel = 0; // abort save
@ -129,6 +163,7 @@ CExperimentalSettingsScreen::keyHandler(uint8_t event)
case 2:
case 3:
_adjust(+1);
_startChar = 0;
break;
case 4:
_rowSel = 0; // abort save
@ -151,6 +186,7 @@ CExperimentalSettingsScreen::keyHandler(uint8_t event)
case 1:
case 2:
case 3:
_startChar = 0;
_rowSel++;
UPPERLIMIT(_rowSel, 2);
break;

View file

@ -35,10 +35,12 @@ class CExperimentalSettingsScreen : public CPasswordScreen
float _window;
int _thermoMode;
int _animateCount;
int _startChar;
void _initUI();
public:
CExperimentalSettingsScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
bool animate();
bool keyHandler(uint8_t event);
void onSelect();
};

View file

@ -87,12 +87,12 @@ bool
CFontDumpScreen::keyHandler(uint8_t event)
{
if(event & keyPressed) {
// press LEFT or DOWN to show prior 64 characters
if(event & (key_Left | key_Down)) {
// press LEFT or UP to show prior 64 characters
if(event & (key_Left | key_Up)) {
_startChar -= 64;
}
// press RIGHT or UP to show next 64 characters
if(event & (key_Right | key_Up)) {
// press RIGHT or DOWN to show next 64 characters
if(event & (key_Right | key_Down)) {
_startChar += 64;
}
// CENTRE press

View file

@ -99,7 +99,22 @@ CFuelMixtureScreen::show()
// navigation line
yPos = 53;
xPos = _display.xCentre();
_printMenuText(xPos, yPos, "\021 exit \020", _rowSel == 0, eCentreJustify);
switch(_rowSel) {
case 0:
_printMenuText(xPos, yPos, " \021 Exit \020 ", _rowSel == 0, eCentreJustify); // " < Exit > "
break;
case 1:
case 2:
_display.drawFastHLine(0, 52, 128, WHITE);
_printMenuText(xPos, 56, "\030\031Sel Save \033\032 \3600.1", false, eCentreJustify); // "^vSel Save <> +-0.1"
break;
case 3:
case 4:
_display.drawFastHLine(0, 52, 128, WHITE);
_printMenuText(xPos, 56, "\030\031Sel Save \033\032 \36010", false, eCentreJustify); // "^vSel Save <> +-10"
break;
}
break;
case 5:

View file

@ -88,7 +88,17 @@ CHeaterSettingsScreen::show()
// navigation line
int yPos = 53;
int xPos = _display.xCentre();
_printMenuText(xPos, yPos, "\021 exit \020", _rowSel == 0, eCentreJustify);
switch(_rowSel) {
case 0:
_printMenuText(xPos, yPos, " \021 Exit \020 ", true, eCentreJustify);
break;
default:
_display.drawFastHLine(0, 52, 128, WHITE);
_printMenuText(xPos, 56, "\030\031Sel \033\032 Adj", false, eCentreJustify);
_printMenuText(xPos, 56, "Save", false, eCentreJustify);
break;
}
}
}
@ -107,7 +117,7 @@ CHeaterSettingsScreen::animate()
_printMenuText(Column, Line2, " ");
_printMenuText(Column, Line1, " ");
if(_rowSel == 4)
_printMenuText(_display.xCentre(), 43, "confirm save", false, eCentreJustify);
_printMenuText(_display.xCentre(), 43, "Confirm save", false, eCentreJustify);
}
else {
_animateCount++;
@ -136,18 +146,6 @@ CHeaterSettingsScreen::animate()
else {
sprintf(msg, "(\365%d)", _fanSensor); // \365 is division character
_printMenuText(xPos, Line2, msg);
/* _printMenuText(xPos, Line2, "(\");
xPos += 6;
// .
// draw old fashioned divide symbol -----
// .
int barOfs = 3;
_display.drawLine(xPos, Line2+barOfs, xPos+4, Line2+barOfs, WHITE);
_display.drawPixel(xPos+2, Line2+barOfs-2, WHITE);
_display.drawPixel(xPos+2, Line2+barOfs+2, WHITE);
xPos += 6;
sprintf(msg, "%d)", _fanSensor);
_printMenuText(xPos, Line2, msg);*/
}
}
return true;

View file

@ -71,7 +71,25 @@ CPrimingScreen::show()
int yPos = 53;
// show next/prev menu navigation line
_printMenuText(_display.xCentre(), yPos, "\021 \020", _rowSel == 0, eCentreJustify);
switch(_rowSel) {
case 0:
_printMenuText(_display.xCentre(), yPos, " \021 \030Edit \020 ", _rowSel == 0, eCentreJustify);
break;
case 1:
case 2:
_display.drawFastHLine(0, 53, 128, WHITE);
_printMenuText(_display.xCentre(), 57, "\030\031 Sel \033\032 Adj", false, eCentreJustify);
break;
case 3:
_display.drawFastHLine(0, 53, 128, WHITE);
if(_colSel == 2) {
_printMenuText(_display.xCentre(), 57, "\033\030\031 Stop", false, eCentreJustify);
}
else {
_printMenuText(_display.xCentre(), 57, "\032 Start \031 Sel", false, eCentreJustify);
}
break;
}
yPos = 40;
if(_rowSel == 1) {
@ -98,12 +116,12 @@ CPrimingScreen::show()
// fuel pump priming menu
yPos = 16;
_printMenuText(border, yPos, "Prime pump");
_printMenuText(border, yPos, "Pump");
if(_rowSel == 3) {
_printMenuText(70, yPos, "OFF", _colSel == 1);
_printMenuText(40, yPos, "OFF", _colSel == 1);
if(_colSel != 2) {
if(!getHeaterInfo().getRunState()) { // prevent option if heater is running
_printMenuText(100, yPos, "ON"); // becomes Hz when actually priming
_printMenuText(70, yPos, "ON"); // becomes Hz when actually priming
}
}
else {
@ -122,7 +140,7 @@ CPrimingScreen::show()
if(_PrimeStop) {
char msg[16];
sprintf(msg, "%.1fHz", pumpHz);
_printMenuText(_display.width()-border, yPos, msg, true, eRightJustify);
_printMenuText(70, yPos, msg, true);
}
}
}

View file

@ -95,6 +95,20 @@ CScreen::_printInverted(int x, int y, const char* str, bool selected, eJUSTIFY j
_display.setTextColor(WHITE, BLACK);
}
void
CScreen::_scrollMessage(int y, const char* str, int& charOffset)
{
char msg[20];
int maxIndex = strlen(str) - 20;
strncpy(msg, &str[charOffset], 19);
msg[19] = 0;
_printMenuText(_display.xCentre(), y, msg, false, eCentreJustify);
charOffset++;
if(charOffset >= maxIndex) {
charOffset = 0;
}
}
void
CScreen::_adjustExtents(CRect& extents, eJUSTIFY justify, const char* str)

View file

@ -44,6 +44,7 @@ protected:
void _printInverted(int x, int y, const char* str, bool selected, eJUSTIFY justify = eLeftJustify);
void _adjustExtents(CRect& rect, eJUSTIFY justify, const char* str);
void _drawMenuSelection(CRect extents, const char* str, int border = 3, int radius = 4);
void _scrollMessage(int y, const char* str, int& charOffset);
void _reqOEMWarning();
public:
CScreen(C128x64_OLED& disp, CScreenManager& mgr);

View file

@ -74,7 +74,7 @@ CSetClockScreen::show()
const int col2 = 90;
const int col3 = _display.width() - border;
_printInverted(0, 16, " Set Clock ", true);
_printInverted(0, 15, " Set Clock ", true);
const BTCDateTime& now = Clock.get();
if(_rowSel == 0) {
@ -127,10 +127,22 @@ CSetClockScreen::show()
_printMenuText(_display.width()-border, yPos, "SET", _rowSel==7, eRightJustify);
}
// navigation line
yPos = 53;
xPos = _display.xCentre();
_printMenuText(xPos, yPos, " return ", _rowSel==0, eCentreJustify);
if(_rowSel == 0) {
yPos = 53;
_printMenuText(_display.width(), yPos, "\030Edit", false, eRightJustify);
_printMenuText(xPos, yPos, " Exit ", true, eCentreJustify);
}
else {
_display.drawFastHLine(0, 52, 128, WHITE);
_printMenuText(xPos, 56, "\033\032 Sel \030\031 Adj", false, eCentreJustify);
if(_rowSel == 7) {
_printMenuText(xPos, 56, "Save", false, eCentreJustify);
}
else {
_printMenuText(xPos, 56, "Abort", false, eCentreJustify);
}
}
}
return true;
}
@ -160,7 +172,8 @@ CSetClockScreen::keyHandler(uint8_t event)
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // exit, return to clock screen
}
else {
_adjTimeDate(-1);
_rowSel--;
ROLLLOWERLIMIT(_rowSel, 1, 7);
}
}
// press RIGHT
@ -169,32 +182,34 @@ CSetClockScreen::keyHandler(uint8_t event)
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // exit, return to clock screen
}
else {
_adjTimeDate(+1);
_rowSel++;
ROLLUPPERLIMIT(_rowSel, 7, 1);
}
}
// press UP
if(event & key_Up) {
_rowSel++;
ROLLUPPERLIMIT(_rowSel, 7, 1);
if(_rowSel == 0)
_rowSel = 1;
_adjTimeDate(+1);
}
// press DOWN
if(event & key_Down) {
if(_rowSel == 0) {
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // exit, return to clock screen
} else {
_rowSel--;
ROLLLOWERLIMIT(_rowSel, 1, 7);
_adjTimeDate(-1);
}
}
}
if(event & keyRepeat) {
if(_rowSel>=1) {
if(_rowSel >= 1) {
// hold RIGHT
if(event & key_Right) {
if(event & key_Up) {
_adjTimeDate(+1);
}
// hold LEFT
if(event & key_Left) {
if(event & key_Down) {
_adjTimeDate(-1);
}
}

View file

@ -72,7 +72,7 @@ CSetTimerScreen::show()
NVstore.getTimerInfo(_timerID, _timerInfo);
}
sprintf(str, " Set Timer %d ", _timerID + 1);
_printInverted(0, 16, str, true);
_printInverted(0, 15, str, true);
if(_SaveTime) {
long tDelta = millis() - _SaveTime;
@ -102,49 +102,61 @@ CSetTimerScreen::show()
}
}
else {
// start
xPos = 18;
yPos = 28;
_printMenuText(xPos, yPos, "On", false, eRightJustify);
_printMenuText(xPos+18, yPos, ":");
xPos += 6;
sprintf(str, "%02d", _timerInfo.start.hour);
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==0);
xPos += 17;
sprintf(str, "%02d", _timerInfo.start.min);
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==1);
// start
xPos = 18;
yPos = 28;
_printMenuText(xPos, yPos, "On", false, eRightJustify);
_printMenuText(xPos+18, yPos, ":");
xPos += 6;
sprintf(str, "%02d", _timerInfo.start.hour);
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==0);
xPos += 17;
sprintf(str, "%02d", _timerInfo.start.min);
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==1);
// stop
xPos = 18;
yPos = 40;
_printMenuText(xPos, yPos, "Off", false, eRightJustify);
_printMenuText(xPos+18, yPos, ":");
xPos += 6;
sprintf(str, "%02d", _timerInfo.stop.hour);
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==2);
xPos += 17;
sprintf(str, "%02d", _timerInfo.stop.min);
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==3);
// control
const char* msg;
xPos = _display.width() - border;
_printEnabledTimers();
yPos = 40;
if(_timerInfo.repeat)
msg = "Repeat";
else
msg = "Once";
if(_rowSel == 1)
_printMenuText(xPos, yPos, msg, _colSel==5, eRightJustify);
else
_printInverted(xPos, yPos, msg, _timerInfo.repeat, eRightJustify);
// stop
xPos = 18;
yPos = 41;
_printMenuText(xPos, yPos, "Off", false, eRightJustify);
_printMenuText(xPos+18, yPos, ":");
xPos += 6;
sprintf(str, "%02d", _timerInfo.stop.hour);
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==2);
xPos += 17;
sprintf(str, "%02d", _timerInfo.stop.min);
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==3);
// control
const char* msg;
xPos = _display.width() - border;
_printEnabledTimers();
yPos = 41;
if(_timerInfo.repeat)
msg = "Repeat";
else
msg = "Once";
if(_rowSel == 1)
_printMenuText(xPos, yPos, msg, _colSel==5, eRightJustify);
else
_printInverted(xPos, yPos, msg, _timerInfo.repeat, eRightJustify);
}
// navigation line
yPos = 53;
xPos = _display.xCentre();
_printMenuText(xPos, yPos, "\021 return \020", _rowSel==0, eCentreJustify);
if(_rowSel == 2) {
_display.drawFastHLine(0, 53, 128, WHITE);
_printMenuText(_display.xCentre(), 57, "\033\032 Sel \030\031 Adj", false, eCentreJustify);
_printMenuText(_display.xCentre(), 57, "Done", false, eCentreJustify);
}
else if(_rowSel == 1) {
_display.drawFastHLine(0, 53, 128, WHITE);
_printMenuText(_display.xCentre(), 57, "\033\032 Sel \030\031 Adj", false, eCentreJustify);
_printMenuText(_display.xCentre(), 57, "Save", false, eCentreJustify);
}
else {
_printMenuText(xPos, yPos, " \021 Exit \020 ", _rowSel==0, eCentreJustify);
}
return true;
}
@ -192,10 +204,12 @@ CSetTimerScreen::keyHandler(uint8_t event)
_ScreenManager.prevMenu();
break;
case 1:
// select previous field
_colSel--;
ROLLLOWERLIMIT(_colSel, 0, 5);
break;
case 2:
// select previous day
_colSel--;
ROLLLOWERLIMIT(_colSel, 0, 6);
break;
@ -208,41 +222,17 @@ CSetTimerScreen::keyHandler(uint8_t event)
_ScreenManager.nextMenu();
break;
case 1:
// select next field
_colSel++;
ROLLUPPERLIMIT(_colSel, 5, 0);
break;
case 2:
// select next day
_colSel++;
ROLLUPPERLIMIT(_colSel, 6, 0);
break;
}
}
// press UP
if(event & key_Up) {
// switch(_rowSel) {
// case 0:
// _rowSel = 1;
// _colSel = 5;
// break;
// // case 1:
// // _colSel--;
// // ROLLLOWERLIMIT(_colSel, 0, 5);
// // break;
// }
}
// press DOWN
if(event & key_Down) {
switch(_rowSel) {
case 0:
_rowSel = 1;
_colSel = 0;
break;
// case 1:
// _colSel++;
// ROLLUPPERLIMIT(_colSel, 5, 0);
// break;
}
}
}
// handle held down keys
@ -250,42 +240,38 @@ CSetTimerScreen::keyHandler(uint8_t event)
bHeld = true;
if(_rowSel == 1) {
if(_colSel < 4) {
// fast repeat of hour/minute adjustments by holding up or down keys
if(event & key_Down) _adjust(-1);
if(event & key_Up) _adjust(+1);
// if(event & key_Left) _adjust(-1);
// if(event & key_Right) _adjust(+1);
}
else if(_colSel == 4) {
// if(event & key_Right) {
if(event & key_Up) {
if(event & (key_Up | key_Down)) {
// enable per day programming by holding up or down
_timerInfo.enabled &= 0x7f; // strip next day flag
_rowSel = 2;
_colSel = 0;
}
}
}
if(_rowSel==2) {
}
}
if(event & keyReleased) {
if(!bHeld) {
int maskDOW = 0x01 << _colSel;
if(event & key_Left) {
// switch(_rowSel) {
// case 1:
// _adjust(-1);
// break;
// }
}
// released DOWN - can only leave adjustment by using OK (centre button)
if(event & key_Down) {
// adjust selected item
switch(_rowSel) {
case 1:
_adjust(-1);
if(!(_colSel == 4 && (_timerInfo.enabled & 0x7F) != 0)) {
_adjust(-1);
}
else {
// bump into per day setup
_rowSel = 2;
_colSel = 0;
}
break;
case 2:
// adjust selected item
@ -294,14 +280,6 @@ CSetTimerScreen::keyHandler(uint8_t event)
break;
}
}
if(event & key_Right) {
// switch(_rowSel) {
// case 1:
// // adjust selected item
// _adjust(+1);
// break;
// }
}
// released UP
if(event & key_Up) {
switch(_rowSel) {
@ -314,6 +292,11 @@ CSetTimerScreen::keyHandler(uint8_t event)
if(!(_colSel == 4 && (_timerInfo.enabled & 0x7F) != 0)) {
_adjust(+1); // adjust selected item, unless in per day mode
}
else {
// bump into per day setup
_rowSel = 2;
_colSel = 0;
}
break;
case 2:
// adjust selected item
@ -391,22 +374,28 @@ CSetTimerScreen::_printEnabledTimers()
}
else {
if(_rowSel==1 && _colSel==4) {
_printMenuText(xPos, yPos, "Hold UP", true, eRightJustify);
CRect extents;
extents.width = 7 * dayWidth + 2;
extents.height = 8;
extents.xPos = xPos - extents.width;
extents.yPos = yPos;
extents.Expand(border);
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
}
else {
xPos -= 7 * dayWidth; // back step 7 day entries
int xSel = xPos + _colSel * dayWidth;
for(int i=0; i<7; i++) {
int dayMask = 0x01 << i;
_printInverted(xPos, yPos, briefDOW[i], _timerInfo.enabled & dayMask);
xPos += dayWidth;
}
if(_rowSel == 2) {
CRect extents;
extents.xPos = xSel;
extents.yPos = yPos;
_drawMenuSelection(extents, briefDOW[_colSel]);
}
xPos -= 7 * dayWidth; // back step 7 day entries
int xSel = xPos + _colSel * dayWidth; // note location of selection now (xPos gets changed)
// print days, inverse if enabled
for(int i=0; i<7; i++) {
int dayMask = 0x01 << i;
_printInverted(xPos, yPos, briefDOW[i], _timerInfo.enabled & dayMask);
xPos += dayWidth;
}
// draw selection loop afterwards - writing text otherwise obliterates it
if(_rowSel==2) {
CRect extents;
extents.xPos = xSel;
extents.yPos = yPos;
_drawMenuSelection(extents, briefDOW[_colSel]);
}
}
}

View file

@ -83,7 +83,7 @@ CSettingsScreen::show()
int yPos = 53;
int xPos = _display.xCentre();
_printMenuText(xPos, yPos, "\021 enter \020", true, eCentreJustify);
_printMenuText(xPos, yPos, " \021 \030Edit \031\352T \020 ", true, eCentreJustify);
}
return true;
@ -126,18 +126,6 @@ CSettingsScreen::animate()
_printMenuText(xPos, Line2, " "); // erase
sprintf(msg, "(\365%d)", fanSensor); // \365 is division character
_printMenuText(xPos, Line2, msg);
/* _printMenuText(xPos, Line2, "(");
xPos += 6;
// .
// draw old fashioned divide symbol -----
// .
int barOfs = 3;
_display.drawLine(xPos, Line2+barOfs, xPos+4, Line2+barOfs, WHITE);
_display.drawPixel(xPos+2, Line2+barOfs-2, WHITE);
_display.drawPixel(xPos+2, Line2+barOfs+2, WHITE);
xPos += 6;
sprintf(msg, "%d)", fanSensor);
_printMenuText(xPos, Line2, msg); */
}
}

View file

@ -36,6 +36,10 @@
#define STA_HOLD_TIME 10
static const int LIMIT_AWAY = 0;
static const int LIMIT_LEFT = 1;
static const int LIMIT_RIGHT = 2;
CWiFiScreen::CWiFiScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreenHeader(display, mgr)
{
_initUI();
@ -52,6 +56,27 @@ CWiFiScreen::_initUI()
{
_rowSel = 0;
_bShowMAC = false;
if(isWifiAP()) {
if(isWifiConfigPortal()) {
_colSel = 0; // " WiFi: CFG AP only "
_colLimit = LIMIT_LEFT; // left most selection
}
else {
_colSel = 1; // " WiFi: AP only ";
_colLimit = LIMIT_RIGHT; // right most selection
}
}
else {
if(isWifiConfigPortal()) {
_colSel = 2; // " WiFi: CFG STA+AP "
_colLimit = LIMIT_AWAY; // away from menu limits
}
else {
_colSel = 3; // " WiFi: STA+AP ";
_colLimit = LIMIT_RIGHT; // right most selection
}
}
}
bool
@ -63,15 +88,25 @@ CWiFiScreen::show()
if(isWifiConnected() || isWifiAP()) {
const char* pTitle = NULL;
if(isWifiAP())
pTitle = isWifiConfigPortal() ? " WiFi: CFG AP only " : " WiFi: AP only ";
else
pTitle = isWifiConfigPortal() ? " WiFi: CFG STA+AP " : " WiFi: STA+AP ";
switch(_colSel) {
case 0:
pTitle = " WiFi: CFG AP only ";
break;
case 1:
pTitle = " WiFi: AP only ";
break;
case 2:
pTitle = " WiFi: CFG STA+AP ";
break;
case 3:
pTitle = " WiFi: STA+AP ";
break;
}
if(_rowSel == 0)
_printInverted(3, yPos, pTitle, true); // inverted title bar
if(_rowSel == 1)
_printMenuText(3, yPos, pTitle, true); // selection box
else
_printInverted(3, yPos, pTitle, true); // inverted title bar
yPos += 3;
// only show STA IP address if available!
@ -95,12 +130,41 @@ CWiFiScreen::show()
_printInverted(0, yPos, " WiFi Inactive ", true);
}
// show next/prev menu navigation line
_printMenuText(_display.xCentre(), 53, "\021 \020", _rowSel == 0, eCentreJustify);
return true;
}
bool
CWiFiScreen::animate()
{
bool retval = false;
// show next/prev menu navigation line
if(_rowSel == 0) {
_printMenuText(_display.xCentre(), 53, " \021 \020 ", true, eCentreJustify);
if(_bShowMAC)
_printMenuText(_display.xCentre(), 53, "\030Sel \031IP", false, eCentreJustify);
else
_printMenuText(_display.xCentre(), 53, "\030Sel \031MAC", false, eCentreJustify);
}
if(_rowSel == 1) {
_display.drawFastHLine(0, 52, 128, WHITE);
const char* pMsg = NULL;
switch(_colLimit) {
case LIMIT_AWAY:
pMsg = "\031 ESC Set \033\032 Sel"; // both Sel arrows
break;
case LIMIT_LEFT:
pMsg = "\031 ESC Set \032 Sel"; // only right Sel arrow
break;
case LIMIT_RIGHT:
pMsg = "\031 ESC Set \033 Sel"; // only left Sel arrow
break;
}
if(pMsg)
_printMenuText(_display.xCentre(), 56, pMsg, false, eCentreJustify);
}
CScreen::animate();
return true;
}
bool
CWiFiScreen::keyHandler(uint8_t event)
@ -112,13 +176,37 @@ CWiFiScreen::keyHandler(uint8_t event)
}
// press LEFT
if(event & key_Left) {
_ScreenManager.prevMenu();
_rowSel = 0;
if(_rowSel == 0) {
_ScreenManager.prevMenu();
}
else {
if(isWifiAP()) {
_colSel = 0;
_colLimit = LIMIT_LEFT;
}
else {
_colSel--;
LOWERLIMIT(_colSel, 0);
_colLimit = (_colSel == 0) ? LIMIT_LEFT : LIMIT_AWAY;
}
}
}
// press RIGHT
if(event & key_Right) {
_ScreenManager.nextMenu();
_rowSel = 0;
if(_rowSel == 0) {
_ScreenManager.nextMenu();
}
else {
if(isWifiAP()) {
_colSel = 1;
_colLimit = LIMIT_RIGHT;
}
else {
_colSel++;
UPPERLIMIT(_colSel, 3);
_colLimit = (_colSel == 3) ? LIMIT_RIGHT : LIMIT_AWAY;
}
}
}
// press UP
if(event & key_Up) {
@ -135,24 +223,30 @@ CWiFiScreen::keyHandler(uint8_t event)
}
if(event & keyRepeat) { // track key hold time
_repeatCount++;
if(event & key_Centre) {
_repeatCount++;
}
}
if(event & keyReleased) {
if(event & key_Centre) {
if(_rowSel) {
if(_repeatCount > STA_HOLD_TIME) {
wifiEnterConfigPortal(true, _repeatCount > STA_HOLD_TIME, 5000); // press - reboot into portal, long press - erase credentials
}
else {
if(isWifiConfigPortal()) {
wifiEnterConfigPortal(false, false, 5000); // stop config portal, reboot
}
else {
wifiEnterConfigPortal(true, false, 5000); // stop config portal, reboot
}
switch(_colSel) {
case 0:
wifiEnterConfigPortal(true, true, 5000); // CFG AP: erase credentials, reboot into portal
break;
case 1:
wifiEnterConfigPortal(false, true, 5000); // AP Only: erase credentials, reboot into webserver
break;
case 2:
wifiEnterConfigPortal(true, false, 5000); // CFG STA+AP: keep credentials, reboot into portal
break;
case 3:
wifiEnterConfigPortal(false, false, 5000); // STA+AP: keep credentials, reboot into webserver
break;
}
_rowSel = 2; // stop ticker display
}
}
_repeatCount = 0;

View file

@ -33,9 +33,11 @@ public:
CWiFiScreen(C128x64_OLED& display, CScreenManager& mgr);
void onSelect();
bool show();
bool animate();
bool keyHandler(uint8_t event);
private:
int _rowSel;
int _colLimit;
int _rowSel, _colSel;
int _repeatCount;
bool _bShowMAC;
void _initUI();

View file

@ -201,9 +201,9 @@ void wifiEnterConfigPortal(bool state, bool erase, long rebootDelay)
const char* content[2];
if(isWifiSTA() && !erase)
content[0] = "WiFi Mode -> STA+AP";
content[0] = "WiFi Mode \032 STA+AP";
else
content[0] = "WiFi Mode -> AP only";
content[0] = "WiFi Mode \032 AP only";
if(erase) {
wm.resetSettings();
@ -212,11 +212,11 @@ void wifiEnterConfigPortal(bool state, bool erase, long rebootDelay)
if(state) {
DebugPort.println("*** Rebooting into config portal ***");
content[1] = "Web -> Config Portal";
content[1] = "Web \032 Config Portal";
}
else {
DebugPort.println("*** Rebooting into web server ***");
content[1] = "Web -> Heater control";
content[1] = "Web \032 Heater control";
}
restartServer = (millis() + rebootDelay) | 1; // prepare to reboot in the future - ensure non zero!