standalone sx1276 demo program

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Committer:
ftagius
Date:
Thu Sep 03 14:43:30 2015 +0000
Revision:
34:75e4c3600d2f
Parent:
32:a2472bbe7c92
fix lib dependencies

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ftagius 32:a2472bbe7c92 1 #include "datetime.h"
ftagius 32:a2472bbe7c92 2 #include "rtc_api.h"
ftagius 32:a2472bbe7c92 3 #include "mbed.h"
ftagius 32:a2472bbe7c92 4
ftagius 32:a2472bbe7c92 5 void SetDateTime
ftagius 32:a2472bbe7c92 6 (int year = 2015
ftagius 32:a2472bbe7c92 7 ,int mon = 5
ftagius 32:a2472bbe7c92 8 ,int day = 26
ftagius 32:a2472bbe7c92 9 ,int hour = 10
ftagius 32:a2472bbe7c92 10 ,int min = 0
ftagius 32:a2472bbe7c92 11 ,int sec = 0
ftagius 32:a2472bbe7c92 12 )
ftagius 32:a2472bbe7c92 13 {
ftagius 32:a2472bbe7c92 14 // struct tm Clock;
ftagius 32:a2472bbe7c92 15 Clock.tm_year = year - 1900;
ftagius 32:a2472bbe7c92 16 Clock.tm_mon = mon;
ftagius 32:a2472bbe7c92 17 Clock.tm_mday = day;
ftagius 32:a2472bbe7c92 18 Clock.tm_hour = hour;
ftagius 32:a2472bbe7c92 19 Clock.tm_min = min;
ftagius 32:a2472bbe7c92 20 Clock.tm_sec = sec;
ftagius 32:a2472bbe7c92 21 time_t epoch = mktime(&Clock);
ftagius 32:a2472bbe7c92 22 if (epoch == (time_t) -1) {
ftagius 32:a2472bbe7c92 23 error("Error in clock setting\r\n");
ftagius 32:a2472bbe7c92 24 }
ftagius 32:a2472bbe7c92 25 set_time(epoch);
ftagius 32:a2472bbe7c92 26 }
ftagius 32:a2472bbe7c92 27
ftagius 32:a2472bbe7c92 28 void ShowDateTime()
ftagius 32:a2472bbe7c92 29 {
ftagius 32:a2472bbe7c92 30 char str[32];
ftagius 32:a2472bbe7c92 31 time_t seconds = time(NULL);
ftagius 32:a2472bbe7c92 32 struct tm *gpsd = localtime(&seconds);
ftagius 32:a2472bbe7c92 33 struct tm *tminfo = localtime(&seconds);
ftagius 32:a2472bbe7c92 34
ftagius 32:a2472bbe7c92 35 strftime(str, 32, "%F,%T", tminfo);
ftagius 32:a2472bbe7c92 36 //printf("RTC: %s\r\n", str);
ftagius 32:a2472bbe7c92 37 printf("%02d/%02d/%02d,", gpsd->tm_mon, gpsd->tm_mday, gpsd->tm_year+1900);
ftagius 32:a2472bbe7c92 38 printf("%02d:%02d:%02d ", gpsd->tm_hour, gpsd->tm_min, gpsd->tm_sec);
ftagius 32:a2472bbe7c92 39 }
ftagius 32:a2472bbe7c92 40