This was originally a question I did in my junior year. It was an out-of-class exercise. In the single-chip microcomputer course, an experiment is to control the digital display of a clock. The program logic is very simple and can be expressed by the following pseudo code.
While (true)
{
Accumulate ms time and carry;
If (ScanKeys (& code ))
ProcessKey (code); // process the key
Display (); // refresh the Digital Display
}
The above logic is based on memory, and is actually written in 8051 assembly language, control 6 Led7-segment digital tubes. Output the display code to a port or a peripheral to control the digital display. The hour, minute, and second are stored in the storage unit. You can press a specific key to adjust the value of the hour, minute, and second of the clock.
This part of the code already exists in the book. The instructor's extra-curricular question is like this. He said that when he tried to adjust the time, the corresponding data bit blinks. And screen saver functions. In the end, I was the only professional who made this program (of course, because few people tried to do this). I made dynamic Screen Saver effects (inspired by the flash of the neon lights) beyond the expectation of the teacher. I remember that I quickly drew a detailed flowchart and quickly wrote the main function code. Then, two weeks later, we could have a chance to get on the machine. After a long, anxious and excited wait. It is not until I enter all the written code on my computer. After simple debugging, the code runs successfully and the expected results are displayed.
I drew a clean and clear flowchart on the draft and introduced a state variable in the internal register. Through this variable, I recorded the status of the current program, which is blinking, screensaver, it is still displayed normally. Then, different Display control codes are output in the Display function based on the corresponding status and specific time.
After many years, I checked my own Led controls and suddenly came up with the idea of re-implementing the Single-Chip Microcomputer Program in winform. I thought it was not difficult, but the status was cumbersome, it still took some time to debug.
Effect:
Source code: (vs2005)
Http://files.cnblogs.com/hoodlum1980/LedTest_02 (vs8).rar