Added option for temperature readout in Farenheit.

This commit is contained in:
rljonesau 2019-02-07 07:24:22 +11:00
parent ef500a9f76
commit 0a666e1e2f
6 changed files with 117 additions and 16 deletions

View file

@ -26,6 +26,7 @@
#include "KeyPad.h"
#include "../Protocol/helpers.h"
#include "../Utility/UtilClasses.h"
#include "../Utility/NVStorage.h"
#define MAXIFONT tahoma_16ptFontInfo
@ -55,7 +56,14 @@ CBasicScreen::show()
float fTemp = getActualTemperature();
if(fTemp > -80) {
sprintf(msg, "%.1f`", fTemp);
if(NVstore.getDegFMode()) {
fTemp = fTemp * 9 / 5 + 32;
sprintf(msg, "%.1f`F", fTemp);
}
else {
sprintf(msg, "%.1f`C", fTemp);
}
{
CTransientFont AF(_display, &MAXIFONT); // temporarily use a large font
_printMenuText(_display.xCentre(), 25, msg, false, eCentreJustify);
@ -103,7 +111,14 @@ CBasicScreen::show()
if(tDelta < 0) {
// Show current heat demand setting
if(getHeaterInfo().isThermostat()) {
sprintf(msg, "Setpoint = %.0f`C", getHeaterInfo().getTemperature_Desired());
float fTemp = getHeaterInfo().getTemperature_Desired();
if(NVstore.getDegFMode()) {
fTemp = fTemp * 9 / 5 + 32;
sprintf(msg, "Setpoint = %.0f`F", fTemp);
}
else {
sprintf(msg, "Setpoint = %.0f`C", fTemp);
}
}
else {
sprintf(msg, "Setpoint = %.1fHz", getHeaterInfo().getPump_Fixed());
@ -179,6 +194,14 @@ CBasicScreen::keyHandler(uint8_t event)
_nModeSel = getHeaterInfo().isThermostat() ? 0 : 1;
}
}
// hold UP to toggle degC/degF mode selection
if(event & key_Up) {
if(repeatCount > 2) {
repeatCount = -1; // prevent double handling
_showMode = millis() + 5000;
NVstore.setDegFMode(NVstore.getDegFMode() ? 0 : 1);
}
}
// hold CENTRE to turn ON or OFF
if(event & key_Centre) {
if(getHeaterInfo().getRunState()) {

View file

@ -28,6 +28,7 @@
#include "KeyPad.h"
#include "../Protocol/helpers.h"
#include "../Protocol/Protocol.h"
#include "../Utility/NVStorage.h"
#define MINIFONT miniFontInfo
@ -204,6 +205,12 @@ CDetailedScreen::keyHandler(uint8_t event)
else _reqOEMWarning();
}
}
if(event & key_Up) {
if(_keyRepeatCount > 1) { // held Down - togle thermo/fixed mode
_keyRepeatCount = -1; // prevent double handling
NVstore.setDegFMode(NVstore.getDegFMode() ? 0 : 1);
}
}
}
}
// release event
@ -246,7 +253,13 @@ CDetailedScreen::showThermometer(float desired, float actual)
if(actual > -80) {
#ifdef MINI_TEMPLABEL
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
sprintf(msg, "%.1f`C", actual);
if(NVstore.getDegFMode()) {
actual = actual * 9 / 5 + 32;
sprintf(msg, "%.1f`F", actual);
}
else {
sprintf(msg, "%.1f`C", actual);
}
#else
sprintf(msg, "%.1f", actual);
#endif
@ -263,7 +276,13 @@ CDetailedScreen::showThermometer(float desired, float actual)
if(desired > 0) {
int yPos = Y_BULB + TEMP_YPOS(desired) - 2;
_display.drawBitmap(X_BULB-1, yPos, thermoPtr, 3, 5, WHITE); // set indicator against bulb
sprintf(msg, "%.0f`C", desired);
if(NVstore.getDegFMode()) {
desired = desired * 9 / 5 + 32;
sprintf(msg, "%.0f`F", desired);
}
else {
sprintf(msg, "%.0f`C", desired);
}
}
else {
sprintf(msg, "%.1fHz", -desired);
@ -291,7 +310,13 @@ CDetailedScreen::showBodyThermometer(int actual)
// determine width and position right justified
#ifdef MINI_BODYLABEL
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
sprintf(label, "%d`C", actual);
if(NVstore.getDegFMode()) {
actual = actual * 9 / 5 + 32;
sprintf(label, "%d`F", actual);
}
else {
sprintf(label, "%d`C", actual);
}
#else
sprintf(label, "%d", actual);
#endif

View file

@ -22,6 +22,7 @@
#include "PrimingScreen.h"
#include "KeyPad.h"
#include "../Protocol/helpers.h"
#include "../Utility/NVStorage.h"
///////////////////////////////////////////////////////////////////////////
//
@ -65,11 +66,21 @@ CPrimingScreen::show()
_printInverted(border, yPos, "Thermostat", col == 0);
_printInverted(_display.width()-border, yPos, "Fixed Hz", col == 1, eRightJustify);
}
yPos = 28;
if(_rowSel == 2) {
_printMenuText(border, yPos, "degC", _colSel == 0);
_printMenuText(_display.width()-border, yPos, "degF", _colSel == 1, eRightJustify);
}
else {
int col = NVstore.getDegFMode();
_printInverted(border, yPos, "degC", col == 0);
_printInverted(_display.width()-border, yPos, "degF", col == 1, eRightJustify);
}
// fuel pump priming menu
yPos = 28;
yPos = 16;
_printMenuText(border, yPos, "Prime pump");
if(_rowSel == 2) {
if(_rowSel == 3) {
_printMenuText(70, yPos, "OFF", _colSel == 1);
if(_colSel != 2) {
if(!getHeaterInfo().getRunState()) { // prevent option if heater is running
@ -117,9 +128,13 @@ CPrimingScreen::keyHandler(uint8_t event)
setThermostatMode(1);
break;
case 2:
_colSel = 0;
NVstore.setDegFMode(0);
break;
case 3:
_colSel = 1;
break;
case 3: break;
case 4: break;
}
}
// press RIGHT
@ -133,10 +148,14 @@ CPrimingScreen::keyHandler(uint8_t event)
setThermostatMode(0);
break;
case 2:
_colSel = 1;
NVstore.setDegFMode(1);
break;
case 3:
if(!getHeaterInfo().getRunState())
_colSel = 2;
break;
case 3: break;
case 4: break;
}
}
// press UP
@ -145,9 +164,11 @@ CPrimingScreen::keyHandler(uint8_t event)
_reqOEMWarning();
else {
_rowSel++;
UPPERLIMIT(_rowSel, 2);
if(_rowSel == 2)
UPPERLIMIT(_rowSel, 3);
if(_rowSel == 3)
_colSel = 1; // select OFF upon entry to priming menu
if(_rowSel == 2)
_colSel = NVstore.getDegFMode();
if(_rowSel == 1)
_colSel = getHeaterInfo().isThermostat() ? 0 : 1;
}
@ -159,10 +180,12 @@ CPrimingScreen::keyHandler(uint8_t event)
_colSel = 0;
if(_rowSel == 1)
_colSel = getHeaterInfo().isThermostat() ? 0 : 1;
if(_rowSel == 2)
_colSel = NVstore.getDegFMode();
}
// check if fuel priming was selected
if(_rowSel == 2 && _colSel == 2) {
if(_rowSel == 3 && _colSel == 2) {
reqPumpPrime(true);
_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

View file

@ -9,7 +9,7 @@
// Dot Factory Settings
//
// Flip/Rotate Padding Removal Line Wrap Descriptors
// [X] Flip X Height(Y): None (O) At column [X] Generate descriptor array
// [X] Flip X Height(Y): Tightest (O) At column [X] Generate descriptor array
// [ ] Flip Y Width(X): Tightest ( ) At bitmap Char Width: In Bits
// 90deg Char Height: In Bits
// Font Height: In Bits
@ -216,6 +216,18 @@ const uint8_t tahoma_16ptBitmaps[] PROGMEM =
0x03, 0xC0, // ####
0x03, 0xC0, // ####
// @300 'F' (9 pixels wide)
0xFF, 0xFF, // ################
0xFF, 0xFF, // ################
0xFF, 0xFF, // ################
0xFF, 0xFF, // ################
0xE3, 0x80, // ### ###
0xE3, 0x80, // ### ###
0xE3, 0x80, // ### ###
0xE3, 0x80, // ### ###
0xE3, 0x80, // ### ###
0xE3, 0x80, // ### ###
};
// Character descriptors for Tahoma 16pt
@ -260,7 +272,7 @@ const FONT_CHAR_INFO tahoma_16ptDescriptors[] PROGMEM =
{12, 16, 244}, // 'C'
{0, 0, 0}, // 'D'
{0, 0, 0}, // 'E'
{0, 0, 0}, // 'F'
{10, 16, 300}, // 'F'
{0, 0, 0}, // 'G'
{0, 0, 0}, // 'H'
{0, 0, 0}, // 'I'

View file

@ -203,6 +203,19 @@ CHeaterStorage::setDimTime(unsigned long val)
_calValues.DimTime = val;
}
unsigned char
CHeaterStorage::getDegFMode()
{
return _calValues.degF;
}
void
CHeaterStorage::setDegFMode(unsigned char val)
{
_calValues.degF = val;
save();
}
///////////////////////////////////////////////////////////////////////////////////////
// ESP32
//
@ -289,7 +302,7 @@ CESP32HeaterStorage::loadTimer(int idx)
validatedLoad("stopHour", timer.stop.hour, 0, s8inBounds, 0, 23);
validatedLoad("stopMin", timer.stop.min, 0, s8inBounds, 0, 59);
validatedLoad("enabled", timer.enabled, 0, u8inBounds, 0, 255); // all 8 bits used!
validatedLoad("repeat", timer.repeat, 0, u8inBounds, 0, 1);
validatedLoad("repea*t", timer.repeat, 0, u8inBounds, 0, 1);
preferences.end();
}
@ -314,6 +327,7 @@ CESP32HeaterStorage::loadUI()
{
preferences.begin("user", false);
validatedLoad("dimTime", _calValues.DimTime, 60000, s32inBounds, 0, 600000);
validatedLoad("degF", _calValues.degF, 0, u8inBounds, 0, 1);
preferences.end();
}
@ -321,7 +335,8 @@ void
CESP32HeaterStorage::saveUI()
{
preferences.begin("user", false);
preferences.putUChar("dimTime", _calValues.DimTime);
preferences.putULong("dimTime", _calValues.DimTime);
preferences.putUChar("degF", _calValues.degF);
preferences.end();
}

View file

@ -110,6 +110,7 @@ struct sTimer {
struct sNVStore {
sHeater Heater;
long DimTime;
uint8_t degF;
sTimer timer[2];
bool valid();
void init();
@ -150,6 +151,7 @@ public:
unsigned char getFanSensor();
unsigned char getGlowDrive();
unsigned long getDimTime();
unsigned char getDegFMode();
void setPmin(float);
void setPmax(float);
@ -161,6 +163,7 @@ public:
void setFanSensor(unsigned char val);
void setGlowDrive(unsigned char val);
void setDimTime(unsigned long val);
void setDegFMode(unsigned char val);
void getTimerInfo(int idx, sTimer& timerInfo);
void setTimerInfo(int idx, const sTimer& timerInfo);