Nathan Yonkee
/
Nucleo_display_time_copy
copy display time
Fork of Nucleo_display_time by
Revision 2:b3aa9dd045be, committed 2018-02-06
- Comitter:
- tulanthoar
- Date:
- Tue Feb 06 07:19:24 2018 +0000
- Parent:
- 1:a474ab5e98f9
- Commit message:
- import to local repo
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r a474ab5e98f9 -r b3aa9dd045be main.cpp --- a/main.cpp Fri Apr 21 19:43:43 2017 +0000 +++ b/main.cpp Tue Feb 06 07:19:24 2018 +0000 @@ -1,26 +1,38 @@ #include "mbed.h" - +#include "LowPowerTimer.h" +#include "arm_math.h" DigitalOut myled(LED1); int main() { - - printf("RTC example\n"); + Serial pc(PA_9, PA_10, 115200); + pc.printf("RTC example\n"); set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTC - printf("Date and time are set.\n"); - + LowPowerTimer lp; + AnalogIn ai(PA_6); + Timer p2; + p2.start(); + lp.start(); + pc.printf("Date and time are set.\n"); +unsigned int i = 0; while(1) { - time_t seconds = time(NULL); + //time_t seconds = time(NULL); //printf("Time as seconds since January 1, 1970 = %d\n", seconds); + //float nowms = abs(lp.read_us()); + //float insin = sqrt(nowms); + myled = 1; - printf("Time as a basic string = %s", ctime(&seconds)); //char buffer[32]; //strftime(buffer, 32, "%I:%M:%S %p\n", localtime(&seconds)); //printf("Time as a custom formatted string = %s", buffer); - - myled = !myled; - wait(1); + wait_us(1); + myled = 0; + for(int j = 0; j < 50; ++j){ + pc.printf("{\"data\":\"%d\",\"val\":%4.2f}\n", ++i, (float)(ai.read()*3.3f)); + wait(0.1); + } + } }