Further work on Screen5 - Fuel/Air settings menu
This commit is contained in:
parent
36a0755005
commit
fac5c8d1ae
4 changed files with 173 additions and 72 deletions
|
@ -953,3 +953,24 @@ float getActualTemperature()
|
||||||
{
|
{
|
||||||
return fFilteredTemperature;
|
return fFilteredTemperature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getPumpMin()
|
||||||
|
{
|
||||||
|
return DefaultBTCParams.getPump_Min();
|
||||||
|
}
|
||||||
|
|
||||||
|
float getPumpMax()
|
||||||
|
{
|
||||||
|
return DefaultBTCParams.getPump_Max();
|
||||||
|
}
|
||||||
|
|
||||||
|
short getFanMin()
|
||||||
|
{
|
||||||
|
return DefaultBTCParams.getFan_Min();
|
||||||
|
}
|
||||||
|
|
||||||
|
short getFanMax()
|
||||||
|
{
|
||||||
|
return DefaultBTCParams.getFan_Max();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#include "Screen5.h"
|
#include "Screen5.h"
|
||||||
#include "BTCWifi.h"
|
#include "BTCWifi.h"
|
||||||
|
|
||||||
|
const int border = 4;
|
||||||
|
const int radius = 4;
|
||||||
|
const char* baseLabel = "<- ->";
|
||||||
|
|
||||||
CScreen5::CScreen5(C128x64_OLED& display, CScreenManager& mgr) : CScreen(display, mgr)
|
CScreen5::CScreen5(C128x64_OLED& display, CScreenManager& mgr) : CScreen(display, mgr)
|
||||||
{
|
{
|
||||||
|
@ -43,68 +46,91 @@ CScreen5::show(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
||||||
CScreen::show(CtlFrame, HtrFrame);
|
CScreen::show(CtlFrame, HtrFrame);
|
||||||
|
|
||||||
CRect extents;
|
CRect extents;
|
||||||
|
char str[16];
|
||||||
|
int yPos;
|
||||||
|
const int col2 = 90;
|
||||||
|
const int col3 = _display.width() - border;
|
||||||
|
|
||||||
_display.setCursor(0, 16);
|
_display.setCursor(0, 16);
|
||||||
_display.print("Fuel Settings:");
|
_display.print("Fuel Settings:");
|
||||||
|
|
||||||
if(_rowSel == 1) {
|
switch(_rowSel) {
|
||||||
_display.setCursor(0, 30);
|
case 0:
|
||||||
_display.print("Enter password...");
|
yPos = 28;
|
||||||
_showPassword();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
char str[16];
|
|
||||||
int yPos = 28;
|
|
||||||
const int border = 4;
|
|
||||||
const int radius = 4;
|
|
||||||
const int col2 = 90;
|
|
||||||
const int col3 = _display.width() - border;
|
|
||||||
CRect extents;
|
|
||||||
_display.setCursor(0, yPos);
|
_display.setCursor(0, yPos);
|
||||||
_display.print("Pump (Hz)");
|
_display.print("Pump (Hz)");
|
||||||
_display.setCursor(col2, yPos);
|
_display.setCursor(col2, yPos);
|
||||||
sprintf(str, "%.1f", CtlFrame.getPump_Min());
|
sprintf(str, "%.1f", CtlFrame.getPump_Min());
|
||||||
_display.printRightJustified(str);
|
_display.printRightJustified(str);
|
||||||
if(_rowSel == 3 && _colSel == 0) {
|
|
||||||
_display.getTextExtents(str, extents);
|
|
||||||
extents.xPos = col2 - extents.width;
|
|
||||||
extents.yPos = yPos;
|
|
||||||
extents.Expand(border);
|
|
||||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
|
||||||
}
|
|
||||||
_display.setCursor(col3, yPos);
|
_display.setCursor(col3, yPos);
|
||||||
sprintf(str, "%.1f", CtlFrame.getPump_Max());
|
sprintf(str, "%.1f", CtlFrame.getPump_Max());
|
||||||
_display.printRightJustified(str);
|
_display.printRightJustified(str);
|
||||||
if(_rowSel == 3 && _colSel == 1) {
|
|
||||||
_display.getTextExtents(str, extents);
|
|
||||||
extents.xPos = col3 - extents.width;
|
|
||||||
extents.yPos = yPos;
|
|
||||||
extents.Expand(border);
|
|
||||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
|
||||||
}
|
|
||||||
yPos = 40;
|
yPos = 40;
|
||||||
_display.setCursor(0, yPos);
|
_display.setCursor(0, yPos);
|
||||||
_display.print("Fan (RPM)");
|
_display.print("Fan (RPM)");
|
||||||
_display.setCursor(col2, yPos);
|
_display.setCursor(col2, yPos);
|
||||||
sprintf(str, "%d", CtlFrame.getFan_Min());
|
sprintf(str, "%d", CtlFrame.getFan_Min());
|
||||||
_display.printRightJustified(str);
|
_display.printRightJustified(str);
|
||||||
if(_rowSel == 2 && _colSel == 0) {
|
|
||||||
_display.getTextExtents(str, extents);
|
|
||||||
extents.xPos = col2 - extents.width;
|
|
||||||
extents.yPos = yPos;
|
|
||||||
extents.Expand(border);
|
|
||||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
|
||||||
}
|
|
||||||
_display.setCursor(col3, yPos);
|
_display.setCursor(col3, yPos);
|
||||||
sprintf(str, "%d", CtlFrame.getFan_Max());
|
sprintf(str, "%d", CtlFrame.getFan_Max());
|
||||||
_display.printRightJustified(str);
|
_display.printRightJustified(str);
|
||||||
if(_rowSel == 2 && _colSel == 1) {
|
break;
|
||||||
_display.getTextExtents(str, extents);
|
case 1:
|
||||||
extents.xPos = col3 - extents.width;
|
_display.setCursor(_display.xCentre(), 30);
|
||||||
extents.yPos = yPos;
|
_display.printCentreJustified("Enter password...");
|
||||||
extents.Expand(border);
|
_showPassword();
|
||||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
break;
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
_display.clearDisplay();
|
||||||
|
//50, 38, 26, 14
|
||||||
|
yPos = border + 36;
|
||||||
|
// Pump Minimum adjustment
|
||||||
|
_display.setCursor(0, yPos);
|
||||||
|
_display.print("Pump Min");
|
||||||
|
_display.setCursor(col3, yPos);
|
||||||
|
sprintf(str, "%.1f", adjPump[0]);
|
||||||
|
_display.printRightJustified(str);
|
||||||
|
if(_rowSel == 2) {
|
||||||
|
_drawSelectionBox(col3, yPos, str);
|
||||||
}
|
}
|
||||||
|
// Pump Maximum adjustment
|
||||||
|
yPos = border + 24;
|
||||||
|
_display.setCursor(0, yPos);
|
||||||
|
_display.print("Pump Hz Max");
|
||||||
|
_display.setCursor(col3, yPos);
|
||||||
|
sprintf(str, "%.1f", adjPump[1]);
|
||||||
|
_display.printRightJustified(str);
|
||||||
|
if(_rowSel == 3) {
|
||||||
|
_drawSelectionBox(col3, yPos, str);
|
||||||
|
}
|
||||||
|
// Fan Minimum adjustment
|
||||||
|
yPos = border + 12;
|
||||||
|
_display.setCursor(0, yPos);
|
||||||
|
_display.print("Fan Min");
|
||||||
|
_display.setCursor(col3, yPos);
|
||||||
|
sprintf(str, "%d", adjFan[0]);
|
||||||
|
_display.printRightJustified(str);
|
||||||
|
if(_rowSel == 4) {
|
||||||
|
_drawSelectionBox(col3, yPos, str);
|
||||||
|
}
|
||||||
|
// Fan Maximum adjustment
|
||||||
|
yPos = border;
|
||||||
|
_display.setCursor(0, yPos);
|
||||||
|
_display.print("Fan RPM Max");
|
||||||
|
_display.setCursor(col3, yPos);
|
||||||
|
sprintf(str, "%d", adjFan[1]);
|
||||||
|
_display.printRightJustified(str);
|
||||||
|
if(_rowSel == 5) {
|
||||||
|
_drawSelectionBox(col3, yPos, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
yPos = 53;
|
||||||
|
_display.setCursor(_display.xCentre(), yPos);
|
||||||
|
_display.printCentreJustified(baseLabel);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_display.display();
|
_display.display();
|
||||||
|
@ -133,6 +159,10 @@ CScreen5::keyHandler(uint8_t event)
|
||||||
_bPWOK = true;
|
_bPWOK = true;
|
||||||
_rowSel = 2;
|
_rowSel = 2;
|
||||||
_colSel = 0;
|
_colSel = 0;
|
||||||
|
adjPump[0] = getPumpMin();
|
||||||
|
adjPump[1] = getPumpMax();
|
||||||
|
adjFan[0] = getFanMin();
|
||||||
|
adjFan[1] = getFanMax();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(int i= 0; i < 4; i++)
|
for(int i= 0; i < 4; i++)
|
||||||
|
@ -157,7 +187,9 @@ CScreen5::keyHandler(uint8_t event)
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
_colSel = 0;
|
case 4:
|
||||||
|
case 5:
|
||||||
|
_adjustSetting(-1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,11 +201,13 @@ CScreen5::keyHandler(uint8_t event)
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
_colSel++;
|
_colSel++;
|
||||||
UPPERLIMIT(_colSel, 3);
|
UPPERLIMIT(_colSel, 5);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
_colSel = 1;
|
case 4:
|
||||||
|
case 5:
|
||||||
|
_adjustSetting(+1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,16 +215,17 @@ CScreen5::keyHandler(uint8_t event)
|
||||||
if(event & key_Up) {
|
if(event & key_Up) {
|
||||||
switch(_rowSel) {
|
switch(_rowSel) {
|
||||||
case 0:
|
case 0:
|
||||||
_rowSel = 1;
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
_rowSel++;
|
||||||
_colSel = 0;
|
_colSel = 0;
|
||||||
|
UPPERLIMIT(_rowSel, 5);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
_PWdig[_colSel]++;
|
_PWdig[_colSel]++;
|
||||||
ROLLUPPERLIMIT(_PWdig[_colSel], 9, 0);
|
ROLLUPPERLIMIT(_PWdig[_colSel], 9, 0);
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
_rowSel = 3;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// press DOWN
|
// press DOWN
|
||||||
|
@ -201,10 +236,13 @@ CScreen5::keyHandler(uint8_t event)
|
||||||
ROLLLOWERLIMIT(_PWdig[_colSel], 0, 9);
|
ROLLLOWERLIMIT(_PWdig[_colSel], 0, 9);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
_rowSel--; // force skip over line 1 (password)
|
_rowSel = 0;
|
||||||
// deliberately not breaking
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
_rowSel--;
|
_rowSel--;
|
||||||
|
_colSel = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +273,6 @@ CScreen5::_showPassword()
|
||||||
for(int i =0 ; i < 4; i++) {
|
for(int i =0 ; i < 4; i++) {
|
||||||
|
|
||||||
int xPos = _display.xCentre() - (2 - i) * (charWidth + spaceWidth);
|
int xPos = _display.xCentre() - (2 - i) * (charWidth + spaceWidth);
|
||||||
// Serial.print(" xPos="); Serial.print(xPos);
|
|
||||||
char str[8];
|
char str[8];
|
||||||
|
|
||||||
if(_PWdig[i] < 0) {
|
if(_PWdig[i] < 0) {
|
||||||
|
@ -251,13 +288,47 @@ CScreen5::_showPassword()
|
||||||
// draw selection box
|
// draw selection box
|
||||||
extents.Expand(border);
|
extents.Expand(border);
|
||||||
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
||||||
// // draw white background
|
|
||||||
// extents.Expand(1);
|
|
||||||
// _display.fillRect(extents.xPos, extents.yPos, extents.width, extents.height, WHITE);
|
|
||||||
extents.Expand(-border);
|
extents.Expand(-border);
|
||||||
}
|
}
|
||||||
_display.setCursor(extents.xPos, extents.yPos);
|
_display.setCursor(extents.xPos, extents.yPos);
|
||||||
_display.print(str);
|
_display.print(str);
|
||||||
}
|
}
|
||||||
// Serial.println("");
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CScreen5::_drawSelectionBox(int x, int y, const char* str, int border, int radius)
|
||||||
|
{
|
||||||
|
CRect extents;
|
||||||
|
_display.getTextExtents(str, extents);
|
||||||
|
extents.xPos = x - extents.width;
|
||||||
|
extents.yPos = y;
|
||||||
|
extents.Expand(border);
|
||||||
|
_display.drawRoundRect(extents.xPos, extents.yPos, extents.width, extents.height, radius, WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CScreen5::_adjustSetting(int dir)
|
||||||
|
{
|
||||||
|
switch(_rowSel) {
|
||||||
|
case 2:
|
||||||
|
adjPump[0] += (float(dir) * 0.1f);
|
||||||
|
LOWERLIMIT(adjPump[0], 0.5f);
|
||||||
|
UPPERLIMIT(adjPump[0], 10.f);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
adjPump[1] += (float(dir) * 0.1f);
|
||||||
|
LOWERLIMIT(adjPump[1], 0.5f);
|
||||||
|
UPPERLIMIT(adjPump[1], 10.f);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
adjFan[0] += dir * 10;
|
||||||
|
LOWERLIMIT(adjFan[0], 1000);
|
||||||
|
UPPERLIMIT(adjFan[0], 5000);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
adjFan[1] += dir * 10;
|
||||||
|
LOWERLIMIT(adjFan[1], 1000);
|
||||||
|
UPPERLIMIT(adjFan[1], 5000);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -28,9 +28,14 @@ class CProtocol;
|
||||||
class CScreen5 : public CScreen {
|
class CScreen5 : public CScreen {
|
||||||
bool _bPWOK;
|
bool _bPWOK;
|
||||||
int _PWdig[4];
|
int _PWdig[4];
|
||||||
|
float adjPump[2];
|
||||||
|
short adjFan[2];
|
||||||
int _rowSel;
|
int _rowSel;
|
||||||
int _colSel;
|
int _colSel;
|
||||||
void _showPassword();
|
void _showPassword();
|
||||||
|
void _drawSelectionBox(int x, int y, const char* str, int border = 3, int radius = 4);
|
||||||
|
void _adjustSetting(int dir);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CScreen5(C128x64_OLED& display, CScreenManager& mgr);
|
CScreen5(C128x64_OLED& display, CScreenManager& mgr);
|
||||||
void show(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
void show(const CProtocol& CtlFrame, const CProtocol& HtrFrame);
|
||||||
|
|
|
@ -35,6 +35,10 @@ extern float getFixedHz();
|
||||||
extern float getPumpHz();
|
extern float getPumpHz();
|
||||||
extern void reqPumpPrime(bool on);
|
extern void reqPumpPrime(bool on);
|
||||||
extern float getActualTemperature();
|
extern float getActualTemperature();
|
||||||
|
extern float getPumpMin();
|
||||||
|
extern float getPumpMax();
|
||||||
|
extern short getFanMin();
|
||||||
|
extern short getFanMax();
|
||||||
|
|
||||||
#define LOWERLIMIT(A, B) if(A < B) A = B
|
#define LOWERLIMIT(A, B) if(A < B) A = B
|
||||||
#define UPPERLIMIT(A, B) if(A > B) A = B
|
#define UPPERLIMIT(A, B) if(A > B) A = B
|
||||||
|
|
Loading…
Reference in a new issue