HEPTA-Sat Training 2022 / Mbed 2 deprecated Lab3-05_power_saving

Dependencies:   HEPTA_CDH HEPTA_COM HEPTA_EPS HEPTA_SENSOR mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "HEPTA_EPS.h"
00003 RawSerial pc(USBTX,USBRX,9600);
00004 HEPTA_EPS eps(p16,p26);
00005 int main() {
00006     int flag = 0;     // condition
00007     float btvol;
00008     for(int i = 0; i < 100; i++) {
00009         //Get Battery Voltage
00010         eps.vol(&btvol);
00011         pc.printf("BatVol = %.2f [V]\r\n",btvol);
00012         //Power Saving Mode
00013         if(btvol <= 3.5) {
00014             eps.shut_down_regulator();
00015             flag = 1;
00016         } else {
00017             eps.turn_on_regulator();
00018             flag = 0;
00019         }
00020         if(flag == 1) {
00021             pc.printf("Power saving mode ON\r\n"); 
00022         }
00023         wait(1.0);
00024     }
00025 }