solution
Revision 0:edb20fa1ab21, committed 2012-07-04
- Comitter:
- sherckuith
- Date:
- Wed Jul 04 06:42:58 2012 +0000
- Commit message:
- solution;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Jul 04 06:42:58 2012 +0000
@@ -0,0 +1,75 @@
+#include "mbed.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+#include <math.h>
+#define MESSAGE_BUFFER_SIZE 1024
+//#include "lib_crc.h"
+
+Serial pc(USBTX, USBRX);
+DigitalOut ho(p26);
+
+char line = '\n';
+char c;
+char sav[40];
+char tstr[32];
+struct tm t;
+time_t seconds;
+
+void Display() { //Getting Data and putting on LED Screen
+ time_t seconds = time(NULL);
+ strftime(tstr, 32,"%H:%M:%S", localtime(&seconds));
+ pc.printf("%s\n\r", tstr);
+ wait(0.95);
+}
+
+void input() {
+ memset(sav, 0, 40);
+ do {
+ c = pc.getc();
+ pc.putc (c);
+ strcat(sav, &c);
+ } while (c != ' ');
+}
+
+void TimeSet() {
+
+ pc.printf("SET TIME\n\r");
+ pc.printf("--------\n\n\r");
+
+ do {
+ pc.printf("Please input local time:\n\r");
+ pc.printf("YYYY MM DD HH MM SS\n\r");
+
+ input();
+ t.tm_year = atoi(sav);
+ input();
+ t.tm_mon = atoi(sav);
+ input();
+ t.tm_mday = atoi(sav);
+ input();
+ t.tm_hour = atoi(sav);
+ input();
+ t.tm_min = atoi(sav);
+ input();
+ t.tm_sec = atoi(sav);
+
+ pc.printf("\n\n\r");
+ pc.printf("Is the time correct? [Y/N]\n\n\r");
+ c=pc.getc();
+ } while (c != 'Y');
+
+ t.tm_year = t.tm_year - 1900;
+ t.tm_mon = t.tm_mon - 1;
+
+ set_time(mktime(&t));
+}
+
+int main () {
+ TimeSet();
+ pc.printf("ok...\n\n\r");
+ while (1) {
+ Display();
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jul 04 06:42:58 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/976df7c37ad5 \ No newline at end of file