AN-00134 Serial Arduino Displaying Images from the uSD Card RAW

Description This application note shows how to program an Arduino host so that it can control a Goldelox display module (acting as a slave device) and make it display images. The images are contained in a graphics file saved on a μSD card mounted on the display module. The Arduino host sends serial commands to the display module to access and display the images. The graphics file is of a format that is readable by 4D-LAB’s processors. This graphics file is generated using the Workshop 4 IDE.
Supported Processor GOLDELOX
Supported Environment Serial
Difficulty Medium

 

File Downloads
Files

Description

This application note explores the possibilities provided by the Serial environment in Workshop for a Goldelox display module to work with an Arduino host. In this example, the host is an Arduino Uno board. The host can also be an Arduino Mega 2560 or Due. Ideally, the application described in this document should work with any Arduino board that supports software serial or with at least one UART serial port. See specifications of Aduino boards here.

Before getting started, the following are required:

or any superseded module that supports the Serial environment. Visit www.4dsystems.com.au to see the latest products using the Goldelox graphics processor.

When downloading an application note, a list of recommended application notes is shown. It is assumed that the user has read or has a working knowledge of the topics presented in these recommended application notes.

 

Application Overview

This application note shows how to program an Arduino host so that it can control a Goldelox display module (acting as a slave device) and make it display images. The images are contained in a graphics file saved on a µSD card mounted on the display module. The Arduino host sends serial commands to the display module to access and display the images. The graphics file is of a format that is readable by 4D-LAB’s processors. This graphics file is generated using the Workshop 4 IDE.

 

Setup Procedure

The following are the steps involved in creating this project:

  1. Generate the graphics file using Workshop 4 ViSi. Copy the generated graphics file to the uSD card and mount the uSD card to the display module.
  2. Configure the display module as a serial slave device by loading it with the SPE application.
  3. Program the Arduino host. Here the Goldelox-Serial-Arduino library will be used in writing the sketch for the Arduino host.
  4. Connect the Arduino host to the display module. The Arduino board will be the master. By communicating with the slave display module, it will be able to access and display the images stored inside the graphics file on the uSD card of the display module.

For steps 1 and 2, refer to the application note Serial Displaying Images from the uSD Card RAW. Serial Displaying Images from the uSD Card RAW shows how the Serial Commander is used to access and show the images saved on the uSD card of the display module.

For step 4, refer to the application note Serial Connection to an Arduino Host.

 

Program the Arduino Host

A thorough understanding of the application note Serial Connection to an Arduino Host is required before attempting to proceed further beyond this point. Serial Connection to an Arduino Host provides the basic information that a user needs to be able to get started with the Serial Environment and Arduino. The following is a list of the topics discussed in Serial Connection to an Arduino Host.

  • How to download and install the Serial-Arduino library (choose a library according to your display module’s processor)
  • How to modify the library for Arduino Due (due to a Due bug reported by a forum user)
  • How to define the serial port to be used for talking to the display
  • How to set the baud rate
  • The Error Handling Routine
  • How to set the Timeout Limit
  • How to reset the Arduino Host and the Display
  • How to let the Display Start Up
  • How to set the Screen Orientation
  • How to Clear the Screen
  • The uSD Card Mount Routine
  • How to enable message logging to the Serial Monitor of the Arduino IDE

Discussion of any of these topics is avoided in other Serial-Arduino application notes unless necessary. Users are encouraged to read Serial Connection to an Arduino Host first.

 

Set the Address of an Object

Use the method “media_SetAdd(…)” to be able to access an object inside the uSD card. An object can be accessed by using its 32-bit address in the uSD card. The prototype for media_SetAdd(…)  is

void media_SetAdd(word  Hiword, word  Loword);

 where the argument “Hiword” is the high word of the 32-bit address, and the argument "Loword” is the low word of the 32-bit address. To access Image1 for example, write

Display.media_SetAdd(0, 0);

 

To access Image2, write

Display.media_SetAdd(0, 0x2000);

Note that the addresses of the objects are saved as defined constants in an include file of the ViSi project. For more information, see Serial Displaying Images from the uSD Card RAW.

 

Show the Object

Immediately after having set the address of an object, use the method “media_Image(…)” to show it. The prototype for this method is

void media_Image(word  X, word  Y);

where the arguments “X” and “Y” are the x and y coordinates of the location at which the object will be displayed. To display Image1 at the top-left corner of the display module, for example, write,

Display.media_SetAdd(0, 0);

Display.media_Image(0, 0);

 The code above will show Image1 at the top-left corner of the display module, like as shown below.

 

To display Image2 at the top-middle part of the display module, write,

Display.media_SetAdd(0, 0x2000);

Display.media_Image(77, 4);

The code above will show Image2 at the top-middle part of the display module, like as shown below.

 

Connect the Arduino Host to the Display Module.

Refer to the section “Connect the Display Module to the Arduino Host” of the application note Serial Connection to an Arduino Host for the following topics:

  • Using the New 4D Arduino Adaptor Shield (Rev 2.00)
    • Definition of Jumpers and Headers
    • Default Jumper Settings
    • Change the Arduino Host Serial Port
    • Power the Arduino Host and the Display Separately
  • Using the Old 4D Arduino Adaptor Shield (Rev 1)
  • Connection Using Jumper Wires

Note that in the attached sketch, the Arduino Uno uses a software serial port (TX pin is pin 10, RX pin is pin 11) to communicate with the display module. It uses the hardware serial port Serial0 to communicate with the Serial Monitor of the Arduino IDE.

Share: