Monday, October 7, 2013 12:00 am

Using an LCD touch screen with an Embedded Device

Written by 
Rate this item
(8 votes)

In modern times, everyone carries a powerful computer in their pocket. Smart phone technology gives your eyes and fingers an easy way to manipulate data. This intuitive interface is not restricted to your smart phone. Touch screen displays are also available for your own embedded creations. A touchscreen and display allows the device to be controlled and used without a PC interface.

The NANO54415 module with Versamodule Displays

The NANO54415 is a high performance 32 bit module built with a Mini PCI Express connector.

NANO54415 features

  • 10/100Mbps Ethernet
  • 8 UARTs, 4 I2C, 2 CAN, 3 SPI, 1-Wire® and SSI support
  • SD/MMC and MicroSD flash card ready
  • 30 digital I/Os
  • 6 12-bit analog-to-digital converters (ADC)
  • 2 12-bit digital-to-analog converters (DAC)
  • 8 pulse width modulators (PWM))

Creating a touch screen interface on your NetBurner NANO54415 just got a whole lot easier. Versamodule's custom plug and play displays are designed to work specifically with the NANO54415. A Versamodule LCD can be plugged directly in to either a NANO54415 development board or a custom Versamodule development board. With the hardware interface taken care of, the application developer is left with writing the software the drives the display. This article describes this process, using the display driver software included with all Versamodule displays.

Versamodule hardware used

  • VMO - NANO54415 socket board with add on headers
  • VMA - 2.8" touch screen LCD adapter board for VMO

To see all Versamodule displays and add on boards, check out the Versamodule product list

Your first LCD application

When working with new hardware, writing a simple application is often the best way to learn the ropes. A basic application demonstrates the hardware and the software library to go with it. In software land, the first application is generally a “Hello World” application. In hardware land, the first application is often a Blink LED project. In this example, we’ll combine the two and write Hello World to the LED display. In the following code example, the standard NetBurner start up code has been removed, leaving behind a code snippet that initializes the LCD and prints “Hello World” to the screen.

// Set up I/O Pins
Init_IO();

// Initialize the SPI port
DSPI_Init();

// Initialize the LCD
LCD_InitLandscape();

// Clear LCD to white
LCD_CLS(0xFFFF);

// Hello World @ position (0,0), black text on white background
LCD_String("Hello World",Tahoma19x23,0,0,5,0x0000,0xFFFF);

In the example, the initialization code uses Versamodule libraries to accelerate the development process. But one thing is still missing. The LCD that is being used is not just a display, but a touch screen as well. Adding touch screen support is also a matter of using the Versamodule initialization code. Let’s modify the previous snippet so that instead of "Hello World being displayed, we get a counter that counts all touch screen presses.

// Set up I/O Pins
Init_IO();

// Initialize the SPI port
DSPI_Init();

// Initialize the touch screen controller
I2CInit(0x3f);
SX8654_Init();

// Initialize the LCD
LCD_InitLandscape();

// Clear LCD to white
LCD_CLS(0xFFFF);

// Create full screen touch box area 0
CreateTouchBox(0,0,DISPLAY_WIDTH,DISPLAY_HEIGHT,0,true);

int counter = 0;

while(1) {
    // If touch screen was touched
    if(TOUCH_OPTION == TOUCHED) {
        // if touch was valid, update touch location
        if (GetPenLocation() == true) {
            // If the touch was withing box area 0
            if(CheckContainer(sx8654_touch.pen_x,sx8654_touch.pen_y,0)) {
                WaitForTouchRelease(60*TICKS_PER_SECOND);
                // Update the counter
                char lcdBuffer[8];
                siprintf(lcdBuffer,"%d",counter++);
                LCD_String(lcdBuffer,Tahoma19x23,0,0,5,0x0000,0xFFFF);
            }
        }
    }
}

Versamodule demo

You are not restricted to basic text boxes and touch screen. The included library allows you to create feature rich applications. But why read about the features of the LCD when you can see it for yourself. Here’s a demo video of the Versamodule VM7 4.3" LCD running demo code that is created with the included library.

Read 7195 times Last modified on Thursday, July 27, 2017 8:06 am

Leave a comment

NetBurner Learn

The NetBurner Learn website is a place to learn faster ways to design, code, and build your NetBurner based product. Sign-up for our monthly newsletter!

Latest Articles