commit_cell_locker

Dependencies:   MPU6050_SIM5320_TEST

Fork of KOPIRANO_cell_locker by Suad Suljic

Files at this revision

API Documentation at this revision

Comitter:
suads
Date:
Mon Nov 13 15:48:57 2017 +0000
Parent:
1:75966605a6a3
Commit message:
first commit cell_locker

Changed in this revision

DataLogger/DataLogger.cpp Show annotated file Show diff for this revision Revisions of this file
DataLogger/DataLogger.h 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
diff -r 75966605a6a3 -r aabc92901e25 DataLogger/DataLogger.cpp
--- a/DataLogger/DataLogger.cpp	Fri Nov 10 15:35:26 2017 +0000
+++ b/DataLogger/DataLogger.cpp	Mon Nov 13 15:48:57 2017 +0000
@@ -1,5 +1,7 @@
 
 #include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 
 
 #include "log.h"
@@ -145,6 +147,79 @@
 
  return (_datalist+i);
 }
+template<class T>
+void DataLogger<T>::get(uint16_t &tempDate,uint16_t &tempTime){
+    char buffer[26];
+
+    time_t seconds = time(NULL);
+    sprintf(buffer,"%s", ctime(&seconds));
+
+    printf("|%s|",buffer);
+    buffer[25]='\0';
+
+    char month[2]= {'0','0'};
+    char hour[2]={'0','0'};
+    char minute[2]={'0','0'};
+    char day[2]={'0','0'};
+
+    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;
+
+//wait(1);
+    
+    
+ }   
+ 
+
+
+
 
 
 
diff -r 75966605a6a3 -r aabc92901e25 DataLogger/DataLogger.h
--- a/DataLogger/DataLogger.h	Fri Nov 10 15:35:26 2017 +0000
+++ b/DataLogger/DataLogger.h	Mon Nov 13 15:48:57 2017 +0000
@@ -3,6 +3,7 @@
 
 //#include "DataLogger.h"
 #include <stdint.h>
+#include "mbed.h"
 
 #define DATASIZE 20
 
@@ -32,6 +33,7 @@
     void print();
     uint16_t getsize();
     uint8_t position();
+    void get(uint16_t &tempDate,uint16_t &tempTime);
     T* getfirst();
     T* getlast();
     uint16_t getnumberOfDays();
diff -r 75966605a6a3 -r aabc92901e25 main.cpp
--- a/main.cpp	Fri Nov 10 15:35:26 2017 +0000
+++ b/main.cpp	Mon Nov 13 15:48:57 2017 +0000
@@ -169,6 +169,10 @@
         nomotion++;
         if(nomotion==3 && motionlogged==0) {
             printf("SAVE NO motion\n");
+            uint16_t tempdate;
+            uint16_t temptime;
+            //time_t seconds = time(NULL);
+            mojlogger.get(tempdate,temptime);
             //motionFsm->handle(stop);
             mojlog.setLog(900,0,0,900);
             mojlogger.savelog(mojlog);