2019-04-19 23:49:22 +00:00
|
|
|
/*
|
|
|
|
* 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 "128x64OLED.h"
|
|
|
|
#include "HomeMenuSelScreen.h"
|
|
|
|
#include "KeyPad.h"
|
2019-06-15 23:09:29 +00:00
|
|
|
#include "../Utility/helpers.h"
|
2019-04-19 23:49:22 +00:00
|
|
|
#include "../Utility/UtilClasses.h"
|
|
|
|
#include "../Utility/NVStorage.h"
|
2019-07-02 08:27:20 +00:00
|
|
|
#include "../Utility/BTC_GPIO.h"
|
2019-04-19 23:49:22 +00:00
|
|
|
#include "fonts/Icons.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHomeMenuSelScreen::CHomeMenuSelScreen(C128x64_OLED& display, CScreenManager& mgr) : CPasswordScreen(display, mgr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CHomeMenuSelScreen::onSelect()
|
|
|
|
{
|
|
|
|
CScreenHeader::onSelect();
|
|
|
|
_rowSel = 0;
|
|
|
|
_action = NVstore.getHomeMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CHomeMenuSelScreen::_initUI()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CHomeMenuSelScreen::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, " Home Menu Actions ", true, eCentreJustify);
|
|
|
|
|
2019-04-27 10:41:47 +00:00
|
|
|
// _printMenuText(66, 14, "On timeout:", false, eRightJustify);
|
2019-06-01 00:18:31 +00:00
|
|
|
_drawBitmap(30, 14, TimeoutIconInfo);
|
2019-04-19 23:49:22 +00:00
|
|
|
switch(_action.onTimeout) {
|
|
|
|
case 0: strcpy(msg, "Default"); break;
|
|
|
|
case 1: strcpy(msg, "Detailed"); break;
|
|
|
|
case 2: strcpy(msg, "Basic"); break;
|
|
|
|
case 3: strcpy(msg, "Clock"); break;
|
|
|
|
}
|
2019-04-27 10:41:47 +00:00
|
|
|
_printMenuText(50, 14, msg, _rowSel == 3);
|
2019-04-19 23:49:22 +00:00
|
|
|
|
2019-04-27 10:41:47 +00:00
|
|
|
// _printMenuText(66, 26, "On start:", false, eRightJustify);
|
2019-06-01 00:18:31 +00:00
|
|
|
_drawBitmap(32, 26, StartIconInfo);
|
2019-04-19 23:49:22 +00:00
|
|
|
switch(_action.onStart) {
|
|
|
|
case 0: strcpy(msg, "Default"); break;
|
|
|
|
case 1: strcpy(msg, "Detailed"); break;
|
|
|
|
case 2: strcpy(msg, "Basic"); break;
|
|
|
|
case 3: strcpy(msg, "Clock"); break;
|
|
|
|
}
|
2019-04-27 10:41:47 +00:00
|
|
|
_printMenuText(50, 26, msg, _rowSel == 2);
|
2019-04-19 23:49:22 +00:00
|
|
|
|
2019-04-27 10:41:47 +00:00
|
|
|
// _printMenuText(66, 38, "On stop:", false, eRightJustify);
|
2019-06-01 00:18:31 +00:00
|
|
|
_drawBitmap(31, 38, StopIconInfo);
|
2019-04-19 23:49:22 +00:00
|
|
|
switch(_action.onStop) {
|
|
|
|
case 0: strcpy(msg, "Default"); break;
|
|
|
|
case 1: strcpy(msg, "Detailed"); break;
|
|
|
|
case 2: strcpy(msg, "Basic"); break;
|
|
|
|
case 3: strcpy(msg, "Clock"); break;
|
|
|
|
}
|
2019-04-27 10:41:47 +00:00
|
|
|
_printMenuText(50, 38, msg, _rowSel == 1);
|
2019-04-19 23:49:22 +00:00
|
|
|
|
2019-04-27 10:41:47 +00:00
|
|
|
/* if(_rowSel == 0)
|
|
|
|
_printMenuText(_display.xCentre(), 53, " \021 \030Edit Exit \020 ", true, eCentreJustify);
|
|
|
|
else {
|
|
|
|
_display.drawFastHLine(0, 52, 128, WHITE);
|
|
|
|
_printMenuText(_display.xCentre(), 56, "\030\031Sel \033\032 Adj", false, eCentreJustify);
|
|
|
|
_printMenuText(_display.xCentre(), 56, "Save", false, eCentreJustify);
|
|
|
|
}*/
|
2019-04-19 23:49:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-27 10:41:47 +00:00
|
|
|
bool
|
|
|
|
CHomeMenuSelScreen::animate()
|
|
|
|
{
|
|
|
|
if(_rowSel != 4) {
|
|
|
|
int yPos = 53;
|
|
|
|
int xPos = _display.xCentre();
|
|
|
|
const char* pMsg = NULL;
|
|
|
|
switch(_rowSel) {
|
|
|
|
case 0:
|
|
|
|
_printMenuText(xPos, yPos, " \021 \030Edit Exit \020 ", true, eCentreJustify);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
_display.drawFastHLine(0, 52, 128, WHITE);
|
|
|
|
pMsg = " Menu to switch to when the heater stops. ";
|
|
|
|
_scrollMessage(56, pMsg, _scrollChar);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
_display.drawFastHLine(0, 52, 128, WHITE);
|
|
|
|
pMsg = " Menu to switch to when the heater starts. ";
|
|
|
|
_scrollMessage(56, pMsg, _scrollChar);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
_display.drawFastHLine(0, 52, 128, WHITE);
|
|
|
|
pMsg = " Menu to return to after no keypad activity. ";
|
|
|
|
_scrollMessage(56, pMsg, _scrollChar);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-19 23:49:22 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
CHomeMenuSelScreen::keyHandler(uint8_t event)
|
|
|
|
{
|
|
|
|
if(event & keyPressed) {
|
|
|
|
// UP press
|
|
|
|
if(event & key_Up) {
|
|
|
|
if(_rowSel == 4) {
|
|
|
|
_showStoringMessage();
|
|
|
|
NVstore.setHomeMenu(_action);
|
|
|
|
saveNV();
|
|
|
|
_rowSel = 0;
|
|
|
|
}
|
|
|
|
else {
|
2019-04-27 10:41:47 +00:00
|
|
|
_scrollChar = 0;
|
2019-04-19 23:49:22 +00:00
|
|
|
_rowSel++;
|
|
|
|
UPPERLIMIT(_rowSel, 3);
|
|
|
|
}
|
|
|
|
}
|
2019-06-04 20:15:12 +00:00
|
|
|
// DOWN press
|
2019-04-19 23:49:22 +00:00
|
|
|
if(event & key_Down) {
|
2019-04-27 10:41:47 +00:00
|
|
|
_scrollChar = 0;
|
2019-04-19 23:49:22 +00:00
|
|
|
_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
|
|
|
|
CHomeMenuSelScreen::adjust(int dir)
|
|
|
|
{
|
|
|
|
switch(_rowSel) {
|
|
|
|
case 1:
|
|
|
|
_action.onStop += dir;
|
2019-06-02 12:47:35 +00:00
|
|
|
WRAPLIMITS(_action.onStop, 0, 3);
|
2019-04-19 23:49:22 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
_action.onStart += dir;
|
2019-06-02 12:47:35 +00:00
|
|
|
WRAPLIMITS(_action.onStart, 0, 3);
|
2019-04-19 23:49:22 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
_action.onTimeout += dir;
|
2019-06-02 12:47:35 +00:00
|
|
|
WRAPLIMITS(_action.onTimeout, 0, 3);
|
2019-04-19 23:49:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|