Trend indicator for voltage page
This commit is contained in:
parent
7958810e7d
commit
27b471b0b8
|
@ -81,9 +81,9 @@ void sensorTask(void *param){
|
|||
bool INA226_1_ready = false; // INA226_1 initialized and ready to use
|
||||
|
||||
// Create integer arrays for average building
|
||||
int avgsize = 300;
|
||||
constexpr int arrayBatV{300};
|
||||
constexpr int arrayBatC{300};
|
||||
const int avgsize = 300;
|
||||
constexpr int arrayBatV{avgsize};
|
||||
constexpr int arrayBatC{avgsize};
|
||||
movingAvg batV(arrayBatV);
|
||||
movingAvg batC(arrayBatC);
|
||||
batV.begin();
|
||||
|
|
|
@ -167,15 +167,16 @@ public:
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -196,15 +196,16 @@ class PageBME280 : public Page
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -54,12 +54,12 @@ class PageBattery : public Page
|
|||
bool simulation = config->getBool(config->useSimuData);
|
||||
|
||||
// Get voltage value
|
||||
String name1 = "BatVolt"; // Value name
|
||||
String name1 = "VBat"; // Value name
|
||||
if(String(powsensor1) == "INA219" || String(powsensor1) == "INA226"){
|
||||
// Switch average values
|
||||
switch (average) {
|
||||
case 0:
|
||||
value1 = commonData.data.batteryVoltage; // Real data
|
||||
value1 = commonData.data.batteryVoltage; // Live data
|
||||
break;
|
||||
case 1:
|
||||
value1 = commonData.data.batteryVoltage10; // Average 10s
|
||||
|
@ -84,11 +84,11 @@ class PageBattery : public Page
|
|||
String unit1 = "V"; // Unit of value
|
||||
|
||||
// Get current value
|
||||
String name2 = "BatCurr"; // Value name
|
||||
String name2 = "IBat"; // Value name
|
||||
if(String(powsensor1) == "INA219" || String(powsensor1) == "INA226"){
|
||||
switch (average) {
|
||||
case 0:
|
||||
value2 = commonData.data.batteryCurrent; // Real data
|
||||
value2 = commonData.data.batteryCurrent; // Live data
|
||||
break;
|
||||
case 1:
|
||||
value2 = commonData.data.batteryCurrent10; // Average 10s
|
||||
|
@ -113,11 +113,11 @@ class PageBattery : public Page
|
|||
String unit2 = "A"; // Unit of value
|
||||
|
||||
// Get power value
|
||||
String name3 = "BatPow"; // Value name
|
||||
String name3 = "PBat"; // Value name
|
||||
if(String(powsensor1) == "INA219" || String(powsensor1) == "INA226"){
|
||||
switch (average) {
|
||||
case 0:
|
||||
value3 = commonData.data.batteryPower; // Real data
|
||||
value3 = commonData.data.batteryPower; // Live data
|
||||
break;
|
||||
case 1:
|
||||
value3 = commonData.data.batteryPower10; // Average 10s
|
||||
|
|
|
@ -335,15 +335,16 @@ public:
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -268,15 +268,16 @@ class PageDST810 : public Page
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -308,15 +308,16 @@ class PageForValues : public Page
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -308,15 +308,16 @@ class PageForValues2 : public Page
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -227,15 +227,16 @@ public:
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -119,15 +119,16 @@ class PageOneValue : public Page{
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -218,15 +218,16 @@ public:
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -247,15 +247,16 @@ class PageThreeValues : public Page
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -186,15 +186,16 @@ class PageTwoValues : public Page
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,19 +2,38 @@
|
|||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60ExtensionPort.h"
|
||||
#include "movingAvg.h" // Lib for moving average building
|
||||
|
||||
class PageVoltage : public Page
|
||||
{
|
||||
bool init = false; // Marker for init done
|
||||
bool keylock = false; // Keylock
|
||||
int average = 0; // Average type [0...3], 0=off, 1=10s, 2=60s, 3=300s
|
||||
bool trend = true; // Trend indicator [0|1], 0=off, 1=on
|
||||
double raw = 0;
|
||||
|
||||
public:
|
||||
PageVoltage(CommonData &common){
|
||||
common.logger->logDebug(GwLog::LOG,"Show PageVoltage");
|
||||
}
|
||||
virtual int handleKey(int key){
|
||||
if(key == 11){ // Code for keylock
|
||||
keylock = !keylock; // Toggle keylock
|
||||
return 0; // Commit the key
|
||||
// Change average
|
||||
if(key == 1){
|
||||
average ++;
|
||||
average = average % 4; // Modulo 4
|
||||
return 0; // Commit the key
|
||||
}
|
||||
|
||||
// Trend indicator
|
||||
if(key == 5){
|
||||
trend = !trend;
|
||||
return 0; // Commit the key
|
||||
}
|
||||
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
keylock = !keylock; // Toggle keylock
|
||||
return 0; // Commit the key
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
@ -32,10 +51,43 @@ public:
|
|||
String batVoltage = config->getString(config->batteryVoltage);
|
||||
String batType = config->getString(config->batteryType);
|
||||
String backlightMode = config->getString(config->backlight);
|
||||
|
||||
double value1 = 0;
|
||||
double valueTrend = 0; // Average over 10 values
|
||||
|
||||
// Get voltage value
|
||||
String name1 = "VBat";
|
||||
double value1 = commonData.data.batteryVoltage; // Live supplay voltage
|
||||
|
||||
// Create trend value
|
||||
if(init == false){ // Load start values for first page run
|
||||
valueTrend = commonData.data.batteryVoltage10;
|
||||
init = true;
|
||||
}
|
||||
else{ // Reading trend value
|
||||
valueTrend = commonData.data.batteryVoltage10;
|
||||
}
|
||||
|
||||
// Get raw value for trend indicator
|
||||
raw = commonData.data.batteryVoltage; // Live data
|
||||
|
||||
// Switch average values
|
||||
switch (average) {
|
||||
case 0:
|
||||
value1 = commonData.data.batteryVoltage; // Live data
|
||||
break;
|
||||
case 1:
|
||||
value1 = commonData.data.batteryVoltage10; // Average 10s
|
||||
break;
|
||||
case 2:
|
||||
value1 = commonData.data.batteryVoltage60; // Average 60s
|
||||
break;
|
||||
case 3:
|
||||
value1 = commonData.data.batteryVoltage300; // Average 300s
|
||||
break;
|
||||
default:
|
||||
value1 = commonData.data.batteryVoltage; // Default
|
||||
break;
|
||||
}
|
||||
bool valid1 = true;
|
||||
|
||||
// Optical warning by limit violation
|
||||
|
@ -101,8 +153,8 @@ public:
|
|||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold32pt7b);
|
||||
display.setCursor(20, 100);
|
||||
display.print(name1); // Page name
|
||||
|
||||
display.print(name1); // Value name
|
||||
|
||||
// Show unit
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold20pt7b);
|
||||
|
@ -115,6 +167,28 @@ public:
|
|||
display.setCursor(295, 100);
|
||||
display.print(batType);
|
||||
|
||||
// Show average settings
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(320, 100);
|
||||
switch (average) {
|
||||
case 0:
|
||||
display.print("Avg: 1s");
|
||||
break;
|
||||
case 1:
|
||||
display.print("Avg: 10s");
|
||||
break;
|
||||
case 2:
|
||||
display.print("Avg: 60s");
|
||||
break;
|
||||
case 3:
|
||||
display.print("Avg: 300s");
|
||||
break;
|
||||
default:
|
||||
display.print("Avg: 1s");
|
||||
break;
|
||||
}
|
||||
|
||||
// Reading bus data or using simulation data
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&DSEG7Classic_BoldItalic60pt7b);
|
||||
|
@ -148,18 +222,44 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// Trend indicator
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold32pt7b);
|
||||
if(trend == true){
|
||||
display.setCursor(310, 240);
|
||||
display.print(" ");
|
||||
if(int(raw * 10) > int(valueTrend * 10)){
|
||||
display.setCursor(310, 240);
|
||||
display.print("+ ");
|
||||
}
|
||||
if(int(raw * 10) < int(valueTrend * 10)){
|
||||
display.setCursor(310, 240);
|
||||
display.print("- ");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(310, 240);
|
||||
display.print(" ");
|
||||
}
|
||||
|
||||
|
||||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(10, 290);
|
||||
display.print("[AVG]");
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(293, 290);
|
||||
display.print("[TRD]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -341,15 +341,16 @@ public:
|
|||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(130, 290);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue