From c1b1036ece4dca5c00827f712575879df284241b Mon Sep 17 00:00:00 2001 From: rljonesau Date: Fri, 19 Apr 2019 21:38:39 +1000 Subject: [PATCH] New features: Version information screen Adjustable frame rate User selectable default menu Extra large fonts for clock and basic menu --- Arduino/BTCDieselHeater/BTCDieselHeater.ino | 23 +- .../BTCDieselHeater/src/OLED/BasicScreen.cpp | 5 +- .../BTCDieselHeater/src/OLED/ClockScreen.cpp | 4 +- .../BTCDieselHeater/src/OLED/GPIOScreen.cpp | 2 +- .../src/OLED/OtherOptionsScreen.cpp | 156 +++++++ .../src/OLED/OtherOptionsScreen.h | 46 ++ .../src/OLED/ScreenManager.cpp | 15 +- .../src/OLED/VersionInfoScreen.cpp | 100 +++++ .../src/OLED/VersionInfoScreen.h | 42 ++ .../BTCDieselHeater/src/OLED/fonts/Tahoma24.c | 399 ++++++++++++++++++ .../BTCDieselHeater/src/OLED/fonts/Tahoma24.h | 7 + .../BTCDieselHeater/src/Protocol/helpers.h | 25 +- .../BTCDieselHeater/src/RTC/TimerManager.cpp | 3 +- .../BTCDieselHeater/src/Utility/NVStorage.cpp | 28 ++ .../BTCDieselHeater/src/Utility/NVStorage.h | 10 + 15 files changed, 845 insertions(+), 20 deletions(-) create mode 100644 Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.cpp create mode 100644 Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.h create mode 100644 Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.cpp create mode 100644 Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.h create mode 100644 Arduino/BTCDieselHeater/src/OLED/fonts/Tahoma24.c create mode 100644 Arduino/BTCDieselHeater/src/OLED/fonts/Tahoma24.h diff --git a/Arduino/BTCDieselHeater/BTCDieselHeater.ino b/Arduino/BTCDieselHeater/BTCDieselHeater.ino index b2b49b0..f21e9fa 100644 --- a/Arduino/BTCDieselHeater/BTCDieselHeater.ino +++ b/Arduino/BTCDieselHeater/BTCDieselHeater.ino @@ -115,6 +115,9 @@ #define RX_DATA_TIMOUT 50 +const int FirmwareRevision = 21; +const char* FirmwareDate = "19 Apr 2019"; + #ifdef ESP32 #include "src/Bluetooth/BluetoothESP32.h" @@ -485,7 +488,7 @@ void loop() unsigned long RxTimeElapsed = timenow - lastRxTime; if (BlueWireSerial.available()) { - // Data is avaialable, read and store it now, use it later + // Data is available, read and store it now, use it later // Note that if not in a recognised data receive frame state, the data // will be deliberately lost! BlueWireData.setValue(BlueWireSerial.read()); // read hex byte, store for later use @@ -548,7 +551,8 @@ void loop() // Detect the possible start of a new frame sequence from an OEM controller // This will be the first activity for considerable period on the blue wire // The heater always responds to a controller frame, but otherwise never by itself - if(RxTimeElapsed >= 970) { +// if(RxTimeElapsed >= 970) { + if(RxTimeElapsed >= NVstore.getFrameRate()) { // have not seen any receive data for a second. // OEM controller is probably not connected. // Skip state machine immediately to BTC_Tx, sending our own settings. @@ -1291,3 +1295,18 @@ bool getGPIO(int channel) DebugPort.print("getGPIO: Output #"); DebugPort.print(channel+1); DebugPort.print(" = "); DebugPort.println(retval); return retval; } + +float getVersion() +{ + return float(FirmwareRevision) * 0.1f; +} + +const char* getVersionDate() +{ + return FirmwareDate; +} + +int getBoardRevision() +{ + return BoardRevision; +} \ No newline at end of file diff --git a/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp index 88dd183..ffa0434 100644 --- a/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp @@ -21,6 +21,7 @@ #include "128x64OLED.h" #include "fonts/tahoma16.h" +#include "fonts/tahoma24.h" #include "fonts/Icons.h" #include "BasicScreen.h" #include "KeyPad.h" @@ -29,7 +30,8 @@ #include "../Utility/NVStorage.h" -#define MAXIFONT tahoma_16ptFontInfo +#define MAXIFONT tahoma_24ptFontInfo +//#define MAXIFONT tahoma_16ptFontInfo /////////////////////////////////////////////////////////////////////////// // @@ -67,6 +69,7 @@ CBasicScreen::show() { CTransientFont AF(_display, &MAXIFONT); // temporarily use a large font +// _printMenuText(_display.xCentre(), 23, msg, false, eCentreJustify); _printMenuText(_display.xCentre(), 25, msg, false, eCentreJustify); } } diff --git a/Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp index 68d79f1..cf8e49a 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp @@ -23,6 +23,7 @@ #include "KeyPad.h" #include "../Protocol/helpers.h" #include "fonts/Tahoma16.h" +#include "fonts/Tahoma24.h" #include "../RTC/Clock.h" /////////////////////////////////////////////////////////////////////////// @@ -64,7 +65,8 @@ CClockScreen::show() int yPos = 25; { - CTransientFont AF(_display, &tahoma_16ptFontInfo); // temporarily use a large font +// CTransientFont AF(_display, &tahoma_16ptFontInfo); // temporarily use a large font + CTransientFont AF(_display, &tahoma_24ptFontInfo); // temporarily use a large font _printMenuText(_display.xCentre(), yPos, str, false, eCentreJustify); } sprintf(str, "%s %d %s %d", now.dowStr(), now.day(), now.monthStr(), now.year()); diff --git a/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.cpp index 2351f70..c94bfed 100644 --- a/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.cpp @@ -343,7 +343,7 @@ CGPIOInfoScreen::show() sprintf(msg, "%d", GPIOalg.getValue()); _printMenuText(58, Line1, msg); - _printMenuText(_display.xCentre(), 53, " \021 \030Edit \020 ", true, eCentreJustify); + _printMenuText(_display.xCentre(), 53, " \021 \020 ", true, eCentreJustify); return true; } diff --git a/Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.cpp new file mode 100644 index 0000000..b0d7830 --- /dev/null +++ b/Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.cpp @@ -0,0 +1,156 @@ +/* + * 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 . + * + */ + +#include "128x64OLED.h" +#include "OtherOptionsScreen.h" +#include "KeyPad.h" +#include "../Protocol/helpers.h" +#include "../Utility/UtilClasses.h" +#include "../Utility/NVStorage.h" +#include "../Utility/GPIO.h" +#include "fonts/Icons.h" + + + +COtherOptionsScreen::COtherOptionsScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr) +{ +} + +void +COtherOptionsScreen::onSelect() +{ + CScreenHeader::onSelect(); + _rowSel = 0; + _frameRate = NVstore.getFrameRate(); + _homeMenu = NVstore.getHomeMenu(); +} + +void +COtherOptionsScreen::_initUI() +{ +} + +bool +COtherOptionsScreen::show() +{ + char msg[16]; + + _display.clearDisplay(); + + if(!CPasswordScreen::show()) { // for showing "saving settings" + + if(_rowSel == 4) { + _printInverted(_display.xCentre(), 0, " Saving Settings ", true, eCentreJustify); + _printMenuText(_display.xCentre(), 35, "Press UP to", false, eCentreJustify); + _printMenuText(_display.xCentre(), 43, "confirm save", false, eCentreJustify); + } + else { + _printInverted(_display.xCentre(), 0, " Other Options ", true, eCentreJustify); + + _printMenuText(66, 14, "Frame Rate:", false, eRightJustify); + sprintf(msg, "%dms", _frameRate); + _printMenuText(70, 14, msg, _rowSel == 2); + + _printMenuText(66, 25, "Home menu:", false, eRightJustify); + switch(_homeMenu) { + 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(70, 25, msg, _rowSel == 1); + + _printMenuText(_display.xCentre(), 53, " \021 Exit \020 ", _rowSel == 0, eCentreJustify); + } + } + return true; +} + + +bool +COtherOptionsScreen::keyHandler(uint8_t event) +{ + if(event & keyPressed) { + // UP press + if(event & key_Up) { + if(_rowSel == 4) { + _showStoringMessage(); + NVstore.setFrameRate(_frameRate); + NVstore.setHomeMenu(_homeMenu); + saveNV(); + _rowSel = 0; + } + else { + _rowSel++; + UPPERLIMIT(_rowSel, 2); + } + } + // UP press + if(event & key_Down) { + _rowSel--; + LOWERLIMIT(_rowSel, 0); + } + // CENTRE press + if(event & key_Centre) { + if(_rowSel == 0) { + _ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // force return to main menu + } + else { + _rowSel = 4; + } + } + // 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 +COtherOptionsScreen::adjust(int dir) +{ + switch(_rowSel) { + case 1: + _homeMenu += dir; + ROLLLOWERLIMIT(_homeMenu, 0, 3); + ROLLUPPERLIMIT(_homeMenu, 3, 0); + break; + case 2: + _frameRate += dir * 50; + LOWERLIMIT(_frameRate, 300); + UPPERLIMIT(_frameRate, 1500); + break; + } +} \ No newline at end of file diff --git a/Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.h b/Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.h new file mode 100644 index 0000000..ce5e7ad --- /dev/null +++ b/Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.h @@ -0,0 +1,46 @@ +/* + * 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 __OTHEROPTIONSCREEN_H__ +#define __OTHEROPTIONSCREEN_H__ + +#include +#include "PasswordScreen.h" + +class C128x64_OLED; +class CScreenManager; + + +class COtherOptionsScreen : public CPasswordScreen +{ + int _rowSel; + uint16_t _frameRate; + uint8_t _homeMenu; + void _initUI(); +public: + COtherOptionsScreen(C128x64_OLED& display, CScreenManager& mgr); + bool show(); + bool keyHandler(uint8_t event); + void onSelect(); + void adjust(int dir); +}; + +#endif diff --git a/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp b/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp index fc4fe50..104aff8 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp @@ -36,6 +36,8 @@ #include "TimerChartScreen.h" #include "InheritSettingsScreen.h" #include "GPIOScreen.h" +#include "VersionInfoScreen.h" +#include "OtherOptionsScreen.h" #include #include "../cfg/pins.h" #include "../cfg/BTCConfig.h" @@ -183,6 +185,7 @@ CScreenManager::begin(bool bNoClock) menuloop.push_back(new CGPIOInfoScreen(*_pDisplay, *this)); // GPIO info menuloop.push_back(new CSettingsScreen(*_pDisplay, *this)); // Tuning info _Screens.push_back(menuloop); + // create timer screens loop menuloop.clear(); menuloop.push_back(new CTimerChartScreen(*_pDisplay, *this, 0)); // timer chart @@ -201,16 +204,21 @@ CScreenManager::begin(bool bNoClock) menuloop.push_back(new CSetTimerScreen(*_pDisplay, *this, 12)); // set timer 13 menuloop.push_back(new CSetTimerScreen(*_pDisplay, *this, 13)); // set timer 14 _Screens.push_back(menuloop); + // create heater tuning screens loop - password protected menuloop.clear(); menuloop.push_back(new CFuelMixtureScreen(*_pDisplay, *this)); // tuning menuloop.push_back(new CHeaterSettingsScreen(*_pDisplay, *this)); // tuning _Screens.push_back(menuloop); + // create User Settings screens loop menuloop.clear(); menuloop.push_back(new CThermostatModeScreen(*_pDisplay, *this)); // experimental settings screen menuloop.push_back(new CGPIOScreen(*_pDisplay, *this)); // GPIO settings screen + menuloop.push_back(new CVersionInfoScreen(*_pDisplay, *this)); // GPIO settings screen + menuloop.push_back(new COtherOptionsScreen(*_pDisplay, *this)); // Other options screen _Screens.push_back(menuloop); + // create branch screens menuloop.clear(); menuloop.push_back(new CSetClockScreen(*_pDisplay, *this)); // clock set branch screen @@ -250,8 +258,11 @@ CScreenManager::checkUpdate() // Clock // return to those upon timeout, otherwise return to Basic Control screen if(_rootMenu > 2) { - _subMenu = 1; - _rootMenu = 1; + _rootMenu = _subMenu = 1; + if(NVstore.getHomeMenu()) { // allow user to override defualt screen + DebugPort.print("Falling back to user home screen #"); DebugPort.println(NVstore.getHomeMenu()-1); + _rootMenu = _subMenu = NVstore.getHomeMenu()-1; + } } _enterScreen(); } diff --git a/Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.cpp new file mode 100644 index 0000000..5a49d0d --- /dev/null +++ b/Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.cpp @@ -0,0 +1,100 @@ +/* + * 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 . + * + */ + +#include "128x64OLED.h" +#include "VersionInfoScreen.h" +#include "KeyPad.h" +#include "../Protocol/helpers.h" +#include "../Utility/UtilClasses.h" +#include "../Utility/NVStorage.h" +#include "../Utility/GPIO.h" +#include "fonts/Icons.h" + + + +CVersionInfoScreen::CVersionInfoScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreenHeader(display, mgr) +{ +} + +void +CVersionInfoScreen::onSelect() +{ + CScreenHeader::onSelect(); +} + +void +CVersionInfoScreen::_initUI() +{ +} + +bool +CVersionInfoScreen::show() +{ + char msg[16]; + + _display.clearDisplay(); + + _printInverted(_display.xCentre(), 0, " Version Information ", true, eCentreJustify); + + _printMenuText(0, 14, "Firmware:"); + sprintf(msg, "V%.1f", getVersion()); + _printMenuText(55, 14, msg); + _printMenuText(55, 25, getVersionDate()); + + _printMenuText(0, 38, "Hardware:"); + int PCB = getBoardRevision(); + sprintf(msg, "V%.1f", float(PCB)*0.1f); + _printMenuText(55, 38, msg); + if(PCB == 20) { + _printMenuText(108, 38, "Analog", false, eCentreJustify); + _display.drawLine(88, 42, 127, 42, WHITE); + } + + _printMenuText(_display.xCentre(), 53, " \021 \020 ", true, eCentreJustify); + return true; +} + + +bool +CVersionInfoScreen::keyHandler(uint8_t event) +{ + if(event & keyPressed) { + // UP press + if(event & key_Up) { + } + // CENTRE press + if(event & key_Centre) { + } + // LEFT press + if(event & key_Left) { + _ScreenManager.prevMenu(); + } + // RIGHT press + if(event & key_Right) { + _ScreenManager.nextMenu(); + } + } + + _ScreenManager.reqUpdate(); + + return true; +} + diff --git a/Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.h b/Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.h new file mode 100644 index 0000000..2d188c6 --- /dev/null +++ b/Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.h @@ -0,0 +1,42 @@ +/* + * 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 __VERSIONINFOSCREEN_H__ +#define __VERSIONINFOSCREEN_H__ + +#include +#include "PasswordScreen.h" + +class C128x64_OLED; +class CScreenManager; + + +class CVersionInfoScreen : public CScreenHeader +{ + void _initUI(); +public: + CVersionInfoScreen(C128x64_OLED& display, CScreenManager& mgr); + bool show(); + bool keyHandler(uint8_t event); + void onSelect(); +}; + +#endif diff --git a/Arduino/BTCDieselHeater/src/OLED/fonts/Tahoma24.c b/Arduino/BTCDieselHeater/src/OLED/fonts/Tahoma24.c new file mode 100644 index 0000000..ab0eb07 --- /dev/null +++ b/Arduino/BTCDieselHeater/src/OLED/fonts/Tahoma24.c @@ -0,0 +1,399 @@ +// +// Font data for Tahoma 24pt +// +// Generated by The Dot Factory: +// http://www.eran.io/the-dot-factory-an-lcd-font-and-image-generator/ +// +///////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Dot Factory Settings +// +// Flip/Rotate Padding Removal Line Wrap Descriptors +// [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 +// Comments Byte [ ] Multiple descriptor arrays +// [X] Variable Name Bit layout: RowMajor +// [X] BMP visualise [#] Order: MSBfirst Create new when exceeds [80] +// [X] Char descriptor Format: Hex +// Style: Cpp Leading: 0x Image width: In Bits +// Image height: In Bits +// Variable name format +// Bitmaps: const uint8_t PROGMEM {0}Bitmaps Space char generation +// Char Info: const FONT_CHAR_INFO PROGMEM {0}Descriptors [ ] Generate space bitmap +// Font Info: const FONT_INFO {0}FontInfo [2] pixels for space char +// Width: const uint8_t {0}Width +// Height: const uint8_t {0}Height +// +///////////////////////////////////////////////////////////////////////////////////////////////////// + + +#include "tahoma24.h" + +// Character bitmaps for Tahoma 24pt +const uint8_t tahoma_24ptBitmaps [] PROGMEM = +{ + // @0 ' ' (2 pixels wide) + 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, // + + // @10 '.' (6 pixels wide) + 0xFC, // ###### + 0xFC, // ###### + 0xFC, // ###### + 0xFC, // ###### + 0xFC, // ###### + 0xFC, // ###### + + // @16 '0' (18 pixels wide) + 0x03, 0xFF, 0x80, // ########### + 0x0F, 0xFF, 0xE0, // ############### + 0x3F, 0xFF, 0xF8, // ################### + 0x7F, 0xFF, 0xFC, // ##################### + 0x7F, 0xFF, 0xFC, // ##################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFC, 0x00, 0x7E, // ###### ###### + 0xF8, 0x00, 0x3E, // ##### ##### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x00, 0x1E, // #### #### + 0xF8, 0x00, 0x3E, // ##### ##### + 0xFC, 0x00, 0x7E, // ###### ###### + 0xFF, 0xFF, 0xFE, // ####################### + 0x7F, 0xFF, 0xFC, // ##################### + 0x7F, 0xFF, 0xFC, // ##################### + 0x3F, 0xFF, 0xF8, // ################### + 0x0F, 0xFF, 0xE0, // ############### + 0x03, 0xFF, 0x80, // ########### + + // @70 '1' (16 pixels wide) + 0x1E, 0x00, 0x1E, // #### #### + 0x1E, 0x00, 0x1E, // #### #### + 0x1E, 0x00, 0x1E, // #### #### + 0x1E, 0x00, 0x1E, // #### #### + 0x3E, 0x00, 0x1E, // ##### #### + 0x7F, 0xFF, 0xFE, // ###################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0x00, 0x00, 0x1E, // #### + 0x00, 0x00, 0x1E, // #### + 0x00, 0x00, 0x1E, // #### + 0x00, 0x00, 0x1E, // #### + 0x00, 0x00, 0x1E, // #### + + // @118 '2' (17 pixels wide) + 0x00, 0x00, 0x1E, // #### + 0x7E, 0x00, 0x3E, // ###### ##### + 0x7C, 0x00, 0x7E, // ##### ###### + 0x78, 0x00, 0x7E, // #### ###### + 0xF8, 0x00, 0xFE, // ##### ####### + 0xF0, 0x01, 0xFE, // #### ######## + 0xF0, 0x03, 0xFE, // #### ######### + 0xF0, 0x07, 0xFE, // #### ########## + 0xF0, 0x1F, 0xDE, // #### ####### #### + 0xF8, 0x3F, 0x9E, // ##### ####### #### + 0xFF, 0xFF, 0x1E, // ################ #### + 0xFF, 0xFE, 0x1E, // ############### #### + 0x7F, 0xFC, 0x1E, // ############# #### + 0x7F, 0xF8, 0x1E, // ############ #### + 0x3F, 0xF0, 0x1E, // ########## #### + 0x0F, 0xC0, 0x1E, // ###### #### + 0x00, 0x00, 0x1E, // #### + + // @169 '3' (17 pixels wide) + 0x00, 0x00, 0xFC, // ###### + 0x7C, 0x00, 0x7C, // ##### ##### + 0x78, 0x00, 0x3C, // #### #### + 0x78, 0x00, 0x3E, // #### ##### + 0xF0, 0x00, 0x1E, // #### #### + 0xF0, 0x78, 0x1E, // #### #### #### + 0xF0, 0x78, 0x1E, // #### #### #### + 0xF0, 0x78, 0x1E, // #### #### #### + 0xF0, 0x78, 0x1E, // #### #### #### + 0xF8, 0xF8, 0x3E, // ##### ##### ##### + 0xFF, 0xFC, 0x3E, // ############## ##### + 0xFF, 0xFF, 0xFE, // ####################### + 0x7F, 0xFF, 0xFC, // ##################### + 0x7F, 0xDF, 0xFC, // ######### ########### + 0x3F, 0x8F, 0xF8, // ####### ######### + 0x1F, 0x0F, 0xF0, // ##### ######## + 0x00, 0x03, 0xE0, // ##### + + // @220 '4' (18 pixels wide) + 0x00, 0x07, 0xC0, // ##### + 0x00, 0x1F, 0xC0, // ####### + 0x00, 0x3F, 0xC0, // ######## + 0x00, 0xFF, 0xC0, // ########## + 0x01, 0xFF, 0xC0, // ########### + 0x07, 0xF3, 0xC0, // ####### #### + 0x0F, 0xE3, 0xC0, // ####### #### + 0x3F, 0x83, 0xC0, // ####### #### + 0x7F, 0x03, 0xC0, // ####### #### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0xFF, 0xFF, 0xFE, // ####################### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + 0x00, 0x03, 0xC0, // #### + + // @274 '5' (17 pixels wide) + 0x00, 0x00, 0x7C, // ##### + 0xFF, 0xF8, 0x3C, // ############# #### + 0xFF, 0xF8, 0x3C, // ############# #### + 0xFF, 0xF0, 0x3E, // ############ ##### + 0xFF, 0xF0, 0x1E, // ############ #### + 0xFF, 0xF0, 0x1E, // ############ #### + 0xFF, 0xF0, 0x1E, // ############ #### + 0xF0, 0xF0, 0x1E, // #### #### #### + 0xF0, 0xF0, 0x1E, // #### #### #### + 0xF0, 0xF8, 0x3E, // #### ##### ##### + 0xF0, 0xFC, 0x7E, // #### ###### ###### + 0xF0, 0xFF, 0xFC, // #### ############## + 0xF0, 0xFF, 0xFC, // #### ############## + 0xF0, 0x7F, 0xFC, // #### ############# + 0xF0, 0x7F, 0xF8, // #### ############ + 0xF0, 0x3F, 0xF0, // #### ########## + 0x00, 0x0F, 0xC0, // ###### + + // @325 '6' (17 pixels wide) + 0x00, 0xFF, 0x80, // ######### + 0x07, 0xFF, 0xE0, // ############## + 0x0F, 0xFF, 0xF8, // ################# + 0x1F, 0xFF, 0xFC, // ################### + 0x3F, 0xFF, 0xFC, // #################### + 0x7F, 0xFF, 0xFE, // ###################### + 0x7F, 0x70, 0x7E, // ####### ### ###### + 0xFC, 0x70, 0x1E, // ###### ### #### + 0xF8, 0xF0, 0x1E, // ##### #### #### + 0xF0, 0xF0, 0x1E, // #### #### #### + 0xF0, 0xF8, 0x3E, // #### ##### ##### + 0xF0, 0xFF, 0xFE, // #### ############### + 0xF0, 0xFF, 0xFC, // #### ############## + 0xF0, 0x7F, 0xFC, // #### ############# + 0xF8, 0x7F, 0xF8, // ##### ############ + 0x00, 0x3F, 0xF0, // ########## + 0x00, 0x0F, 0xC0, // ###### + + // @376 '7' (17 pixels wide) + 0xF0, 0x00, 0x00, // #### + 0xF0, 0x00, 0x02, // #### # + 0xF0, 0x00, 0x0E, // #### ### + 0xF0, 0x00, 0x3E, // #### ##### + 0xF0, 0x00, 0xFE, // #### ####### + 0xF0, 0x03, 0xFE, // #### ######### + 0xF0, 0x0F, 0xFE, // #### ########### + 0xF0, 0x3F, 0xFE, // #### ############# + 0xF0, 0xFF, 0xF8, // #### ############# + 0xF3, 0xFF, 0xE0, // #### ############# + 0xFF, 0xFF, 0x80, // ################# + 0xFF, 0xFE, 0x00, // ############### + 0xFF, 0xF8, 0x00, // ############# + 0xFF, 0xE0, 0x00, // ########### + 0xFF, 0x80, 0x00, // ######### + 0xFE, 0x00, 0x00, // ####### + 0xF8, 0x00, 0x00, // ##### + + // @427 '8' (18 pixels wide) + 0x00, 0x03, 0xE0, // ##### + 0x0F, 0x07, 0xF8, // #### ######## + 0x3F, 0xCF, 0xF8, // ######## ######### + 0x7F, 0xEF, 0xFC, // ########## ########## + 0x7F, 0xFF, 0xFC, // ##################### + 0x7F, 0xFF, 0xFE, // ###################### + 0xFF, 0xFC, 0x3E, // ############## ##### + 0xF8, 0xF8, 0x1E, // ##### ##### #### + 0xF0, 0xF8, 0x1E, // #### ##### #### + 0xF0, 0x7C, 0x1E, // #### ##### #### + 0xF8, 0x7C, 0x1E, // ##### ##### #### + 0xFF, 0xFE, 0x3E, // ############### ##### + 0xFF, 0xFF, 0xFE, // ####################### + 0x7F, 0xFF, 0xFC, // ##################### + 0x7F, 0xDF, 0xFC, // ######### ########### + 0x3F, 0x8F, 0xF8, // ####### ######### + 0x1F, 0x0F, 0xF0, // ##### ######## + 0x00, 0x03, 0xE0, // ##### + + // @481 '9' (17 pixels wide) + 0x07, 0xE0, 0x00, // ###### + 0x1F, 0xF8, 0x00, // ########## + 0x3F, 0xFC, 0x3E, // ############ ##### + 0x7F, 0xFC, 0x1E, // ############# #### + 0x7F, 0xFE, 0x1E, // ############## #### + 0xFF, 0xFE, 0x1E, // ############### #### + 0xF8, 0x3E, 0x1E, // ##### ##### #### + 0xF0, 0x1E, 0x1E, // #### #### #### + 0xF0, 0x1E, 0x3E, // #### #### ##### + 0xF0, 0x1C, 0x7E, // #### ### ###### + 0xFC, 0x1D, 0xFC, // ###### ### ####### + 0xFF, 0xFF, 0xFC, // ###################### + 0x7F, 0xFF, 0xF8, // #################### + 0x7F, 0xFF, 0xF0, // ################### + 0x3F, 0xFF, 0xE0, // ################# + 0x0F, 0xFF, 0xC0, // ############## + 0x03, 0xFE, 0x00, // ######### + + // @532 ':' (5 pixels wide) + 0x07, 0x80, 0xf0, // #### #### + 0x0F, 0xc1, 0xf8, // ###### ###### + 0x0F, 0xc1, 0xf8, // ###### ###### + 0x0F, 0xc1, 0xf8, // ###### ###### + 0x07, 0x80, 0xf0, // #### #### + 0x00, 0x00, 0x00, // + + // @550 'C' (12 pixels wide) + 0x07, 0xE0, // ###### + 0x1F, 0xF8, // ########## + 0x3F, 0xFC, // ############ + 0x7F, 0xFE, // ############## + 0xF8, 0x1F, // ##### ##### + 0xF0, 0x0F, // #### #### + 0xE0, 0x07, // ### ### + 0xE0, 0x07, // ### ### + 0xE0, 0x07, // ### ### + 0xE0, 0x07, // ### ### + 0x70, 0x0E, // ### ### + 0x78, 0x1E, // #### #### + + // @574 'F' (9 pixels wide) + 0xFF, 0xFF, // ################ + 0xFF, 0xFF, // ################ + 0xFF, 0xFF, // ################ + 0xFF, 0xFF, // ################ + 0xE3, 0x80, // ### ### + 0xE3, 0x80, // ### ### + 0xE3, 0x80, // ### ### + 0xE3, 0x80, // ### ### + 0xE3, 0x80, // ### ### + 0xE3, 0x80, // ### ### + + // @594 '`' (8 pixels wide) + 0x3C, 0x00, // #### + 0x7E, 0x00, // ###### + 0xE7, 0x00, // ### ### + 0xC3, 0x00, // ## ## + 0xC3, 0x00, // ## ## + 0xE7, 0x00, // ### ### + 0x7E, 0x00, // ###### + 0x3C, 0x00, // #### + + // @610 '-' (10 pixels wide) + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + 0xF0, // #### + + // @620 ' ' (6 pixels wide) + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + 0x00, 0x00, // + + // @632 '.' (5 pixels wide) + 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x3c, // #### + 0x00, 0x00, 0x7e, // ###### + 0x00, 0x00, 0x7e, // ###### + 0x00, 0x00, 0x7e, // ###### + 0x00, 0x00, 0x3c, // #### + 0x00, 0x00, 0x00, // + +}; + + + +// Character descriptors for Tahoma 24pt +// { [Char width in bits], [Char height in bits], [Offset into tahoma_24ptCharBitmaps in bytes] } +const FONT_CHAR_INFO tahoma_24ptDescriptors[] PROGMEM = +{ + {5, 16, 620}, // ' ' + {0, 0, 0}, // '!' + {0, 0, 0}, // '"' + {0, 0, 0}, // '#' + {0, 0, 0}, // '$' + {0, 0, 0}, // '%' + {0, 0, 0}, // '&' + {0, 0, 0}, // ''' + {0, 0, 0}, // '(' + {0, 0, 0}, // ')' + {0, 0, 0}, // '*' + {0, 0, 0}, // '+' + {0, 0, 0}, // ',' + {10, 4, 610}, // '-' + {7, 23, 632}, // '.' + {0, 0, 0}, // '/' + {18, 23, 16}, // '0' + {16, 23, 70}, // '1' + {17, 23, 118}, // '2' + {17, 23, 169}, // '3' + {18, 23, 220}, // '4' + {17, 23, 274}, // '5' + {17, 23, 325}, // '6' + {17, 23, 376}, // '7' + {18, 23, 427}, // '8' + {17, 23, 481}, // '9' + {5, 23, 532}, // ':' + {0, 0, 0}, // ';' + {0, 0, 0}, // '<' + {0, 0, 0}, // '=' + {0, 0, 0}, // '>' + {0, 0, 0}, // '?' + {0, 0, 0}, // '@' + {0, 0, 0}, // 'A' + {0, 0, 0}, // 'B' + {12, 16, 550}, // 'C' + {0, 0, 0}, // 'D' + {0, 0, 0}, // 'E' + {10, 16, 574}, // 'F' + {0, 0, 0}, // 'G' + {0, 0, 0}, // 'H' + {0, 0, 0}, // 'I' + {0, 0, 0}, // 'J' + {0, 0, 0}, // 'K' + {0, 0, 0}, // 'L' + {0, 0, 0}, // 'M' + {0, 0, 0}, // 'N' + {0, 0, 0}, // 'O' + {0, 0, 0}, // 'P' + {0, 0, 0}, // 'Q' + {0, 0, 0}, // 'R' + {0, 0, 0}, // 'S' + {0, 0, 0}, // 'T' + {0, 0, 0}, // 'U' + {0, 0, 0}, // 'V' + {0, 0, 0}, // 'W' + {0, 0, 0}, // 'X' + {0, 0, 0}, // 'Y' + {0, 0, 0}, // 'Z' + {0, 0, 0}, // '[' + {0, 0, 0}, // '\' + {0, 0, 0}, // ']' + {0, 0, 0}, // '^' + {0, 0, 0}, // '_' + {8, 16, 594}, // '`' +}; + +// Font information for Tahoma 24pt +const FONT_INFO tahoma_24ptFontInfo = +{ + 39, // Character height + ' ', // Start character + '`', // End character + 2, // width of space character + tahoma_24ptDescriptors, // Character descriptor array + tahoma_24ptBitmaps, // Character bitmap array +}; + diff --git a/Arduino/BTCDieselHeater/src/OLED/fonts/Tahoma24.h b/Arduino/BTCDieselHeater/src/OLED/fonts/Tahoma24.h new file mode 100644 index 0000000..3a043f7 --- /dev/null +++ b/Arduino/BTCDieselHeater/src/OLED/fonts/Tahoma24.h @@ -0,0 +1,7 @@ +#include "FontTypes.h" + +// Font data for Tahoma 16pt +extern const uint8_t tahoma_24ptBitmaps[] PROGMEM; // stored in program flash memory +extern const FONT_CHAR_INFO tahoma_24ptDescriptors[] PROGMEM; // stored in program flash memory +extern const FONT_INFO tahoma_24ptFontInfo; + diff --git a/Arduino/BTCDieselHeater/src/Protocol/helpers.h b/Arduino/BTCDieselHeater/src/Protocol/helpers.h index 6228ad1..1f6eb2c 100644 --- a/Arduino/BTCDieselHeater/src/Protocol/helpers.h +++ b/Arduino/BTCDieselHeater/src/Protocol/helpers.h @@ -47,18 +47,21 @@ extern void setGlowDrive(unsigned char val); extern void saveNV(); extern void setSystemVoltage(float val); extern const CProtocolPackage& getHeaterInfo(); -extern void interpretJsonCommand(char* pLine); -extern void resetWebModerator(); -extern void resetJSONmoderator(); +extern void interpretJsonCommand(char* pLine); +extern void resetWebModerator(); +extern void resetJSONmoderator(); extern const char* getBlueWireStatStr(); -extern bool hasOEMcontroller(); -extern bool hasOEMLCDcontroller(); -extern int getBlueWireStat(); -extern int getSmartError(); -extern bool isCyclicActive(); -extern void setupGPIO(); -extern void setGPIO(int channel, bool state); -extern bool getGPIO(int channel); +extern bool hasOEMcontroller(); +extern bool hasOEMLCDcontroller(); +extern int getBlueWireStat(); +extern int getSmartError(); +extern bool isCyclicActive(); +extern float getVersion(); +extern const char* getVersionDate(); +extern int getBoardRevision(); +extern void setupGPIO(); +extern void setGPIO(int channel, bool state); +extern bool getGPIO(int channel); diff --git a/Arduino/BTCDieselHeater/src/RTC/TimerManager.cpp b/Arduino/BTCDieselHeater/src/RTC/TimerManager.cpp index 8925b84..def15c0 100644 --- a/Arduino/BTCDieselHeater/src/RTC/TimerManager.cpp +++ b/Arduino/BTCDieselHeater/src/RTC/TimerManager.cpp @@ -264,8 +264,7 @@ CTimerManager::manageTime(int _hour, int _minute, int _dow) if(newID) { DebugPort.println("Start of timer interval, starting heater"); requestOn(); - activeDow = dow; // dow when timer interval started -// activeRepeat = lookup & 0x80; + activeDow = dow; // dow when timer interval start was detected retval = 1; } else { diff --git a/Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp b/Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp index 0abca8e..19cdb1e 100644 --- a/Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp +++ b/Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp @@ -339,6 +339,30 @@ CHeaterStorage::setGPIOalgMode(unsigned char val) _calValues.Options.GPIOalgMode = val; } +uint16_t +CHeaterStorage::getFrameRate() +{ + return _calValues.Options.FrameRate; +} + +void +CHeaterStorage::setFrameRate(uint16_t val) +{ + _calValues.Options.FrameRate = val; +} + +uint8_t +CHeaterStorage::getHomeMenu() +{ + return _calValues.Options.HomeMenu; +} + +void +CHeaterStorage::setHomeMenu(uint8_t val) +{ + _calValues.Options.HomeMenu = val; +} + /////////////////////////////////////////////////////////////////////////////////////// // ESP32 // @@ -461,6 +485,8 @@ CESP32HeaterStorage::loadUI() validatedLoad("GPIOinMode", _calValues.Options.GPIOinMode, 0, u8inBounds, 0, 3); validatedLoad("GPIOoutMode", _calValues.Options.GPIOoutMode, 0, u8inBounds, 0, 2); validatedLoad("GPIOalgMode", _calValues.Options.GPIOalgMode, 0, u8inBounds, 0, 2); + validatedLoad("HomeMenu", _calValues.Options.HomeMenu, 0, u8inBounds, 0, 3); + validatedLoad("FrameRate", _calValues.Options.FrameRate, 1000, u16inBounds, 300, 1500); preferences.end(); } @@ -477,6 +503,8 @@ CESP32HeaterStorage::saveUI() preferences.putUChar("GPIOinMode", _calValues.Options.GPIOinMode); preferences.putUChar("GPIOoutMode", _calValues.Options.GPIOoutMode); preferences.putUChar("GPIOalgMode", _calValues.Options.GPIOalgMode); + preferences.putUChar("HomeMenu", _calValues.Options.HomeMenu); + preferences.putUShort("FrameRate", _calValues.Options.FrameRate); preferences.end(); } diff --git a/Arduino/BTCDieselHeater/src/Utility/NVStorage.h b/Arduino/BTCDieselHeater/src/Utility/NVStorage.h index 564436c..a424201 100644 --- a/Arduino/BTCDieselHeater/src/Utility/NVStorage.h +++ b/Arduino/BTCDieselHeater/src/Utility/NVStorage.h @@ -72,6 +72,8 @@ struct sBTCoptions { uint8_t GPIOinMode; uint8_t GPIOoutMode; uint8_t GPIOalgMode; + uint16_t FrameRate; + uint8_t HomeMenu; bool valid() { bool retval = true; @@ -83,6 +85,8 @@ struct sBTCoptions { retval &= cyclicMode < 10; retval &= GPIOinMode < 4; retval &= GPIOoutMode < 3; + retval &= (FrameRate >= 300) && (FrameRate <= 1500); + retval &= HomeMenu < 4; return retval; } void init() { @@ -95,6 +99,8 @@ struct sBTCoptions { GPIOinMode = 0; GPIOoutMode = 0; GPIOalgMode = 0; + FrameRate = 1000; + HomeMenu = 0; }; }; @@ -152,6 +158,8 @@ public: GPIOinModes getGPIOinMode(); GPIOoutModes getGPIOoutMode(); GPIOalgModes getGPIOalgMode(); + uint16_t getFrameRate(); + uint8_t getHomeMenu(); void setPmin(float); void setPmax(float); @@ -172,6 +180,8 @@ public: void setGPIOinMode(unsigned char val); void setGPIOoutMode(unsigned char val); void setGPIOalgMode(unsigned char val); + void setFrameRate(uint16_t val); + void setHomeMenu(uint8_t val); void getTimerInfo(int idx, sTimer& timerInfo); void setTimerInfo(int idx, const sTimer& timerInfo);