First working, tested and calibrated unit

Dependencies:   mbed USBDevice

Revision:
3:a170b248ead8
Parent:
2:ddc96642fcdb
Child:
4:f7cc009aed74
--- a/main.cpp	Mon Mar 27 20:54:42 2017 +0000
+++ b/main.cpp	Mon Mar 27 21:00:03 2017 +0000
@@ -38,40 +38,27 @@
 PwmOut myled2(LED2);
 PwmOut myled3(LED3);
 DigitalOut heartbeatLED(LED4);
-
-
 Serial pc(SERIAL_TX, SERIAL_RX);
 DigitalOut MOSFET(PA_4);      // Connected to Gate of MOSFET
 AnalogIn   VBin(PA_1);        // To measure battery Voltage
 DigitalOut LED(D4);           // Activity indicator
-
 DigitalIn enable(PA_5);
 
 #define WIRE_LEAD_RES (0.23F)
-
 // BOARD SPECIFIC CALIBRATION CONSTANTS
 #define BOARDNUMBER 1
-
 #if BOARDNUMBER == 1
 #define V_SCALE  3.735935F
-
-
 #elif BOARDNUMBER == 2
 #define V_SCALE 3.3F
-
 #elif BOARDNUMBER == 3
 #define V_SCALE 3.3F
-
 #else
 #define V_SCALE 3.3F
-
 #endif
 
 Ticker heartbeat;
 
-
-
-
 // Parameters
 #define PULSEWIDTH  1.0f  // seconds
 char    serial_inchar,waiting;
@@ -83,34 +70,6 @@
 }
 
 
-int16_t map(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max) // found here: C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\WMath.cpp
-{
-    return (int16_t)((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
-}
-
-float mapf(float x, float in_min, float in_max, float out_min, float out_max)
-{
-    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
-}
-
-// Heartbeat monitor
-//void pulse()
-//{
-//    heartbeatLED = !heartbeatLED;
-//}
-//
-//void heartbeat_start()
-//{
-//    heartbeatLED = 1;
-//    heartbeat.attach(&pulse, 0.5);
-//}
-//
-//void heartbeat_stop()
-//{
-//    heartbeat.detach();
-//}
-
-
 int main()
 {
 
@@ -149,31 +108,31 @@
         mbedKeyBoard.printf("Open Voltage = %1.3f, Loaded Voltage = %1.3f, ESR = %1.3f\n\r",
                             OpenVoltage, LoadVoltage, Esr);
         printf("Open Voltage = %1.3f, Loaded Voltage = %1.3f, ESR = %1.3f\n\r",
-                            OpenVoltage, LoadVoltage, Esr);
+               OpenVoltage, LoadVoltage, Esr);
     }
 
-
-
 #else
 
     //Perform Board Calibration
     printf("\n\rCalibration Mode\n\r");
     waiting = 1;
+
     while (pc.readable()) { // flush buffer
         serial_inchar = pc.getc();
     }
+
     printf("Set Vin to 3.600V then [press any key]\n\r");
+
     while(waiting == 1) {
         wait(0.05);
     }
+
     printf("Reading...\n\r");
     wait(0.5);
     OpenVoltage = VBin.read();
-
     printf("Cut/paste this calibration into the calibration section...\n\r\n\r");
     printf("#define V_SCALE %fF\n\r",3.6/OpenVoltage);
 
+#endif
 
-#endif
-  
 }
\ No newline at end of file