Now can define day timer operates on
This commit is contained in:
parent
283eff4288
commit
ec1631b84b
6 changed files with 163 additions and 78 deletions
|
@ -232,7 +232,7 @@ CProtocol::setVoltage_Supply(short voltsx10)
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
CProtocol::getVoltage_Supply() const
|
CProtocol::getVoltage_SupplyRaw() const
|
||||||
{
|
{
|
||||||
short val = 0;
|
short val = 0;
|
||||||
val = Heater.SupplyV_MSB & 0xff;
|
val = Heater.SupplyV_MSB & 0xff;
|
||||||
|
@ -242,6 +242,12 @@ CProtocol::getVoltage_Supply() const
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
CProtocol::getVoltage_Supply() const
|
||||||
|
{
|
||||||
|
return getVoltage_SupplyRaw() + 0.6; // compensate for series protection diode
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CProtocol::Init(int FrameMode)
|
CProtocol::Init(int FrameMode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -148,6 +148,7 @@ public:
|
||||||
void setStoredErrCode(unsigned char state) { Heater.StoredErrorCode = state; };
|
void setStoredErrCode(unsigned char state) { Heater.StoredErrorCode = state; };
|
||||||
//
|
//
|
||||||
float getVoltage_Supply() const;
|
float getVoltage_Supply() const;
|
||||||
|
float getVoltage_SupplyRaw() const;
|
||||||
void setVoltage_Supply(short voltsx10);
|
void setVoltage_Supply(short voltsx10);
|
||||||
|
|
||||||
// fan set/get
|
// fan set/get
|
||||||
|
|
|
@ -48,6 +48,13 @@ CScreen::_printMenuText(int x, int y, const char* str, bool selected, eJUSTIFY j
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CScreen::_drawMenuSelection(CRect extents, const char* str, int border, int radius)
|
||||||
|
{
|
||||||
|
_display.getTextExtents(str, extents);
|
||||||
|
extents.Expand(border);
|
||||||
|
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CScreen::_printInverted(int x, int y, const char* str, bool selected, eJUSTIFY justify)
|
CScreen::_printInverted(int x, int y, const char* str, bool selected, eJUSTIFY justify)
|
||||||
|
|
|
@ -44,6 +44,7 @@ protected:
|
||||||
void _printMenuText(int x, int y, const char* str, bool selected = false, eJUSTIFY justify = eLeftJustify, int border = 3, int radius = 4);
|
void _printMenuText(int x, int y, const char* str, bool selected = false, eJUSTIFY justify = eLeftJustify, int border = 3, int radius = 4);
|
||||||
void _printInverted(int x, int y, const char* str, bool selected, eJUSTIFY justify = eLeftJustify);
|
void _printInverted(int x, int y, const char* str, bool selected, eJUSTIFY justify = eLeftJustify);
|
||||||
void _adjustExtents(CRect& rect, eJUSTIFY justify, const char* str);
|
void _adjustExtents(CRect& rect, eJUSTIFY justify, const char* str);
|
||||||
|
void _drawMenuSelection(CRect extents, const char* str, int border = 3, int radius = 4);
|
||||||
public:
|
public:
|
||||||
CScreen(C128x64_OLED& disp, CScreenManager& mgr);
|
CScreen(C128x64_OLED& disp, CScreenManager& mgr);
|
||||||
virtual ~CScreen();
|
virtual ~CScreen();
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
#include "NVStorage.h"
|
#include "NVStorage.h"
|
||||||
#include "RTClib.h"
|
#include "RTClib.h"
|
||||||
|
|
||||||
|
const char* briefDOW[] = { "S", "M", "T", "W", "T", "F", "S" };
|
||||||
|
|
||||||
CScreen7::CScreen7(C128x64_OLED& display, CScreenManager& mgr, int instance) : CScreenHeader(display, mgr)
|
CScreen7::CScreen7(C128x64_OLED& display, CScreenManager& mgr, int instance) : CScreenHeader(display, mgr)
|
||||||
{
|
{
|
||||||
_rowSel = 0;
|
_rowSel = 0;
|
||||||
|
@ -55,14 +57,10 @@ CScreen7::show()
|
||||||
sprintf(str, " Timer %d ", _instance + 1);
|
sprintf(str, " Timer %d ", _instance + 1);
|
||||||
_printInverted(0, 16, str, true);
|
_printInverted(0, 16, str, true);
|
||||||
|
|
||||||
switch(_rowSel) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
yPos = 28;
|
|
||||||
xPos = 32;
|
|
||||||
|
|
||||||
// start
|
// start
|
||||||
_printMenuText(xPos, yPos, "Start", false, eRightJustify);
|
xPos = 18;
|
||||||
|
yPos = 28;
|
||||||
|
_printMenuText(xPos, yPos, "On", false, eRightJustify);
|
||||||
_printMenuText(xPos+18, yPos, ":");
|
_printMenuText(xPos+18, yPos, ":");
|
||||||
xPos += 6;
|
xPos += 6;
|
||||||
sprintf(str, "%02d", _timer.start.hour);
|
sprintf(str, "%02d", _timer.start.hour);
|
||||||
|
@ -72,9 +70,9 @@ CScreen7::show()
|
||||||
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==1);
|
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==1);
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
xPos = 32;
|
xPos = 18;
|
||||||
yPos = 40;
|
yPos = 40;
|
||||||
_printMenuText(xPos, yPos, "Stop", false, eRightJustify);
|
_printMenuText(xPos, yPos, "Off", false, eRightJustify);
|
||||||
_printMenuText(xPos+18, yPos, ":");
|
_printMenuText(xPos+18, yPos, ":");
|
||||||
xPos += 6;
|
xPos += 6;
|
||||||
sprintf(str, "%02d", _timer.stop.hour);
|
sprintf(str, "%02d", _timer.stop.hour);
|
||||||
|
@ -84,17 +82,9 @@ CScreen7::show()
|
||||||
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==3);
|
_printMenuText(xPos, yPos, str, _rowSel==1 && _colSel==3);
|
||||||
|
|
||||||
// control
|
// control
|
||||||
xPos = _display.width() - border;
|
|
||||||
yPos = 28;
|
|
||||||
const char* msg;
|
const char* msg;
|
||||||
if(_timer.enabled)
|
xPos = _display.width() - border;
|
||||||
msg = "Enabled";
|
_printEnabledTimers();
|
||||||
else
|
|
||||||
msg = "Disabled";
|
|
||||||
if(_rowSel == 1)
|
|
||||||
_printMenuText(xPos, yPos, msg, _colSel==4, eRightJustify);
|
|
||||||
else
|
|
||||||
_printInverted(xPos, yPos, msg, _timer.enabled, eRightJustify);
|
|
||||||
|
|
||||||
yPos = 40;
|
yPos = 40;
|
||||||
if(_timer.repeat)
|
if(_timer.repeat)
|
||||||
|
@ -110,20 +100,19 @@ CScreen7::show()
|
||||||
yPos = 53;
|
yPos = 53;
|
||||||
xPos = _display.xCentre();
|
xPos = _display.xCentre();
|
||||||
_printMenuText(xPos, yPos, "<- ->", _rowSel==0, eCentreJustify);
|
_printMenuText(xPos, yPos, "<- ->", _rowSel==0, eCentreJustify);
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CScreen7::keyHandler(uint8_t event)
|
CScreen7::keyHandler(uint8_t event)
|
||||||
{
|
{
|
||||||
|
static bool bHeld = false;
|
||||||
// handle initial key press
|
// handle initial key press
|
||||||
if(event & keyPressed) {
|
if(event & keyPressed) {
|
||||||
|
bHeld = false;
|
||||||
// press CENTRE
|
// press CENTRE
|
||||||
if(event & key_Centre) {
|
if(event & key_Centre) {
|
||||||
if(_rowSel == 1) {
|
if(_rowSel != 0) {
|
||||||
NVstore.setTimerInfo(_instance, _timer);
|
NVstore.setTimerInfo(_instance, _timer);
|
||||||
NVstore.save();
|
NVstore.save();
|
||||||
_rowSel = 0;
|
_rowSel = 0;
|
||||||
|
@ -140,6 +129,10 @@ CScreen7::keyHandler(uint8_t event)
|
||||||
_colSel--;
|
_colSel--;
|
||||||
ROLLLOWERLIMIT(_colSel, 0, 5);
|
ROLLLOWERLIMIT(_colSel, 0, 5);
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
_colSel--;
|
||||||
|
ROLLLOWERLIMIT(_colSel, 0, 6);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// press RIGHT - navigate fields, or screens
|
// press RIGHT - navigate fields, or screens
|
||||||
|
@ -152,9 +145,53 @@ CScreen7::keyHandler(uint8_t event)
|
||||||
_colSel++;
|
_colSel++;
|
||||||
ROLLUPPERLIMIT(_colSel, 5, 0);
|
ROLLUPPERLIMIT(_colSel, 5, 0);
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
_colSel++;
|
||||||
|
ROLLUPPERLIMIT(_colSel, 6, 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// press UP
|
}
|
||||||
|
|
||||||
|
// handle held down keys
|
||||||
|
if(event & keyRepeat) {
|
||||||
|
bHeld = true;
|
||||||
|
if(_rowSel == 1) {
|
||||||
|
if(_colSel < 4) {
|
||||||
|
if(event & key_Down) adjust(-1);
|
||||||
|
if(event & key_Up) adjust(+1);
|
||||||
|
}
|
||||||
|
else if(_colSel == 4) {
|
||||||
|
if(event & key_Up) {
|
||||||
|
_timer.enabled &= 0x7f; // strip next day flag
|
||||||
|
_rowSel = 2;
|
||||||
|
_colSel = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(_rowSel==2) {
|
||||||
|
if(event & key_Down) {
|
||||||
|
_rowSel = 1;
|
||||||
|
_colSel = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event & keyReleased) {
|
||||||
|
if(!bHeld) {
|
||||||
|
// released DOWN - can only leave adjustment by using OK (centre button)
|
||||||
|
int maskDOW = 0x01 << _colSel;
|
||||||
|
if(event & key_Down) {
|
||||||
|
// adjust selected item
|
||||||
|
if(_rowSel == 1)
|
||||||
|
adjust(-1);
|
||||||
|
if(_rowSel == 2) {
|
||||||
|
// adjust selected item
|
||||||
|
_timer.enabled ^= maskDOW;
|
||||||
|
_timer.enabled &= 0x7f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// released UP
|
||||||
if(event & key_Up) {
|
if(event & key_Up) {
|
||||||
switch(_rowSel) {
|
switch(_rowSel) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -166,20 +203,13 @@ CScreen7::keyHandler(uint8_t event)
|
||||||
// adjust selected item
|
// adjust selected item
|
||||||
adjust(+1);
|
adjust(+1);
|
||||||
break;
|
break;
|
||||||
}
|
case 2:
|
||||||
}
|
|
||||||
// press DOWN - can only leave adjustment by using OK (centre button)
|
|
||||||
if(event & key_Down) {
|
|
||||||
// adjust selected item
|
// adjust selected item
|
||||||
if(_rowSel == 1) adjust(-1);
|
_timer.enabled ^= maskDOW;
|
||||||
|
_timer.enabled &= 0x7f;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle held down keys
|
|
||||||
if(event & keyRepeat) {
|
|
||||||
if(_rowSel == 1) {
|
|
||||||
if(event & key_Down) adjust(-1);
|
|
||||||
if(event & key_Up) adjust(+1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,3 +259,42 @@ CScreen7::adjust(int dir)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CScreen7::_printEnabledTimers()
|
||||||
|
{
|
||||||
|
const int dayWidth = 8;
|
||||||
|
int xPos = _display.width() - border;
|
||||||
|
int yPos = 28;
|
||||||
|
|
||||||
|
if(_timer.enabled == 0x00 && _rowSel != 2) {
|
||||||
|
_printMenuText(xPos, yPos, "Disabled", _colSel==4, eRightJustify);
|
||||||
|
}
|
||||||
|
else if(_timer.enabled & 0x80) {
|
||||||
|
if(_rowSel==1 && _colSel==4)
|
||||||
|
_printMenuText(xPos, yPos, "Enabled", true, eRightJustify);
|
||||||
|
else
|
||||||
|
_printInverted(xPos, yPos, "Enabled", true, eRightJustify);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(_rowSel==1 && _colSel==4) {
|
||||||
|
_printMenuText(xPos, yPos, "Hold UP", true, eRightJustify);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xPos -= 7 * dayWidth; // back step 7 day entries
|
||||||
|
int xSel = xPos + _colSel * dayWidth;
|
||||||
|
for(int i=0; i<7; i++) {
|
||||||
|
int dayMask = 0x01 << i;
|
||||||
|
_printInverted(xPos, yPos, briefDOW[i], _timer.enabled & dayMask);
|
||||||
|
xPos += dayWidth;
|
||||||
|
}
|
||||||
|
if(_rowSel == 2) {
|
||||||
|
CRect extents;
|
||||||
|
extents.xPos = xSel;
|
||||||
|
extents.yPos = yPos;
|
||||||
|
_drawMenuSelection(extents, briefDOW[_colSel]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ class CScreen7 : public CScreenHeader {
|
||||||
int _instance;
|
int _instance;
|
||||||
sTimer _timer;
|
sTimer _timer;
|
||||||
void adjust(int dir);
|
void adjust(int dir);
|
||||||
|
void _printEnabledTimers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CScreen7(C128x64_OLED& display, CScreenManager& mgr, int instance);
|
CScreen7(C128x64_OLED& display, CScreenManager& mgr, int instance);
|
||||||
|
|
Loading…
Reference in a new issue