Added large clock screen
This commit is contained in:
parent
069633c61f
commit
2a7e3fce1b
|
@ -105,6 +105,7 @@
|
|||
#include <time.h>
|
||||
#include "RTClib.h"
|
||||
#include "Wire.h"
|
||||
#include "BTCDateTime.h"
|
||||
|
||||
#define FAILEDSSID "BTCESP32"
|
||||
#define FAILEDPASSWORD "thereisnospoon"
|
||||
|
@ -170,7 +171,7 @@ bool hasOEMController = false;
|
|||
//const CProtocol* pRxFrame = NULL;
|
||||
//const CProtocol* pTxFrame = NULL;
|
||||
CProtocolPackage HeaterData;
|
||||
DateTime currentTime;
|
||||
BTCDateTime currentTime;
|
||||
|
||||
unsigned long moderator;
|
||||
bool bUpdateDisplay = false;
|
||||
|
@ -1007,7 +1008,7 @@ void checkRTC()
|
|||
}
|
||||
}
|
||||
|
||||
const DateTime& getCurrentTime()
|
||||
const BTCDateTime& getCurrentTime()
|
||||
{
|
||||
return currentTime;
|
||||
}
|
||||
|
|
|
@ -34,13 +34,10 @@
|
|||
#include "Screen6.h"
|
||||
#include "RTClib.h"
|
||||
#include "Arial.h"
|
||||
#include "BTCDateTime.h"
|
||||
|
||||
extern RTC_DS3231 rtc;
|
||||
|
||||
static char daysOfTheWeek[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||
static char months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
static char monthDays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
int daysInMonth(int month, int year);
|
||||
|
||||
CScreen6::CScreen6(C128x64_OLED& display, CScreenManager& mgr) : CScreenHeader(display, mgr)
|
||||
{
|
||||
|
@ -49,6 +46,11 @@ CScreen6::CScreen6(C128x64_OLED& display, CScreenManager& mgr) : CScreenHeader(d
|
|||
_nextT = millis();
|
||||
}
|
||||
|
||||
void
|
||||
CScreen6::showTime(int)
|
||||
{
|
||||
// override and DO NOTHING!
|
||||
}
|
||||
|
||||
void
|
||||
CScreen6::show()
|
||||
|
@ -66,16 +68,11 @@ CScreen6::show()
|
|||
|
||||
_printInverted(0, 16, " Clock ", true);
|
||||
|
||||
const DateTime& now = getCurrentTime();
|
||||
const BTCDateTime& now = getCurrentTime();
|
||||
switch(_rowSel) {
|
||||
case 0:
|
||||
// update printable values
|
||||
_month = now.month();
|
||||
_year = now.year();
|
||||
_day = now.day();
|
||||
_hour = now.hour();
|
||||
_min = now.minute();
|
||||
_sec = now.second();
|
||||
working = now;
|
||||
// DELIBERATE DROP THROUGH HERE
|
||||
case 1:
|
||||
yPos = 28;
|
||||
|
@ -83,30 +80,30 @@ CScreen6::show()
|
|||
// date
|
||||
if(_rowSel==0) {
|
||||
xPos = 20;
|
||||
_printMenuText(xPos, yPos, daysOfTheWeek[now.dayOfTheWeek()]);
|
||||
_printMenuText(xPos, yPos, working.dowStr());
|
||||
}
|
||||
|
||||
sprintf(str, "%d", _day);
|
||||
sprintf(str, "%d", working.day());
|
||||
xPos += 20 + 12;
|
||||
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==0, eRightJustify);
|
||||
xPos += 4;
|
||||
_printMenuText(xPos, yPos, months[_month-1], _rowSel==1 && _colSel==1);
|
||||
_printMenuText(xPos, yPos, working.monthStr(), _rowSel==1 && _colSel==1);
|
||||
xPos += 22;
|
||||
sprintf(str, "%d", _year);
|
||||
sprintf(str, "%d", working.year());
|
||||
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==2);
|
||||
// time
|
||||
yPos = 40;
|
||||
xPos = 26;
|
||||
sprintf(str, "%02d", _hour);
|
||||
sprintf(str, "%02d", working.hour());
|
||||
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==3);
|
||||
xPos += 16;
|
||||
_printMenuText(xPos, yPos, ":");
|
||||
xPos += 8;
|
||||
sprintf(str, "%02d", _min);
|
||||
sprintf(str, "%02d", working.minute());
|
||||
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==4);
|
||||
xPos += 16;
|
||||
_printMenuText(xPos, yPos, ":");
|
||||
sprintf(str, "%02d", _sec);
|
||||
sprintf(str, "%02d", working.second());
|
||||
xPos += 8;
|
||||
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==5);
|
||||
if(_rowSel==1)
|
||||
|
@ -133,7 +130,7 @@ CScreen6::keyHandler(uint8_t event)
|
|||
case 1:
|
||||
_rowSel = 0;
|
||||
if(_colSel == 6) { // set the RTC!
|
||||
rtc.adjust(DateTime(_year, _month, _day, _hour, _min, _sec));
|
||||
rtc.adjust(working);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -201,54 +198,28 @@ CScreen6::keyHandler(uint8_t event)
|
|||
_ScreenManager.reqUpdate();
|
||||
}
|
||||
|
||||
int daysInMonth(int month, int year)
|
||||
{
|
||||
if(month >= 1 && month <= 12) {
|
||||
int days = monthDays[month-1];
|
||||
if((month == 2) && ((year & 0x03) == 0))
|
||||
days++;
|
||||
return days;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
CScreen6::adjTimeDate(int dir)
|
||||
{
|
||||
int days;
|
||||
switch(_colSel) {
|
||||
case 0:
|
||||
_day += dir;
|
||||
days = daysInMonth(_month, _year);
|
||||
ROLLUPPERLIMIT(_day, days, 1);
|
||||
ROLLLOWERLIMIT(_day, 1, days);
|
||||
working.adjustDay(dir);
|
||||
break;
|
||||
case 1:
|
||||
_month += dir;
|
||||
ROLLUPPERLIMIT(_month, 12, 1);
|
||||
ROLLLOWERLIMIT(_month, 1, 12);
|
||||
days = daysInMonth(_month, _year); // trap shorter months
|
||||
UPPERLIMIT(_day, days);
|
||||
working.adjustMonth(dir);
|
||||
break;
|
||||
case 2:
|
||||
_year += dir;
|
||||
days = daysInMonth(_month, _year);
|
||||
UPPERLIMIT(_day, days); // pick up 29 Feb
|
||||
working.adjustYear(dir);
|
||||
break;
|
||||
case 3:
|
||||
_hour += dir;
|
||||
ROLLUPPERLIMIT(_hour, 23, 0);
|
||||
ROLLLOWERLIMIT(_hour, 0, 23);
|
||||
working.adjustHour(dir);
|
||||
break;
|
||||
case 4:
|
||||
_min += dir;
|
||||
ROLLUPPERLIMIT(_min, 59, 0);
|
||||
ROLLLOWERLIMIT(_min, 0, 59);
|
||||
working.adjustMinute(dir);
|
||||
break;
|
||||
case 5:
|
||||
_sec += dir;
|
||||
ROLLUPPERLIMIT(_sec, 59, 0);
|
||||
ROLLLOWERLIMIT(_sec, 0, 59);
|
||||
working.adjustSecond(dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "stdint.h"
|
||||
#include "ScreenHeader.h"
|
||||
#include "BTCDateTime.h"
|
||||
|
||||
class C128x64_OLED;
|
||||
class CScreenManager;
|
||||
|
@ -30,12 +31,13 @@ class CScreen6 : public CScreenHeader {
|
|||
int _rowSel;
|
||||
int _colSel;
|
||||
unsigned long _nextT;
|
||||
int _month, _year, _day, _hour, _min, _sec;
|
||||
BTCDateTime working;
|
||||
|
||||
void adjTimeDate(int dir);
|
||||
|
||||
public:
|
||||
CScreen6(C128x64_OLED& display, CScreenManager& mgr);
|
||||
void show();
|
||||
void showTime(int);
|
||||
void keyHandler(uint8_t event);
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "NVStorage.h"
|
||||
#include "RTClib.h"
|
||||
#include "Arial.h"
|
||||
#include "BTCDateTime.h"
|
||||
|
||||
|
||||
#define MINIFONT miniFontInfo
|
||||
|
@ -191,7 +192,7 @@ CScreenHeader::showTimers()
|
|||
void
|
||||
CScreenHeader::showTime(int numTimers)
|
||||
{
|
||||
const DateTime& now = getCurrentTime();
|
||||
const BTCDateTime& now = getCurrentTime();
|
||||
|
||||
char msg[16];
|
||||
if(now.second() & 0x01)
|
||||
|
|
|
@ -36,7 +36,7 @@ protected:
|
|||
void showWifiIcon();
|
||||
void showBatteryIcon(float voltage);
|
||||
int showTimers();
|
||||
void showTime(int numTimers); // x location depends upon how many timers are active
|
||||
virtual void showTime(int numTimers); // x location depends upon how many timers are active
|
||||
public:
|
||||
CScreenHeader(C128x64_OLED& disp, CScreenManager& mgr);
|
||||
virtual void show();
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "Screen5.h"
|
||||
#include "Screen6.h"
|
||||
#include "Screen7.h"
|
||||
#include "Screen8.h"
|
||||
|
||||
//
|
||||
// **** NOTE: If trying use hardware SPI on the ESP32 there are two very lame
|
||||
|
@ -143,12 +144,13 @@ CScreenManager::init()
|
|||
_pDisplay->display();
|
||||
|
||||
DebugPort.println("Creating Screens");
|
||||
_Screens.push_back(new CScreen1(*_pDisplay, *this));
|
||||
_Screens.push_back(new CScreen2(*_pDisplay, *this));
|
||||
_Screens.push_back(new CScreen3(*_pDisplay, *this));
|
||||
_Screens.push_back(new CScreen4(*_pDisplay, *this));
|
||||
_Screens.push_back(new CScreen5(*_pDisplay, *this));
|
||||
_Screens.push_back(new CScreen6(*_pDisplay, *this));
|
||||
_Screens.push_back(new CScreen1(*_pDisplay, *this)); // detail control
|
||||
_Screens.push_back(new CScreen2(*_pDisplay, *this)); // basic control
|
||||
_Screens.push_back(new CScreen8(*_pDisplay, *this)); // clock
|
||||
_Screens.push_back(new CScreen3(*_pDisplay, *this)); // mode / priming
|
||||
_Screens.push_back(new CScreen4(*_pDisplay, *this)); // comms info
|
||||
_Screens.push_back(new CScreen5(*_pDisplay, *this)); // tuning
|
||||
_Screens.push_back(new CScreen6(*_pDisplay, *this)); // clock set
|
||||
_Screens.push_back(new CScreen7(*_pDisplay, *this, 0)); // timer 1
|
||||
_Screens.push_back(new CScreen7(*_pDisplay, *this, 1)); // timer 2
|
||||
_currentScreen = 1;
|
||||
|
|
|
@ -193,12 +193,39 @@ const uint8_t tahoma_16ptBitmaps[] PROGMEM =
|
|||
0xE0, 0x07, // ### ###
|
||||
0x70, 0x0E, // ### ###
|
||||
0x78, 0x1E, // #### ####
|
||||
|
||||
// @268 ':' (4 pixels wide)
|
||||
0x3C, 0x3C, // #### ####
|
||||
0x3C, 0x3C, // #### ####
|
||||
0x3C, 0x3C, // #### ####
|
||||
0x3C, 0x3C, // #### ####
|
||||
|
||||
// @276 ' ' (4 pixels wide)
|
||||
0x00, 0x00, //
|
||||
0x00, 0x00, //
|
||||
0x00, 0x00, //
|
||||
0x00, 0x00, //
|
||||
|
||||
};
|
||||
|
||||
// Character descriptors for Tahoma 16pt
|
||||
// { [Char width in bits], [Char height in bits], [Offset into tahoma_16ptCharBitmaps in bytes] }
|
||||
const FONT_CHAR_INFO tahoma_16ptDescriptors[] PROGMEM =
|
||||
{
|
||||
{4, 16, 276}, // ' '
|
||||
{0, 0, 0}, // '!'
|
||||
{0, 0, 0}, // '"'
|
||||
{0, 0, 0}, // '#'
|
||||
{0, 0, 0}, // '$'
|
||||
{0, 0, 0}, // '%'
|
||||
{0, 0, 0}, // '&'
|
||||
{0, 0, 0}, // '''
|
||||
{0, 0, 0}, // '('
|
||||
{0, 0, 0}, // ')'
|
||||
{0, 0, 0}, // '*'
|
||||
{0, 0, 0}, // '+'
|
||||
{0, 0, 0}, // ,
|
||||
{0, 0, 0}, // -
|
||||
{4, 16, 0}, // '.'
|
||||
{0, 0, 0}, // '/'
|
||||
{11, 16, 8}, // '0'
|
||||
|
@ -211,7 +238,7 @@ const FONT_CHAR_INFO tahoma_16ptDescriptors[] PROGMEM =
|
|||
{11, 16, 162}, // '7'
|
||||
{11, 16, 184}, // '8'
|
||||
{11, 16, 206}, // '9'
|
||||
{0, 0, 0}, // ':'
|
||||
{4, 16, 268}, // ':'
|
||||
{0, 0, 0}, // ';'
|
||||
{0, 0, 0}, // '<'
|
||||
{0, 0, 0}, // '='
|
||||
|
@ -257,7 +284,7 @@ const FONT_CHAR_INFO tahoma_16ptDescriptors[] PROGMEM =
|
|||
const FONT_INFO tahoma_16ptFontInfo =
|
||||
{
|
||||
16, // Character height
|
||||
'.', // Start character
|
||||
' ', // Start character
|
||||
'`', // End character
|
||||
2, // Width, in pixels, of space character
|
||||
tahoma_16ptDescriptors, // Character descriptor array
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
*/
|
||||
|
||||
class CProtocolPackage;
|
||||
class DateTime;
|
||||
class BTCDateTime;
|
||||
|
||||
|
||||
extern void ToggleOnOff();
|
||||
extern void requestOn();
|
||||
|
@ -37,7 +38,7 @@ extern void setFanMin(short);
|
|||
extern void setFanMax(short);
|
||||
extern void saveNV();
|
||||
extern const CProtocolPackage& getHeaterInfo();
|
||||
extern const DateTime& getCurrentTime();
|
||||
extern const BTCDateTime& getCurrentTime();
|
||||
|
||||
#define LOWERLIMIT(A, B) if(A < B) A = B
|
||||
#define UPPERLIMIT(A, B) if(A > B) A = B
|
||||
|
|
Loading…
Reference in a new issue