New battery percentage formula for iSpindel in chart.

Sun, 20 Aug 2023 11:40:51 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 20 Aug 2023 11:40:51 +0200
changeset 501
a01ae5ff0e96
parent 500
cf75e6fadcb1
child 502
0f15edebc665

New battery percentage formula for iSpindel in chart.

src/ChartiSpindel.cpp file | annotate | diff | comparison | revisions
translations/bmsapp_en.ts file | annotate | diff | comparison | revisions
translations/bmsapp_nl.ts file | annotate | diff | comparison | revisions
--- a/src/ChartiSpindel.cpp	Sun Aug 20 11:08:05 2023 +0200
+++ b/src/ChartiSpindel.cpp	Sun Aug 20 11:40:51 2023 +0200
@@ -210,10 +210,11 @@
 	else if (series == density)
 	    t_tooltip->setText(QString(tr("%1\nDensity %2 SG")).arg(timeis.toString("dd-MM-yyyy hh:mm")).arg(point.y(), 5, 'f', 4));
 	else if (series == battery) {
-	    double batt = point.y() - 3.064;	/* 0% */
+	    const float battery_max = 4.13;
+            const float battery_min = 3.43;
+	    double batt = ((point.y() - battery_min) / (battery_max - battery_min)) * 100;
 	    if (batt < 0)
 		batt = 0;
-	    batt = round(batt / 1.17875 * 1000.0) / 10;	/* 100% range */
 	    if (batt > 100)
 		batt = 100;
 	    t_tooltip->setText(QString(tr("%1\nBattery %2 volt\nCapacity %3%")).arg(timeis.toString("dd-MM-yyyy hh:mm"))
--- a/translations/bmsapp_en.ts	Sun Aug 20 11:08:05 2023 +0200
+++ b/translations/bmsapp_en.ts	Sun Aug 20 11:40:51 2023 +0200
@@ -235,7 +235,7 @@
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/ChartiSpindel.cpp" line="219"/>
+        <location filename="../src/ChartiSpindel.cpp" line="220"/>
         <source>%1
 Battery %2 volt
 Capacity %3%</source>
@@ -1007,7 +1007,7 @@
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailiSpindel.cpp" line="159"/>
+        <location filename="../src/DetailiSpindel.cpp" line="158"/>
         <source>Offline</source>
         <translation type="unfinished"></translation>
     </message>
--- a/translations/bmsapp_nl.ts	Sun Aug 20 11:08:05 2023 +0200
+++ b/translations/bmsapp_nl.ts	Sun Aug 20 11:40:51 2023 +0200
@@ -271,7 +271,7 @@
 Dichtheid %2 SG</translation>
     </message>
     <message>
-        <location filename="../src/ChartiSpindel.cpp" line="219"/>
+        <location filename="../src/ChartiSpindel.cpp" line="220"/>
         <source>%1
 Battery %2 volt
 Capacity %3%</source>
@@ -1091,7 +1091,7 @@
         <translation>Online</translation>
     </message>
     <message>
-        <location filename="../src/DetailiSpindel.cpp" line="159"/>
+        <location filename="../src/DetailiSpindel.cpp" line="158"/>
         <source>Offline</source>
         <translation>Offline</translation>
     </message>

mercurial