This is a continuation of the prior post about the Times Square Scroll display on a 16 character by 2 line LCD Display. The entire Python code for that program is at the top of that blog post. I discussed a code fragment for a simplier version that only displays on the top line of the display. That fragment replaced lines 49 through 75. It's now time to discuss the two line version. So that the reader will not have to go back and forth between this post and the last post, I have repeated the code fragment for the top line only display and made a code fragment that corresponds to lines 49 through 75 of the complete program.
Recall in the prior post I showed that it is possible to have a garbled display of the text where previously entered characters on the other display line, and newly entered characters both get displayed. Recall Fig. 5 from the last post.
There are two opportunities for this to occur with the two line display. We have the end of the address space situation discussed in the last post. Recall, if we don't take corrective action, the next character will be displayed on the wrong display line. That situation will be solved in nearly the same manner as we solved it before.
The end of the address space situation is solved in the four lines, 12 to 15, in the top line only display. The four lines, 17 to 20, handle this in the two line display. The code is very similar but the two line display must deal with characters on both lines. The two line version simply subtracts 28h from the address counter if the address counter reaches 28h or 68h. I'm going to explain line 18 further in my next post which talks about hexadecimal numbers.
Now let's discuss the second cause of a garbled display. When we have completed the first pass through the text on the top line, we move down to the bottom line. However, the characters that we put into the top line memory are still in that memory. Eventually, as we add more characters to the bottom line, and the Visible Memory window continues to move, the characters that are in the top line memory start to become visible. When we finish the bottom line, we move to the top line and the old bottom line characters evenually start to show up. This goes on and on until we push the switch to stop the program from running.
I solve that problem by overwriting the old characters with spaces. Evety time I finish writing a character to the display, I erase a character before I write the next character. I could not allow the display to shift automatically after I write a character. Code line 1 of the top line only version does not appear in the two line version. After I write a character (code line 11), I write a space to the same address position on the other display line (code lines 12 and 13). I then restore the address counter back to the line I was writing characters to, and increment the address counter (code line 14, and increment by adding 81h rather than 80h to the address counter). Finally, I manually shift the display to the left, which moves the Visible Memory window to the right (code line 15).
For example, if I write a character to memory position 10h on the top line, I write a space to memory position 50h, overwriting any character that was there. Look at Figures 2,3, or 4 in the last post for reference.
Code line 12 of the two line version will be discussed further in the next post.
No comments:
Post a Comment