yasuyuki onodera
/
mbed_Ampere
USB current meter for TG-LPC11U35-501
Revision 2:d6fcc8bfc037, committed 2015-09-26
- Comitter:
- yasuyuki
- Date:
- Sat Sep 26 13:14:29 2015 +0000
- Parent:
- 1:e1d55b71e910
- Commit message:
- revised
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r e1d55b71e910 -r d6fcc8bfc037 main.cpp --- a/main.cpp Tue Jun 24 08:42:52 2014 +0000 +++ b/main.cpp Sat Sep 26 13:14:29 2015 +0000 @@ -13,57 +13,58 @@ //#pragma O0 //#pragma O1 -//#pragma O2 // default -//#pragma O3 -//#pragma Otime +//#pragma O2 +//#pragma O3 // default +//#pragma Otime // default //#pragma Ospace #if defined(TARGET_LPC1768) -DigitalOut led1(LED1); -DigitalOut led2(LED2); I2C i2c(p28,p27); AnalogIn ain(p15); #endif // for TG-LPC11U35-501 #if defined(TARGET_LPC11U35_501) -DigitalOut led1(P0_20); -DigitalOut led2(P0_21); I2C i2c(P0_5,P0_4); AnalogIn ain(P0_11); #endif // for Nucleo #if defined(TARGET_NUCLEO_F401RE) -DigitalOut led1(D13); I2C i2c(D14,D15); AnalogIn ain(PA_0); #endif AQM0802 lcd(i2c); +Ticker tic; -int main() { - + +void display() +{ + char msg[10]; int mA; + static int mAh=0; - sprintf(msg, "%d", SystemCoreClock ); + // current + mA = ain.read()*3.3*1000; + mAh+=mA; + if(mAh/3600>99999)mAh=0; // overflow + + sprintf(msg," %4dmA ",mA); lcd.locate(0,0); lcd.print(msg); - wait(1); - - sprintf(msg, "current "); - lcd.locate(0,0); + + sprintf(msg,"%5dmAh",mAh/3600); + lcd.locate(0,1); lcd.print(msg); - - while(1) { - // current - mA = ain.read()*3.3*1000; +} - sprintf(msg," %4dmA",mA); - lcd.locate(0,1); - lcd.print(msg); - wait(1); +int main() { + + tic.attach(&display,1); // Do not exceed 2147sec + + while(true) { } }
diff -r e1d55b71e910 -r d6fcc8bfc037 mbed.bld --- a/mbed.bld Tue Jun 24 08:42:52 2014 +0000 +++ b/mbed.bld Sat Sep 26 13:14:29 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/024bf7f99721 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/7e07b6fb45cf \ No newline at end of file