Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 //********************** 00002 // USB current meter for mbed 00003 // 00004 // LPC1768 flash=512KB, ADC=12bits 00005 // LPC11U35 flash=64KB, ADC=10bits 00006 // Nucleo ADC=12bits 00007 // 00008 // (C)Copyright 2014 All rights reserved by Y.Onodera 00009 // http://einstlab.web.fc2.com 00010 //********************** 00011 #include "mbed.h" 00012 #include "AQM0802.h" 00013 00014 //#pragma O0 00015 //#pragma O1 00016 //#pragma O2 00017 //#pragma O3 // default 00018 //#pragma Otime // default 00019 //#pragma Ospace 00020 00021 00022 #if defined(TARGET_LPC1768) 00023 I2C i2c(p28,p27); 00024 AnalogIn ain(p15); 00025 #endif 00026 // for TG-LPC11U35-501 00027 #if defined(TARGET_LPC11U35_501) 00028 I2C i2c(P0_5,P0_4); 00029 AnalogIn ain(P0_11); 00030 #endif 00031 // for Nucleo 00032 #if defined(TARGET_NUCLEO_F401RE) 00033 I2C i2c(D14,D15); 00034 AnalogIn ain(PA_0); 00035 #endif 00036 00037 AQM0802 lcd(i2c); 00038 Ticker tic; 00039 00040 00041 void display() 00042 { 00043 00044 char msg[10]; 00045 int mA; 00046 static int mAh=0; 00047 00048 // current 00049 mA = ain.read()*3.3*1000; 00050 mAh+=mA; 00051 if(mAh/3600>99999)mAh=0; // overflow 00052 00053 sprintf(msg," %4dmA ",mA); 00054 lcd.locate(0,0); 00055 lcd.print(msg); 00056 00057 sprintf(msg,"%5dmAh",mAh/3600); 00058 lcd.locate(0,1); 00059 lcd.print(msg); 00060 00061 } 00062 00063 int main() { 00064 00065 tic.attach(&display,1); // Do not exceed 2147sec 00066 00067 while(true) { 00068 } 00069 00070 }
Generated on Thu Jul 14 2022 02:04:48 by
1.7.2