2018-11-26 11:58:15 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the "bluetoothheater" distribution
|
|
|
|
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-11-24 11:03:47 +00:00
|
|
|
#include "Screen3.h"
|
2018-12-16 07:34:39 +00:00
|
|
|
#include "KeyPad.h"
|
|
|
|
#include "../Protocol/helpers.h"
|
2018-11-24 11:03:47 +00:00
|
|
|
|
2018-12-01 00:36:25 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// CScreen3
|
|
|
|
//
|
|
|
|
// This screen allows the temeprature control mode to be selected and
|
|
|
|
// allows pump priming
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2018-11-24 11:03:47 +00:00
|
|
|
|
|
|
|
|
2018-12-01 00:36:25 +00:00
|
|
|
CScreen3::CScreen3(C128x64_OLED& display, CScreenManager& mgr) : CScreenHeader(display, mgr)
|
2018-11-25 04:45:17 +00:00
|
|
|
{
|
|
|
|
_PrimeStop = 0;
|
|
|
|
_PrimeCheck = 0;
|
|
|
|
_rowSel = 0;
|
|
|
|
_colSel = 0;
|
|
|
|
}
|
|
|
|
|
2018-11-24 11:03:47 +00:00
|
|
|
|
2018-11-25 04:45:17 +00:00
|
|
|
void
|
2018-12-01 00:36:25 +00:00
|
|
|
CScreen3::show()
|
2018-11-24 11:03:47 +00:00
|
|
|
{
|
2018-12-01 00:36:25 +00:00
|
|
|
CScreenHeader::show();
|
2018-11-25 04:45:17 +00:00
|
|
|
|
2018-11-24 11:03:47 +00:00
|
|
|
CRect extents;
|
2018-12-01 00:36:25 +00:00
|
|
|
int yPos = 52;
|
2018-11-29 11:11:50 +00:00
|
|
|
|
|
|
|
// show next/prev screen navigation line
|
2018-12-07 04:18:24 +00:00
|
|
|
_printMenuText(_display.xCentre(), yPos, "<- ->", _rowSel == 0, eCentreJustify);
|
2018-11-24 11:03:47 +00:00
|
|
|
|
2018-12-01 00:36:25 +00:00
|
|
|
yPos = 40;
|
2018-11-25 04:45:17 +00:00
|
|
|
if(_rowSel == 1) {
|
2018-12-02 06:30:40 +00:00
|
|
|
// follow user desired setting, heater info is laggy
|
2018-12-07 04:18:24 +00:00
|
|
|
_printMenuText(border, yPos, "Thermostat", _colSel == 0);
|
|
|
|
_printMenuText(_display.width()-border, yPos, "Fixed Hz", _colSel == 1, eRightJustify);
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-12-02 06:30:40 +00:00
|
|
|
// follow actual heater settings
|
|
|
|
int col = getHeaterInfo().isThermostat() ? 0 : 1;
|
2018-12-01 00:36:25 +00:00
|
|
|
_printInverted(border, yPos, "Thermostat", col == 0);
|
|
|
|
_printInverted(_display.width()-border, yPos, "Fixed Hz", col == 1, eRightJustify);
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// fuel pump priming menu
|
2018-12-01 00:36:25 +00:00
|
|
|
yPos = 28;
|
2018-12-07 04:18:24 +00:00
|
|
|
_printMenuText(border, yPos, "Prime pump");
|
2018-11-25 04:45:17 +00:00
|
|
|
if(_rowSel == 2) {
|
2018-12-07 04:18:24 +00:00
|
|
|
_printMenuText(70, yPos, "OFF", _colSel == 1);
|
2018-11-29 11:11:50 +00:00
|
|
|
if(_colSel != 2) {
|
2018-12-01 00:36:25 +00:00
|
|
|
if(!getHeaterInfo().getRunState()) { // prevent option if heater is running
|
2018-12-07 04:18:24 +00:00
|
|
|
_printMenuText(100, yPos, "ON"); // becomes Hz when actually priming
|
2018-11-29 11:11:50 +00:00
|
|
|
}
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|
2018-11-29 11:11:50 +00:00
|
|
|
else {
|
2018-12-01 00:36:25 +00:00
|
|
|
float pumpHz = getHeaterInfo().getPump_Actual();
|
2018-11-29 11:11:50 +00:00
|
|
|
// recognise if heater has stopped pump, after an initial holdoff upon first starting
|
|
|
|
long tDelta = millis() - _PrimeCheck;
|
|
|
|
if(_PrimeCheck && tDelta > 0 && pumpHz < 0.1) {
|
|
|
|
stopPump();
|
|
|
|
}
|
|
|
|
// test if time is up, stop priming if so
|
|
|
|
tDelta = millis() - _PrimeStop;
|
|
|
|
if(_PrimeStop && tDelta > 0) {
|
|
|
|
stopPump();
|
|
|
|
}
|
2018-11-24 11:03:47 +00:00
|
|
|
|
2018-11-29 11:11:50 +00:00
|
|
|
if(_PrimeStop) {
|
|
|
|
char msg[16];
|
|
|
|
sprintf(msg, "%.1fHz", pumpHz);
|
2018-12-07 04:18:24 +00:00
|
|
|
_printMenuText(_display.width()-border, yPos, msg, true, eRightJustify);
|
2018-11-29 11:11:50 +00:00
|
|
|
}
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-01 18:25:10 +00:00
|
|
|
// _display.display();
|
2018-11-26 10:26:38 +00:00
|
|
|
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-25 04:45:17 +00:00
|
|
|
void
|
|
|
|
CScreen3::keyHandler(uint8_t event)
|
2018-11-24 11:03:47 +00:00
|
|
|
{
|
2018-12-01 00:36:25 +00:00
|
|
|
|
2018-11-24 11:03:47 +00:00
|
|
|
if(event & keyPressed) {
|
|
|
|
// press CENTRE
|
|
|
|
if(event & key_Centre) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// press LEFT
|
|
|
|
if(event & key_Left) {
|
2018-11-25 04:45:17 +00:00
|
|
|
switch(_rowSel) {
|
2018-11-24 11:03:47 +00:00
|
|
|
case 0:
|
2018-11-29 11:11:50 +00:00
|
|
|
_ScreenManager.prevScreen();
|
2018-11-24 11:03:47 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-11-25 04:45:17 +00:00
|
|
|
_colSel = 0;
|
2018-11-24 11:03:47 +00:00
|
|
|
setThermostatMode(1);
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-11-25 04:45:17 +00:00
|
|
|
_colSel = 1;
|
2018-11-24 11:03:47 +00:00
|
|
|
break;
|
|
|
|
case 3: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// press RIGHT
|
|
|
|
if(event & key_Right) {
|
2018-11-25 04:45:17 +00:00
|
|
|
switch(_rowSel) {
|
2018-11-24 11:03:47 +00:00
|
|
|
case 0:
|
2018-11-29 11:11:50 +00:00
|
|
|
_ScreenManager.nextScreen();
|
2018-11-24 11:03:47 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-11-25 04:45:17 +00:00
|
|
|
_colSel = 1;
|
2018-11-24 11:03:47 +00:00
|
|
|
setThermostatMode(0);
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-12-01 00:36:25 +00:00
|
|
|
if(!getHeaterInfo().getRunState())
|
2018-11-25 04:45:17 +00:00
|
|
|
_colSel = 2;
|
2018-11-24 11:03:47 +00:00
|
|
|
break;
|
|
|
|
case 3: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// press UP
|
|
|
|
if(event & key_Up) {
|
2018-11-25 04:45:17 +00:00
|
|
|
_rowSel++;
|
|
|
|
UPPERLIMIT(_rowSel, 2);
|
|
|
|
if(_rowSel == 2)
|
|
|
|
_colSel = 1; // select OFF upon entry to priming menu
|
2018-12-02 06:30:40 +00:00
|
|
|
if(_rowSel == 1)
|
|
|
|
_colSel = getHeaterInfo().isThermostat() ? 0 : 1;
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|
|
|
|
// press DOWN
|
|
|
|
if(event & key_Down) {
|
2018-11-25 04:45:17 +00:00
|
|
|
_rowSel--;
|
|
|
|
LOWERLIMIT(_rowSel, 0);
|
|
|
|
_colSel = 0;
|
2018-12-02 06:30:40 +00:00
|
|
|
if(_rowSel == 1)
|
|
|
|
_colSel = getHeaterInfo().isThermostat() ? 0 : 1;
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check if fuel priming was selected
|
2018-11-25 04:45:17 +00:00
|
|
|
if(_rowSel == 2 && _colSel == 2) {
|
2018-11-24 11:03:47 +00:00
|
|
|
reqPumpPrime(true);
|
2018-11-25 04:45:17 +00:00
|
|
|
_PrimeStop = millis() + 150000; // allow 2.5 minutes - much the same as the heater itself cuts out at
|
|
|
|
_PrimeCheck = millis() + 3000; // holdoff upon start before testing for heater shutting off pump
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
stopPump();
|
|
|
|
}
|
|
|
|
|
2018-11-29 11:11:50 +00:00
|
|
|
_ScreenManager.reqUpdate();
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-25 04:45:17 +00:00
|
|
|
void
|
|
|
|
CScreen3::stopPump()
|
2018-11-24 11:03:47 +00:00
|
|
|
{
|
|
|
|
reqPumpPrime(false);
|
2018-11-25 04:45:17 +00:00
|
|
|
_PrimeCheck = 0;
|
|
|
|
_PrimeStop = 0;
|
|
|
|
if(_colSel == 2)
|
|
|
|
_colSel = 1;
|
2018-11-24 11:03:47 +00:00
|
|
|
}
|