
trabalho
Dependencies: X_NUCLEO_IKS01A1 mbed-rtos mbed
Fork of HelloWorld_IKS01A1 by
Revision 20:3e1e0f78defa, committed 2016-05-07
- Comitter:
- stwykd
- Date:
- Sat May 07 17:35:43 2016 +0000
- Parent:
- 19:d442ff60498c
- Child:
- 21:6292c9ac498a
- Commit message:
- Solve some compile errors in main.cpp
Changed in this revision
expansionBoard.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/expansionBoard.cpp Sat May 07 17:13:53 2016 +0000 +++ b/expansionBoard.cpp Sat May 07 17:35:43 2016 +0000 @@ -14,7 +14,6 @@ class ExansionBoard { /* Retrieve the composing elements of the expansion board */ - void readIDs(){ uint8_t id; humidity_sensor->ReadID(&id);
--- a/main.cpp Sat May 07 17:13:53 2016 +0000 +++ b/main.cpp Sat May 07 17:35:43 2016 +0000 @@ -18,7 +18,7 @@ #include <ctime> #include <stdexcept> -struct tm tm = {tm.tm_hour = 0}; +struct tm t; double T; int main() { @@ -52,21 +52,21 @@ //Read day scanf("%s", day); if (atoi(day)!=0) - tm.tm_mday = atoi(day); + t.tm_mday = atoi(day); // Read month scanf("%s", month); if (atoi(month)!=0) - tm.tm_mon = atoi(month)-1; + t.tm_mon = atoi(month)-1; //Read year scanf("%s", year); if (atoi(year)!=0) - tm.tm_year = atoi(year)-1900; + t.tm_year = atoi(year)-1900; // Check whether date is correct - if (mktime(&tm)>0) { - printf("DATE UPDATED TO %d %d %d", tm.tm_mday, - tm.tm_mon+1, tm.tm_year+1900); - set_time(mktime(&tm)); + if (mktime(&t)>0) { + printf("DATE UPDATED TO %d %d %d", t.tm_mday, + t.tm_mon+1, t.tm_year+1900); + set_time(mktime(&t)); } else printf("Time inserted is invalid"); } @@ -75,21 +75,22 @@ scanf("%s", hour); if (atoi(hour)!=0) - tm.tm_hour = atoi(hour); + t.tm_hour = atoi(hour); scanf("%s", min); if (atoi(min)!=0) - tm.tm_min = atoi(min); + t.tm_min = atoi(min); scanf("%s", sec); if (atoi(sec)!=0) - tm.tm_sec = atoi(sec); + t.tm_sec = atoi(sec); //If the user sets this before without DATE, it's gonna be garbage // Check whether time is correct - if (mktime(&tm)>0) - set_time(mktime(&tm)); - printf("TIME UPDATED TO %d %d %d", tm.tm_hour, - tm.tm_min, tm.tm_sec); + if (mktime(&t)>0) { + set_time(mktime(&t)); + printf("TIME UPDATED TO %d %d %d", t.tm_hour, + t.tm_min, t.tm_sec); + } else printf("Time inserted is invalid"); } else if (strcmp("SETT", command)==0) { @@ -98,7 +99,8 @@ T = atof(arg); printf("T UPDATED TO %.1f", T); } - else throw std::out_of_range ("T MUST BE WITHIN 0.1 AND 60.0"); + //TODO Find a way to enable exceptions + //else throw std::out_of_range ("T MUST BE WITHIN 0.1 AND 60.0"); } else if (strcmp("STATE", command)==0) { scanf("%s", arg); @@ -127,7 +129,7 @@ else printf("There is no command matching. Please try again"); // Clear the input to avoid it to being reused in the next cycle - command[0] = arg[0] = 0; + command[0] = arg[0] = 0x00; return 0; } \ No newline at end of file