2018-11-26 11:58:15 +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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-11-17 02:08:22 +00:00
|
|
|
#ifndef __DISPLAY_H__
|
|
|
|
#define __DISPLAY_H__
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
|
2018-11-25 04:45:17 +00:00
|
|
|
class CProtocol;
|
|
|
|
class C128x64_OLED;
|
|
|
|
class CScreen;
|
2018-11-17 02:08:22 +00:00
|
|
|
|
2018-11-25 04:45:17 +00:00
|
|
|
class CScreenManager {
|
2018-11-27 10:44:47 +00:00
|
|
|
static const int _maxScreens = 5;
|
2018-11-25 04:45:17 +00:00
|
|
|
CScreen* _pScreen[_maxScreens];
|
|
|
|
CScreen* _pActiveScreen;
|
|
|
|
C128x64_OLED* _pDisplay;
|
|
|
|
int _currentScreen;
|
2018-11-27 10:44:47 +00:00
|
|
|
bool _bReqUpdate;
|
2018-11-25 04:45:17 +00:00
|
|
|
void _switchScreen();
|
|
|
|
public:
|
|
|
|
CScreenManager();
|
|
|
|
~CScreenManager();
|
|
|
|
void init();
|
2018-11-27 10:44:47 +00:00
|
|
|
void checkUpdate(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
2018-11-25 04:45:17 +00:00
|
|
|
void animate();
|
|
|
|
void nextScreen();
|
|
|
|
void prevScreen();
|
|
|
|
void keyHandler(uint8_t event);
|
2018-11-27 10:44:47 +00:00
|
|
|
void reqUpdate();
|
2018-11-25 04:45:17 +00:00
|
|
|
};
|
2018-11-23 10:34:37 +00:00
|
|
|
|
2018-11-25 04:45:17 +00:00
|
|
|
class CScreen {
|
|
|
|
protected:
|
|
|
|
C128x64_OLED& _display;
|
|
|
|
CScreenManager& _Manager;
|
|
|
|
void showBTicon();
|
|
|
|
void showWifiIcon();
|
|
|
|
void showBatteryIcon(float voltage);
|
2018-11-28 11:15:23 +00:00
|
|
|
void _drawSelectionBox(int x, int y, const char* str, int border = 3, int radius = 4);
|
|
|
|
void _drawSelectionBoxRightJustified(int x, int y, const char* str, int border = 3, int radius = 4);
|
|
|
|
void _drawSelectionBoxCentreJustified(int x, int y, const char* str, int border = 3, int radius = 4);
|
2018-11-28 19:32:26 +00:00
|
|
|
void _drawMenuText(int x, int y, bool selected, const char* str, int border = 3, int radius = 4);
|
|
|
|
void _drawMenuTextCentreJustified(int x, int y, bool selected, const char* str, int border = 3, int radius = 4);
|
|
|
|
void _drawMenuTextRightJustified(int x, int y, bool selected, const char* str, int border = 3, int radius = 4);
|
2018-11-25 04:45:17 +00:00
|
|
|
public:
|
|
|
|
CScreen(C128x64_OLED& disp, CScreenManager& mgr);
|
|
|
|
virtual ~CScreen();
|
|
|
|
virtual void animate();
|
|
|
|
virtual void show(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
|
|
|
virtual void keyHandler(uint8_t event) {};
|
|
|
|
};
|
2018-11-23 10:34:37 +00:00
|
|
|
|
2018-11-17 02:08:22 +00:00
|
|
|
#endif // __DISPLAY_H__
|