   }
 }
 
+int MAX_V_BATT = 12;
+int MIN_V_BATT = 10;
+
+double a =  1 / double(MAX_V_BATT -  MIN_V_BATT);
+double b = 1 - a * MAX_V_BATT;
+
+// coumpute battery percentage
+double getBatteryFitted(double VFinal) {
+    if (VFinal > MAX_V_BATT) {
+      return 1.0;
+    }
+    if (VFinal < MIN_V_BATT) {
+      return 0.0;
+    }
+    return a * VFinal - b;
+}
+
 // coumpute battery percentage
 double getBattery(double VFinal) {
     int i;

  Serial.print(getIError());
  Serial.print(",");
  Serial.print(getBattery(VFinal), 2);
  Serial.print("\n");
}


long samples = 0;

// magic string
const char MAGIC[] = "EnerginoAbs";
const int REVISION = 1;

void reset() {
