
trabalho
Dependencies: X_NUCLEO_IKS01A1 mbed-rtos mbed
Fork of HelloWorld_IKS01A1 by
Revision 16:b9cfb5171af6, committed 2016-05-06
- Comitter:
- nlsantos
- Date:
- Fri May 06 00:50:48 2016 +0000
- Parent:
- 15:9de308b656f5
- Child:
- 17:37294fc50c80
- Commit message:
- date and time functions created ;
Changed in this revision
mailBox.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/mailBox.cpp Thu May 05 15:45:28 2016 +0000 +++ b/mailBox.cpp Fri May 06 00:50:48 2016 +0000 @@ -11,12 +11,7 @@ int accelerometer; int gyroscope; int magnetometer; - int dd; - int mm; - int yyyy; - int hh; - int min; - int ss; + }log_data;
--- a/main.cpp Thu May 05 15:45:28 2016 +0000 +++ b/main.cpp Fri May 06 00:50:48 2016 +0000 @@ -52,6 +52,9 @@ static TempSensor *temp_sensor1 = mems_expansion_board->ht_sensor; static TempSensor *temp_sensor2 = mems_expansion_board->pt_sensor; +//sensor time +struct tm t; + /* Helper function for printing floats & doubles */ static char *printDouble(char* str, double v, int decimalDigits=2) { @@ -118,16 +121,41 @@ } bool setDate( int hh, int mm, int yyyy) { + bool success; + printf("Enter current date : \n"); + printf( "YYYY MM DD [enter] \n"); + scanf ("%d %d %d", &t.tm_year, &t.tm_mon, &t.tm_mday); + + // adjust for tm structure required values + t.tm_year = t.tm_year - 1900; + t.tm_mon = t.tm_mon - 1; + // set the time + set_time(mktime(&t)); + + success= true; - bool success; + return success; } bool setTime (int hh, int mm, int ss) { - bool success; - return success; + bool success = false; + + // get the current time from the terminal + + printf("Enter current time:\n"); + printf("HH MM SS[enter]\n"); + scanf("%d %d %d", &t.tm_hour, &t.tm_min, &t.tm_sec); + + + // set the time + set_time(mktime(&t)); + success = true; + + return success; + } bool logTime (int time, bool state) @@ -171,7 +199,7 @@ while (userInstruction !=0 || userInstruction <=9) { - printf ("Please select and option "); + printf ("Please select and option" ); }