From 220657956fc75b4e265ed56f36cf4825174df94a Mon Sep 17 00:00:00 2001 From: rljonesau Date: Tue, 12 Mar 2019 18:09:50 +1100 Subject: [PATCH] Omitted InheritSettingsScreen.cpp/.h --- .../src/OLED/InheritSettingsScreen.cpp | 129 ++++++++++++++++++ .../src/OLED/InheritSettingsScreen.h | 41 ++++++ README.md | 7 +- 3 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 Arduino/BTCDieselHeater/src/OLED/InheritSettingsScreen.cpp create mode 100644 Arduino/BTCDieselHeater/src/OLED/InheritSettingsScreen.h diff --git a/Arduino/BTCDieselHeater/src/OLED/InheritSettingsScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/InheritSettingsScreen.cpp new file mode 100644 index 0000000..94ba93d --- /dev/null +++ b/Arduino/BTCDieselHeater/src/OLED/InheritSettingsScreen.cpp @@ -0,0 +1,129 @@ +/* + * This file is part of the "bluetoothheater" distribution + * (https://gitlab.com/mrjones.id.au/bluetoothheater) + * + * Copyright (C) 2018 Ray Jones + * + * 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 . + * + */ + + +/////////////////////////////////////////////////////////////////////////// +// +// CSettingsScreen +// +// This screen allows the fuel mixture endpoints to be adjusted +// +/////////////////////////////////////////////////////////////////////////// + +#include "InheritSettingsScreen.h" +#include "KeyPad.h" +#include "../Protocol/helpers.h" +// #include "../Wifi/BTCWifi.h" + + +CInheritSettingsScreen::CInheritSettingsScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr) +{ + _initUI(); +} + +void +CInheritSettingsScreen::onSelect() +{ + // ensure standard entry to screen - especially after a dimming timeout + CPasswordScreen::onSelect(); + _nAdoptSettings = hasOEMLCDcontroller() ? 1 : 2; +} + +void +CInheritSettingsScreen::_initUI() +{ + // ensure standard entry to screen - especially after a dimming timeout + _nAdoptSettings = 0; +} + +bool +CInheritSettingsScreen::show() +{ + CScreenHeader::show(); + + _display.writeFillRect(0, 16, 96, 12, WHITE); + _printInverted(3, 18, "Inherit Settings", true); + + if(!CPasswordScreen::show()) { + + switch(_nAdoptSettings) { + case 0: + _ScreenManager.selectInheritScreen(false); // force return to main menu + _ScreenManager.reqUpdate(); + return false; + case 1: + _display.clearDisplay(); + _display.writeFillRect(0, 0, 128, 24, WHITE); + _printInverted(_display.xCentre(), 4, "ADOPT LCD controller", true, eCentreJustify); + _printInverted(_display.xCentre(), 13, "settings? ", true, eCentreJustify); + _printMenuText(_display.xCentre(), 35, "Press RIGHT to", false, eCentreJustify); + _printMenuText(_display.xCentre(), 45, "inherit and save", false, eCentreJustify); + break; + case 2: + _display.clearDisplay(); + _display.writeFillRect(0, 0, 128, 24, WHITE); + _printInverted(_display.xCentre(), 4, " CANNOT inherit knob ", true, eCentreJustify); + _printInverted(_display.xCentre(), 13, " controller settings ", true, eCentreJustify); + _printMenuText(_display.xCentre(), 35, "Press any key", false, eCentreJustify); + _printMenuText(_display.xCentre(), 45, "to abort", false, eCentreJustify); + break; + } + + } + + return true; +} + + +bool +CInheritSettingsScreen::keyHandler(uint8_t event) +{ + if(CPasswordScreen::keyHandler(event)) { + if(_isPasswordOK()) { + setPumpMin(getHeaterInfo().getPump_Min()); + setPumpMax(getHeaterInfo().getPump_Max()); + setFanMin(getHeaterInfo().getFan_Min()); + setFanMax(getHeaterInfo().getFan_Max()); + setFanSensor(getHeaterInfo().getFan_Sensor()); + setSystemVoltage(getHeaterInfo().getSystemVoltage()); + saveNV(); + _showStoringMessage(); + _nAdoptSettings = 0; // will cause return to main menu after storing message expires + } + } + + else { + if(event & keyPressed) { + // press RIGHT + if(event & key_Right) { + if(hasOEMLCDcontroller()) { // inheritance only valid for LCD controllers + _getPassword(); + _ScreenManager.reqUpdate(); + return true; + } + } + _nAdoptSettings = 0; // will cause return to main menu + } + } + _ScreenManager.reqUpdate(); + return true; +} + diff --git a/Arduino/BTCDieselHeater/src/OLED/InheritSettingsScreen.h b/Arduino/BTCDieselHeater/src/OLED/InheritSettingsScreen.h new file mode 100644 index 0000000..795223f --- /dev/null +++ b/Arduino/BTCDieselHeater/src/OLED/InheritSettingsScreen.h @@ -0,0 +1,41 @@ +/* + * This file is part of the "bluetoothheater" distribution + * (https://gitlab.com/mrjones.id.au/bluetoothheater) + * + * Copyright (C) 2018 Ray Jones + * + * 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 . + * + */ + +#ifndef __INHERITSETTINGSSCREEN_H__ +#define __INHERITSETTINGSSCREEN_H__ + +#include +#include "PasswordScreen.h" + +class C128x64_OLED; +class CScreenManager; + +class CInheritSettingsScreen : public CPasswordScreen { + int _nAdoptSettings; + void _initUI(); +public: + CInheritSettingsScreen(C128x64_OLED& display, CScreenManager& mgr); + bool show(); + bool keyHandler(uint8_t event); + void onSelect(); +}; + +#endif \ No newline at end of file diff --git a/README.md b/README.md index d367019..0ec3b71 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,11 @@ Working so far: * WiFi Connection to existing network or Standalone Access Point Mode (Passwd: thereisnospoon) * Wifi control * DebugPort data sent via Telnet if/when available on the network. -* Two timers - including selectable day and repeat functionality +* 14 timers - including selectable day and repeat functionality + Simplisticly this allows each day to have 2 individual start stop regimes, but + a single timer can be set to repeat every day if desired, or on certain days. + Timers can also be set to be one-shot. + This is an extremely flexible system! * Battery backed Real Time Clock - DS3231 * Prototype "Green PCB" in production, using naked ESP32 and HC-05 modules * Temperature readout in Celcius or Farenheit @@ -44,7 +48,6 @@ To be implemented * Implement narrow hysteresis to trick heater into a tighter thermostat temperature range. eg tell heater it is 23 degrees when it really is only 22.25 degrees (only 0.25 above set point). * MQTT pub/sub * "fuel gauge" - Integrate pump frequency, assuming a repeatable dose of fuel per pump cycle... -* Proper 7 day timer with each day settable for at least 2 times (eg morning/evening) * Expand hardware compatability with different MCU setups. IE Arduino Due/Mega/Pro ESP8266 & ESP32 * Documentation * Regular Hot Burn cycle (DPF mode!)