User Tools

Site Tools


clockcontrol

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
clockcontrol [2019/05/07 11:08]
hutch [Helps]
clockcontrol [2019/05/07 11:17] (current)
hutch
Line 38: Line 38:
  
 Add this functionality to the original state-diagram and then implement it using the conversion process outlined in the text.  Be sure to follow the guidelines in [[http://​ecen330wiki.groups.et.byu.net/​wiki/​doku.php?​id=coding_strategy_standard_for_state_machines| Coding and Debugging State Machines]]. Add this functionality to the original state-diagram and then implement it using the conversion process outlined in the text.  Be sure to follow the guidelines in [[http://​ecen330wiki.groups.et.byu.net/​wiki/​doku.php?​id=coding_strategy_standard_for_state_machines| Coding and Debugging State Machines]].
- 
----- 
-=== Clock Display Helps === 
- 
-You can use the '​C'​ function ''​[[http://​www.tutorialspoint.com/​c_standard_library/​c_function_sprintf.htm|sprintf()]]''​ to greatly reduce the amount of work for generating the display. ''​sprintf()''​ is just like ''​printf()''​ except that, instead of printing to a terminal window, it "​prints"​ the characters to a ''​char''​ array. Here is what I suggest: 
-  * Use three different variables to maintain the time as hours, minutes and seconds. 
-  * Use ''​sprintf()''​ to format these three variables into a time string (array of ''​char''​). Study the formatting directives for ''​sprintf()''​. For example, "''​%2hd''"​ prints a decimal value ("​h"​ indicates a short int) with a width of 2 with a leading space if the leading digit would be a 0. "''​%02hd''"​ prints a decimal value but includes the leading 0. Think about how you might use these formatting strings together to format a time string. Combining these formatting strings with a couple of other things will completely format the clock string with no additional programming. 
-  * Keep two ''​char''​ arrays. One array is used to store the string containing the current time displayed on the LCD. The other string keeps track of the clock string that was written previously. Each time a change is made to the time either by keeping time, or by setting the time, compare the characters in the two ''​char''​ arrays. When you find a difference between the two arrays, erase the character(s) on the LCD display at that position and then redraw the new character(s). Redrawing is just drawing the previous character as background (''​DISPLAY_BLACK''​) in this case. You then simply draw the new character in its place. 
-  * DISPLAY_WIDTH and DISPLAY_HEIGHT are defined in display.h to be the correct values for the TFT display. 
  
 ---- ----
  
clockcontrol.txt ยท Last modified: 2019/05/07 11:17 by hutch