2019-04-06 10:45:25 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the "bluetoothheater" distribution
|
|
|
|
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
|
|
|
*
|
2019-09-08 00:14:36 +00:00
|
|
|
* Copyright (C) 2019 Ray Jones <ray@mrjones.id.au>
|
2019-04-06 10:45:25 +00:00
|
|
|
*
|
|
|
|
* 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-12-01 00:36:25 +00:00
|
|
|
#include <Arduino.h>
|
|
|
|
#include "ScreenHeader.h"
|
2018-12-16 07:34:39 +00:00
|
|
|
#include "../Protocol/Protocol.h"
|
2019-06-15 23:09:29 +00:00
|
|
|
#include "../Utility/helpers.h"
|
2019-06-30 12:39:40 +00:00
|
|
|
#include "../WiFi/BTCWifi.h"
|
2018-12-16 07:34:39 +00:00
|
|
|
#include "../Bluetooth/BluetoothAbstract.h"
|
|
|
|
#include "../Utility/NVStorage.h"
|
|
|
|
#include "../RTC/Clock.h"
|
|
|
|
#include "fonts/Arial.h"
|
|
|
|
#include "fonts/Icons.h"
|
|
|
|
#include "fonts/MiniFont.h"
|
2019-02-20 10:50:28 +00:00
|
|
|
#include "../RTC/TimerManager.h"
|
2019-07-21 11:17:54 +00:00
|
|
|
#include "../Protocol/SmartError.h"
|
|
|
|
#include "../Utility/DataFilter.h"
|
2018-12-07 11:16:04 +00:00
|
|
|
|
2018-12-01 00:36:25 +00:00
|
|
|
|
|
|
|
#define MINIFONT miniFontInfo
|
|
|
|
|
2019-07-30 09:21:55 +00:00
|
|
|
#define X_BT_ICON 12
|
2018-12-01 00:36:25 +00:00
|
|
|
#define Y_BT_ICON 0
|
2019-07-30 09:21:55 +00:00
|
|
|
#define X_WIFI_ICON 22
|
2019-04-10 23:00:36 +00:00
|
|
|
#define Y_WIFI_ICON 0
|
|
|
|
#define X_CLOCK 50
|
|
|
|
#define Y_CLOCK 0
|
2019-09-07 13:48:46 +00:00
|
|
|
#define X_TIMER_ICON 84
|
2018-12-07 11:16:04 +00:00
|
|
|
#define Y_TIMER_ICON 0
|
2019-04-10 23:00:36 +00:00
|
|
|
#define X_BATT_ICON 103
|
|
|
|
#define Y_BATT_ICON 0
|
|
|
|
|
2019-07-30 09:21:55 +00:00
|
|
|
// |0 |10 |20 |30 |40 |50 |60 |70 |80 |90 |100 |110 |120
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWOOOOOOOOOOOO xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWOOOOOOOOOOOO xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWOOOOOOOOOOOO xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWOOOOOOOOOOOO xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWOOOOOOOOOOOO xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWW xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWAAAAAAAAAAAA xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWAAAAAAAAAAAA xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWAAAAAAAAAAAA xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB WWWWWWWWWWWWAAAAAAAAAAAA xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxBBBBBB AAAAAAAAAAAA xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxx xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxx xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxx xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxx xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxx xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxx xxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
|
|
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
2018-12-01 00:36:25 +00:00
|
|
|
|
|
|
|
CScreenHeader::CScreenHeader(C128x64_OLED& disp, CScreenManager& mgr) : CScreen(disp, mgr)
|
|
|
|
{
|
2018-12-09 01:10:56 +00:00
|
|
|
_colon = false;
|
2019-08-03 02:42:49 +00:00
|
|
|
_hdrDetail = false;
|
2018-12-01 00:36:25 +00:00
|
|
|
}
|
|
|
|
|
2019-08-03 09:52:37 +00:00
|
|
|
void
|
|
|
|
CScreenHeader::onSelect()
|
|
|
|
{
|
|
|
|
CScreen::onSelect();
|
|
|
|
|
|
|
|
_batteryCount = 255;
|
|
|
|
_animateCount = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-18 23:06:12 +00:00
|
|
|
bool
|
2019-07-21 11:17:54 +00:00
|
|
|
CScreenHeader::show(bool erase)
|
2018-12-01 00:36:25 +00:00
|
|
|
{
|
2019-07-21 11:17:54 +00:00
|
|
|
if(erase)
|
|
|
|
_display.clearDisplay(); // erase everything
|
|
|
|
else {
|
|
|
|
_display.fillRect(0, 17, 128, 47, BLACK); // only erase below the header
|
|
|
|
_display.fillRect(119, 0, 9, 17, BLACK); // erase top of body thermo
|
2019-07-30 09:21:55 +00:00
|
|
|
_display.fillRect(0, 0, X_BT_ICON, 17, BLACK); // erase top of ambient thermo
|
2019-07-21 11:17:54 +00:00
|
|
|
}
|
2018-12-01 00:36:25 +00:00
|
|
|
|
|
|
|
// standard header items
|
2018-12-01 18:51:53 +00:00
|
|
|
// Bluetooth
|
2018-12-02 06:30:40 +00:00
|
|
|
showBTicon();
|
|
|
|
|
2019-06-02 09:19:08 +00:00
|
|
|
// WiFi icon is updated in animate()
|
2018-12-02 06:30:40 +00:00
|
|
|
|
2019-07-21 11:17:54 +00:00
|
|
|
// Battery is updated in animate
|
2018-12-01 00:36:25 +00:00
|
|
|
|
2018-12-02 06:30:40 +00:00
|
|
|
// clock
|
2019-05-20 12:09:59 +00:00
|
|
|
showTime();
|
2019-01-18 23:06:12 +00:00
|
|
|
|
|
|
|
return true;
|
2018-12-01 00:36:25 +00:00
|
|
|
}
|
|
|
|
|
2019-08-03 02:42:49 +00:00
|
|
|
void crackVer(char* msg, int newVer)
|
|
|
|
{
|
|
|
|
int major = (int)(newVer * 0.01);
|
|
|
|
int minor = newVer - major*100;
|
|
|
|
float prtMajor = major * 0.1;
|
|
|
|
sprintf(msg, "V%.1f.%d", prtMajor, minor);
|
|
|
|
}
|
|
|
|
|
2018-12-01 18:51:53 +00:00
|
|
|
// Animate IN/OUT arrows against the WiFi icon, according to actual web server traffic:
|
|
|
|
// an IN (down) arrow is drawn if incoming data has been detected.
|
|
|
|
// an OUT (up) arrow is drawn if outgoing data has been sent.
|
2018-12-01 18:25:10 +00:00
|
|
|
//
|
2018-12-01 18:51:53 +00:00
|
|
|
// Each arrow is drawn for one animation interval with a minimum of one clear interval
|
|
|
|
// creating a clean flash on the display.
|
|
|
|
// Both arrows may appear in the same interval.
|
2018-12-01 18:25:10 +00:00
|
|
|
// The following is a typical sequence, relative to animation ticks, note the gap
|
2018-12-01 18:51:53 +00:00
|
|
|
// that always appears in the animation interval between either arrow shown:
|
2018-12-01 18:25:10 +00:00
|
|
|
//
|
2018-12-01 18:51:53 +00:00
|
|
|
// | | | | | | | | | | | | | | | | |
|
|
|
|
// _________^^^^^________________________________________^^^^^_________________________
|
|
|
|
// ______________vvvvv_____vvvvv_______________vvvvv_____vvvvv_____vvvvv_______________
|
2018-12-01 18:25:10 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
CScreenHeader::animate()
|
|
|
|
{
|
2019-06-02 09:19:08 +00:00
|
|
|
// animate timer icon,
|
|
|
|
// inserting an update icon if new firmware available from internet web server
|
2019-05-20 12:09:59 +00:00
|
|
|
_animateCount++;
|
2019-08-03 02:42:49 +00:00
|
|
|
WRAPUPPERLIMIT(_animateCount, 11, 0);
|
|
|
|
int newVer = isUpdateAvailable(true);
|
|
|
|
if(newVer) {
|
2019-05-20 12:09:59 +00:00
|
|
|
int xPos = X_TIMER_ICON - 3;
|
|
|
|
int yPos = Y_TIMER_ICON;
|
2019-08-03 02:42:49 +00:00
|
|
|
char msg[16];
|
|
|
|
CTransientFont AF(_display, &miniFontInfo); // temporarily use a mini font
|
2019-05-20 12:09:59 +00:00
|
|
|
switch(_animateCount) {
|
|
|
|
case 0:
|
2019-06-01 00:18:31 +00:00
|
|
|
_display.fillRect(xPos, yPos, TimerIconInfo.width+3, TimerIconInfo.height, BLACK);
|
2019-08-03 02:42:49 +00:00
|
|
|
_display.fillRect(xPos-2, yPos+12, 21, 5, BLACK); // erase annotation
|
2019-05-20 12:09:59 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2019-06-01 00:18:31 +00:00
|
|
|
_drawBitmap(xPos+6, yPos, UpdateIconInfo);
|
2019-08-03 02:42:49 +00:00
|
|
|
crackVer(msg, newVer);
|
|
|
|
_printMenuText(xPos+19, yPos+12, msg, false, eRightJustify);
|
2019-05-20 12:09:59 +00:00
|
|
|
break;
|
2019-08-03 02:42:49 +00:00
|
|
|
case 2:
|
|
|
|
_display.fillRect(xPos, yPos, TimerIconInfo.width+3, TimerIconInfo.height, BLACK);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
_display.fillRect(xPos-8, yPos+12, 30, 5, BLACK); // erase version annotation
|
2019-05-20 12:09:59 +00:00
|
|
|
default:
|
|
|
|
showTimers();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-06-16 10:37:25 +00:00
|
|
|
else {
|
|
|
|
showTimers();
|
2019-08-03 02:42:49 +00:00
|
|
|
}
|
2019-07-26 12:13:46 +00:00
|
|
|
|
2019-08-03 02:42:49 +00:00
|
|
|
_batteryCount++;
|
|
|
|
WRAPUPPERLIMIT(_batteryCount, 5, 0);
|
|
|
|
int xPos = X_BATT_ICON;
|
|
|
|
int yPos = Y_BATT_ICON;
|
|
|
|
switch(_batteryCount) {
|
|
|
|
case 0:
|
|
|
|
// establish battery icon flash pattern
|
|
|
|
// > 0.5 over LVC - solid
|
|
|
|
// < 0.5 over LVC - slow flash
|
|
|
|
// < LVC - fast flash
|
|
|
|
_batteryWarn = SmartError.checkVolts(FilteredSamples.FastipVolts.getValue(), FilteredSamples.FastGlowAmps.getValue(), false);
|
|
|
|
|
|
|
|
showBatteryIcon(getBatteryVoltage(true));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if(_batteryWarn == 2)
|
|
|
|
_display.fillRect(xPos, yPos, BatteryIconInfo.width, BatteryIconInfo.height, BLACK);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if(_batteryWarn == 2)
|
2019-07-26 12:13:46 +00:00
|
|
|
showBatteryIcon(getBatteryVoltage(true));
|
2019-08-03 02:42:49 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if(_batteryWarn) // works for either < LVC, or < LVC+0.5
|
|
|
|
_display.fillRect(xPos, yPos, BatteryIconInfo.width, BatteryIconInfo.height, BLACK);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if(_batteryWarn == 2)
|
|
|
|
showBatteryIcon(getBatteryVoltage(true));
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if(_batteryWarn == 2)
|
|
|
|
_display.fillRect(xPos, yPos, BatteryIconInfo.width, BatteryIconInfo.height, BLACK);
|
|
|
|
break;
|
2019-07-26 12:13:46 +00:00
|
|
|
|
2019-06-16 10:37:25 +00:00
|
|
|
}
|
2019-05-20 12:09:59 +00:00
|
|
|
|
2019-06-02 09:19:08 +00:00
|
|
|
showWifiIcon();
|
2019-06-01 00:18:31 +00:00
|
|
|
|
2019-06-02 09:19:08 +00:00
|
|
|
return true; // true if we need to update the physical display
|
2018-12-01 18:25:10 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 00:36:25 +00:00
|
|
|
void
|
|
|
|
CScreenHeader::showBTicon()
|
|
|
|
{
|
2019-05-07 19:38:14 +00:00
|
|
|
if(getBluetoothClient().isConnected()) {
|
2019-06-01 00:18:31 +00:00
|
|
|
_drawBitmap(X_BT_ICON, Y_BT_ICON, BluetoothIconInfo, WHITE);
|
2018-12-02 06:30:40 +00:00
|
|
|
}
|
2019-08-25 20:37:41 +00:00
|
|
|
else {
|
|
|
|
_display.fillRect(X_BT_ICON, Y_BT_ICON, BluetoothIconInfo.width, BluetoothIconInfo.height, BLACK);
|
|
|
|
}
|
2018-12-01 00:36:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CScreenHeader::showWifiIcon()
|
|
|
|
{
|
2019-06-02 09:19:08 +00:00
|
|
|
if(isWifiConnected() || isWifiAP()) { // STA or AP mode active
|
|
|
|
_drawBitmap(X_WIFI_ICON, Y_WIFI_ICON, WifiWideIconInfo, WHITE, BLACK); // wide icon erases annotations!
|
|
|
|
|
|
|
|
int xPos = X_WIFI_ICON + WifiIconInfo.width + 1; // x loaction of upload/download arrows
|
|
|
|
|
|
|
|
// UP arrow animation
|
|
|
|
//
|
|
|
|
int yPos = 0;
|
|
|
|
|
|
|
|
if(hasWebServerSpoken(true)) {
|
|
|
|
// we have emitted data to the web client, show an UP arrow
|
|
|
|
_UpAnnotation.holdon = 2; // hold up arrow on for 2 cycles
|
|
|
|
_UpAnnotation.holdoff = 8; // hold blank for 8 cycles
|
|
|
|
};
|
|
|
|
|
|
|
|
if(_UpAnnotation.holdon) {
|
|
|
|
_UpAnnotation.holdon--;
|
|
|
|
_drawBitmap(xPos, yPos, WifiOutIconInfo); // add upload arrow
|
|
|
|
}
|
|
|
|
else if(_UpAnnotation.holdoff > 0) {
|
|
|
|
_UpAnnotation.holdoff--; // animation of arrow is now cleared
|
|
|
|
}
|
|
|
|
else {
|
2019-06-06 01:32:43 +00:00
|
|
|
if(NVstore.getUserSettings().enableOTA) {
|
2019-06-02 09:19:08 +00:00
|
|
|
// OTA is enabled, show OTA
|
|
|
|
// erase top right portion of wifi icon
|
|
|
|
_display.fillRect(X_WIFI_ICON+11, Y_WIFI_ICON, 2, 6, BLACK);
|
|
|
|
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
|
|
|
_display.setCursor(X_WIFI_ICON+12, Y_WIFI_ICON);
|
|
|
|
_display.print("OTA");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// low side wifi icon annotation
|
2019-01-18 03:34:32 +00:00
|
|
|
if(isWifiButton()) {
|
|
|
|
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
2019-03-24 06:38:48 +00:00
|
|
|
_display.setCursor(X_WIFI_ICON+12, Y_WIFI_ICON+6);
|
2019-01-18 03:34:32 +00:00
|
|
|
switch(isWifiButton()) {
|
|
|
|
case 1: _display.print("CFG"); break;
|
|
|
|
case 2: _display.print("HTR"); break;
|
|
|
|
case 3: _display.print("ERS"); break;
|
|
|
|
}
|
|
|
|
}
|
2019-06-02 09:19:08 +00:00
|
|
|
else {
|
|
|
|
// DOWN arrow animation
|
|
|
|
//
|
|
|
|
yPos = WifiIconInfo.height - WifiInIconInfo.height + 1;
|
|
|
|
|
|
|
|
if(hasWebClientSpoken(true)) {
|
|
|
|
// we have received data from the web client, show a DOWN arrow
|
|
|
|
_DnAnnotation.holdon = 2; // hold down arrow on for 2 cycles
|
|
|
|
_DnAnnotation.holdoff = 8; // hold blank for 8 cycles
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_DnAnnotation.holdon) {
|
|
|
|
_DnAnnotation.holdon--;
|
|
|
|
_drawBitmap(xPos, yPos, WifiInIconInfo, WHITE); // add down arrow
|
|
|
|
}
|
|
|
|
else if(_DnAnnotation.holdoff > 0) {
|
|
|
|
_DnAnnotation.holdoff--; // nothing drawn after arrow, side annotation stays clear for a while
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// no activity for a while now
|
|
|
|
if(isWifiConfigPortal()) {
|
|
|
|
// if config portal, show CFG
|
|
|
|
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
|
|
|
_display.setCursor(X_WIFI_ICON+12, Y_WIFI_ICON+6);
|
|
|
|
_display.print("CFG");
|
|
|
|
}
|
|
|
|
else if(isWifiAP()) {
|
|
|
|
// if AP only, show AP
|
|
|
|
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
|
|
|
_display.setCursor(X_WIFI_ICON+12, Y_WIFI_ICON+6);
|
|
|
|
_display.print("AP");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-02 06:30:40 +00:00
|
|
|
}
|
2018-12-01 00:36:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CScreenHeader::showBatteryIcon(float voltage)
|
|
|
|
{
|
2019-09-15 02:51:51 +00:00
|
|
|
if(NVstore.getUserSettings().menuMode < 2) {
|
2019-09-07 13:48:46 +00:00
|
|
|
_drawBitmap(X_BATT_ICON, Y_BATT_ICON, BatteryIconInfo);
|
|
|
|
char msg[16];
|
|
|
|
sprintf(msg, "%.1fV", voltage);
|
|
|
|
CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font
|
|
|
|
_display.setCursor(X_BATT_ICON + BatteryIconInfo.width/2,
|
|
|
|
Y_BATT_ICON + BatteryIconInfo.height + 2);
|
|
|
|
_display.printCentreJustified(msg);
|
|
|
|
|
|
|
|
// nominal 10.5 -> 13.5V bargraph
|
|
|
|
int Capacity = (voltage - 10.7) * 4;
|
|
|
|
if(Capacity < 0) Capacity = 0;
|
|
|
|
if(Capacity > 11) Capacity = 11;
|
|
|
|
_display.fillRect(X_BATT_ICON+2 + Capacity, Y_BATT_ICON+2, BatteryIconInfo.width-4-Capacity, 6, BLACK);
|
|
|
|
}
|
2018-12-01 00:36:25 +00:00
|
|
|
}
|
|
|
|
|
2018-12-07 11:16:04 +00:00
|
|
|
int
|
|
|
|
CScreenHeader::showTimers()
|
|
|
|
{
|
2019-08-03 02:42:49 +00:00
|
|
|
int nextTimer = CTimerManager::getNextTimer(); // timer ID and repeat flag info of next scheduled timer
|
2019-02-20 10:50:28 +00:00
|
|
|
if(nextTimer) {
|
2019-04-10 23:00:36 +00:00
|
|
|
int xPos = X_TIMER_ICON;
|
2019-08-03 02:42:49 +00:00
|
|
|
if(nextTimer & 0x80)
|
2019-09-08 01:56:22 +00:00
|
|
|
_drawBitmap(xPos, Y_TIMER_ICON, TimerIconRptInfo);
|
|
|
|
else
|
|
|
|
_drawBitmap(xPos, Y_TIMER_ICON, TimerIconInfo);
|
2019-08-03 02:42:49 +00:00
|
|
|
if(_hdrDetail) {
|
|
|
|
sTimer timerInfo;
|
|
|
|
char msg[8];
|
|
|
|
int activeTimer = CTimerManager::getActiveTimer();
|
|
|
|
if(activeTimer) {
|
|
|
|
CTimerManager::getTimer((activeTimer - 1) & 0xf, timerInfo);
|
|
|
|
sprintf(msg, "%02d:%02d", timerInfo.stop.hour, timerInfo.stop.min);
|
|
|
|
_drawBitmap(xPos-5, Y_TIMER_ICON+12, miniStopIconInfo, WHITE, BLACK);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
CTimerManager::getTimer((nextTimer - 1) & 0xf, timerInfo);
|
|
|
|
sprintf(msg, "%02d:%02d", timerInfo.start.hour, timerInfo.start.min);
|
|
|
|
_drawBitmap(xPos-5, Y_TIMER_ICON+12, miniStartIconInfo, WHITE, BLACK);
|
|
|
|
}
|
|
|
|
CTransientFont AF(_display, &miniFontInfo); // temporarily use a mini font
|
|
|
|
_printMenuText(xPos-1, Y_TIMER_ICON+12, msg);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_display.fillRect(X_TIMER_ICON-5, Y_TIMER_ICON+12, 21, 5, BLACK); // erase annotation
|
|
|
|
}
|
2019-02-20 10:50:28 +00:00
|
|
|
return 1;
|
2018-12-07 11:16:04 +00:00
|
|
|
}
|
2019-08-03 02:42:49 +00:00
|
|
|
_display.fillRect(X_TIMER_ICON-3, Y_TIMER_ICON, TimerIconInfo.width+3, TimerIconInfo.height, BLACK); // erase icon
|
|
|
|
_display.fillRect(X_TIMER_ICON-5, Y_TIMER_ICON+12, 21, 5, BLACK); // erase annotation
|
2019-02-20 10:50:28 +00:00
|
|
|
return 0;
|
2018-12-07 11:16:04 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 00:36:25 +00:00
|
|
|
|
2018-12-07 11:16:04 +00:00
|
|
|
|
|
|
|
void
|
2019-05-20 12:09:59 +00:00
|
|
|
CScreenHeader::showTime()
|
2018-12-07 11:16:04 +00:00
|
|
|
{
|
2018-12-08 22:51:16 +00:00
|
|
|
const BTCDateTime& now = Clock.get();
|
2018-12-07 22:30:55 +00:00
|
|
|
|
2018-12-07 11:16:04 +00:00
|
|
|
char msg[16];
|
2019-01-27 01:17:49 +00:00
|
|
|
if(now.day() == 0xA5) {
|
|
|
|
sprintf(msg, "No RTC");
|
|
|
|
}
|
|
|
|
else {
|
2019-09-07 13:48:46 +00:00
|
|
|
int hr = now.hour();
|
|
|
|
if(NVstore.getUserSettings().clock12hr) {
|
|
|
|
if(hr == 0)
|
|
|
|
hr = 12;
|
|
|
|
if(hr > 12) {
|
|
|
|
hr -= 12;
|
|
|
|
}
|
|
|
|
}
|
2019-01-27 01:17:49 +00:00
|
|
|
if(_colon)
|
2019-09-07 13:48:46 +00:00
|
|
|
sprintf(msg, "%02d:%02d", hr, now.minute());
|
2019-01-27 01:17:49 +00:00
|
|
|
else
|
2019-09-07 13:48:46 +00:00
|
|
|
sprintf(msg, "%02d %02d", hr, now.minute());
|
2019-01-27 01:17:49 +00:00
|
|
|
_colon = !_colon;
|
|
|
|
}
|
2018-12-09 01:10:56 +00:00
|
|
|
|
2019-09-07 13:48:46 +00:00
|
|
|
int timewidth = 0;
|
|
|
|
int xPos = X_CLOCK;
|
2018-12-07 11:16:04 +00:00
|
|
|
{
|
|
|
|
CTransientFont AF(_display, &arial_8ptFontInfo);
|
2019-09-07 13:48:46 +00:00
|
|
|
if(NVstore.getUserSettings().clock12hr)
|
|
|
|
xPos -= 3;
|
|
|
|
_display.fillRect(xPos, Y_CLOCK, 30, arial_8ptFontInfo.nBitsPerLine, BLACK);
|
|
|
|
_printMenuText(xPos, Y_CLOCK-2, msg);
|
|
|
|
CRect extents;
|
|
|
|
extents.xPos = 0;
|
|
|
|
extents.yPos = 0;
|
|
|
|
_display.getTextExtents(msg, extents);
|
|
|
|
timewidth = extents.width;
|
|
|
|
}
|
|
|
|
if(NVstore.getUserSettings().clock12hr) {
|
|
|
|
CTransientFont AF(_display, &miniFontInfo);
|
|
|
|
xPos += timewidth + 2;
|
|
|
|
_display.fillRect(xPos, Y_CLOCK, 8, 10, BLACK);
|
|
|
|
if(now.hour() >= 12)
|
|
|
|
_printMenuText(xPos, Y_CLOCK+5, "PM");
|
|
|
|
else
|
|
|
|
_printMenuText(xPos, Y_CLOCK, "AM");
|
2018-12-07 11:16:04 +00:00
|
|
|
}
|
2019-04-10 23:00:36 +00:00
|
|
|
}
|
|
|
|
|