Commit d8e71eeb authored by Ray Jones's avatar Ray Jones
Browse files

Added Frost Mode setup screen, sub-classed NVstore confirm behaviour

No related merge requests found
Showing with 696 additions and 462 deletions
+696 -462
......@@ -125,7 +125,7 @@
const int FirmwareRevision = 31;
const int FirmwareSubRevision = 7;
const char* FirmwareDate = "30 Oct 2019";
const char* FirmwareDate = "10 Nov 2019";
#ifdef ESP32
......@@ -184,6 +184,7 @@ CKeyPad KeyPad;
CScreenManager ScreenManager;
ABTelnetSpy DebugPort;
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
CGPIOin GPIOin;
CGPIOout GPIOout;
CGPIOalg GPIOalg;
......@@ -334,6 +335,7 @@ void setup() {
// initially, ensure the GPIO outputs are not activated during startup
// (GPIO2 tends to be one with default chip startup)
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
pinMode(GPIOout1_pin, OUTPUT);
pinMode(GPIOout2_pin, OUTPUT);
digitalWrite(GPIOout1_pin, LOW);
......@@ -451,9 +453,7 @@ void setup() {
bBTconnected = false;
Bluetooth.begin();
#if USE_JTAG == 0
setupGPIO();
#endif
#if USE_SW_WATCHDOG == 1 && USE_JTAG == 0
// create a watchdog timer
......@@ -1125,6 +1125,7 @@ bool getExternalThermostatModeActive()
#if USE_JTAG == 0
return GPIOin.usesExternalThermostat() && (NVstore.getUserSettings().ThermostatMethod == 3);
#else
//CANNOT USE GPIO WITH JTAG DEBUG
return false;
#endif
}
......@@ -1134,6 +1135,7 @@ bool getExternalThermostatOn()
#if USE_JTAG == 0
return GPIOin.getState(1);
#else
//CANNOT USE GPIO WITH JTAG DEBUG
return false;
#endif
}
......@@ -1143,6 +1145,7 @@ const char* getExternalThermostatHoldTime()
#if USE_JTAG == 0
return GPIOin.getExtThermHoldTime();
#else
//CANNOT USE GPIO WITH JTAG DEBUG
return "00:00";
#endif
}
......@@ -1593,6 +1596,7 @@ bool isCyclicActive()
void setupGPIO()
{
#if USE_JTAG == 1
//CANNOT USE GPIO WITH JTAG DEBUG
return;
#else
if(BoardRevision == 10 || BoardRevision == 20 || BoardRevision == 21 || BoardRevision == 30) {
......@@ -1654,6 +1658,7 @@ void setupGPIO()
bool toggleGPIOout(int channel)
{
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
if(channel == 0) {
if(NVstore.getUserSettings().GPIO.out1Mode == CGPIOout1::User) {
setGPIOout(channel, !getGPIOout(channel)); // toggle selected GPIO output
......@@ -1673,6 +1678,7 @@ bool toggleGPIOout(int channel)
bool setGPIOout(int channel, bool state)
{
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
if(channel == 0) {
if(GPIOout.getMode1() != CGPIOout1::Disabled) {
DebugPort.printf("setGPIO: Output #%d = %d\r\n", channel+1, state);
......@@ -1698,6 +1704,7 @@ bool getGPIOout(int channel)
DebugPort.printf("getGPIO: Output #%d = %d\r\n", channel+1, retval);
return retval;
#else
//CANNOT USE GPIO WITH JTAG DEBUG
return false;
#endif
}
......@@ -1730,12 +1737,15 @@ void ShowOTAScreen(int percent, eOTAmodes updateType)
void feedWatchdog()
{
#if USE_JTAG == 0
// BEST NOT USE WATCHDOG WITH JTAG DEBUG :-)
uint64_t timeRem = timerRead(watchdogTimer);
if(timeRem > 500000) // 500ms
DebugPort.printf("WD time = %lld\r\n", timeRem); // print longer WD intervals
timerWrite(watchdogTimer, 0); //reset timer (feed watchdog)
timerAlarmWrite(watchdogTimer, 15000000, false); //set time in uS must be fed within this time or reboot
#endif
}
void doJSONwatchdog(int topup)
......@@ -1779,6 +1789,7 @@ void doStreaming()
Bluetooth.check(); // check for Bluetooth activity
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
GPIOin.manage();
GPIOout.manage();
GPIOalg.manage();
......
......@@ -64,56 +64,51 @@ CDS18B20Screen::show()
if(!CPasswordScreen::show()) { // for showing "saving settings"
if(_rowSel == SaveConfirm) {
_showConfirmMessage();
if(_colSel == 0)
_showTitle("DS18B20 Sensor Role");
else
_showTitle("DS18B20 Sensor Offset");
int baseLine = 16;
switch(_nNumSensors) {
case 2: baseLine = 28; break;
case 3: baseLine = 40; break;
}
else {
if(_colSel == 0)
_showTitle("DS18B20 Sensor Role");
else
_showTitle("DS18B20 Sensor Offset");
for(int sensor = 0; sensor<_nNumSensors; sensor++) {
int baseLine = 16;
switch(_nNumSensors) {
case 2: baseLine = 28; break;
case 3: baseLine = 40; break;
switch(_sensorRole[sensor]) {
case 0: strcpy(msg, "Pri"); break;
case 1: strcpy(msg, "Sec"); break;
case 2: strcpy(msg, "Ter"); break;
default: strcpy(msg, " ? "); break;
}
for(int sensor = 0; sensor<_nNumSensors; sensor++) {
switch(_sensorRole[sensor]) {
case 0: strcpy(msg, "Pri"); break;
case 1: strcpy(msg, "Sec"); break;
case 2: strcpy(msg, "Ter"); break;
default: strcpy(msg, " ? "); break;
}
_printMenuText(border, baseLine-sensor*12, msg, _rowSel == (sensor+1) && _colSel == 0);
_printMenuText(border, baseLine-sensor*12, msg, _rowSel == (sensor+1) && _colSel == 0);
OneWireBus_ROMCode romCode;
if(!getTempSensor().getDS18B20().getRomCodeIdx(sensor, romCode)) {
strcpy(msg, "missing?") ;
}
else {
char* buffer = msg;
for (int j = 5; j >= 0; j--) {
sprintf(buffer, "%02X%s", romCode.fields.serial_number[j], j ? ":" : "");
buffer += 3;
}
}
{
CTransientFont AF(_display, &miniFontInfo);
_printMenuText(27, baseLine+2-sensor*12, msg);
OneWireBus_ROMCode romCode;
if(!getTempSensor().getDS18B20().getRomCodeIdx(sensor, romCode)) {
strcpy(msg, "missing?") ;
}
else {
char* buffer = msg;
for (int j = 5; j >= 0; j--) {
sprintf(buffer, "%02X%s", romCode.fields.serial_number[j], j ? ":" : "");
buffer += 3;
}
}
{
CTransientFont AF(_display, &miniFontInfo);
_printMenuText(27, baseLine+2-sensor*12, msg);
}
if(_colSel == 0) {
float temperature;
getTempSensor().getDS18B20().getTemperatureIdx(sensor, temperature, false);
sprintf(msg, "%.01f`C", temperature + _Offset[sensor]);
}
else {
sprintf(msg, "%+.01f", _Offset[sensor]);
}
_printMenuText(90, baseLine-sensor*12, msg, _rowSel == (sensor+1) && _colSel == 1);
if(_colSel == 0) {
float temperature;
getTempSensor().getDS18B20().getTemperatureIdx(sensor, temperature, false);
sprintf(msg, "%.01f`C", temperature + _Offset[sensor]);
}
else {
sprintf(msg, "%+.01f", _Offset[sensor]);
}
_printMenuText(90, baseLine-sensor*12, msg, _rowSel == (sensor+1) && _colSel == 1);
}
}
return true;
......
/*
* 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 "128x64OLED.h"
#include "FrostScreen.h"
#include "KeyPad.h"
#include "fonts/Icons.h"
CFrostScreen::CFrostScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr)
{
}
void
CFrostScreen::onSelect()
{
CScreenHeader::onSelect();
_rowSel = 0;
_frostOn = NVstore.getUserSettings().FrostOn;
_frostRise = NVstore.getUserSettings().FrostRise;
_scrollChar = 0;
}
void
CFrostScreen::_initUI()
{
}
bool
CFrostScreen::show()
{
char msg[16];
_display.clearDisplay();
if(!CPasswordScreen::show()) { // for showing "saving settings"
_showTitle("Frost Mode");
_drawBitmap(25, 20, frostIconInfo);
_drawBitmap(45, 16, StartIconInfo);
if(_frostOn == 0) {
strcpy(msg, "Disabled");
}
else {
sprintf(msg, "< %d`C", _frostOn);
}
_printMenuText(57, 16, msg, _rowSel == 2);
if(_frostOn) {
_drawBitmap(45, 30, StopIconInfo);
sprintf(msg, "> %d`C", _frostOn+_frostRise);
_printMenuText(57, 30, msg, _rowSel == 1);
}
}
return true;
}
bool
CFrostScreen::animate()
{
if(!CPasswordScreen::_busy() && !CPasswordScreen::isPasswordBusy()) {
if(_rowSel != SaveConfirm) {
const char* pMsg = NULL;
switch(_rowSel) {
case 0:
_printMenuText(_display.xCentre(), 53, " \021 \030Edit Exit \020 ", true, eCentreJustify);
break;
case 2:
pMsg = " Define auto start temeprature for frost mode. ";
break;
case 1:
pMsg = " Define auto stop temeprature for frost mode. ";
break;
}
if(pMsg != NULL) {
_display.drawFastHLine(0, 52, 128, WHITE);
_scrollMessage(56, pMsg, _scrollChar);
}
return true;
}
}
return false;
}
bool
CFrostScreen::keyHandler(uint8_t event)
{
if(CPasswordScreen::keyHandler(event)) { // handles save confirm
return true;
}
// sUserSettings us;
if(event & keyPressed) {
// special key handling for save confirm
/* if(_rowSel == SaveConfirm) {
if(event & key_Up) {
_enableStoringMessage();
us = NVstore.getUserSettings();
us.FrostOn = _frostOn;
us.FrostRise = _frostRise;
NVstore.setUserSettings(us);
NVstore.save();
_holdPassword();
}
_rowSel = 0;
onSelect();
}
// normal key handling
else {*/
// UP press
if(event & key_Up) {
_scrollChar = 0;
if(_rowSel == 0) {
_rowSel = 1;
if(_frostOn == 0)
_rowSel = 2;
}
else {
_rowSel++;
UPPERLIMIT(_rowSel, 2);
}
}
// DOWN press
if(event & key_Down) {
_scrollChar = 0;
_rowSel--;
if(_frostOn == 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 = SaveConfirm;
}
}
// 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
CFrostScreen::adjust(int dir)
{
switch(_rowSel) {
case 1:
_frostRise += dir;
BOUNDSLIMIT(_frostRise, 1, 30);
break;
case 2:
_frostOn += dir;
BOUNDSLIMIT(_frostOn, 0, 30);
break;
}
}
void
CFrostScreen::_saveNV()
{
sUserSettings us = NVstore.getUserSettings();
us.FrostOn = _frostOn;
us.FrostRise = _frostRise;
NVstore.setUserSettings(us);
NVstore.save();
}
/*
* 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/>.
*
*/
#ifndef __FROSTSCREEN_H__
#define __FROSTSCREEN_H__
#include <stdint.h>
#include "PasswordScreen.h"
#include "../Utility/NVStorage.h"
class C128x64_OLED;
class CScreenManager;
class CFrostScreen : public CPasswordScreen
{
// int _rowSel;
int _scrollChar;
uint8_t _frostOn;
uint8_t _frostRise;
void _initUI();
protected:
void _saveNV();
public:
CFrostScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
bool animate();
bool keyHandler(uint8_t event);
void onSelect();
void adjust(int dir);
};
#endif
......@@ -38,7 +38,6 @@ CFuelCalScreen::CFuelCalScreen(C128x64_OLED& display, CScreenManager& mgr) : CPa
_initUI();
_mlPerStroke = 0.02;
_LVC = 115;
_tOfs = 0;
}
void
......@@ -48,7 +47,6 @@ CFuelCalScreen::onSelect()
_initUI();
_mlPerStroke = NVstore.getHeaterTuning().pumpCal;
_LVC = NVstore.getHeaterTuning().lowVolts;
// _tOfs = NVstore.getHeaterTuning().DS18B20probe[0].offset;
}
void
......@@ -69,43 +67,38 @@ CFuelCalScreen::show()
if(!CPasswordScreen::show()) { // for showing "saving settings"
if(_rowSel == 10) {
_showConfirmMessage();
if(_animateCount < 0) {
_display.clearDisplay();
_animateCount = 0;
}
else {
if(_animateCount < 0) {
_display.clearDisplay();
_animateCount = 0;
}
// _printInverted(_display.xCentre(), 0, " Special Features ", true, eCentreJustify);
_showTitle("Special Features");
// fuel calibration
int yPos = Line1;
_printMenuText(col, yPos, "mL/stroke : ", false, eRightJustify);
sprintf(msg, "%.03f", _mlPerStroke);
_printMenuText(col, yPos, msg, _rowSel == 1);
// low voltage cutout
yPos = Line2;
_printMenuText(col, yPos, "L.V.C. < ", false, eRightJustify);
if(_LVC)
sprintf(msg, "%.1fV", float(_LVC) * 0.1);
else
strcpy(msg, "OFF");
_printMenuText(col, yPos, msg, _rowSel == 2);
// navigation line
yPos = 53;
int xPos = _display.xCentre();
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;
}
_showTitle("Special Features");
// fuel calibration
int yPos = Line1;
_printMenuText(col, yPos, "mL/stroke : ", false, eRightJustify);
sprintf(msg, "%.03f", _mlPerStroke);
_printMenuText(col, yPos, msg, _rowSel == 1);
// low voltage cutout
yPos = Line2;
_printMenuText(col, yPos, "L.V.C. < ", false, eRightJustify);
if(_LVC)
sprintf(msg, "%.1fV", float(_LVC) * 0.1);
else
strcpy(msg, "OFF");
_printMenuText(col, yPos, msg, _rowSel == 2);
// navigation line
yPos = 53;
int xPos = _display.xCentre();
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;
}
}
......@@ -122,31 +115,26 @@ CFuelCalScreen::animate()
_display.fillRect(0, Line3-3, BatteryIconInfo.width, 35, BLACK);
_drawBitmap(6, Line1-3, FuelIconSmallInfo);
_drawBitmap(0, Line2-1 , BatteryIconInfo);
// _drawBitmap(5, Line3-3, miniThermoIconInfo);
break;
case 2:
_display.fillRect(6, Line1-3, FuelIconSmallInfo.width, FuelIconSmallInfo.height, BLACK); // scrub prior drip
_drawBitmap(6, Line1-2, FuelIconSmallInfo); // drip fuel
_display.fillRect(BatteryIconInfo.width - 4, Line2+2, 2, 5, BLACK); // deplete battery
// _display.fillRect(7, Line3+3, 2, 2, WHITE); // grow thermometer
break;
case 4:
_display.fillRect(6, Line1-2, FuelIconSmallInfo.width, FuelIconSmallInfo.height, BLACK); // scrub prior drip
_drawBitmap(6, Line1-1, FuelIconSmallInfo); // drip fuel
_display.fillRect(BatteryIconInfo.width - 7, Line2+2, 2, 5, BLACK); // deplete battery
// _display.fillRect(7, Line3+2, 2, 1, WHITE); // grow thermometer
break;
case 6:
_display.fillRect(6, Line1-1, FuelIconSmallInfo.width, FuelIconSmallInfo.height, BLACK); // scrub prior drip
_drawBitmap(6, Line1, FuelIconSmallInfo); // drip fuel
_display.fillRect(BatteryIconInfo.width - 10, Line2+2, 2, 5, BLACK); // deplete battery
// _display.fillRect(7, Line3+1, 2, 1, WHITE); // grow thermometer
break;
case 8:
_display.fillRect(6, Line1, FuelIconSmallInfo.width, FuelIconSmallInfo.height, BLACK); // scrub prior drip
_drawBitmap(6, Line1+1, FuelIconSmallInfo); // drip fuel
_display.fillRect(BatteryIconInfo.width - 13, Line2+2, 2, 5, BLACK); // deplete battery
// _display.fillRect(7, Line3, 2, 1, WHITE); // grow thermometer
break;
}
......@@ -161,7 +149,9 @@ CFuelCalScreen::animate()
bool
CFuelCalScreen::keyHandler(uint8_t event)
{
sHeaterTuning tuning;
if(CPasswordScreen::keyHandler(event)) { // handle confirm save
return true;
}
if(event & keyRepeat) {
if(event & key_Left) {
......@@ -184,9 +174,6 @@ CFuelCalScreen::keyHandler(uint8_t event)
case 3:
_adjust(-1);
break;
case 10:
_rowSel = 0; // abort save
break;
}
}
// press RIGHT to select next screen
......@@ -200,9 +187,6 @@ CFuelCalScreen::keyHandler(uint8_t event)
case 3:
_adjust(+1);
break;
case 10:
_rowSel = 0; // abort save
break;
}
}
if(event & key_Down) {
......@@ -217,21 +201,8 @@ CFuelCalScreen::keyHandler(uint8_t event)
case 2:
case 3:
_rowSel++;
// UPPERLIMIT(_rowSel, 3);
UPPERLIMIT(_rowSel, 2);
break;
case 10: // confirmed save
_display.clearDisplay();
_animateCount = -1;
_enableStoringMessage();
tuning = NVstore.getHeaterTuning();
tuning.pumpCal = _mlPerStroke;
tuning.lowVolts = _LVC;
// tuning.DS18B20probe[0].offset = _tOfs;
NVstore.setHeaterTuning(tuning);
saveNV();
_rowSel = 0;
break;
}
}
// CENTRE press
......@@ -245,7 +216,7 @@ CFuelCalScreen::keyHandler(uint8_t event)
case 3:
_animateCount = -1;
_display.clearDisplay();
_rowSel = 10;
_rowSel = SaveConfirm;
break;
}
}
......@@ -286,10 +257,16 @@ CFuelCalScreen::_adjust(int dir)
}
}
break;
/* case 3:
_tOfs += dir * 0.1;
BOUNDSLIMIT(_tOfs, -10, 10);
break;
*/
}
}
void
CFuelCalScreen::_saveNV()
{
sHeaterTuning tuning = NVstore.getHeaterTuning();
tuning.pumpCal = _mlPerStroke;
tuning.lowVolts = _LVC;
// tuning.DS18B20probe[0].offset = _tOfs;
NVstore.setHeaterTuning(tuning);
NVstore.save();
}
\ No newline at end of file
......@@ -30,13 +30,13 @@ class CScreenManager;
class CFuelCalScreen : public CPasswordScreen
{
int _rowSel;
void _adjust(int dir);
float _mlPerStroke;
float _tOfs;
uint8_t _LVC;
int _animateCount;
void _initUI();
protected:
void _saveNV();
public:
CFuelCalScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
......
......@@ -169,6 +169,10 @@ CFuelMixtureScreen::animate()
bool
CFuelMixtureScreen::keyHandler(uint8_t event)
{
if(CPasswordScreen::keyHandler(event)) { // handle confirm save
return true;
}
if(event & keyPressed) {
// press CENTRE
if(event & key_Centre) {
......@@ -182,10 +186,7 @@ CFuelMixtureScreen::keyHandler(uint8_t event)
case 4:
_animateCount = -1;
_display.clearDisplay();
_rowSel = 5; // enter save confirm mode
break;
case 5:
_rowSel = 0;
_rowSel = SaveConfirm; // enter save confirm mode
break;
}
}
......@@ -201,9 +202,6 @@ CFuelMixtureScreen::keyHandler(uint8_t event)
case 4:
_adjustSetting(-1);
break;
case 5:
_rowSel = 0;
break;
}
}
// press RIGHT
......@@ -218,9 +216,6 @@ CFuelMixtureScreen::keyHandler(uint8_t event)
case 4:
_adjustSetting(+1);
break;
case 5:
_rowSel = 0;
break;
}
}
// press UP
......@@ -242,17 +237,6 @@ CFuelMixtureScreen::keyHandler(uint8_t event)
_colSel = 0;
UPPERLIMIT(_rowSel, 4);
break;
case 5:
_display.clearDisplay();
_animateCount = -1;
_enableStoringMessage();
setPumpMin(adjPump[0]);
setPumpMax(adjPump[1]);
setFanMin(adjFan[0]);
setFanMax(adjFan[1]);
saveNV();
_rowSel = 0;
break;
}
}
}
......@@ -266,9 +250,6 @@ CFuelMixtureScreen::keyHandler(uint8_t event)
_rowSel--;
_colSel = 0;
break;
case 5:
_rowSel = 0;
break;
}
}
_ScreenManager.reqUpdate();
......@@ -322,4 +303,14 @@ CFuelMixtureScreen::_adjustSetting(int dir)
UPPERLIMIT(adjFan[0], 5000);
LOWERLIMIT(adjFan[1], 1000);
UPPERLIMIT(adjFan[1], 5000);
}
\ No newline at end of file
}
void
CFuelMixtureScreen::_saveNV()
{
setPumpMin(adjPump[0]);
setPumpMax(adjPump[1]);
setFanMin(adjFan[0]);
setFanMax(adjFan[1]);
saveNV();
}
......@@ -31,13 +31,13 @@ class CScreenManager;
class CFuelMixtureScreen : public CPasswordScreen {
float adjPump[2];
uint16_t adjFan[2];
int _rowSel;
int _colSel;
int _animateCount;
void _adjustSetting(int dir);
void _initUI();
void _load();
protected:
void _saveNV();
public:
CFuelMixtureScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
......
......@@ -28,6 +28,7 @@
#include "../Utility/BoardDetect.h"
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
extern CGPIOout GPIOout;
extern CGPIOin GPIOin;
extern CGPIOalg GPIOalg;
......@@ -88,6 +89,7 @@ CGPIOInfoScreen::animate()
break;
}
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
_drawBitmap(40, 16, GPIOin.getState(0) ? CloseIconInfo : OpenIconInfo);
#endif
......@@ -103,11 +105,13 @@ CGPIOInfoScreen::animate()
break;
}
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
_drawBitmap(40, 28, GPIOin.getState(1) ? CloseIconInfo : OpenIconInfo);
#endif
int bulbmode = 0;
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
bulbmode = GPIOout.getState(0);
#endif
static bool iconstate = false;
......@@ -134,6 +138,7 @@ CGPIOInfoScreen::animate()
}
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
bulbmode = GPIOout.getState(1);
#endif
switch(NVstore.getUserSettings().GPIO.out2Mode) {
......@@ -156,6 +161,7 @@ CGPIOInfoScreen::animate()
}
else {
#if USE_JTAG == 0
//CANNOT USE GPIO WITH JTAG DEBUG
sprintf(msg, "%d%%", GPIOalg.getValue() * 100 / 4096);
_printMenuText(23, Line1, msg);
#endif
......
......@@ -95,110 +95,105 @@ CGPIOSetupScreen::show()
if(!CPasswordScreen::show()) { // for showing "saving settings"
if(_rowSel == 10) {
_showConfirmMessage();
_showTitle("GPIO Configuration");
_drawBitmap(0, Line3, InputIconInfo);
_drawBitmap(11, Line3, _1IconInfo);
{
const char* msgText = NULL;
switch(_GPIOparams.in1Mode) {
case CGPIOin1::Disabled: msgText = " --- "; break;
case CGPIOin1::Start: msgText = "Start"; break;
case CGPIOin1::Run: msgText = "Run "; break;
case CGPIOin1::StartStop: msgText = animated ? "Start" : "Stop "; break;
case CGPIOin1::Stop: msgText = "Stop "; break;
}
if(msgText)
_printMenuText(Column1, Line3, msgText, _rowSel == 4);
}
else {
_showTitle("GPIO Configuration");
_drawBitmap(0, Line3, InputIconInfo);
_drawBitmap(11, Line3, _1IconInfo);
{
const char* msgText = NULL;
switch(_GPIOparams.in1Mode) {
case CGPIOin1::Disabled: msgText = " --- "; break;
case CGPIOin1::Start: msgText = "Start"; break;
case CGPIOin1::Run: msgText = "Run "; break;
case CGPIOin1::StartStop: msgText = animated ? "Start" : "Stop "; break;
case CGPIOin1::Stop: msgText = "Stop "; break;
}
if(msgText)
_printMenuText(Column1, Line3, msgText, _rowSel == 4);
_drawBitmap(0, Line2, InputIconInfo);
_drawBitmap(11, Line2, _2IconInfo);
{
const char* msgText = NULL;
switch(_GPIOparams.in2Mode) {
case CGPIOin2::Disabled: msgText = " --- "; break;
case CGPIOin2::Stop: msgText = "Stop "; break;
case CGPIOin2::Thermostat: msgText = "\352T"; break;
}
_drawBitmap(0, Line2, InputIconInfo);
_drawBitmap(11, Line2, _2IconInfo);
{
const char* msgText = NULL;
switch(_GPIOparams.in2Mode) {
case CGPIOin2::Disabled: msgText = " --- "; break;
case CGPIOin2::Stop: msgText = "Stop "; break;
case CGPIOin2::Thermostat: msgText = "\352T"; break;
}
if(msgText)
_printMenuText(Column1, Line2, msgText, _rowSel == 2);
if(_GPIOparams.in2Mode == CGPIOin2::Thermostat) {
_drawBitmap(Column1 + 13, Line2-2, TimerIconInfo);
const char* modeStr = "No";
switch(_ExtHold) {
case 60000: modeStr = "1m"; break;
case 120000: modeStr = "2m"; break;
case 300000: modeStr = "5m"; break;
case 600000: modeStr = "10m"; break;
case 900000: modeStr = "15m"; break;
case 1200000: modeStr = "20m"; break;
case 1800000: modeStr = "30m"; break;
case 3600000: modeStr = "1hr"; break;
}
_printMenuText(Column1 + 29, Line2, modeStr, _rowSel == 3);
if(msgText)
_printMenuText(Column1, Line2, msgText, _rowSel == 2);
if(_GPIOparams.in2Mode == CGPIOin2::Thermostat) {
_drawBitmap(Column1 + 13, Line2-2, TimerIconInfo);
const char* modeStr = "No";
switch(_ExtHold) {
case 60000: modeStr = "1m"; break;
case 120000: modeStr = "2m"; break;
case 300000: modeStr = "5m"; break;
case 600000: modeStr = "10m"; break;
case 900000: modeStr = "15m"; break;
case 1200000: modeStr = "20m"; break;
case 1800000: modeStr = "30m"; break;
case 3600000: modeStr = "1hr"; break;
}
_printMenuText(Column1 + 29, Line2, modeStr, _rowSel == 3);
}
}
_drawBitmap(70, Line3, OutputIconInfo);
_drawBitmap(80, Line3, _1IconInfo);
{
const char* msgText = NULL;
switch(_GPIOparams.out1Mode) {
case CGPIOout1::Disabled: msgText = "---"; break;
case CGPIOout1::Status: msgText = "Status"; break;
case CGPIOout1::User: msgText = "User"; break;
case CGPIOout1::Thresh:
if(_rowSel == 6) {
sprintf(msg, " %dC", s8abs(_GPIOparams.thresh[0]));
_printMenuText(Column2, Line3, msg, false);
_printMenuText(Column2, Line3, _GPIOparams.thresh[0] >= 0 ? ">" : "<", true);
}
else {
sprintf(msg, "%s %dC", _GPIOparams.thresh[0] >= 0 ? ">" : "<", s8abs(_GPIOparams.thresh[0]));
_printMenuText(Column2, Line3, msg, _rowSel == 8);
}
break;
}
if(msgText)
_printMenuText(Column2, Line3, msgText, _rowSel == 6);
_drawBitmap(70, Line3, OutputIconInfo);
_drawBitmap(80, Line3, _1IconInfo);
{
const char* msgText = NULL;
switch(_GPIOparams.out1Mode) {
case CGPIOout1::Disabled: msgText = "---"; break;
case CGPIOout1::Status: msgText = "Status"; break;
case CGPIOout1::User: msgText = "User"; break;
case CGPIOout1::Thresh:
if(_rowSel == 6) {
sprintf(msg, " %d`C", s8abs(_GPIOparams.thresh[0]));
_printMenuText(Column2, Line3, msg, false);
_printMenuText(Column2, Line3, _GPIOparams.thresh[0] >= 0 ? ">" : "<", true);
}
else {
sprintf(msg, "%s %d`C", _GPIOparams.thresh[0] >= 0 ? ">" : "<", s8abs(_GPIOparams.thresh[0]));
_printMenuText(Column2, Line3, msg, _rowSel == 8);
}
break;
}
_drawBitmap(70, Line2, OutputIconInfo);
_drawBitmap(80, Line2, _2IconInfo);
{
const char* msgText = NULL;
switch(_GPIOparams.out2Mode) {
case CGPIOout2::Disabled: msgText = "---"; break;
case CGPIOout2::User: msgText = "User"; break;
case CGPIOout2::Thresh:
if(_rowSel == 5) {
sprintf(msg, " %d`C", s8abs(_GPIOparams.thresh[1]));
_printMenuText(Column2, Line2, msg, false);
_printMenuText(Column2, Line2, _GPIOparams.thresh[1] >= 0 ? ">" : "<", true);
}
else {
sprintf(msg, "%s %d`C", _GPIOparams.thresh[1] >= 0 ? ">" : "<", s8abs(_GPIOparams.thresh[1]));
_printMenuText(Column2, Line2, msg, _rowSel == 7);
}
break;
}
if(msgText)
_printMenuText(Column2, Line2, msgText, _rowSel == 5);
if(msgText)
_printMenuText(Column2, Line3, msgText, _rowSel == 6);
}
_drawBitmap(70, Line2, OutputIconInfo);
_drawBitmap(80, Line2, _2IconInfo);
{
const char* msgText = NULL;
switch(_GPIOparams.out2Mode) {
case CGPIOout2::Disabled: msgText = "---"; break;
case CGPIOout2::User: msgText = "User"; break;
case CGPIOout2::Thresh:
if(_rowSel == 5) {
sprintf(msg, " %d`C", s8abs(_GPIOparams.thresh[1]));
_printMenuText(Column2, Line2, msg, false);
_printMenuText(Column2, Line2, _GPIOparams.thresh[1] >= 0 ? ">" : "<", true);
}
else {
sprintf(msg, "%s %d`C", _GPIOparams.thresh[1] >= 0 ? ">" : "<", s8abs(_GPIOparams.thresh[1]));
_printMenuText(Column2, Line2, msg, _rowSel == 7);
}
break;
}
if(msgText)
_printMenuText(Column2, Line2, msgText, _rowSel == 5);
}
if(getBoardRevision() == BRD_V2_FULLGPIO || getBoardRevision() == BRD_V1_FULLGPIO) {
_drawBitmap(0, Line1-1, algIconInfo);
const char* msgText = NULL;
switch(_GPIOparams.algMode) {
case CGPIOalg::Disabled: msgText = "Disabled"; break;
case CGPIOalg::HeatDemand: msgText = "Enabled"; break;
}
if(msgText)
_printMenuText(23, Line1, msgText, _rowSel == 1);
if(getBoardRevision() == BRD_V2_FULLGPIO || getBoardRevision() == BRD_V1_FULLGPIO) {
_drawBitmap(0, Line1-1, algIconInfo);
const char* msgText = NULL;
switch(_GPIOparams.algMode) {
case CGPIOalg::Disabled: msgText = "Disabled"; break;
case CGPIOalg::HeatDemand: msgText = "Enabled"; break;
}
if(msgText)
_printMenuText(23, Line1, msgText, _rowSel == 1);
}
}
......@@ -211,7 +206,7 @@ CGPIOSetupScreen::animate()
CPasswordScreen::animate();
if(!CPasswordScreen::_busy()) {
if(_rowSel != 10) {
if(_rowSel != SaveConfirm) {
int yPos = 53;
int xPos = _display.xCentre();
const char* pMsg = NULL;
......@@ -314,8 +309,10 @@ CGPIOSetupScreen::animate()
bool
CGPIOSetupScreen::keyHandler(uint8_t event)
{
if(CPasswordScreen::keyHandler(event)) { // handle confirm save
return true;
}
sUserSettings us;
if(event & keyPressed) {
_repeatCount = 0;
}
......@@ -376,9 +373,6 @@ CGPIOSetupScreen::keyHandler(uint8_t event)
_scrollChar = 0;
_adjust(-1);
break;
case 10:
_rowSel = 0; // abort save
break;
}
}
// press RIGHT to select next screen
......@@ -398,24 +392,16 @@ CGPIOSetupScreen::keyHandler(uint8_t event)
_scrollChar = 0;
_adjust(+1);
break;
case 10:
_rowSel = 0; // abort save
break;
}
}
if(event & key_Down) {
if(_rowSel == 10) {
_rowSel = 0; // abort save
}
else {
_scrollChar = 0;
_rowSel--;
if((_rowSel == 3) && (_GPIOparams.in2Mode != CGPIOin2::Thermostat))
_rowSel--; // force skip if not set to external thermostat
if((_rowSel == 1) && ((getBoardRevision() == BRD_V2_GPIO_NOALG) || (getBoardRevision() == BRD_V3_GPIO_NOALG))) // GPIO but NO analog support
_rowSel--; // force skip if analog input is not supported by PCB
LOWERLIMIT(_rowSel, 0);
}
_scrollChar = 0;
_rowSel--;
if((_rowSel == 3) && (_GPIOparams.in2Mode != CGPIOin2::Thermostat))
_rowSel--; // force skip if not set to external thermostat
if((_rowSel == 1) && ((getBoardRevision() == BRD_V2_GPIO_NOALG) || (getBoardRevision() == BRD_V3_GPIO_NOALG))) // GPIO but NO analog support
_rowSel--; // force skip if analog input is not supported by PCB
LOWERLIMIT(_rowSel, 0);
}
// UP press
if(event & key_Up) {
......@@ -434,18 +420,6 @@ CGPIOSetupScreen::keyHandler(uint8_t event)
_rowSel++; // force skip if not set to external thermostat
UPPERLIMIT(_rowSel, 6);
break;
case 10: // confirmed save
_enableStoringMessage();
us = NVstore.getUserSettings();
us.GPIO = _GPIOparams;
us.ExtThermoTimeout = _ExtHold;
NVstore.setUserSettings(us);
saveNV();
setupGPIO();
_rowSel = 0;
break;
}
}
// CENTRE press
......@@ -460,7 +434,7 @@ CGPIOSetupScreen::keyHandler(uint8_t event)
case 4:
case 5:
case 6:
_rowSel = 10;
_rowSel = SaveConfirm;
break;
case 7:
_rowSel = 5;
......@@ -551,3 +525,15 @@ CGPIOSetupScreen::_adjust(int dir)
}
void
CGPIOSetupScreen::_saveNV()
{
sUserSettings us = NVstore.getUserSettings();
us.GPIO = _GPIOparams;
us.ExtThermoTimeout = _ExtHold;
NVstore.setUserSettings(us);
NVstore.save();
setupGPIO();
}
......@@ -31,7 +31,6 @@ class CScreenManager;
class CGPIOSetupScreen : public CPasswordScreen
{
int _rowSel;
void _adjust(int dir);
sGPIOparams _GPIOparams;
unsigned long _ExtHold;
......@@ -39,6 +38,8 @@ class CGPIOSetupScreen : public CPasswordScreen
int _scrollChar;
int _repeatCount;
void _initUI();
protected:
void _saveNV();
public:
CGPIOSetupScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
......
......@@ -76,31 +76,25 @@ CHeaterSettingsScreen::show()
if(!CPasswordScreen::show()) { // for showing "saving settings"
if(_rowSel == 4) {
_showConfirmMessage();
}
else {
// _printInverted(_display.xCentre(), 0, " Heater Settings ", true, eCentreJustify);
_showTitle("Heater Settings");
_printMenuText(97, Line3, "System voltage:", false, eRightJustify);
_printMenuText(97, Line2, "Fan sensor:", false, eRightJustify);
_printMenuText(97, Line1, "Glowplug power:", false, eRightJustify);
sprintf(msg, "%dV", _sysVoltage);
_printMenuText(Column, Line3, msg, _rowSel == 3);
// navigation line
int yPos = 53;
int xPos = _display.xCentre();
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;
}
_showTitle("Heater Settings");
_printMenuText(97, Line3, "System voltage:", false, eRightJustify);
_printMenuText(97, Line2, "Fan sensor:", false, eRightJustify);
_printMenuText(97, Line1, "Glowplug power:", false, eRightJustify);
sprintf(msg, "%dV", _sysVoltage);
_printMenuText(Column, Line3, msg, _rowSel == 3);
// navigation line
int yPos = 53;
int xPos = _display.xCentre();
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;
}
}
......@@ -113,10 +107,10 @@ CHeaterSettingsScreen::animate()
{
char msg[16];
if(isPasswordBusy() || (_rowSel == 4)) { // Password screen activity
if(isPasswordBusy() || (_rowSel == SaveConfirm)) { // Password screen activity
_printMenuText(Column, Line2, " ");
_printMenuText(Column, Line1, " ");
if(_rowSel == 4)
if(_rowSel == SaveConfirm)
_printMenuText(_display.xCentre(), 43, "Confirm save", false, eCentreJustify);
}
else {
......@@ -155,6 +149,10 @@ CHeaterSettingsScreen::animate()
bool
CHeaterSettingsScreen::keyHandler(uint8_t event)
{
if(CPasswordScreen::keyHandler(event)) { // handle confirm save
return true;
}
if(event & keyPressed) {
// press LEFT to select previous screen
if(event & key_Left) {
......@@ -167,9 +165,6 @@ CHeaterSettingsScreen::keyHandler(uint8_t event)
case 3:
_adjust(-1);
break;
case 4:
_rowSel = 0; // abort save
break;
}
}
// press RIGHT to select next screen
......@@ -183,9 +178,6 @@ CHeaterSettingsScreen::keyHandler(uint8_t event)
case 3:
_adjust(+1);
break;
case 4:
_rowSel = 0; // abort save
break;
}
}
if(event & key_Down) {
......@@ -202,14 +194,6 @@ CHeaterSettingsScreen::keyHandler(uint8_t event)
_rowSel++;
UPPERLIMIT(_rowSel, 3);
break;
case 4: // confirmed save
_enableStoringMessage();
setSystemVoltage(float(_sysVoltage));
setFanSensor(_fanSensor);
setGlowDrive(_glowDrive);
saveNV();
_rowSel = 0;
break;
}
}
// CENTRE press
......@@ -221,7 +205,7 @@ CHeaterSettingsScreen::keyHandler(uint8_t event)
case 1:
case 2:
case 3:
_rowSel = 4;
_rowSel = SaveConfirm;
break;
}
}
......@@ -247,3 +231,12 @@ CHeaterSettingsScreen::_adjust(int dir)
break;
}
}
void
CHeaterSettingsScreen::_saveNV()
{
setSystemVoltage(float(_sysVoltage));
setFanSensor(_fanSensor);
setGlowDrive(_glowDrive);
saveNV();
}
......@@ -30,13 +30,14 @@ class CScreenManager;
class CHeaterSettingsScreen : public CPasswordScreen
{
int _rowSel;
void _adjust(int dir);
int _sysVoltage;
int _fanSensor;
int _glowDrive;
int _animateCount;
void _initUI();
protected:
void _saveNV();
public:
CHeaterSettingsScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
......
......@@ -52,40 +52,36 @@ CHomeMenuSelScreen::show()
if(!CPasswordScreen::show()) { // for showing "saving settings"
if(_rowSel == 4) {
_showConfirmMessage();
_showTitle("Home Menu Actions");
_drawBitmap(30, 14, TimeoutIconInfo);
switch(_action.onTimeout) {
case 0: strcpy(msg, "Default"); break;
case 1: strcpy(msg, "Detailed"); break;
case 2: strcpy(msg, "Basic"); break;
case 3: strcpy(msg, "Clock"); break;
}
else {
_showTitle("Home Menu Actions");
_drawBitmap(30, 14, TimeoutIconInfo);
switch(_action.onTimeout) {
case 0: strcpy(msg, "Default"); break;
case 1: strcpy(msg, "Detailed"); break;
case 2: strcpy(msg, "Basic"); break;
case 3: strcpy(msg, "Clock"); break;
}
_printMenuText(50, 14, msg, _rowSel == 3);
_drawBitmap(32, 26, StartIconInfo);
switch(_action.onStart) {
case 0: strcpy(msg, "Default"); break;
case 1: strcpy(msg, "Detailed"); break;
case 2: strcpy(msg, "Basic"); break;
case 3: strcpy(msg, "Clock"); break;
}
_printMenuText(50, 26, msg, _rowSel == 2);
_drawBitmap(31, 38, StopIconInfo);
switch(_action.onStop) {
case 0: strcpy(msg, "Default"); break;
case 1: strcpy(msg, "Detailed"); break;
case 2: strcpy(msg, "Basic"); break;
case 3: strcpy(msg, "Clock"); break;
}
_printMenuText(50, 38, msg, _rowSel == 1);
_printMenuText(50, 14, msg, _rowSel == 3);
_drawBitmap(32, 26, StartIconInfo);
switch(_action.onStart) {
case 0: strcpy(msg, "Default"); break;
case 1: strcpy(msg, "Detailed"); break;
case 2: strcpy(msg, "Basic"); break;
case 3: strcpy(msg, "Clock"); break;
}
_printMenuText(50, 26, msg, _rowSel == 2);
_drawBitmap(31, 38, StopIconInfo);
switch(_action.onStop) {
case 0: strcpy(msg, "Default"); break;
case 1: strcpy(msg, "Detailed"); break;
case 2: strcpy(msg, "Basic"); break;
case 3: strcpy(msg, "Clock"); break;
}
_printMenuText(50, 38, msg, _rowSel == 1);
}
return true;
}
......@@ -93,7 +89,7 @@ bool
CHomeMenuSelScreen::animate()
{
if(!CPasswordScreen::_busy()) {
if(_rowSel != 4) {
if(_rowSel != SaveConfirm) {
int yPos = 53;
int xPos = _display.xCentre();
const char* pMsg = NULL;
......@@ -127,23 +123,16 @@ CHomeMenuSelScreen::animate()
bool
CHomeMenuSelScreen::keyHandler(uint8_t event)
{
sUserSettings us;
if(CPasswordScreen::keyHandler(event)) { // handle confirm save
return true;
}
if(event & keyPressed) {
// UP press
if(event & key_Up) {
if(_rowSel == 4) {
_enableStoringMessage();
us = NVstore.getUserSettings();
us.HomeMenu = _action;
NVstore.setUserSettings(us);
saveNV();
_rowSel = 0;
}
else {
_scrollChar = 0;
_rowSel++;
UPPERLIMIT(_rowSel, 3);
}
_scrollChar = 0;
_rowSel++;
UPPERLIMIT(_rowSel, 3);
}
// DOWN press
if(event & key_Down) {
......@@ -157,7 +146,7 @@ CHomeMenuSelScreen::keyHandler(uint8_t event)
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // force return to main menu
}
else {
_rowSel = 4;
_rowSel = SaveConfirm;
}
}
// LEFT press
......@@ -200,6 +189,16 @@ CHomeMenuSelScreen::adjust(int dir)
}
}
void
CHomeMenuSelScreen::_saveNV()
{
sUserSettings us = NVstore.getUserSettings();
us.HomeMenu = _action;
NVstore.setUserSettings(us);
NVstore.save();
}
CNoHeaterHomeMenuSelScreen::CNoHeaterHomeMenuSelScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr)
......@@ -214,7 +213,7 @@ CNoHeaterHomeMenuSelScreen::onSelect()
_action = NVstore.getUserSettings().HomeMenu;
_dispTimeout = NVstore.getUserSettings().dimTime;
_menuTimeout = NVstore.getUserSettings().menuTimeout;
if(_action.onTimeout == 0)
if(_action.onTimeout == 0 || _action.onTimeout == 1)
_action.onTimeout = 2;
}
......@@ -232,41 +231,36 @@ CNoHeaterHomeMenuSelScreen::show()
if(!CPasswordScreen::show()) { // for showing "saving settings"
if(_rowSel == 4) {
_showConfirmMessage();
_showTitle("Home Menu Actions");
_drawBitmap(22, 14, TimeoutIconInfo);
switch(_action.onTimeout) {
case 2: strcpy(msg, "Temperature"); break;
case 3: strcpy(msg, "Clock"); break;
}
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);
_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;
}
......@@ -274,7 +268,7 @@ bool
CNoHeaterHomeMenuSelScreen::animate()
{
if(!CPasswordScreen::_busy()) {
if(_rowSel != 4) {
if(_rowSel != SaveConfirm) {
int yPos = 53;
int xPos = _display.xCentre();
const char* pMsg = NULL;
......@@ -308,25 +302,16 @@ CNoHeaterHomeMenuSelScreen::animate()
bool
CNoHeaterHomeMenuSelScreen::keyHandler(uint8_t event)
{
sUserSettings us;
if(CPasswordScreen::keyHandler(event)) { // handle confirm save
return true;
}
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);
}
_scrollChar = 0;
_rowSel++;
UPPERLIMIT(_rowSel, 3);
}
// DOWN press
if(event & key_Down) {
......@@ -340,7 +325,7 @@ CNoHeaterHomeMenuSelScreen::keyHandler(uint8_t event)
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // force return to main menu
}
else {
_rowSel = 4;
_rowSel = SaveConfirm;
}
}
// LEFT press
......@@ -383,3 +368,15 @@ CNoHeaterHomeMenuSelScreen::adjust(int dir)
break;
}
}
void
CNoHeaterHomeMenuSelScreen::_saveNV()
{
sUserSettings us = NVstore.getUserSettings();
us.HomeMenu = _action;
us.menuTimeout = _menuTimeout;
us.dimTime = _dispTimeout;
NVstore.setUserSettings(us);
NVstore.save();
}
......@@ -31,10 +31,11 @@ class CScreenManager;
class CHomeMenuSelScreen : public CPasswordScreen
{
int _rowSel;
int _scrollChar;
sHomeMenuActions _action;
void _initUI();
protected:
void _saveNV();
public:
CHomeMenuSelScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
......@@ -46,12 +47,13 @@ public:
class CNoHeaterHomeMenuSelScreen : public CPasswordScreen
{
int _rowSel;
int _scrollChar;
sHomeMenuActions _action;
long _dispTimeout;
long _menuTimeout;
void _initUI();
protected:
void _saveNV();
public:
CNoHeaterHomeMenuSelScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
......
......@@ -28,6 +28,7 @@
CMenuSelScreen::CMenuSelScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr)
{
_bReload = false;
}
void
......@@ -38,7 +39,6 @@ CMenuSelScreen::onSelect()
_menuMode = NVstore.getUserSettings().menuMode;
_holdPW = NVstore.getUserSettings().holdPassword;
_scrollChar = 0;
_bReload = false;
}
void
......@@ -56,32 +56,28 @@ CMenuSelScreen::show()
if(!CPasswordScreen::show()) { // for showing "saving settings"
if(_bReload) {
_bReload = false;
_ScreenManager.reqReload();
return false;
}
if(_rowSel == SaveConfirm) {
_showConfirmMessage();
_showTitle("Menu Options");
_drawBitmap(25, 16, MenuIconInfo);
switch(_menuMode) {
case 0: strcpy(msg, "Standard"); break;
case 1: strcpy(msg, "Basic"); break;
case 2: strcpy(msg, "No heater"); break;
}
else {
_showTitle("Menu Options");
_drawBitmap(25, 16, MenuIconInfo);
switch(_menuMode) {
case 0: strcpy(msg, "Standard"); break;
case 1: strcpy(msg, "Basic"); break;
case 2: strcpy(msg, "No heater"); break;
}
_printMenuText(45, 16, msg, _rowSel == 2);
_printMenuText(45, 16, msg, _rowSel == 2);
_drawBitmap(25, 28, passwordIconInfo);
if(_holdPW)
strcpy(msg, "Retain 24hrs");
else
strcpy(msg, "Forget");
_printMenuText(45, 30, msg, _rowSel == 1);
_drawBitmap(25, 28, passwordIconInfo);
if(_holdPW)
strcpy(msg, "Retain 24hrs");
else
strcpy(msg, "Forget");
_printMenuText(45, 30, msg, _rowSel == 1);
}
}
return true;
}
......@@ -91,6 +87,7 @@ CMenuSelScreen::animate()
{
if(!CPasswordScreen::_busy() && !CPasswordScreen::isPasswordBusy()) {
if(_bReload) {
_bReload = false;
_ScreenManager.reqReload();
return false;
}
......@@ -132,41 +129,23 @@ CMenuSelScreen::keyHandler(uint8_t event)
if(_isPasswordOK()) {
_rowSel = 1;
}
return true;
}
else {
_scrollChar = 0;
sUserSettings us;
if(event & keyPressed) {
// UP press
if(event & key_Up) {
if(_rowSel == SaveConfirm) {
_enableStoringMessage();
us = NVstore.getUserSettings();
us.menuMode = _menuMode;
us.holdPassword = _holdPW;
NVstore.setUserSettings(us);
NVstore.save();
switch(us.menuMode) {
case 0: DebugPort.println("Invoking Full menu control mode"); break;
case 1: DebugPort.println("Invoking Basic menu mode"); break;
case 2: DebugPort.println("Invoking No Heater menu mode"); break;
if(_rowSel == 0) {
_getPassword();
if(_isPasswordOK()) {
_rowSel = 1;
}
_holdPassword();
_bReload = true;
_rowSel = 0;
}
else {
if(_rowSel == 0) {
_getPassword();
if(_isPasswordOK()) {
_rowSel = 1;
}
}
else {
_rowSel++;
UPPERLIMIT(_rowSel, 2);
}
_rowSel++;
UPPERLIMIT(_rowSel, 2);
}
}
// DOWN press
......@@ -220,4 +199,18 @@ CMenuSelScreen::adjust(int dir)
}
void
CMenuSelScreen::_saveNV()
{
sUserSettings us = NVstore.getUserSettings();
us.menuMode = _menuMode;
us.holdPassword = _holdPW;
NVstore.setUserSettings(us);
NVstore.save();
switch(us.menuMode) {
case 0: DebugPort.println("Invoking Full menu control mode"); break;
case 1: DebugPort.println("Invoking Basic menu mode"); break;
case 2: DebugPort.println("Invoking No Heater menu mode"); break;
}
_bReload = true;
}
......@@ -31,12 +31,13 @@ class CScreenManager;
class CMenuSelScreen : public CPasswordScreen
{
int _rowSel;
int _scrollChar;
int _menuMode;
uint8_t _holdPW;
bool _bReload;
void _initUI();
protected:
void _saveNV();
public:
CMenuSelScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
......
......@@ -66,6 +66,7 @@ CPasswordScreen::_initUI()
__initPassword(false);
_SaveTime = 0;
_rowSel = 0;
}
void
......@@ -93,6 +94,11 @@ CPasswordScreen::show()
return true;
}
}
else if(_rowSel == SaveConfirm) {
_showConfirmMessage();
return true;
}
return false;
}
......@@ -191,6 +197,21 @@ CPasswordScreen::keyHandler(uint8_t event)
}
return true;
}
if(_rowSel == SaveConfirm) {
if(event & keyPressed) {
_rowSel = 0;
if(event & key_Up) {
_enableStoringMessage();
_saveNV();
if(__Expiry)
_holdPassword(); // extend password hold time (if enabled)
}
onSelect();
return true;
}
}
return false;
}
......
......@@ -43,6 +43,8 @@ protected:
void _enableStoringMessage();
void _initUI();
bool _busy();
virtual void _saveNV() {};
int _rowSel;
public:
CPasswordScreen(C128x64_OLED& display, CScreenManager& mgr);
void onSelect();
......
......@@ -48,6 +48,7 @@
#include "MQTTScreen.h"
#include "DS18B20Screen.h"
#include "TempSensorScreen.h"
#include "FrostScreen.h"
#include <Wire.h>
#include "../cfg/pins.h"
#include "../cfg/BTCConfig.h"
......@@ -461,6 +462,7 @@ CScreenManager::_loadScreens()
menuloop.clear();
if(NVstore.getUserSettings().menuMode == 0) {
menuloop.push_back(new CThermostatModeScreen(*_pDisplay, *this)); // thermostat settings screen
menuloop.push_back(new CFrostScreen(*_pDisplay, *this)); // frost mode screen
menuloop.push_back(new CHomeMenuSelScreen(*_pDisplay, *this)); // Home menu settings screen
menuloop.push_back(new CTimeoutsScreen(*_pDisplay, *this)); // Other options screen
menuloop.push_back(new CMenuSelScreen(*_pDisplay, *this)); // Menu mode screen
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment