sf
Diff: batter.cpp
- Revision:
- 0:e1658d625afc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/batter.cpp Tue Sep 27 09:41:52 2016 +0000 @@ -0,0 +1,29 @@ +#include "batter.h" + +//batter +AnalogIn batter_volt(PA_3); +DigitalOut batter_free(PB_5); + +BatterVol::BatterVol() +{ + + batter_free=1; +} + +unsigned short BatterVol::detect(void) +{ + float batval; + unsigned short bata; + + batter_free=0; + wait(5); + batter_free=1; + wait(3); + + batval=batter_volt.read(); + batval*=4.17; //3*7.1/5.1 + + bata=(unsigned short)(batval*100); + + return bata; +}