Graphical Display of Keypad on GLCD using PIC microcontroller

///Graphical Display of Keypad on GLCD using PIC microcontroller
  • Graphical Display of Keypad on GLCD using PIC microcontroller

Graphical Display of Keypad on GLCD using PIC microcontroller

A graphical LCD is an electronic display unit which can display any type of elements provided by the user. Unlike a character LCD which can only display alphanumeric characters, a graphical LCD can display images, fonts and other structures. This article gives details of graphic LCD interfacing with a PIC microcontroller.

Previously we learned how to interface Keypad and GLCD with PIC microcontrollers. Now let’s integrate both these peripherals to display the keypad and its response on the GLCD graphically. To this end, we need to create functions for keypad input reception and GLCD display of keypad, along with the standard GLCD libraries.

Displaying Keypad on GLCD

To display keypad response on the GLCD, we need to first display the initial state of the keypad and then display an appropriate animation for the key pressed. The display is then reverted back to the initial state ready to display the next keypad response. This could be done with or without bitmaps.

In bitmap method, the display image for initial state and the animation image for each key pressed is stored at different locations in the RAM. After displaying the initial image, whenever a key is pressed the corresponding bitmap is displayed. The display is then reverted back after some delay. The downside of this method is that the code itself occupies a lot of RAM since each bitmap has a size of 8Kb (128*64 bits). Also, the delay in displaying a full bitmap is high. So here we will be using character display method which does not use bitmaps.

Graphical Display of Keypad on GLCD

To display the initial 4*4 matrix keypad we need to display each keys as characters at the required locations. You could also create and print some custom characters to create the frame of the keypad.

Example Firmware:

Now that the initial keypad display is done, we need to read a key press and then display a corresponding key animation.

Keypad Input Reception

As specified in our previous tutorial on Matrix keypad interfacing with a PIC Microcontroller, the keypad that we use here is a 4*4 matrix keypad with 4 columns and 4 rows. We use the rows as output from the microcontroller to the keypad and the columns as the input to read and determine which key was pressed. This can be done in Pull up mode or Pulldown mode. Here we will be using Pull up mode, where we will be sensing for an input ‘Low’ in the column pins.

In keypad interfacing, we will provide output ‘Low’ to each of the row pins sequentially and check the column pins for input ‘Low’ in each case. The output swipe of ‘Low’ across each row is fast enough to complete at least one full cycle by the time a key is released after the key press. When the key is pressed, the corresponding row and column pins will be shorted, providing us with an input ‘Low’ at the particular column, in the particular stage of the output swipe. Thus the appropriate key press could be determined. This key value is to be returned to the calling function to display it in the GLCD.

Example Firmware:

Here ‘read’ is a user defined macro to read the 4 bits of columns. The ‘wait’ function is used for debouncing the input, where we will wait till the key is released to ensure that the key is detected only once after a single press.

Example Firmware:

Note: Here we have used PORTB for the keypad. Hence the program can only run independently from the microcontroller and not in debug mode since the ICD3 uses PORT B for programming and debugging. Also, caution should be exercised while placing the jumpers in programming mode while uploading the program and in PORT mode while running the program.

Animation display for key press

After sensing a key press, we should first go to the location of the particular character. This could be done with simple Switch-case statements. An offset is also provided to specify the column offset from the character position.

Example Firmware:

Next, we will create a custom function, similar to the character display library function, to display the negative image of the character as the key press animation. We will also turn ON the column before and after the character for better visualization of the negative image.

Example Firmware:

After displaying the animation we need to revert the display back to its initial state. This could be done by writing a ‘space’ to the left of the character position, to turn OFF the column left of the negative image. The actual character image is then displayed over the negative image, providing us with the initial keypad display on the GLCD.

Example Firmware:

Here we have also displayed the recently pressed key on the top left corner of the display.

After reverting back to initial display state, we can now check for subsequent keys pressed and display its animation. Hence we have the keypad response display on GLCD. This methodology could be applied to touch screen keypads to obtain keypad response.

Graphical Display of Keypad on GLCD demo

 

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
Spread the love, share this

Leave A Comment

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
close-link
25% OFF - OpenLabPro Course
Use Coupon: CRS25UL

 
PIC Microcontroller Primer
Want to learn indepth programming, peripheral interfacing and driver development?
close-link
Launched: IoT online Course - 25% Off when you complete your order today.
Checkout Now
close-image

Subscribe To our Email Newsletter

Be the first to get latest updates and exclusive content straight to your email inbox.
Send me Tutorials and Guides
close-link