fork
Dependencies: MPU6050_SIM5320_TEST
Fork of MPU_SDCARD by
main.cpp
- Committer:
- suads
- Date:
- 2017-11-10
- Revision:
- 1:483775fd3399
- Parent:
- 0:203cf529f52a
File content as of revision 1:483775fd3399:
#include "mbed.h" time_t read_rtc(void) { return 0; } int main() { // attach_rtc(&read_rtc, NULL, NULL, NULL); set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37 while (true) { time_t seconds = time(NULL); printf("Time as seconds since January 1, 1970 = %d\n", seconds); printf("Time as a basic string = %s", ctime(&seconds)); char buffer[32]; strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); printf("Time as a custom formatted string = %s", buffer); wait(1); } } /* #include "mbed.h" void get(char* buffer,uint16_t &tempDate,uint16_t &tempTime); char buffer[26]; time_t read_rtc(void) { return 0; } int main() { set_time(1503687670); // Set RTC time to Wed, 28 Oct 2009 11:35:37 while (true) { uint16_t datum; uint16_t vrijeme; time_t seconds = time(NULL); //printf("Time as seconds since January 1, 1970 = %d\n", seconds); sprintf(buffer,"%s", ctime(&seconds)); // char buffer[32]; // strftime(buffer, 32,"%s",ctime(&seconds)); // printf("Time as a custom formatted string = %s\n", seconds); //sprintf (buffer,"%s",seconds); printf("|%s|",buffer); buffer[25]='\0'; get(buffer,datum,vrijeme); printf("aaa %d bb %d\n",datum,vrijeme); wait(1); } } void get(char* buffer,uint16_t &tempDate,uint16_t &tempTime){ // char *a=buffer; //uint8_t month=0; char month[2]={'0','0'}; char hour[2]; char minute[2]; char day[2]; day[0]=buffer[8]; day[1]=buffer[9]; hour[0]=buffer[11]; hour[1]=buffer[12]; minute[0]=buffer[14]; minute[1]=buffer[15]; char *output = NULL; //output = strstr (buffer,"Mar"); if(strstr (buffer,"Jan")) month[1]='1'; else if(strstr (buffer,"Feb")) month[1]='2'; else if(strstr (buffer,"Mar")) month[1]='3'; else if(strstr (buffer,"Apr")) month[1]='4'; else if(strstr (buffer,"May")) month[1]='5'; else if(strstr (buffer,"Jun")) month[1]='6'; else if(strstr (buffer,"Jul")) month[1]='7'; else if(strstr (buffer,"Aug")) month[1]='8'; else if(strstr (buffer,"Sep")) month[1]='9'; else if(strstr (buffer,"Okt")) { month[0]='1'; month[1]='0'; } else if(strstr (buffer,"Nov")) { month[0]='1'; month[1]='1'; } else if(strstr (buffer,"Dec")) { month[0]='1'; month[1]='2'; } printf("Datum je |%s|.|%s| |%s|:|%s| \n",day,month,hour,minute); char tempdate [4]; sprintf(tempdate,"%s%s",month,day); int i =atoi(tempdate); tempDate=i; printf("Datum je |%d|\n",i); char temptime [4]; sprintf(temptime,"%s%s",hour,minute); int x=atoi(temptime); printf("Vrijeme je |%d|\n",x); tempTime=x; } */