Added Hour Meters screen

This commit is contained in:
Ray Jones 2019-07-26 23:12:00 +10:00
parent d2116fc18c
commit ca0e763da6
5 changed files with 155 additions and 5 deletions

View File

@ -44,7 +44,7 @@ Working so far:
* Two new experimental thermostat modes (No practical testing - presently too hot in .au!): * Two new experimental thermostat modes (No practical testing - presently too hot in .au!):
Tighten or loosen the thermostat temperature range by specifying a hysteresis value. eg tell the heater it is 23 degrees when it really is only 22.25 degrees (only 0.25 above set point). Tighten or loosen the thermostat temperature range by specifying a hysteresis value. eg tell the heater it is 23 degrees when it really is only 22.25 degrees (only 0.25 above set point).
Request a linear change in Hz according to the deviation from the setpoint Request a linear change in Hz according to the deviation from the setpoint
* 2 external digital inputs, 2 digital outputs, analogue input * 2 external digital inputs, 2 digital outputs, analogue input .This would allow external timer units for example, or analogue temperature demand (which is still only 1 degree resolution with standard heater thermostat).
* New Mk2 "Red PCB" that properly fits into an off the shelf case (requires machining) * New Mk2 "Red PCB" that properly fits into an off the shelf case (requires machining)
* Software updates over WiFi: * Software updates over WiFi:
Native OTA via espota.exe or espota.py (AP or STA mode) Native OTA via espota.exe or espota.py (AP or STA mode)
@ -54,14 +54,14 @@ Working so far:
* "Fuel gauge" - Integrates pump frequency, assumes a repeatable dose of fuel per pump stroke. * "Fuel gauge" - Integrates pump frequency, assumes a repeatable dose of fuel per pump stroke.
* Low voltage cut out, definable threshold - auto adjusts for cable voltage drop during start * Low voltage cut out, definable threshold - auto adjusts for cable voltage drop during start
* Temperature probe offset to correct adverse readings. * Temperature probe offset to correct adverse readings.
* Hour meter - run time, glow time
To be implemented To be implemented
-------------------------- --------------------------
* 433MHz Rx stream, 433MHz Tx stream connections. This would allow external timer units for example, or analogue temperature demand (which is still only 1 degree resolution with standard heater thermostat). * 433MHz Rx stream, 433MHz Tx stream connections.
* MQTT pub/sub * MQTT pub/sub
* Regular Hot Burn cycle (DPF mode!) * Regular Hot Burn cycle (DPF mode!)
* Hour meter - run time, glow time
* list under construction..... * list under construction.....
Suggestions Suggestions

View File

@ -0,0 +1,108 @@
/*
* 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 "HourMeterScreen.h"
#include "KeyPad.h"
#include "../Utility/helpers.h"
#include "../Utility/HourMeter.h"
CHourMeterScreen::CHourMeterScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreen(display, mgr)
{
}
void makeHourMeter(char* hrs, char* str, unsigned long seconds)
{
unsigned long minutes = seconds / 60;
unsigned long hours = minutes / 60;
unsigned long days = hours / 24;
unsigned long printMins = minutes - (hours * 60);
sprintf(hrs, "%02ld:", hours);
if(hours > 48)
sprintf(str, "%02ld (%ldd)", printMins, days);
else
sprintf(str, "%02ld", printMins);
}
bool
CHourMeterScreen::show()
{
char msg[32];
char hrs[16];
int colon = 75;
_display.clearDisplay();
// standard version information screens,
// animation of update available via animate() if firmware update is available on web server
_printInverted(_display.xCentre(), 0, " Hour Meters ", true, eCentreJustify);
makeHourMeter(hrs, msg, pHourMeter->getRunTime());
_printMenuText(38, 14, "Run", false, eRightJustify);
_printMenuText(colon, 14, hrs, false, eRightJustify);
_printMenuText(colon, 14, msg);
makeHourMeter(hrs, msg, pHourMeter->getGlowTime());
_printMenuText(38, 26, "Glow", false, eRightJustify);
_printMenuText(colon, 26, hrs, false, eRightJustify);
_printMenuText(colon, 26, msg);
makeHourMeter(hrs, msg, sysUptime());
_printMenuText(38, 38, "UpTime", false, eRightJustify);
_printMenuText(colon, 38, hrs, false, eRightJustify);
_printMenuText(colon, 38, msg);
_printMenuText(_display.xCentre(), 53, " \021 Exit \020 ", true, eCentreJustify); // " < Exit > "
return true;
}
bool
CHourMeterScreen::keyHandler(uint8_t event)
{
if(event & keyPressed) {
// UP press
if(event & key_Up) {
}
// DOWN press
if(event & key_Down) {
}
// LEFT press
if(event & key_Left) {
_ScreenManager.prevMenu();
}
// RIGHT press
if(event & key_Right) {
_ScreenManager.nextMenu();
}
// CENTRE press
if(event & key_Centre) {
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // force return to main menu
}
}
_ScreenManager.reqUpdate();
return true;
}

View File

@ -0,0 +1,40 @@
/*
* 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/>.
*
*/
#ifndef __HOURMETERSCREEN_H__
#define __HOURMETERSCREEN_H__
#include <stdint.h>
#include "Screen.h"
class C128x64_OLED;
class CScreenManager;
class CHourMeterScreen : public CScreen
{
public:
CHourMeterScreen(C128x64_OLED& display, CScreenManager& mgr);
bool show();
bool keyHandler(uint8_t event);
};
#endif

View File

@ -40,6 +40,7 @@
#include "VersionInfoScreen.h" #include "VersionInfoScreen.h"
#include "HomeMenuSelScreen.h" #include "HomeMenuSelScreen.h"
#include "OtherOptionsScreen.h" #include "OtherOptionsScreen.h"
#include "HourMeterScreen.h"
#include <Wire.h> #include <Wire.h>
#include "../cfg/pins.h" #include "../cfg/pins.h"
#include "../cfg/BTCConfig.h" #include "../cfg/BTCConfig.h"
@ -299,8 +300,9 @@ CScreenManager::begin(bool bNoClock)
// create User Settings screens loop // create User Settings screens loop
menuloop.clear(); menuloop.clear();
menuloop.push_back(new CGPIOScreen(*_pDisplay, *this)); // GPIO settings screen menuloop.push_back(new CGPIOScreen(*_pDisplay, *this)); // GPIO settings screen
menuloop.push_back(new CThermostatModeScreen(*_pDisplay, *this)); // experimental settings screen menuloop.push_back(new CThermostatModeScreen(*_pDisplay, *this)); // thermostat settings screen
menuloop.push_back(new CVersionInfoScreen(*_pDisplay, *this)); // GPIO settings screen menuloop.push_back(new CVersionInfoScreen(*_pDisplay, *this)); // GPIO settings screen
menuloop.push_back(new CHourMeterScreen(*_pDisplay, *this)); // Hour Meter screen
menuloop.push_back(new CHomeMenuSelScreen(*_pDisplay, *this)); // Home menu settings screen menuloop.push_back(new CHomeMenuSelScreen(*_pDisplay, *this)); // Home menu settings screen
menuloop.push_back(new COtherOptionsScreen(*_pDisplay, *this)); // Other options screen menuloop.push_back(new COtherOptionsScreen(*_pDisplay, *this)); // Other options screen
_Screens.push_back(menuloop); _Screens.push_back(menuloop);

View File

@ -476,7 +476,7 @@ bool makeJSONStringSysInfo(CModerator& moderator, char* opStr, int len)
sprintf(str, "%d/%d/%d %02d:%02d:%02d", now.day(), now.month(), now.year(), now.hour(), now.minute(), now.second()); sprintf(str, "%d/%d/%d %02d:%02d:%02d", now.day(), now.month(), now.year(), now.hour(), now.minute(), now.second());
bSend |= moderator.addJson("DateTime", str, root); bSend |= moderator.addJson("DateTime", str, root);
if(bTriggerSysParams) { if(bTriggerSysParams) {
bSend |= moderator.addJson("UpTime", sysUptime(), root); bSend |= moderator.addJson("SysUpTime", sysUptime(), root);
bSend |= moderator.addJson("SysVer", getVersionStr(), root); bSend |= moderator.addJson("SysVer", getVersionStr(), root);
bSend |= moderator.addJson("SysDate", getVersionDate(), root); bSend |= moderator.addJson("SysDate", getVersionDate(), root);
bSend |= moderator.addJson("SysFreeMem", ESP.getFreeHeap(), root); bSend |= moderator.addJson("SysFreeMem", ESP.getFreeHeap(), root);