try this
Fork of DS1307_RTC by
Revision 2:a9a0784930bd, committed 2014-11-01
- Comitter:
- jebradshaw
- Date:
- Sat Nov 01 14:56:37 2014 +0000
- Parent:
- 1:95a90bac5d6d
- Commit message:
- Still need to implement arrays for day and month names
Changed in this revision
DS1307_RTC.cpp | Show annotated file Show diff for this revision Revisions of this file |
DS1307_RTC.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/DS1307_RTC.cpp Sat Nov 01 14:05:25 2014 +0000 +++ b/DS1307_RTC.cpp Sat Nov 01 14:56:37 2014 +0000 @@ -9,9 +9,10 @@ { _i2c.frequency(400000); -// *Day[] = {"","Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; -// *Mon[] = {"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; +/* Day[] = {"","Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; + Mon[] = {"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};*/ + /* Day[0] = ""; Day[1] = "Sun"; Day[2] = "Mon"; @@ -34,6 +35,7 @@ Mon[10] = "Oct"; Mon[11] = "Nov"; Mon[12] = "Dec"; + */ rtc_sec = 0; rtc_minute = 0; @@ -138,10 +140,15 @@ rtc_minute = unbcd(RTC_read_reg(1)); rtc_hours = unbcd(RTC_read_reg(2)); rtc_day = unbcd(RTC_read_reg(3)); + if(rtc_day > 7) + rtc_day = 0; rtc_date = unbcd(RTC_read_reg(4)); rtc_month = unbcd(RTC_read_reg(5)); + if(rtc_month > 12) + rtc_month = 0; rtc_year = unbcd(RTC_read_reg(6)) + YEAR_OFFSET; - sprintf(str, "%2d:%02d:%02d %s %s %d %d", rtc_hours,rtc_minute,rtc_sec,Day[rtc_day],Mon[rtc_month], rtc_date, rtc_year); + sprintf(str, "%2d:%02d:%02d", rtc_hours,rtc_minute,rtc_sec); + //sprintf(str, "%2d:%02d:%02d %s %s %d %d", rtc_hours,rtc_minute,rtc_sec,Day[rtc_day],Mon[rtc_month], rtc_date, rtc_year); //pc.printf("%s", str); }
--- a/DS1307_RTC.h Sat Nov 01 14:05:25 2014 +0000 +++ b/DS1307_RTC.h Sat Nov 01 14:56:37 2014 +0000 @@ -20,8 +20,8 @@ void set_RTC_time_UTC(float utc_time, int timezone); void get_RTC_time(char *str); - char *Day[]; - char *Mon[]; +// char *Day[]; +// char *Mon[]; int rtc_sec; int rtc_minute;