Used with KL25Z Freescale board to access the Avnet Wi-Go Battery charger
Dependents: Wi-Go_IOT_Demo IoT_World_Hackathon_WiGo_NSP_Demo Wi-Go_IOT_Demo_MKII
Fork of WiGo_BattCharger by
Modified BattCharger from https://mbed.org/users/monpjc/code/WiGo_BattCharger/ - removed LED pins and added raw read.
Diff: WiGo_BattCharger.cpp
- Revision:
- 3:fb966ae74766
- Parent:
- 2:f52adda183d2
diff -r f52adda183d2 -r fb966ae74766 WiGo_BattCharger.cpp --- a/WiGo_BattCharger.cpp Fri May 17 20:13:01 2013 +0000 +++ b/WiGo_BattCharger.cpp Fri Sep 06 09:06:39 2013 +0000 @@ -1,11 +1,11 @@ #include "WiGo_BattCharger.h" #include "mbed.h" -WiGo_BattCharger::WiGo_BattCharger( PinName battlow, PinName battmed, PinName battfull, PinName en1, PinName en2, PinName snsen, PinName sense, PinName supplystate, PinName chargestate ) : _battlow(battlow), _battmed(battmed), _battfull(battfull), _en1(en1), _en2(en2), _snsen(snsen), _sense(sense), _supplystate(supplystate), _chargestate(chargestate) +WiGo_BattCharger::WiGo_BattCharger( PinName en1, PinName en2, PinName snsen, PinName sense, + PinName supplystate, PinName chargestate ) + : _en1(en1), _en2(en2), _snsen(snsen), _sense(sense), + _supplystate(supplystate), _chargestate(chargestate) { - _battlow = BATT_LED_OFF; //Default State - _battmed = BATT_LED_OFF; - _battfull = BATT_LED_OFF; _en1 = 0; //100mA Charge _en2 = 0; _snsen = 1; //Off @@ -45,6 +45,11 @@ _snsen = 0; } +unsigned short WiGo_BattCharger::readRaw( void ) +{ + return _sense.read_u16(); +} + float WiGo_BattCharger::read( void ) { return _sense; @@ -60,42 +65,6 @@ return _supplystate; } -void WiGo_BattCharger::LEDupdate( int n ) -{ - float batt_level; - - if( n == 1 ) { - sense_en(1); - batt_level = read(); - if( batt_level <= BATT_0 ) { - _battlow = BATT_LED_OFF; - _battmed = BATT_LED_OFF; - _battfull = BATT_LED_OFF; - } - if( batt_level > BATT_0 && batt_level <= 0.605 ) { - _battlow = BATT_LED_ON; - _battmed = BATT_LED_OFF; - _battfull = BATT_LED_OFF; - } - if( batt_level > 0.605 && batt_level <= BATT_100 ) { - _battlow = BATT_LED_ON; - _battmed = BATT_LED_ON; - _battfull = BATT_LED_OFF; - } - if( batt_level > BATT_100 ) { - _battlow = BATT_LED_ON; - _battmed = BATT_LED_ON; - _battfull = BATT_LED_ON; - } - } - else - { - _battlow = BATT_LED_OFF; - _battmed = BATT_LED_OFF; - _battfull = BATT_LED_OFF; - } -} - int WiGo_BattCharger::level( void ) { float returnValue = 0; @@ -111,3 +80,5 @@ return (int)returnValue; } + +