This is the library to manage the time format

Dependents:   Trisula_Data_Logger

Files at this revision

API Documentation at this revision

Comitter:
DimasFN
Date:
Mon Nov 26 18:54:32 2018 +0000
Commit message:
Reading ADC and RTC and then print the reading result;

Changed in this revision

RTC_Reader.cpp Show annotated file Show diff for this revision Revisions of this file
RTC_Reader.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC_Reader.cpp	Mon Nov 26 18:54:32 2018 +0000
@@ -0,0 +1,37 @@
+// Source code link
+// https://os.mbed.com/users/cromda/code/DS3231/file/6718c4fabf95/DS3231.h/
+
+//#include "mbed.h"
+#include "DS3231.h"
+#include "RTC_Reader.h"
+
+DS3231 i2c(PF_0,PF_1);
+namespace RTC_READER_DS3231{
+    void RTC_::Read_RTC_Data()
+    {   
+        i2c.setI2Cfrequency(400000);
+        i2c.convertTemperature();
+        //i2c.writeRegister(DS3231_Aging_Offset,0);
+        //i2c.setTime(19,52,50); // uncomment to set time
+        //i2c.setDate(8,26,11,2018); // uncomment to set date
+        int reg=i2c.readRegister(DS3231_Aging_Offset);
+        if (reg>127){
+            reg=reg-256;
+        }
+        i2c.readDate(&RTC_date,&RTC_month,&RTC_year);
+        i2c.readTime(&RTC_hour,&RTC_minute,&RTC_second);
+        /*i2c.readDateTime(
+            &RTC_dayOfWeek,&RTC_date,&RTC_month,
+            &RTC_year,&RTC_hour,&RTC_minute,
+            &RTC_second
+            );*/
+            //char buffer[2+2+4+5+2+2];
+            string Output_String=0;
+            //Output_String=sprintf (buffer, "%d-%d-%d-%d-%d-%d", 
+            //RTC_date,   RTC_month,   RTC_year,
+            //RTC_hour,   RTC_minute,  RTC_second);
+            //Output_String+=RTC_date+'-'+RTC_month+'-'+RTC_year+'-'+RTC_hour+'-'+RTC_minute+'-'+RTC_second;
+            //printf(" %d %d %d %d %d %d ",RTC_date,RTC_month,RTC_year,RTC_hour,RTC_minute,RTC_second);
+            //return Output_String;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC_Reader.h	Mon Nov 26 18:54:32 2018 +0000
@@ -0,0 +1,23 @@
+#ifndef _RTC_READER_H_
+#define _RTC_READER_H_
+#include "iostream"
+#include "string"
+
+namespace RTC_READER_DS3231{
+    class RTC_
+    {
+          public:
+              void Read_RTC_Data();
+          public:
+              int RTC_hour;
+              int RTC_minute;
+              int RTC_second;
+              int RTC_dayOfWeek;
+              int RTC_date;
+              int RTC_month;
+              int RTC_year;
+    };
+}
+
+#endif
+  
\ No newline at end of file