Titled Timer screen - lost std header

Added missing source files
This commit is contained in:
Ray Jones 2019-07-28 09:07:29 +10:00
parent d563cb0c8a
commit 6c21a9c6a6
21 changed files with 1010 additions and 655 deletions

115
src/OLED/BTScreen.cpp Normal file
View file

@ -0,0 +1,115 @@
/*
* 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/>.
*
*/
#include "BTScreen.h"
#include "KeyPad.h"
#include "../Utility/helpers.h"
#include "../Bluetooth/BluetoothAbstract.h"
#include "../Utility/NVStorage.h"
#include "fonts/Arial.h"
///////////////////////////////////////////////////////////////////////////
//
// CBTScreen
//
// This screen presents Bluetooth status information
//
///////////////////////////////////////////////////////////////////////////
static const int LIMIT_AWAY = 0;
static const int LIMIT_LEFT = 1;
static const int LIMIT_RIGHT = 2;
CBTScreen::CBTScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreen(display, mgr)
{
_initUI();
}
void
CBTScreen::onSelect()
{
CScreen::onSelect();
_initUI();
}
void
CBTScreen::_initUI()
{
_rowSel = 0;
_colSel = 0;
}
bool
CBTScreen::show()
{
// CScreenHeader::show(false);
CScreen::show();
int yPos = 18;
_showTitle("Bluetooth info");
yPos = 35;
_printMenuText(0, yPos, "MAC:");
_printMenuText(25, yPos, getBluetoothClient().getMAC());
_printMenuText(_display.xCentre(), 53, " \021 \020 ", true, eCentreJustify);
_printMenuText(_display.xCentre(), 53, "Exit", false, eCentreJustify);
return true;
}
bool
CBTScreen::keyHandler(uint8_t event)
{
if(event & keyPressed) {
// press CENTRE
if(event & key_Centre) {
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop); // force return to main menu
}
// press LEFT
if(event & key_Left) {
switch(_rowSel) {
case 0:
_ScreenManager.prevMenu();
break;
}
}
// press RIGHT
if(event & key_Right) {
switch(_rowSel) {
case 0:
_ScreenManager.nextMenu();
break;
}
}
// press UP
if(event & key_Up) {
}
// press DOWN
if(event & key_Down) {
}
_ScreenManager.reqUpdate();
}
return true;
}

42
src/OLED/BTScreen.h Normal file
View file

@ -0,0 +1,42 @@
/*
* 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 __BTSCREEN_H__
#define __BTSCREEN_H__
#include <stdint.h>
#include "ScreenHeader.h"
class C128x64_OLED;
class CScreenManager;
class CBTScreen : public CScreen {
public:
CBTScreen(C128x64_OLED& display, CScreenManager& mgr);
void onSelect();
bool show();
bool keyHandler(uint8_t event);
private:
int _rowSel, _colSel;
void _initUI();
};
#endif

View file

@ -227,7 +227,7 @@ CFuelCalScreen::keyHandler(uint8_t event)
case 4: // confirmed save
_display.clearDisplay();
_animateCount = -1;
_showStoringMessage();
_enableStoringMessage();
tuning = NVstore.getHeaterTuning();
tuning.pumpCal = _mlPerStroke;
tuning.lowVolts = _LVC;

View file

@ -245,7 +245,7 @@ CFuelMixtureScreen::keyHandler(uint8_t event)
case 5:
_display.clearDisplay();
_animateCount = -1;
_showStoringMessage();
_enableStoringMessage();
setPumpMin(adjPump[0]);
setPumpMax(adjPump[1]);
setFanMin(adjFan[0]);

View file

@ -227,7 +227,7 @@ CGPIOScreen::keyHandler(uint8_t event)
UPPERLIMIT(_rowSel, 3);
break;
case 4: // confirmed save
_showStoringMessage();
_enableStoringMessage();
us = NVstore.getUserSettings();
us.GPIO = _GPIOparams;
NVstore.setUserSettings(us);

View file

@ -203,7 +203,7 @@ CHeaterSettingsScreen::keyHandler(uint8_t event)
UPPERLIMIT(_rowSel, 3);
break;
case 4: // confirmed save
_showStoringMessage();
_enableStoringMessage();
setSystemVoltage(float(_sysVoltage));
setFanSensor(_fanSensor);
setGlowDrive(_glowDrive);

View file

@ -133,7 +133,7 @@ CHomeMenuSelScreen::keyHandler(uint8_t event)
// UP press
if(event & key_Up) {
if(_rowSel == 4) {
_showStoringMessage();
_enableStoringMessage();
us = NVstore.getUserSettings();
us.HomeMenu = _action;
NVstore.setUserSettings(us);

View file

@ -105,7 +105,7 @@ CInheritSettingsScreen::keyHandler(uint8_t event)
setFanSensor(getHeaterInfo().getFan_Sensor());
setSystemVoltage(getHeaterInfo().getSystemVoltage());
saveNV();
_showStoringMessage();
_enableStoringMessage();
_nAdoptSettings = 0; // will cause return to main menu after storing message expires
}
}

View file

@ -0,0 +1,149 @@
/*
* 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/>.
*
*/
#include "MenuTrunkScreen.h"
#include "KeyPad.h"
#include "../Utility/helpers.h"
#include "../Utility/macros.h"
#include "fonts/Arial.h"
///////////////////////////////////////////////////////////////////////////
//
// CMenuTrunkScreen
//
// This screen presents Bluetooth status information
//
///////////////////////////////////////////////////////////////////////////
static const int LIMIT_AWAY = 0;
static const int LIMIT_LEFT = 1;
static const int LIMIT_RIGHT = 2;
CMenuTrunkScreen::CMenuTrunkScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreen(display, mgr)
{
_initUI();
}
void
CMenuTrunkScreen::onSelect()
{
CScreen::onSelect();
// _initUI();
}
void
CMenuTrunkScreen::_initUI()
{
_rowSel = 0;
_colSel = 0;
}
bool
CMenuTrunkScreen::show()
{
_display.clearDisplay();
CScreen::show();
int yPos[] = { 53, 41, 29, 17 };
_showTitle("Menu Trunk");
_printMenuText(_display.xCentre(), yPos[_rowSel], " \021 \020 ", true, eCentreJustify);
_printMenuText(_display.xCentre(), yPos[3], "Heater Tuning", false, eCentreJustify);
_printMenuText(_display.xCentre(), yPos[2], "System Settings", false, eCentreJustify);
_printMenuText(_display.xCentre(), yPos[1], "User Settings", false, eCentreJustify);
_printMenuText(_display.xCentre(), yPos[0], "Root menu", false, eCentreJustify);
return true;
}
bool
CMenuTrunkScreen::keyHandler(uint8_t event)
{
if(event & keyPressed) {
// press CENTRE
if(event & key_Centre) {
_rowSel = 0;
}
// press LEFT
if(event & key_Left) {
switch(_rowSel) {
case 0:
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop);
_ScreenManager.prevMenu();
break;
case 1:
_ScreenManager.selectMenu(CScreenManager::UserSettingsLoop);
// _ScreenManager.prevMenu();
break;
case 2:
_ScreenManager.selectMenu(CScreenManager::SystemSettingsLoop);
// _ScreenManager.prevMenu();
break;
case 3:
_ScreenManager.selectMenu(CScreenManager::BranchMenu, CScreenManager::HtrSettingsUI);
// _ScreenManager.selectMenu(CScreenManager::TuningMenuLoop);
// _ScreenManager.prevMenu();
break;
}
}
// press RIGHT
if(event & key_Right) {
switch(_rowSel) {
case 0:
_ScreenManager.selectMenu(CScreenManager::RootMenuLoop);
_ScreenManager.nextMenu();
break;
case 1:
_ScreenManager.selectMenu(CScreenManager::UserSettingsLoop);
// _ScreenManager.nextMenu();
break;
case 2:
_ScreenManager.selectMenu(CScreenManager::SystemSettingsLoop);
// _ScreenManager.nextMenu();
break;
case 3:
_ScreenManager.selectMenu(CScreenManager::BranchMenu, CScreenManager::HtrSettingsUI);
// _ScreenManager.selectMenu(CScreenManager::TuningMenuLoop);
// _ScreenManager.nextMenu();
break;
}
}
// press UP
if(event & key_Up) {
_rowSel++;
UPPERLIMIT(_rowSel, 3);
}
// press DOWN
if(event & key_Down) {
_rowSel--;
LOWERLIMIT(_rowSel, 0);
}
_ScreenManager.reqUpdate();
}
return true;
}

View file

@ -0,0 +1,42 @@
/*
* 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 __MENUTRUNKSCREEN_H__
#define __MENUTRUNKSCREEN_H__
#include <stdint.h>
#include "Screen.h"
class C128x64_OLED;
class CScreenManager;
class CMenuTrunkScreen : public CScreen {
public:
CMenuTrunkScreen(C128x64_OLED& display, CScreenManager& mgr);
void onSelect();
bool show();
bool keyHandler(uint8_t event);
private:
int _rowSel, _colSel;
void _initUI();
};
#endif

View file

@ -147,7 +147,7 @@ COtherOptionsScreen::keyHandler(uint8_t event)
settings.FrameRate = _frameRate;
NVstore.setUserSettings(settings);
NVstore.save();
_showStoringMessage();
_enableStoringMessage();
_rowSel = 0;
}
else {

View file

@ -64,11 +64,7 @@ CPasswordScreen::show()
if(_SaveTime) {
_display.clearDisplay();
// _printInverted(_display.xCentre(), 28, " ", true, eCentreJustify);
// _printInverted(_display.xCentre(), 39, " ", true, eCentreJustify);
_display.writeFillRect(34, 26, 60, 26, WHITE);
CTransientFont AF(_display, &arial_8ptBoldFontInfo);
_printInverted(_display.xCentre(), 32, " STORING ", true, eCentreJustify);
_showStoringMessage();
return true;
}
else if(_bGetPassword) {
@ -204,16 +200,10 @@ CPasswordScreen::_getPassword()
}
void
CPasswordScreen::_showStoringMessage()
CPasswordScreen::_enableStoringMessage()
{
_SaveTime = millis() + 1500;
_ScreenManager.reqUpdate();
}
void
CPasswordScreen::_showConfirmMessage()
{
_showTitle("Saving Settings");
_printMenuText(_display.xCentre(), 35, "Press UP to", false, eCentreJustify);
_printMenuText(_display.xCentre(), 43, "confirm save", false, eCentreJustify);
}

View file

@ -37,10 +37,9 @@ protected:
bool _showPassword();
void _getPassword();
bool _isPasswordOK() { return _bPasswordOK; };
void _showStoringMessage();
void _enableStoringMessage();
void _initUI();
bool _busy();
void _showConfirmMessage();
public:
CPasswordScreen(C128x64_OLED& display, CScreenManager& mgr);
void onSelect();

View file

@ -183,10 +183,26 @@ void
CScreen::_showTitle(const char* title)
{
CTransientFont AF(_display, &arial_8ptBoldFontInfo);
_printMenuText(_display.xCentre(), -2, title, false, eCentreJustify);
_printMenuText(_display.xCentre(), -1, title, false, eCentreJustify);
_display.drawFastHLine(0, 10, 128, WHITE);
}
void
CScreen::_showConfirmMessage()
{
_showTitle("Saving Settings");
_printMenuText(_display.xCentre(), 35, "Press UP to", false, eCentreJustify);
_printMenuText(_display.xCentre(), 43, "confirm save", false, eCentreJustify);
}
void
CScreen::_showStoringMessage()
{
_display.writeFillRect(34, 19, 60, 26, WHITE);
CTransientFont AF(_display, &arial_8ptBoldFontInfo);
_printInverted(_display.xCentre(), 25, " STORING ", true, eCentreJustify);
}
// a class used for temporary alternate fonts usage
// Reverts to standard inbuilt font when the instance falls out of scope

View file

@ -57,6 +57,8 @@ protected:
void _reqOEMWarning();
void _drawBitmap(int x, int y, const BITMAP_INFO& info, uint16_t color = WHITE, uint16_t bg = 0xffff);
void _showTitle(const char* title);
void _showConfirmMessage();
void _showStoringMessage();
public:
CScreen(C128x64_OLED& disp, CScreenManager& mgr);
virtual ~CScreen();

View file

@ -83,12 +83,11 @@ CSetClockScreen::show()
}
if(_SaveTime) {
_showStoringMessage();
long tDelta = millis() - _SaveTime;
if(tDelta > 0)
if(tDelta > 0) {
_SaveTime = 0;
_printInverted(_display.xCentre(), 28, " ", true, eCentreJustify);
_printInverted(_display.xCentre(), 39, " ", true, eCentreJustify);
_printInverted(_display.xCentre(), 34, " STORING ", true, eCentreJustify);
}
}
else {
yPos = 28;

View file

@ -33,10 +33,11 @@
#include "../Utility/helpers.h"
#include "../../lib/RTClib/RTClib.h"
#include "../RTC/TimerManager.h"
#include "fonts/Arial.h"
const char* briefDOW[] = { "S", "M", "T", "W", "T", "F", "S" };
CSetTimerScreen::CSetTimerScreen(C128x64_OLED& display, CScreenManager& mgr, int instance) : CScreenHeader(display, mgr)
CSetTimerScreen::CSetTimerScreen(C128x64_OLED& display, CScreenManager& mgr, int instance) : CScreen(display, mgr)
{
_initUI();
_ConflictTime = 0;
@ -47,7 +48,7 @@ CSetTimerScreen::CSetTimerScreen(C128x64_OLED& display, CScreenManager& mgr, int
void
CSetTimerScreen::onSelect()
{
CScreenHeader::onSelect();
CScreen::onSelect();
_initUI();
NVstore.getTimerInfo(_timerID, _timerInfo);
}
@ -63,7 +64,9 @@ CSetTimerScreen::_initUI()
bool
CSetTimerScreen::show()
{
CScreenHeader::show(false);
CScreen::show();
_display.clearDisplay();
char str[20];
int xPos, yPos;
@ -71,35 +74,22 @@ CSetTimerScreen::show()
if(_rowSel == 0) {
NVstore.getTimerInfo(_timerID, _timerInfo);
}
sprintf(str, " Set Timer %d ", _timerID + 1);
_printInverted(0, 15, str, true);
sprintf(str, "Set Timer #%d", _timerID + 1);
_showTitle(str);
if(_SaveTime) {
_showStoringMessage();
long tDelta = millis() - _SaveTime;
if(tDelta > 0)
if(tDelta > 0) {
_SaveTime = 0;
_printInverted(_display.xCentre(), 28, " ", true, eCentreJustify);
_printInverted(_display.xCentre(), 39, " ", true, eCentreJustify);
_printInverted(_display.xCentre(), 34, " STORING ", true, eCentreJustify);
}
}
else if(_ConflictTime) {
long tDelta = millis() - _ConflictTime;
if(tDelta > 0)
_ConflictTime = 0;
sprintf(str, " with Timer %d ", _conflictID);
if(_conflictID >= 10) {
// extra space
_printInverted(_display.xCentre(), 26, " ", true, eCentreJustify);
_printInverted(_display.xCentre(), 45, " ", true, eCentreJustify);
_printInverted(_display.xCentre(), 30, " Conflicts ", true, eCentreJustify);
_printInverted(_display.xCentre(), 38, str, true, eCentreJustify);
}
else {
_printInverted(_display.xCentre(), 26, " ", true, eCentreJustify);
_printInverted(_display.xCentre(), 45, " ", true, eCentreJustify);
_printInverted(_display.xCentre(), 30, " Conflicts ", true, eCentreJustify);
_printInverted(_display.xCentre(), 38, str, true, eCentreJustify);
}
_showConflict(str);
}
else {
// start
@ -140,22 +130,23 @@ CSetTimerScreen::show()
_printMenuText(xPos, yPos, msg, _colSel==5, eRightJustify);
else
_printInverted(xPos, yPos, msg, _timerInfo.repeat, eRightJustify);
}
// navigation line
yPos = 53;
xPos = _display.xCentre();
if(_rowSel == 2) {
_display.drawFastHLine(0, 53, 128, WHITE);
_printMenuText(_display.xCentre(), 57, "\033\032 Sel \030\031 Adj", false, eCentreJustify);
_printMenuText(_display.xCentre(), 57, "Done", false, eCentreJustify);
}
else if(_rowSel == 1) {
_display.drawFastHLine(0, 53, 128, WHITE);
_printMenuText(_display.xCentre(), 57, "\033\032 Sel \030\031 Adj", false, eCentreJustify);
_printMenuText(_display.xCentre(), 57, "Save", false, eCentreJustify);
}
else {
_printMenuText(xPos, yPos, " \021 Exit \020 ", _rowSel==0, eCentreJustify);
// navigation line
yPos = 53;
xPos = _display.xCentre();
if(_rowSel == 2) {
_display.drawFastHLine(0, 53, 128, WHITE);
_printMenuText(_display.xCentre(), 57, "\033\032 Sel \030\031 Adj", false, eCentreJustify);
_printMenuText(_display.xCentre(), 57, "Done", false, eCentreJustify);
}
else if(_rowSel == 1) {
_display.drawFastHLine(0, 53, 128, WHITE);
_printMenuText(_display.xCentre(), 57, "\033\032 Sel \030\031 Adj", false, eCentreJustify);
_printMenuText(_display.xCentre(), 57, "Save", false, eCentreJustify);
}
else {
_printMenuText(xPos, yPos, " \021 Exit \020 ", _rowSel==0, eCentreJustify);
}
}
return true;
@ -394,4 +385,13 @@ CSetTimerScreen::_printEnabledTimers()
}
}
}
void
CSetTimerScreen::_showConflict(const char* str)
{
CTransientFont AF(_display, &arial_8ptBoldFontInfo);
_display.fillRect(19, 22, 90, 36, WHITE);
_printInverted(_display.xCentre(), 39, str, true, eCentreJustify);
_printInverted(_display.xCentre(), 28, "Conflicts", true, eCentreJustify);
}

View file

@ -30,7 +30,7 @@ class C128x64_OLED;
class CScreenManager;
class CProtocol;
class CSetTimerScreen : public CScreenHeader {
class CSetTimerScreen : public CScreen {
int _rowSel;
int _colSel;
int _timerID;
@ -41,7 +41,7 @@ class CSetTimerScreen : public CScreenHeader {
void _adjust(int dir);
void _printEnabledTimers();
void _initUI();
void _showConflict(const char* str);
public:
CSetTimerScreen(C128x64_OLED& display, CScreenManager& mgr, int instance);
void onSelect();

View file

@ -254,7 +254,7 @@ CThermostatModeScreen::keyHandler(uint8_t event)
UPPERLIMIT(_rowSel, 4);
break;
case 10: // confirmed save
_showStoringMessage();
_enableStoringMessage();
settings = NVstore.getUserSettings();
settings.ThermostatMethod = _thermoMode;
settings.ThermostatWindow = _window;

View file

@ -174,7 +174,7 @@ CVersionInfoScreen::keyHandler(uint8_t event)
BoardRevisionReset();
NVstore.init();
NVstore.save();
_showStoringMessage();
_enableStoringMessage();
_rowSel = 11;
}
else {

File diff suppressed because it is too large Load diff