created separate function for hex to char

Dependencies:   SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217

Fork of SS_SensePOC2P0_11Dec2017_USERPID by rashmi v

battery.cpp

Committer:
avp2417
Date:
2017-07-29
Revision:
37:92fcbf22bf91
Parent:
22:ffa88619551d
Child:
45:067673dae242

File content as of revision 37:92fcbf22bf91:

#include "mbed.h"
#include "battery.h"
#include "display_modules.h"
AnalogIn A(PTB1);

uint8_t battery_voltage() {
float b_voltage;
uint8_t battery_condition=0;
        b_voltage = A.read_u16()*(3.3/65535)*2;
        wait(0.001f);
      if (b_voltage>3.64)
             {
                   battery_screen_charge();
                   battery_condition=0;
             }
      else if (3.605>b_voltage>3.57)           ///15% to 10%
            {
                   battery_low_charge();
                   battery_condition=1;
             }
       else if (3.57>b_voltage>3.535)          /// 10% to 5%
            {
                   battery_critically_low_charge();
                   battery_condition=2;
             } 
       else if (3.535>b_voltage)
            {
                   battery_screen_nocharge();
                   battery_condition=3;
             }      
             
         
return  battery_condition;
}