Auto DST adjustment for ds1307/ds3231

ac21

Member
I made a adjustment to marks code to auto adjust for daylight savings time in the US.
The rule is as follows:

begins(+1 hour) at 2:00 a.m. on the second Sunday of March and
ends(-1 hour) at 2:00 a.m. on the first Sunday of November

this is the code tell me what you think the lines in red is what I added.

Code:
      [color=Blue]SYMBOL [/color][color=Purple]character1    [/color][color=DarkCyan]= [/color][color=Purple]B2
      [/color][color=Blue]SYMBOL [/color][color=Purple]character2    [/color][color=DarkCyan]= [/color][color=Purple]B3  
      [/color][color=Blue]SYMBOL [/color][color=Purple]character3    [/color][color=DarkCyan]= [/color][color=Purple]B4  
      [/color][color=Blue]SYMBOL [/color][color=Purple]character4    [/color][color=DarkCyan]= [/color][color=Purple]B5  
      [/color][color=Blue]SYMBOL [/color][color=Purple]character5    [/color][color=DarkCyan]= [/color][color=Purple]B6  
      [/color][color=Blue]SYMBOL [/color][color=Purple]character6    [/color][color=DarkCyan]= [/color][color=Purple]B7
      [/color][color=Blue]SYMBOL [/color][color=Purple]hours         [/color][color=DarkCyan]= [/color][color=Purple]B8
      [/color][color=Blue]SYMBOL [/color][color=Purple]mins          [/color][color=DarkCyan]= [/color][color=Purple]B9
      [/color][color=Blue]SYMBOL [/color][color=Purple]secs          [/color][color=DarkCyan]= [/color][color=Purple]B10
      [/color][color=Blue]SYMBOL [/color][color=Purple]day           [/color][color=DarkCyan]= [/color][color=Purple]B11 
      [/color][color=Blue]SYMBOL [/color][color=Purple]date          [/color][color=DarkCyan]= [/color][color=Purple]B12  
      [/color][color=Blue]SYMBOL [/color][color=Purple]month         [/color][color=DarkCyan]= [/color][color=Purple]B13
      [/color][color=Blue]SYMBOL [/color][color=Purple]year          [/color][color=DarkCyan]= [/color][color=Purple]B14
      [/color][color=Blue]SYMBOL [/color][color=Purple]PM_AM         [/color][color=DarkCyan]= [/color][color=Purple]B15
      [/color][color=Blue]Symbol [/color][color=Purple]DST           [/color][color=DarkCyan]= [/color][color=Purple]b16 
       [/color]

[color=Black]Main: [/color]
[color=Blue]pause [/color][color=Navy]1000
       [/color][color=Blue]HI2Csetup I2Cmaster[/color][color=Black], [/color][color=Navy]%11010000[/color][color=Black], [/color][color=Blue]I2Cslow[/color][color=Black], [/color][color=Blue]I2Cbyte        
       HI2Cin [/color][color=Navy]$0[/color][color=Black],   [/color][color=Blue]([/color][color=Purple]secs[/color][color=Black],[/color][color=Purple]mins[/color][color=Black],[/color][color=Purple]hours[/color][color=Black],[/color][color=Purple]day[/color][color=Black],[/color][color=Purple]date[/color][color=Black],[/color][color=Purple]month[/color][color=Black],[/color][color=Purple]year[/color][color=Blue]) [/color][color=Green]' read time 
       
       [/color]
[color=Black]ClockDisplay:
    [/color][color=Purple]PM_AM [/color][color=DarkCyan]=[/color][color=Red]"P" [/color][color=Black]: [/color][color=Blue]IF [/color][color=Purple]hours [/color][color=DarkCyan]< [/color][color=Navy]$12 [/color][color=Blue]then :[/color][color=Purple]PM_AM [/color][color=DarkCyan]= [/color][color=Red]"A" [/color][color=Black]: [/color][color=Blue]ENDIF       [/color][color=Green]'indicate PM  or AM
    
    [/color][color=Blue]IF [/color][color=Purple]hours [/color][color=DarkCyan]= [/color][color=Navy]$20 [/color][color=DarkCyan]OR [/color][color=Purple]hours [/color][color=DarkCyan]= [/color][color=Navy]$21 [/color][color=Blue]THEN [/color][color=Black]: [/color][color=Blue]LET [/color][color=Purple]hours [/color][color=DarkCyan]= [/color][color=Purple]hours [/color][color=DarkCyan]- [/color][color=Navy]$6 [/color][color=Black]: [/color][color=Blue]ENDIF
    IF [/color][color=Purple]hours [/color][color=DarkCyan]> [/color][color=Navy]$12 [/color][color=Blue]THEN [/color][color=Black]: [/color][color=Blue]LET [/color][color=Purple]hours [/color][color=DarkCyan]= [/color][color=Purple]hours [/color][color=DarkCyan]- [/color][color=Navy]$12 [/color][color=Black]: [/color][color=Blue]ENDIF       [/color][color=Green]'24 to 12 hour format
    [/color][color=Blue]IF [/color][color=Purple]hours [/color][color=DarkCyan]= [/color][color=Navy]$0 [/color][color=Blue]THEN  [/color][color=Black]: [/color][color=Purple]hours [/color][color=DarkCyan]= [/color][color=Navy]$12 [/color][color=Black]: [/color][color=Blue]ENDIF
    
    
    [/color][color=red]IF DST = 1 and month = 3 and day = $07 and date > $07 and hours = $02 then gosub mar[/color]
    
    [color=red]IF DST = 0 and month = 11 and day = $07 and hours = $02 then gosub nov [/color]         
  
    
    
   [/color][color=Blue]BcdTOASCII [/color][color=Purple]hours[/color][color=Black],[/color][color=Purple]character1[/color][color=Black],[/color][color=Purple]character2 [/color][color=Black]: [/color][color=Blue]IF [/color][color=Purple]character1 [/color][color=DarkCyan]= [/color][color=Red]"0" [/color][color=Blue]THEN [/color][color=Black]: [/color][color=Purple]character1 [/color][color=DarkCyan]= [/color][color=Red]" " [/color][color=Black]: [/color][color=Blue]ENDIF [/color][color=Green]' zero blanking character1
   [/color][color=Blue]BcdTOASCII [/color][color=Purple]mins [/color][color=Black],[/color][color=Purple]character3[/color][color=Black],[/color][color=Purple]character4
   [/color][color=Blue]BcdTOASCII [/color][color=Purple]secs [/color][color=Black],[/color][color=Purple]character5[/color][color=Black],[/color][color=Purple]character6 
 [/color][color=Blue]sertxd (CR[/color][color=Black],[/color][color=Blue]LF[/color][color=Black],[/color][color=Purple]character1[/color][color=Black],[/color][color=Purple]character2[/color][color=Black],[/color][color=Red]"."[/color][color=Black],[/color][color=Purple]character3[/color][color=Black],[/color][color=Purple]character4[/color][color=Black],[/color][color=Red]"."[/color][color=Black],[/color][color=Purple]character5[/color][color=Black],[/color][color=Purple]character6[/color][color=Black],[/color][color=Red]" "[/color][color=Black],[/color][color=Purple]PM_AM[/color][color=Black],[/color][color=Red]"M    "[/color][color=Blue]) [/color][color=Green]'(11.58.00 PM)
 [/color]
[color=Black]DateMonthYearDisplay:
   [/color][color=Blue]BcdTOASCII [/color][color=Purple]date [/color][color=Black],[/color][color=Purple]character1[/color][color=Black],[/color][color=Purple]character2
   [/color][color=Blue]BcdTOASCII [/color][color=Purple]month[/color][color=Black],[/color][color=Purple]character3[/color][color=Black],[/color][color=Purple]character4 [/color][color=Black]: [/color][color=Blue]IF [/color][color=Purple]character3 [/color][color=DarkCyan]= [/color][color=Red]"0" [/color][color=Blue]THEN [/color][color=Black]: [/color][color=Purple]character3 [/color][color=DarkCyan]= [/color][color=Red]" " [/color][color=Black]: [/color][color=Blue]ENDIF
   BcdTOASCII [/color][color=Purple]year [/color][color=Black],[/color][color=Purple]character5[/color][color=Black],[/color][color=Purple]character6
 [/color][color=Blue]sertxd ([/color][color=Purple]character3[/color][color=Black],[/color][color=Purple]character4[/color][color=Black],[/color][color=Red]"/"[/color][color=Black],[/color][color=Purple]character1[/color][color=Black],[/color][color=Purple]character2[/color][color=Black],[/color][color=Red]"/20"[/color][color=Black],[/color][color=Purple]character5[/color][color=Black],[/color][color=Purple]character6[/color][color=Black],[/color][color=Blue]CR[/color][color=Black],[/color][color=Blue]LF)[/color][color=Green]' (05/11/13)
     

     [/color][color=Blue]goto [/color][color=Black]main[/color]

    [color=red]	mar: 
	DST=0
	let hours = hours + $01
	HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte           
       HI2Cout $2,  (hours)
	 pause 200
	 return[/color]
       
 [color=red]	 nov:
	 DST=1
	 let hours = hours - $01
	 HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte           
       HI2Cout $2,  (hours)
	 pause 200
	 return [/color]
 

marks

Senior Member
Hi ac21,
thats much the way i'd proberly choose to do it '
luckily no DayLightSavingsTime here to worry about !
here's your code slight rewrite.

Code:
 #terminal 9600 'x1 x2
 ' #terminal 4800 'm2
   SYMBOL secs          = b2
   SYMBOL mins          = b3
   SYMBOL hours         = b4  
   SYMBOL day           = b5  
   SYMBOL date          = b6  
   SYMBOL month         = b7   
   SYMBOL year          = b8
   SYMBOL PM_AM         = b9
   SYMBOL D0            = b10       
   SYMBOL D1            = b11
   SYMBOL D2            = b12 
   SYMBOL D3            = b13
   SYMBOL D4            = b14
   SYMBOL D5            = b15 
   SYMBOL DST           = b16 
            
Initialize:            
   HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte       ' Set to 100kbps 
       HI2Cout $0 , ( $00, $59, $01 , $1, $09, $11 , $14) ' Uncomment to Program         example (01.59.00 AM)
;Progam  Registers  (secs,mins,hours,day,date,month,year) ' Enter in BCD           hours example ( $0 to $23 )
   DST =1

Main: 
pause 1000
  ReadRegisters:     
       HI2Cin  $0 , (secs,mins,hours,day,date,month,year) ' Read from DS3231 or DS1307
       
  DaylightSavingsTime:
    IF DST =0 AND month =$3 THEN 
       IF day =$1 AND date >$7 AND hours =$2 THEN         'Day = $1  Sunday)
         INC hours : HI2Cout  $2 , (hours) : DST =1
       ENDIF     
    ENDIF  
    IF DST =1 AND month =$11 THEN 
       IF day =$1 AND date >$7 AND hours =$2 THEN
         DEC hours : HI2Cout  $2 , (hours) : DST =0
       ENDIF     
    ENDIF
       
  ClockDisplay:
    PM_AM ="P" : IF hours <$12 THEN :PM_AM = "A" : ENDIF       'Indicate P or A
    
    IF hours =$20 OR hours =$21 THEN : LET hours =hours -$6 : ENDIF
    IF hours >$12 THEN : LET hours =hours -$12 : ENDIF       '24 to 12 hour format
    IF hours =$0 THEN  : hours =$12 : ENDIF
    
   BcdTOASCII hours,D5,D4 : IF D5 = "0" THEN : D5 = " " : ENDIF 'Zero blanking 
   BcdTOASCII mins ,D3,D2
   BcdTOASCII secs ,D1,D0   
       sertxd (CR,LF,D5,D4,".",D3,D2,".",D1,D0," ",PM_AM,"M  ") '(11.59.00 PM )
   
   BcdTOASCII date ,D5,D4 
   BcdTOASCII month,D3,D2
   BcdTOASCII year ,D1,D0   
       sertxd (D5,D4,"/",D3,D2,"/20",D1,D0)                     '(28/06/2011)
    IF DST =1 THEN : sertxd ("  DST")  : ENDIF                  '(DST)
               
  GOTO Main
 

hippy

Ex-Staff (retired)
Adjusting for DST can be a lot more complicated than it first appears, and especially if moving the actual RTC time forward or back an hour.

In this case the PICAXE has to be running at the time of a DST change for it to take effect. If the PICAXE is off and the RTC is running on battery power, if the PICAXE is powered up again after the DST change occurs then it will not be adjusted.

If the PICAXE is powered up at an unfortunate time, and the DST adjustment is applied then, it may be that only the hour is changed without adjusting the date which can put the date and time well out.

Also, If the DST flag is not stored in non-volatile memory, if the power goes off and comes back around the DST change time, you may get multiple incorrect DST adjustments occurring. Unlikely as it may be, if the power fails between adjusting the time and storing the DST flag then multiple changes can occur then.

My feeling is that it is better to ignore these possibilities and potential problems and never adjust the actual RTC time when DST changes occur. Keep it always running at non-DST time and adjust the data returned when the RTC date and time is read depending on what the data read is. In pseudo code -

Code:
Gosub ReadTime
If dateAndTime >= startOfDST Then
  If dataAndTime < endOfDST Then
    dateAndTime = dateAndTime + 1 hour
  End If
End If
 

marks

Senior Member
I guess thats why its important to display DST so you are aware time has been adjusted.
added dst saved to eeprom and checking of sent data to rtc.
Code:
#terminal 9600
   SYMBOL secs          = b2
   SYMBOL mins          = b3
   SYMBOL hours         = b4  
   SYMBOL day           = b5  
   SYMBOL date          = b6  
   SYMBOL month         = b7   
   SYMBOL year          = b8
   SYMBOL PM_AM         = b9
   SYMBOL D0            = b10    SYMBOL checkhours            = b10 
   SYMBOL D1            = b11
   SYMBOL D2            = b12 
   SYMBOL D3            = b13
   SYMBOL D4            = b14
   SYMBOL D5            = b15 
   SYMBOL DST           = b16          
Initialize:            
   HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte       ' Set to 100kbps 
       HI2Cout $0 , ( $00, $59, $01 , $1, $02, $11 , $14) ' Uncomment to Program DS3231  example (01.59.00 AM)
        write 10 , 1                             ' Uncomment if programming during DST
       'write 10 , 0                             ' Uncomment if programming ouside DST hours
;Progam  Registers  (secs,mins,hours,day,date,month,year) ' Enter in BCD           hours example ( $0 to $23 )
  
   Read 10 , DST  ' read saved DST at Eeprom location 10
Main: 
pause 1000
  ReadRegisters:     
       HI2Cin  $0 , (secs,mins,hours,day,date,month,year) ' Read from DS3231 
       
  DaylightSavingsTime: 
    IF DST =0 AND month =$3 THEN 'will update from 0200-0800 2nd sunday in march if picaxe powered
       IF day =$1 AND date >$7 AND hours >$1 AND hours <$9 THEN         'Day = $1 is usually a Sunday)
          checkhours =hours +$1 : HI2Cout $2 , (checkhours)  
                     HI2Cin  $2 , (hours) : IF hours = checkhours THEN : Write 10,1: ENDIF 'Validdate rtc data
         Read 10 , DST            
       ENDIF     
    ENDIF  
    IF DST =1 AND month =$11 THEN 'will update from 0200-0900 1st sunday in november if picaxe powered
       IF day =$1 AND date <$8 AND hours >$1 AND hours <$10 THEN
          checkhours =hours -$1 : HI2Cout $2 , (checkhours)  
                     HI2Cin  $2 , (hours) : IF hours = checkhours THEN : Write 10,0: ENDIF 'Validdate rtc data
         Read 10 , DST            
       ENDIF     
    ENDIF
       
  ClockDisplay:
    PM_AM ="P" : IF hours <$12 THEN :PM_AM = "A" : ENDIF       'Indicate P or A
    
    IF hours =$20 OR hours =$21 THEN : LET hours =hours -$6 : ENDIF
    IF hours >$12 THEN : LET hours =hours -$12 : ENDIF       '24 to 12 hour format
    IF hours =$0 THEN  : hours =$12 : ENDIF
    
   BcdTOASCII hours,D5,D4 : IF D5 = "0" THEN : D5 = " " : ENDIF 'Zero blanking 
   BcdTOASCII mins ,D3,D2
   BcdTOASCII secs ,D1,D0   
       sertxd (CR,LF,D5,D4,".",D3,D2,".",D1,D0," ",PM_AM,"M  ") '(11.59.00 PM )
   
   BcdTOASCII date ,D5,D4 
   BcdTOASCII month,D3,D2
   BcdTOASCII year ,D1,D0   
       sertxd (D5,D4,"/",D3,D2,"/20",D1,D0)                     '(28/06/2011)
    IF DST =1 THEN : sertxd ("  DST")  : ENDIF                  '(DST)
               
  GOTO Main
 
Last edited:

hippy

Ex-Staff (retired)
I guess thats why its important to display DST so you are aware time has been adjusted.
added dst saved to eeprom and checking of sent data to rtc.
I think you may have meant to use WRITE rather than READ in the code.

Adding a report of when DST is active possibly helps but still doesn't get round the fundamental potential flaws. Those flaws may be dismissed as unlikely to cause problems but the fact remains that they do exist. "Sometimes automatically adjusts for DST" isn't the same as "always automatically adjust for DST". It's true that the former may be perfectly acceptable but it isn't the later.
 

bryanl

Member
Adjusting for DST can be a lot more complicated than it first appears ... If the PICAXE is powered up at an unfortunate time, ... Also, If the DST flag is not stored in non-volatile memory, if the power goes off and comes back around the DST change time, you may get multiple incorrect DST adjustments occurring.
The clock chip has 56 bytes of SRAM available that I use to store whether or not DST is enabled, DST is in effect, and other flags and values. My grand PICAXE Clock Exercise has both a startup evaluation of current clock status with DST in order to catch DST changes that might have occurred when the power was off. Another routine, called when the hours change, does the current DST changeover. The code is early yet but here is the idea for the startup check (i,j,k etc are byte registers, ij etc are the word registers with i and j bytes etc. dow is a standard day of week calculation)

Code:
DST status check. if clock was off during DST switchover then
 adjustments need to be made
This is successive filtering by DST_Enabled, month, day of
 week, then hour with summer or winter escape depending upon
 stored status of DST_in_effect
#ENDREM
	If DST_enabled=0 Then Goto reset_clock_display	; no DST adjustment worries
	hi2cin 5, (b0) 		; get month
	j = BCDtoBIN b0
	If DST_in_effect=0 Then
		If j<3 OR j>11 Then Goto reset_clock_display	; winter and DST is off
	Else			; see if summertime and DST is on
		If j>3 AND j<11 Then Goto reset_clock_display
	EndIf
	; SerTxd("DST month ",#j,cr,lf)	; should be 3 or 11

; DST status down to the day of week and date in March or November
	hi2cin 6, (b0)			; get year
	i = BCDtoBIN b0
	; j is month from above
	; k = BCDtoBIN da 	; will be set to first possible Sunday for changeover
	; p is to be changeover date

	If j = 3 Then
		k = 8	; first possible DST changeover date in March
		Gosub calculate_dow			; i,j,k => wd
		hi2cin 3, (b0)		; weekday stashed here
		If b0 = 0 Then
			p = 8			; p will be March DST day
		Else
			p = 15 - b0
		EndIf
		hi2cin 4, (b0)		; get current date
		k = BCDtoBIN b0
;		SerTxd("March ",#k, " DST day is ",#p," DST opt=",#DST_in_effect,cr,lf)
		If DST_in_effect = 1 Then
			If k > p Then Goto reset_clock_display	; summer OK
		Else
			If k < p Then Goto reset_clock_display	; not quite yet OK
		EndIf
	Else			; if j=11 (but it must from previous checks!?)
		k = 1		; first possible DST changeover date in November
		Gosub calculate_dow	; i,j,k => wd
		hi2cin 3, (b0)		; weekday offset
		If b0 = 0 Then
			p = 1
		Else
			p = 8 - b0		; p has November DST date
		EndIf
		hi2cin 4, (b0)		; get current date
		k = BCDtoBIN b0
;		SerTxd("Nov ",#k, " DST day is ",#p," DST opt =",#DST_in_effect,cr,lf)
		If DST_in_effect = 0 Then
			If k > p Then Goto reset_clock_display	; winter OK
		Else
			If k < p Then Goto reset_clock_display	; not quite yet OK
		EndIf
	EndIf

; DST status down to the hour on changeover day
	n = k				; current date as parse hours uses k
	hi2cin 2, (b0)		; get hour with flags
	GoSub parse_hours	; launder b0, set thc and morning, k to binary 24 hours
	; SerTxd("DST hour: ",#k,cr,lf)
	If k<2 AND n=p Then
;		SerTxd ("today is changeover, but early yet @",#i,"hours",cr,lf)
		Goto reset_clock_display
	EndIf
	
	hi2cin 5, (b0) 		; get month
	j = BCDtoBIN b0 	; DOW calc may have munged this so reset to be sure
	If DST_in_effect = 1 Then	; see if it needs turned off
		If j = 11 Then			; first Sunday in November 2 am or later
			dec k
			DST_in_effect = 0
		Else
;			SerTxd ("mo ",#j, " DST in effect=",#DST_in_effect," all OK",cr,lf)
			Goto reset_clock_display
		EndIf
	Else				; DST not in effect; see if it needs turned on
		If j = 3 Then	; 2nd Sunday in March after 2 am
			inc k		; need bcdtobin and am/pm, and rollover handled
			If k > 23 Then Goto reset_clock_display	; avoid calendar rollover
				; let user restart clock at a more reasonable time to
				; get DST adjustment
			DST_in_effect = 1
		Else
;			SerTxd ("mo ",#j, " DST in effect=",#DST_in_effect," all OK",cr,lf)
			Goto reset_clock_display
		EndIf
	EndIf	; DST_in_effect?

;	SerTxd ("DST enable and adjust",cr,lf)
; b1 may have been used by somebody so its not a reliable place to for this
	If twc = 1 Then	; 12 hour mode
		If k > 12 Then
			k = k - 12
			morning = 1
		EndIf
	EndIf
	b0 = BINtoBCD k
	If twc = 1 Then
		bit6 = twc
		bit5 = morning
	EndIf
	hi2cout SRAM_flags, (clock_flags)	; save DST condition flags
	hi2cout 2, (b0)					; save adjusted hour
interesting stuff. Right now, I am putting together a UTC toggle function to switch back and forth between local and UTC which can get interesting as calendar rollovers are more likely with that. I'll post the whole thing with my comments on my blog when I get a few more 'experiments' tied down for anyone interested.
 

marks

Senior Member
As usual that was probably worded badly.
when it confirms the rtc returns the correct hour it WRITEs direct to eeprom.
it then READs into variable DST used for sertxd indicating DST.

I do agree with what your saying Hippy!
Power would be required to the picaxe between 2-3am to update ,which happens at the start of DST and the end of DST only.
if it fails you would not see the correct DST indication , and would have to reprogram manualy.

As you'hve pointed out it would be preferable to code dynamically which would be a lot more involved
i might try 1 day when i write some gps code .i have a long list of wants to do's lol
 

hippy

Ex-Staff (retired)
Right now, I am putting together a UTC toggle function to switch back and forth between local and UTC which can get interesting as calendar rollovers are more likely with that.
That's where always keeping the clock on UTC and using that or calculating DST for display makes sense; either add an hour or don't.

It's a tad complicated because adding an hour can take it into another day ( and/or another month in Europe etc ). And you have to reverse that when setting a UTC clock from a DST local time.

It's not too hard though and it also lays the foundation for a world clock. It's also needed for GPS time where you can't force the actual time source forwards or backwards.
 

bryanl

Member
always keeping the clock on UTC and using that or calculating DST for display makes sense; either add an hour or don't.
The issue is one of balance about where to have the calendar smarts: Keep it in the clock chip or replicate it in your own code.

DST adjustments are just one hour. The reason that 2 a.m. is a good adjustment hour is that no rollover is involved to "spring forward" or "fall back" an hour at that time. There are also no a.m. vs p.m. issues either. That keeps things simple as far as clock changes. The only complexity is in determining which 2 am invokes the adjustment.

DST status evaluation and correction brings in the problem of possibly adjusting the hour into another day. That means that calendar smarts would be needed. That means knowing the number of days in each month, being able to determine if it is a leap year, and providing the logic to count the calendar up or down properly.

A UTC clock displaying local time encounters the same problem. With DST status correction, it is possible to ignore any changes that would invoke a calendar rollover (ignore the adjustment until the operator starts the clock at a more reasonable time). UTC vs local changes are much more likely to invoke calendar rollover and this means each display or use of the time would require doing the whole calendar logic and knowledge algorithm thing. That's lotsa' code and lotsa' processing time.

For a clock exercise, working through the DST adjustment, state evaluation, and calendar rollover provide good examples for code expression. Separating the clock keeping function from the mcu provides a few more targets as well. I2C communication is one but matters of updating the display only with what changes, limiting code steps to only what is necessary, update on interrupt (and trying to disambiguate conflicting documentation and examples), interactive feature exploration, time setting and adjustment options, remote persistent storage, and implementation of mcu features like the touch input (again, needing significant disambiguation from conflicting and misleading documentation and examples) all provide good investigation and learning opportunity.

I have more on the disambiguation efforts as suggestions but I am not quite sure where or how to put them yet. I am also trying to clarify the need for consistent conceptual models in a process oriented reference as a part of this. (Very important for education but not so much for training.)
 
Top