Nathan Yonkee
/
Nucleo_display_time
copy of rtc example
main.cpp
- Committer:
- tulanthoar
- Date:
- 2018-02-06
- Revision:
- 2:b3aa9dd045be
- Parent:
- 0:32f1960de3fb
File content as of revision 2:b3aa9dd045be:
#include "mbed.h" #include "LowPowerTimer.h" #include "arm_math.h" DigitalOut myled(LED1); int main() { 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 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); //printf("Time as seconds since January 1, 1970 = %d\n", seconds); //float nowms = abs(lp.read_us()); //float insin = sqrt(nowms); myled = 1; //char buffer[32]; //strftime(buffer, 32, "%I:%M:%S %p\n", localtime(&seconds)); //printf("Time as a custom formatted string = %s", buffer); 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); } } }