2018-12-01 00:36:25 +00:00
|
|
|
#include "ScreenManager.h"
|
2019-01-18 07:09:40 +00:00
|
|
|
#include "DetailedScreen.h"
|
|
|
|
#include "BasicScreen.h"
|
|
|
|
#include "PrimingScreen.h"
|
|
|
|
#include "WiFiScreen.h"
|
|
|
|
#include "FuelMixtureScreen.h"
|
|
|
|
#include "SetClockScreen.h"
|
|
|
|
#include "SetTimerScreen.h"
|
|
|
|
#include "ClockScreen.h"
|
2019-01-16 09:22:17 +00:00
|
|
|
#include "RebootScreen.h"
|
2019-01-18 20:15:02 +00:00
|
|
|
#include "HeaterSettingsScreen.h"
|
2019-01-19 11:05:14 +00:00
|
|
|
#include "SettingsScreen.h"
|
2018-12-16 07:34:39 +00:00
|
|
|
#include <Wire.h>
|
|
|
|
#include "../cfg/pins.h"
|
|
|
|
#include "../cfg/BTCConfig.h"
|
2019-01-19 11:05:14 +00:00
|
|
|
#include "../protocol/helpers.h"
|
2018-11-22 10:30:51 +00:00
|
|
|
|
2018-11-25 04:45:17 +00:00
|
|
|
|
2018-11-27 10:44:47 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// splash creen created using image2cpp http://javl.github.io/image2cpp/
|
|
|
|
// Settings:
|
|
|
|
// Black background
|
|
|
|
// Invert [X]
|
|
|
|
// Arduino code, single bitmap
|
|
|
|
// Identifier: DieselSplash
|
|
|
|
// Draw Mode: Horizontal
|
|
|
|
//
|
2018-11-26 19:25:51 +00:00
|
|
|
const unsigned char DieselSplash [] PROGMEM = {
|
|
|
|
// 'Splash2, 128x64px
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x18, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x02, 0x3e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x06, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x08, 0x00, 0x00, 0x00, 0x0f, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x08, 0x00, 0x00,
|
|
|
|
0x00, 0x10, 0x00, 0x00, 0x21, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x88, 0x00, 0x00,
|
|
|
|
0x00, 0x18, 0x00, 0x00, 0x20, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x84, 0x00, 0x00,
|
|
|
|
0x00, 0x14, 0x00, 0x00, 0x20, 0x40, 0x00, 0x20, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x84, 0x00, 0x00,
|
|
|
|
0x00, 0x52, 0x00, 0x00, 0x40, 0x40, 0x00, 0x10, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x84, 0x00, 0x00,
|
|
|
|
0x00, 0x34, 0x00, 0x00, 0x40, 0x20, 0x00, 0x08, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00,
|
|
|
|
0x00, 0x18, 0x00, 0x00, 0x40, 0x10, 0x00, 0x04, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00,
|
|
|
|
0x00, 0x34, 0x00, 0x00, 0x80, 0x10, 0x00, 0x02, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00,
|
|
|
|
0x00, 0x52, 0x00, 0x00, 0x80, 0x08, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00,
|
|
|
|
0x00, 0x14, 0x00, 0x00, 0x80, 0x08, 0x01, 0xf1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00,
|
|
|
|
0x00, 0x18, 0x00, 0x01, 0x00, 0x04, 0x3e, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00,
|
|
|
|
0x00, 0x10, 0x00, 0x01, 0x00, 0x07, 0xc0, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x06, 0x80, 0x1c, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0xc4, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x18, 0x40, 0x64, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3c, 0x78, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x3c, 0x40, 0x84, 0x00, 0x00, 0x01, 0x80, 0x00, 0x01, 0xc0, 0x40, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x26, 0x23, 0x04, 0x00, 0x00, 0x00, 0x60, 0x00, 0x1e, 0x00, 0x40, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x43, 0x1c, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x01, 0xe0, 0x00, 0x40, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x41, 0xf8, 0x02, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x00, 0x00, 0x40, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x41, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x40, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x40, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x40, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x60, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x30, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x10, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x19, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x0f, 0x88, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x07, 0xf8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x07, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0xf8, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x1f, 0x20, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x03, 0xe8, 0x20, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x7c, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x08, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x04, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x0a, 0x08, 0x00, 0x00, 0x00, 0x21, 0x10, 0x01, 0x00, 0x00, 0x84, 0x00, 0x40, 0x01, 0x40, 0x00,
|
|
|
|
0x11, 0x08, 0x00, 0x00, 0x00, 0x21, 0x10, 0x01, 0x00, 0x00, 0x80, 0x00, 0x40, 0x01, 0x40, 0x00,
|
|
|
|
0x11, 0x3a, 0x4e, 0x73, 0x18, 0xe1, 0x13, 0x1d, 0xcc, 0xb0, 0x80, 0xc7, 0x75, 0x99, 0x4c, 0xb0,
|
|
|
|
0x1f, 0x4a, 0x52, 0x94, 0xa5, 0x21, 0xf4, 0xa5, 0x12, 0xc0, 0x81, 0x29, 0x46, 0x25, 0x52, 0xc0,
|
|
|
|
0x11, 0x4a, 0x52, 0x94, 0x3d, 0x21, 0x17, 0xa5, 0x1e, 0x80, 0x81, 0x29, 0x44, 0x25, 0x5e, 0x80,
|
|
|
|
0x11, 0x49, 0x92, 0x94, 0xa1, 0x21, 0x14, 0x25, 0x10, 0x80, 0x85, 0x29, 0x44, 0x25, 0x50, 0x80,
|
|
|
|
0x11, 0x39, 0x8e, 0x93, 0x18, 0xe1, 0x13, 0x1c, 0xcc, 0x80, 0x78, 0xc9, 0x34, 0x19, 0x4c, 0x80
|
|
|
|
};
|
2018-11-27 10:44:47 +00:00
|
|
|
|
2018-12-01 00:36:25 +00:00
|
|
|
|
2018-11-25 04:45:17 +00:00
|
|
|
CScreenManager::CScreenManager()
|
2018-11-17 02:08:22 +00:00
|
|
|
{
|
2018-11-25 04:45:17 +00:00
|
|
|
_pDisplay = NULL;
|
2018-12-07 11:16:04 +00:00
|
|
|
_currentScreen = -1;
|
2019-01-18 07:09:40 +00:00
|
|
|
_timerScreen = -1;
|
2019-01-19 11:05:14 +00:00
|
|
|
_settingScreen = -1;
|
2018-11-27 10:44:47 +00:00
|
|
|
_bReqUpdate = false;
|
2019-01-18 07:09:40 +00:00
|
|
|
_bSetTime = false;
|
2018-12-22 10:32:13 +00:00
|
|
|
_DimTime = millis() + 60000;
|
2019-01-16 09:22:17 +00:00
|
|
|
_pRebootScreen = NULL;
|
2018-11-25 04:45:17 +00:00
|
|
|
}
|
2018-11-23 10:34:37 +00:00
|
|
|
|
2018-11-25 04:45:17 +00:00
|
|
|
CScreenManager::~CScreenManager()
|
|
|
|
{
|
2018-12-07 11:16:04 +00:00
|
|
|
for(int i=0; i < _Screens.size(); i++) {
|
2018-12-07 04:53:08 +00:00
|
|
|
if(_Screens[i]) {
|
|
|
|
delete _Screens[i];
|
|
|
|
_Screens[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2019-01-18 07:09:40 +00:00
|
|
|
for(int i=0; i < _TimerScreens.size(); i++) {
|
|
|
|
if(_TimerScreens[i]) {
|
|
|
|
delete _TimerScreens[i];
|
|
|
|
_TimerScreens[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(_SetTimeScreen) {
|
|
|
|
delete _SetTimeScreen;
|
|
|
|
_SetTimeScreen = NULL;
|
|
|
|
}
|
2018-11-25 04:45:17 +00:00
|
|
|
if(_pDisplay) {
|
|
|
|
delete _pDisplay; _pDisplay = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-12-12 10:37:02 +00:00
|
|
|
CScreenManager::begin()
|
2018-11-25 04:45:17 +00:00
|
|
|
{
|
|
|
|
|
2018-12-06 19:53:45 +00:00
|
|
|
// 128 x 64 OLED support (I2C)
|
2019-01-10 05:01:52 +00:00
|
|
|
// xxxx_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
2018-11-26 10:26:38 +00:00
|
|
|
_pDisplay = new C128x64_OLED(OLED_SDA_pin, OLED_SCL_pin);
|
2019-01-10 05:01:52 +00:00
|
|
|
#if USE_ADAFRUIT_SH1106 == 1
|
2018-11-26 10:26:38 +00:00
|
|
|
_pDisplay->begin(SH1106_SWITCHCAPVCC);
|
2019-01-10 05:01:52 +00:00
|
|
|
Wire.begin(OLED_SDA_pin, OLED_SCL_pin, 800000); // speed up I2C from the default crappy 100kHz set via the adafruit begin!
|
|
|
|
#elif USE_ADAFRUIT_SSD1306 == 1
|
|
|
|
_pDisplay->begin(SSD1306_SWITCHCAPVCC, 0x3c);
|
|
|
|
_pDisplay->ssd1306_command(SSD1306_SETPRECHARGE); // 0xd9
|
|
|
|
_pDisplay->ssd1306_command(0x1F); // correct lame reversal of OLED current phases
|
|
|
|
#endif
|
2018-11-26 10:26:38 +00:00
|
|
|
|
2018-11-26 19:25:51 +00:00
|
|
|
// replace adafruit splash screen
|
|
|
|
_pDisplay->clearDisplay();
|
|
|
|
_pDisplay->drawBitmap(0, 0, DieselSplash, 128, 64, WHITE);
|
2018-11-17 02:08:22 +00:00
|
|
|
|
|
|
|
// Show initial display buffer contents on the screen --
|
2018-11-25 04:45:17 +00:00
|
|
|
_pDisplay->display();
|
2018-11-17 02:08:22 +00:00
|
|
|
|
2018-12-07 11:16:04 +00:00
|
|
|
DebugPort.println("Creating Screens");
|
2019-01-18 20:15:02 +00:00
|
|
|
_Screens.push_back(new CDetailedScreen(*_pDisplay, *this)); // detail control
|
|
|
|
_Screens.push_back(new CBasicScreen(*_pDisplay, *this)); // basic control
|
|
|
|
_Screens.push_back(new CClockScreen(*_pDisplay, *this)); // clock
|
|
|
|
_Screens.push_back(new CPrimingScreen(*_pDisplay, *this)); // mode / priming
|
|
|
|
_Screens.push_back(new CWiFiScreen(*_pDisplay, *this)); // comms info
|
2019-01-19 11:05:14 +00:00
|
|
|
_Screens.push_back(new CSettingsScreen(*_pDisplay, *this)); // tuning info
|
2019-01-18 07:09:40 +00:00
|
|
|
_SetTimeScreen = new CSetClockScreen(*_pDisplay, *this); // clock set
|
|
|
|
_TimerScreens.push_back(new CSetTimerScreen(*_pDisplay, *this, 0)); // set timer 1
|
|
|
|
_TimerScreens.push_back(new CSetTimerScreen(*_pDisplay, *this, 1)); // set timer 2
|
2019-01-19 11:05:14 +00:00
|
|
|
_SettingsScreens.push_back(new CFuelMixtureScreen(*_pDisplay, *this)); // tuning
|
|
|
|
_SettingsScreens.push_back(new CHeaterSettingsScreen(*_pDisplay, *this)); // tuning
|
2018-12-09 01:10:56 +00:00
|
|
|
|
|
|
|
#if RTC_USE_DS3231==0 && RTC_USE_DS1307==0 && RTC_USE_PCF8523==0
|
|
|
|
_currentScreen = 6; // bring up clock set screen first if using millis based RTC!
|
|
|
|
#else
|
|
|
|
_currentScreen = 1; // basic control screen
|
|
|
|
#endif
|
2018-11-25 04:45:17 +00:00
|
|
|
|
|
|
|
_switchScreen();
|
2018-11-17 02:08:22 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 18:25:10 +00:00
|
|
|
bool
|
2018-12-01 00:36:25 +00:00
|
|
|
CScreenManager::checkUpdate()
|
2018-11-25 04:45:17 +00:00
|
|
|
{
|
2018-12-22 10:32:13 +00:00
|
|
|
if(_DimTime) {
|
|
|
|
long tDelta = millis() - _DimTime;
|
|
|
|
if(tDelta > 0) {
|
2018-12-23 11:15:36 +00:00
|
|
|
// if(NVstore.getDimTime())
|
2018-12-22 10:32:13 +00:00
|
|
|
_pDisplay->dim(true);
|
|
|
|
_DimTime = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-27 10:44:47 +00:00
|
|
|
if(_bReqUpdate) {
|
2019-01-16 09:22:17 +00:00
|
|
|
if(_pRebootScreen) {
|
|
|
|
_pRebootScreen->show();
|
2018-11-27 10:44:47 +00:00
|
|
|
_bReqUpdate = false;
|
2019-01-16 09:22:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
2019-01-18 07:09:40 +00:00
|
|
|
if(_bSetTime) {
|
|
|
|
_SetTimeScreen->show();
|
|
|
|
_bReqUpdate = false;
|
|
|
|
return true;
|
|
|
|
}
|
2019-01-19 11:05:14 +00:00
|
|
|
else if(_settingScreen >= 0) {
|
|
|
|
_SettingsScreens[_settingScreen]->show();
|
|
|
|
_bReqUpdate = false;
|
|
|
|
return true;
|
|
|
|
}
|
2019-01-18 07:09:40 +00:00
|
|
|
else if(_timerScreen >= 0) {
|
|
|
|
_TimerScreens[_timerScreen]->show();
|
|
|
|
_bReqUpdate = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(_currentScreen >= 0) {
|
2019-01-16 09:22:17 +00:00
|
|
|
_Screens[_currentScreen]->show();
|
|
|
|
_bReqUpdate = false;
|
|
|
|
return true;
|
|
|
|
}
|
2018-11-27 10:44:47 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-01 18:25:10 +00:00
|
|
|
return false;
|
2018-11-25 04:45:17 +00:00
|
|
|
}
|
|
|
|
|
2018-11-27 10:44:47 +00:00
|
|
|
void
|
|
|
|
CScreenManager::reqUpdate()
|
|
|
|
{
|
|
|
|
_bReqUpdate = true;
|
|
|
|
}
|
|
|
|
|
2018-12-01 18:25:10 +00:00
|
|
|
bool
|
2018-11-25 04:45:17 +00:00
|
|
|
CScreenManager::animate()
|
2018-11-17 02:08:22 +00:00
|
|
|
{
|
2019-01-20 03:19:38 +00:00
|
|
|
if(_settingScreen >= 0) return _SettingsScreens[_settingScreen]->animate();
|
|
|
|
if(_timerScreen >= 0) return _TimerScreens[_timerScreen]->animate();
|
|
|
|
if(_currentScreen >= 0) return _Screens[_currentScreen]->animate();
|
2018-12-01 18:25:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CScreenManager::refresh()
|
|
|
|
{
|
|
|
|
if(_pDisplay)
|
|
|
|
_pDisplay->display();
|
2018-11-25 04:45:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CScreenManager::_switchScreen()
|
|
|
|
{
|
2019-01-20 03:19:38 +00:00
|
|
|
if(_timerScreen >= 0) _TimerScreens[_timerScreen]->onSelect();
|
|
|
|
else if(_settingScreen >= 0) _SettingsScreens[_settingScreen]->onSelect();
|
|
|
|
else if(_currentScreen >= 0) _Screens[_currentScreen]->onSelect();
|
2018-12-08 04:18:37 +00:00
|
|
|
|
2018-11-27 10:44:47 +00:00
|
|
|
reqUpdate();
|
2018-11-25 04:45:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CScreenManager::nextScreen()
|
|
|
|
{
|
2019-01-18 07:09:40 +00:00
|
|
|
if(_bSetTime) {
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(_timerScreen >= 0) {
|
|
|
|
_timerScreen++;
|
2019-01-19 11:05:14 +00:00
|
|
|
ROLLUPPERLIMIT(_timerScreen, _TimerScreens.size()-1, 0);
|
|
|
|
}
|
|
|
|
else if(_settingScreen >= 0) {
|
|
|
|
_settingScreen++;
|
|
|
|
ROLLUPPERLIMIT(_settingScreen, _SettingsScreens.size()-1, 0);
|
2019-01-18 07:09:40 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
_currentScreen++;
|
2019-01-19 11:05:14 +00:00
|
|
|
ROLLUPPERLIMIT(_currentScreen, _Screens.size()-1, 0);
|
2018-11-23 10:34:37 +00:00
|
|
|
}
|
2018-11-25 04:45:17 +00:00
|
|
|
_switchScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CScreenManager::prevScreen()
|
|
|
|
{
|
2019-01-18 07:09:40 +00:00
|
|
|
if(_bSetTime) {
|
|
|
|
}
|
|
|
|
else if(_timerScreen >=0) {
|
|
|
|
_timerScreen--;
|
2019-01-19 11:05:14 +00:00
|
|
|
ROLLLOWERLIMIT(_timerScreen, 0, _TimerScreens.size()-1);
|
|
|
|
}
|
|
|
|
else if(_settingScreen >= 0) {
|
|
|
|
_settingScreen--;
|
|
|
|
ROLLLOWERLIMIT(_settingScreen, 0, _SettingsScreens.size()-1);
|
2019-01-18 07:09:40 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
_currentScreen--;
|
2019-01-19 11:05:14 +00:00
|
|
|
ROLLLOWERLIMIT(_currentScreen, 0, _Screens.size()-1);
|
2018-11-25 04:45:17 +00:00
|
|
|
}
|
|
|
|
_switchScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CScreenManager::keyHandler(uint8_t event)
|
|
|
|
{
|
2019-01-20 03:19:38 +00:00
|
|
|
if(_DimTime == 0) {
|
|
|
|
_pDisplay->dim(false);
|
|
|
|
_DimTime = (millis() + NVstore.getDimTime()) | 1;
|
|
|
|
return; // initial press when dimmed is thrown away
|
2019-01-19 11:05:14 +00:00
|
|
|
}
|
2018-12-22 10:32:13 +00:00
|
|
|
|
2019-01-16 09:22:17 +00:00
|
|
|
_DimTime = (millis() + NVstore.getDimTime()) | 1;
|
2019-01-20 03:19:38 +00:00
|
|
|
|
|
|
|
// call handler for active screen
|
|
|
|
if(_bSetTime) _SetTimeScreen->keyHandler(event);
|
|
|
|
else if(_settingScreen >= 0) _SettingsScreens[_settingScreen]->keyHandler(event);
|
|
|
|
else if(_timerScreen >= 0) _TimerScreens[_timerScreen]->keyHandler(event);
|
|
|
|
else if(_currentScreen >= 0) _Screens[_currentScreen]->keyHandler(event);
|
|
|
|
|
2018-11-17 02:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-01-18 07:09:40 +00:00
|
|
|
void
|
2019-01-19 11:05:14 +00:00
|
|
|
CScreenManager::selectTimerScreen(bool show)
|
|
|
|
{
|
|
|
|
_timerScreen = show ? 0 : -1;
|
|
|
|
_settingScreen = -1;
|
|
|
|
_bSetTime = false;
|
|
|
|
_switchScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CScreenManager::selectSettingsScreen(bool show)
|
2019-01-18 07:09:40 +00:00
|
|
|
{
|
2019-01-19 11:05:14 +00:00
|
|
|
_settingScreen = show ? 0 : -1;
|
|
|
|
_timerScreen = -1;
|
|
|
|
_bSetTime = false;
|
|
|
|
_switchScreen();
|
2019-01-18 07:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CScreenManager::selectSetTimeScreen(bool show)
|
|
|
|
{
|
|
|
|
_bSetTime = show;
|
2019-01-19 11:05:14 +00:00
|
|
|
_settingScreen = -1;
|
|
|
|
_timerScreen = -1;
|
|
|
|
_switchScreen();
|
2019-01-18 07:09:40 +00:00
|
|
|
}
|
2018-11-17 02:08:22 +00:00
|
|
|
|
2019-01-16 09:22:17 +00:00
|
|
|
void
|
|
|
|
CScreenManager::showRebootMsg(const char* content[2], long delayTime)
|
|
|
|
{
|
|
|
|
if(_pRebootScreen == NULL)
|
|
|
|
_pRebootScreen = new CRebootScreen(*_pDisplay, *this);
|
|
|
|
|
|
|
|
_pRebootScreen->setMessage(content, delayTime);
|
|
|
|
_bReqUpdate = true;
|
|
|
|
_pDisplay->dim(false);
|
|
|
|
}
|
2019-01-18 07:09:40 +00:00
|
|
|
|