PDA

View Full Version : I need help on who to write a program using LCD display and 5 buttons which wil



Potato
05-20-2010, 10:51 AM
The purpose of this program is to display 6 characters on a serial display, allow me to edit the characters, one at a time and when done send the characters out my serial port. I have 5 input buttons, Up, Down, Left, Right, Enter. I want to start with the value ABC123. and display it on the screen. The first character blinking indicating it was the character to change. Press the up button and the first character would change from A to B or the down button would change from A to Z. When satisfied with the letter, I want to press enter and move to the next character.
MY PROBLEM, I don't have a clue as to where to start. Has anyone seen examples of such code? I don't want to re-invent the wheel. I think someone must have done that before me.

All help would be greatly appreciated. Rick

MagIO2
05-20-2010, 02:20 PM
Are you familiar with the serial display? How to position the cursor ...

Of course there are many ways to do that and it depends on what else you want to do.
The easiest way is to have one COG updating the display including the blinking:

repeat
1. copy string from global buffer to internal buffer
2. if it's character off-time, overwrite the character at 'actualPos' with space
3. set the display cursor to the string position
4. write the string
5. wait for some ms
6. decide if it's on- or off- time

Then the second COG would be used to read the buttons and update 'actualPos' by hitting left/right/enter and update the character by hitting up/down in the global buffer.

Potato
05-21-2010, 07:52 AM
Thank You MagIO2. I will let you know how it goes and post my code here. You have given me the basic idea. I am using the Parallax serial display and do know how to position the cursor.
Rick

JonnyMac
05-21-2010, 12:28 PM
As an exercise before bed I wrote a little demo code form my LCD UI module -- then I noticed that you're using a serial display (mine is parallel). I followed MagIOs process and it works well. You should be able to adapt this fairly easily and finish up (I only did the editing portion).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

MagIO2
05-21-2010, 01:51 PM
Thanks for giving positive feedback.

With a parallel LCD (4 bit bus) it's much easier! Grab my LCD driver and set it up in 'screen buffer'-mode and use a blinking character to show the active character. The refresh and blinking is done by the driver. ;o)

How about inverting the actual character instead of blinking. Is it possible to read the font data from an LCD display? Maybe I'll take that as an exercise the next days .... maybe not - currently busy with my driver model.

Potato
05-21-2010, 03:39 PM
John, Thank you very much. This is a great help.
Rick

JonnyMac
05-21-2010, 11:06 PM
MagIO2 said...

Thanks for giving positive feedback.

With a parallel LCD (4 bit bus) it's much easier! Grab my LCD driver and set it up in 'screen buffer'-mode and use a blinking character to show the active character. The refresh and blinking is done by the driver. ;o)

How about inverting the actual character instead of blinking. Is it possible to read the font data from an LCD display? Maybe I'll take that as an exercise the next days .... maybe not - currently busy with my driver model.
You can read the ASCII code, but not the character map data from the DDRAM. What you'd be forced to do is create a (big) table of inverse characters that you could reference based on the ASCII code retrieved from the display. Then you'd have to download the eight bytes to one of the custom characters and display that.


This kind of thing is possible; I once created a rolling digit odometer type display using a BS2p and a table with a rotating digit pattern. In the display I used custom character 0 for the rolling digit. Since the LCD auto refreshes any time I changed the character map the display automatically updated. It was a neat effect.

[Edit] As a quick mental warm-up before I tackle a work project I tried the inverted character approach -- but just on the digits so I didn't have to build a big table. For some digits it looks nice, not so much with others. I don't think I would use this approach. BTW... you don't have to manually create character maps. When working at Parallax in 2001 I wrote a little program called LCD Character Creator and it has the standard character maps built in.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Post Edited (JonnyMac) : 5/21/2010 6:13:47 PM GMT

SkyKit
05-22-2010, 02:57 AM
A few months ago I needed something similar but, sorry, using a different micro. But when editing the characters I found out that is faster if I start with "NNNNNN" or "NNN555" because, statistically, you'll need less keys to reach your desired letter or number.

Potato
05-22-2010, 06:46 AM
Thst's great.
Rick