Changes done in ECG and BT
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of merged_code2_20sept_2017_4th_oct_2017 by
battery.cpp@37:92fcbf22bf91, 2017-07-29 (annotated)
- Committer:
- avp2417
- Date:
- Sat Jul 29 12:12:28 2017 +0000
- Revision:
- 37:92fcbf22bf91
- Parent:
- 22:ffa88619551d
- Child:
- 45:067673dae242
Modification carried out by Nikita related to display screen timeout + Battery monitoring.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikitateggi | 22:ffa88619551d | 1 | #include "mbed.h" |
nikitateggi | 22:ffa88619551d | 2 | #include "battery.h" |
avp2417 | 37:92fcbf22bf91 | 3 | #include "display_modules.h" |
nikitateggi | 22:ffa88619551d | 4 | AnalogIn A(PTB1); |
nikitateggi | 22:ffa88619551d | 5 | |
avp2417 | 37:92fcbf22bf91 | 6 | uint8_t battery_voltage() { |
nikitateggi | 22:ffa88619551d | 7 | float b_voltage; |
avp2417 | 37:92fcbf22bf91 | 8 | uint8_t battery_condition=0; |
avp2417 | 37:92fcbf22bf91 | 9 | b_voltage = A.read_u16()*(3.3/65535)*2; |
nikitateggi | 22:ffa88619551d | 10 | wait(0.001f); |
avp2417 | 37:92fcbf22bf91 | 11 | if (b_voltage>3.64) |
avp2417 | 37:92fcbf22bf91 | 12 | { |
avp2417 | 37:92fcbf22bf91 | 13 | battery_screen_charge(); |
avp2417 | 37:92fcbf22bf91 | 14 | battery_condition=0; |
avp2417 | 37:92fcbf22bf91 | 15 | } |
avp2417 | 37:92fcbf22bf91 | 16 | else if (3.605>b_voltage>3.57) ///15% to 10% |
avp2417 | 37:92fcbf22bf91 | 17 | { |
avp2417 | 37:92fcbf22bf91 | 18 | battery_low_charge(); |
avp2417 | 37:92fcbf22bf91 | 19 | battery_condition=1; |
avp2417 | 37:92fcbf22bf91 | 20 | } |
avp2417 | 37:92fcbf22bf91 | 21 | else if (3.57>b_voltage>3.535) /// 10% to 5% |
avp2417 | 37:92fcbf22bf91 | 22 | { |
avp2417 | 37:92fcbf22bf91 | 23 | battery_critically_low_charge(); |
avp2417 | 37:92fcbf22bf91 | 24 | battery_condition=2; |
avp2417 | 37:92fcbf22bf91 | 25 | } |
avp2417 | 37:92fcbf22bf91 | 26 | else if (3.535>b_voltage) |
avp2417 | 37:92fcbf22bf91 | 27 | { |
avp2417 | 37:92fcbf22bf91 | 28 | battery_screen_nocharge(); |
avp2417 | 37:92fcbf22bf91 | 29 | battery_condition=3; |
avp2417 | 37:92fcbf22bf91 | 30 | } |
avp2417 | 37:92fcbf22bf91 | 31 | |
avp2417 | 37:92fcbf22bf91 | 32 | |
avp2417 | 37:92fcbf22bf91 | 33 | return battery_condition; |
nikitateggi | 22:ffa88619551d | 34 | } |