Main Site Documentation

LCD LiveText


#1

I whipped up a little helper class to make displaying things on an LCD shield a little easier. It creates a virtual screen that you can print to and scroll around the viewable area of the LCD.

(link removed)


#2

cool! I hope you do not mind, I made the video visible on the page and added syntax highlighting on the code example.

Thanks for sharing


#3

Awesome! I was wondering how to embed the video. I’m new to contributing to a Wiki and have found the instructions from MediaWiki a bit lacking and some things are just downright obtuse (why not just have a ‘add a new page’ button for instance?) It is far more helpful to look at other pages to see how they have been done.

Overall I really like having the Wiki to share ideas though. I had been thinking of adding a customer page to my own website so folks could showoff the projects they made with their CNC machines. I think a Wiki would be a great way to accomplish that so I really appreciate you guys creating the Wiki site for use users to share ideas and for opening my eyes as to how cool a Wiki can be.


#4

I just uploaded a new version of the code with a few bug fixes and with all the extraneous references removed. The biggest bug was that the display would get corrupted if you tried to update or scroll the screen while it was flashing. Two functions were accessing the same array at the same time (one reading one writing) which is always a bad idea.

I did a bit of research on the locking/synchronization method used by the LED driver and found out that it fit the bill perfectly.


#5

Jeff, great contribution mate, well done!


#6

I got tired of zipping the project up and uploading it every time I made a change so I created a project for it on CodePlex: http://lcdlivetext.codeplex.com/

You can grab it via SVN now: https://LCDLiveText.svn.codeplex.com/svn

Anyhow, while waiting for my microSD card to arrive I added the ability to create custom characters for the LCD, there are a dozen or so ready to use included. The LCD has enough memory to hold 8 custom characters using ASCII 0-7. If you press select on the LCD shield it will run a quick demo that shows a sneaky way to animate a character on the screen by changing the character data.


#7

I made something like this, only it’s somewhat exclusive to the MeLabs SLCD models: http://melabs.com/slcd/index.htm

I might post it tomorrow. It has the added advantage in that the code even works on X86 targets. In other words, I can connect the LCD to my PC (USB->Serial adapter) and talk to it exactly as I can on the FEZ, with only a single line modification required!


#8

I just updated the project on CodePlex again. I added some ‘Smart Scroll Icons’ that flash on/off on the right-hand side of the display to show you which direction(s) to scroll to to see more text. That way you don’t have to wonder if you need to scroll around to see other data or not.


#9

YANU (Yet ANother Update)

The interface to the LCD Shield’s keys is now event driven! I just did a basic ‘fire and event on key up’ type of thing but you could modify the code to keep track of how long a key was down and emit other events (holding a key down could have a different meaning then just clicking it.)

The updateTimer was also improved to give a much snappier response to key presses. The code is well documented and comes with a sample program. The address to download the code from CodePlex is below and the project is on: (link removed)


#10

Hi Jeff,

am interested in using your code with a generic 20x4 LCD - connected to different pins than the GHI board. I have some separate buttons on digital pins (for up down and enter), not on an analog input like the board does.

Any thoughts on how best to approach it?


#11

Brett,

Take a look at the FEZ_Shield_KeyPadLCD_red.cs driver file. You can ignore/eliminate the section dealing with the analog input for keys.

            public static void Initialize()
            {
                LCD_RS = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di8, false);
                LCD_E = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di9, false);
                LCD_D4 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di4, false);
                LCD_D5 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di5, false);
                LCD_D6 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di6, false);
                LCD_D7 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di7, false);

                AnKey = new AnalogIn((byte)FEZ_Pin.AnalogIn.An0);
                BackLight = new PWM((PWM.Pin)FEZ_Pin.PWM.Di10);

This part of the driver maps the LCDs I/O lines to pins on the FEZ. If your LCD uses the standard Hitachi LCD controller interface then you’ll just need to change the mapping here to match your wiring.

Looking at LCDLiveText.cs the section of code below polls the state of the keys on the LCD shield and looks for a button release (would be similar to setting up an interrupt to only fire on one edge of the signal).

        void updateTimerHandler(object target)
        {
            currentButton = FEZ_Shields.KeypadLCD.GetKey();
            if (currentButton != FEZ_Shields.KeypadLCD.Keys.None
                & lastButton == FEZ_Shields.KeypadLCD.Keys.None)
            {
                lastButton = currentButton;
            }
            else if (currentButton == FEZ_Shields.KeypadLCD.Keys.None
                & lastButton != FEZ_Shields.KeypadLCD.Keys.None)
            {
                buttonArg.button = lastButton;
                lastButton = FEZ_Shields.KeypadLCD.Keys.None;
                OnButtonEvent(buttonArg);
            }

When a button release is seen it fires off the OnButtonEvent. To make this work with buttons wired to input pins you could either poll all of the pins to see if one is pressed and then released or use interrupt capable inputs set to generate an interrupt on one edge of the signal (which ever edge is button up). You could use the same interrupt handler for all the buttons and just have it fire the OnButtonEvent with the buttonArg set to the key that was released.

You’ll also need to change

        // visible area of LCD
        const byte LCD_Cols = FEZ_Shields.KeypadLCD.ROW_SIZE;
        const byte LCD_Rows = FEZ_Shields.KeypadLCD.MAX_ROWS;
        const byte VirtualRows = 4; // virtual screen size
        const byte VirtualCols = 40;//

To the proper values for your LCD. The rest of the LCDLiveText should be the same.