Lab3-04_power_saving_lite
Dependencies: mbed HEPTA_EPS_lite
main.cpp@2:5107160767bb, 2021-08-20 (annotated)
- Committer:
- heptasat2021
- Date:
- Fri Aug 20 12:24:26 2021 +0000
- Revision:
- 2:5107160767bb
- Parent:
- 1:ddac5ec89167
For Hepta-Sat Lite
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
heptasat2021 | 0:da0f6aca15b8 | 1 | #include "mbed.h" |
heptasat2021 | 2:5107160767bb | 2 | #include "HEPTA_EPS.h" |
heptasat2021 | 2:5107160767bb | 3 | HEPTA_EPS eps(PA_0,PA_4); |
heptasat2021 | 0:da0f6aca15b8 | 4 | Serial pc(USBTX,USBRX,9600); |
heptasat2021 | 2:5107160767bb | 5 | int main() { |
heptasat2021 | 2:5107160767bb | 6 | int flag = 0; // condition |
heptasat2021 | 2:5107160767bb | 7 | float btvol; |
heptasat2021 | 2:5107160767bb | 8 | for(int i = 0; i < 100; i++) { |
heptasat2021 | 2:5107160767bb | 9 | //Get Battery Voltage |
heptasat2021 | 2:5107160767bb | 10 | eps.vol(&btvol); |
heptasat2021 | 2:5107160767bb | 11 | pc.printf("BatVol = %.2f [V]\r\n",btvol); |
heptasat2021 | 2:5107160767bb | 12 | //Power Saving Mode |
heptasat2021 | 2:5107160767bb | 13 | if(btvol <= 3.5) { |
heptasat2021 | 2:5107160767bb | 14 | eps.shut_down_regulator(); |
heptasat2021 | 2:5107160767bb | 15 | flag = 1; |
heptasat2021 | 2:5107160767bb | 16 | } else { |
heptasat2021 | 2:5107160767bb | 17 | eps.turn_on_regulator(); |
heptasat2021 | 2:5107160767bb | 18 | flag = 0; |
heptasat2021 | 2:5107160767bb | 19 | } |
heptasat2021 | 2:5107160767bb | 20 | if(flag == 1) { |
heptasat2021 | 2:5107160767bb | 21 | pc.printf("Power saving mode ON\r\n"); |
heptasat2021 | 2:5107160767bb | 22 | } |
heptasat2021 | 2:5107160767bb | 23 | wait(1.0); |
heptasat2021 | 0:da0f6aca15b8 | 24 | } |
heptasat2021 | 0:da0f6aca15b8 | 25 | } |