Data Logger v0
Dependencies: RTC_Reader SDFileSystem DS3231
Diff: main.cpp
- Revision:
- 2:be7912c3fd87
- Parent:
- 1:cd725fbbcbc2
--- a/main.cpp Mon Nov 26 18:55:17 2018 +0000 +++ b/main.cpp Wed Dec 12 17:26:47 2018 +0000 @@ -5,6 +5,7 @@ #include "SDFileSystem.h" #include "DS3231.h" #include "RTC_Reader.h" +#include "sstream" //====================================================================================== //========================== ADC Pin Configurations ==================================== //====================================================================================== @@ -30,7 +31,7 @@ using namespace std; double analog[9]; -int ID, +int ID=1, counter, factor, Offset, @@ -51,21 +52,35 @@ } void Print_Format_Data( - int id, int tInt, int cnt, - int fctr, int ofst, - float a1, float a2, float a3, - float a4, float a5, float a6, - float a7, float a8, float a9 + int tInt, int cnt, int fctr, + int ofst, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, + float a9 ){ - printf("*%d_%d_%d_%d_%d_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f\r\n\r\n", - id,tInt,cnt,fctr,ofst, - a1,a2,a3,a4,a5,a6,a7,a8,a9 - ); + char sprtr='_'; + printf("%X %X ",sprtr,tInt); + printf("%X %X ",sprtr,cnt); + printf("%X %X ",sprtr,fctr); + printf("%X %X ",sprtr,ofst); + printf("%X %X ",sprtr,(int)a1); + printf("%X %X ",sprtr,(int)a2); + printf("%X %X ",sprtr,(int)a3); + printf("%X %X ",sprtr,(int)a4); + printf("%X %X ",sprtr,(int)a5); + printf("%X %X ",sprtr,(int)a6); + printf("%X %X ",sprtr,(int)a7); + printf("%X %X ",sprtr,(int)a8); + printf("%X %X ",sprtr,(int)a9); + printf("\n\r"); + /*printf("_%d_%X_%X_%d_%X_%X_%X_%X_%X_%X_%X_%X_%X\r\n", + tInt,cnt,fctr,ofst, + (int)a1,(int)a2,(int)a3,(int)a4,(int)a5,(int)a6,(int)a7,(int)a8,(int)a9 + );*/ wait(1); // 1 s } void Sampling_Data(){ - ID=1; tInterval=1; OtInterval=tInterval*1000; counter++; @@ -81,22 +96,24 @@ analog[7]= (analog_value8.read()*factor)+Offset; analog[8]= (analog_value9.read()*factor)+Offset; } + +string string_to_Hex(string decimal_value){ + stringstream ss; + ss<< std::hex << decimal_value; // int decimal_value + std::string res ( ss.str() ); + std::cout << res; + return res; +} int main() { - + RTC_READER_DS3231::RTC_ RTC_Ob; + RTC_Ob.RTC_::Read_RTC_Data(); + printf("{%d_%02i-%02i-%02i/%02i:%02i:%02i}",ID, + RTC_Ob.RTC_date, RTC_Ob.RTC_month, RTC_Ob.RTC_year, + RTC_Ob.RTC_hour, RTC_Ob.RTC_minute,RTC_Ob.RTC_second); for(;;){ Sampling_Data(); - RTC_READER_DS3231::RTC_ RTC_Ob; - RTC_Ob.RTC_::Read_RTC_Data(); - printf("*%02i-%02i-%02i/%02i:%02i:%02i#", - RTC_Ob.RTC_date, - RTC_Ob.RTC_month, - RTC_Ob.RTC_year, - RTC_Ob.RTC_hour, - RTC_Ob.RTC_minute, - RTC_Ob.RTC_second - ); - Print_Format_Data(ID,OtInterval,counter,factor,Offset,analog[0],analog[1],analog[2],analog[3],analog[4],analog[5],analog[6],analog[7],analog[8]); + Print_Format_Data(OtInterval,counter,factor,Offset,analog[0],analog[1],analog[2],analog[3],analog[4],analog[5],analog[6],analog[7],analog[8]); } } \ No newline at end of file