Dual CANbus monitor and instrumentation cluster
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed
Fork of CANary by
Diff: utility.cpp
- Revision:
- 25:ddf0ec209f03
- Parent:
- 23:cd03f9c3395e
- Child:
- 26:462ccb580472
diff -r 6cf76ed8c432 -r ddf0ec209f03 utility.cpp --- a/utility.cpp Thu Mar 14 05:02:15 2013 +0000 +++ b/utility.cpp Fri Mar 15 04:28:34 2013 +0000 @@ -231,3 +231,59 @@ fclose(cfile); } } + +void upDate(unsigned char field, bool upDownBar){ + struct tm t; // pointer to a static tm structure + time_t seconds ; + seconds = time(NULL); + t = *localtime(&seconds) ; + switch(field){ + case 0: // year + if (upDownBar) { + t.tm_year = t.tm_year+1; + } else { + t.tm_year = t.tm_year-1; + } + break; + case 1: // month + if (upDownBar) { + t.tm_mon = (t.tm_mon<12)?t.tm_mon+1:1; + } else { + t.tm_mon = (t.tm_mon>2)?t.tm_mon-1:12; + } + break; + case 2: // day + if (upDownBar) { + t.tm_mday = (t.tm_mday<31)?t.tm_mday+1:1; + } else { + t.tm_mday = (t.tm_mday>2)?t.tm_mday-1:31; + } + break; + case 3: // hour + if (upDownBar) { + t.tm_hour = (t.tm_hour<23)?t.tm_hour+1:0; + } else { + t.tm_hour = (t.tm_hour>1)?t.tm_hour-1:23; + } + break; + case 4: // minute + if (upDownBar) { + t.tm_min = (t.tm_min<59)?t.tm_min+1:0; + } else { + t.tm_min = (t.tm_min>1)?t.tm_min-1:59; + } + break; + case 5: // second + if (upDownBar) { + t.tm_sec = (t.tm_sec<59)?t.tm_sec+1:0; + } else { + t.tm_sec = (t.tm_sec>1)?t.tm_sec-1:59; + } + break; + default: + break; + } + set_time(mktime(&t)); +} + +