Skip to content
Snippets Groups Projects
Commit 6c7f2662 authored by John Lee's avatar John Lee
Browse files

Fix the LCD display of watt hours, display volts and amps to three decimal...

Fix the LCD display of watt hours, display volts and amps to three decimal places on the web interface.
parent 8f395312
No related branches found
No related tags found
No related merge requests found
...@@ -114,8 +114,29 @@ ...@@ -114,8 +114,29 @@
if (watth != dataInfo[3]) { if (watth != dataInfo[3]) {
watth = dataInfo[3]; watth = dataInfo[3];
$("#sevenseg_watthour").sevenSeg({ $("#sevenseg_watthour").sevenSeg({
value: dataInfo[3] value: watth
}); });
if (watth < 10) {
$("#sevenseg_watthour").sevenSeg({
digits: 4,
decimalPlaces: 3
});
} else if (watth < 100) {
$("#sevenseg_watthour").sevenSeg({
digits: 4,
decimalPlaces: 2
});
} else if (watth < 1000) {
$("#sevenseg_watthour").sevenSeg({
digits: 4,
decimalPlaces: 1
});
} else {
$("#sevenseg_watthour").sevenSeg({
digits: 4,
decimalPlaces: 0
});
}
} }
break; break;
case MEASUREWATTHOUR: case MEASUREWATTHOUR:
......
...@@ -41,7 +41,7 @@ WiFiClient logClient; ...@@ -41,7 +41,7 @@ WiFiClient logClient;
#define MEASUREWATTHOUR 'm' #define MEASUREWATTHOUR 'm'
#define FW_VERSION 'f' #define FW_VERSION 'f'
#define FWversion 1.1 #define FWversion 1.2
uint8_t onoff = OFF; uint8_t onoff = OFF;
unsigned char measureWh; unsigned char measureWh;
...@@ -511,6 +511,7 @@ void lcd_status(void) ...@@ -511,6 +511,7 @@ void lcd_status(void)
void printPower_LCD(void) void printPower_LCD(void)
{ {
double rwatth;
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(volt, 3); lcd.print(volt, 3);
lcd.print(" V "); lcd.print(" V ");
...@@ -525,17 +526,18 @@ void printPower_LCD(void) ...@@ -525,17 +526,18 @@ void printPower_LCD(void)
} }
lcd.print(" W "); lcd.print(" W ");
if (watth < 10) { rwatth = watth/3600;
lcd.print(watth, 3); if (rwatth < 10) {
lcd.print(rwatth, 3);
lcd.print(" "); lcd.print(" ");
} else if (watth < 100) { } else if (rwatth < 100) {
lcd.print(watth, 2); lcd.print(rwatth, 2);
lcd.print(" "); lcd.print(" ");
} else if (watth < 1000) { } else if (rwatth < 1000) {
lcd.print(watth, 1); lcd.print(rwatth, 1);
lcd.print(" "); lcd.print(" ");
} else { } else {
lcd.print(watth/1000, 0); lcd.print(rwatth/1000, 0);
lcd.print(" K"); lcd.print(" K");
} }
lcd.print("Wh "); lcd.print("Wh ");
...@@ -751,7 +753,7 @@ void handler(void) ...@@ -751,7 +753,7 @@ void handler(void)
if (connectedWeb) { if (connectedWeb) {
if (onoff == ON) { if (onoff == ON) {
String data = String(DATA_PVI); String data = String(DATA_PVI);
data += String(watt, 3) + "," + String(volt) + "," + String(ampere); data += String(watt, 3) + "," + String(volt, 3) + "," + String(ampere, 3);
if (measureWh) { if (measureWh) {
watth += watt; watth += watt;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment