AN-00029 ViSi-Genie Color Picker

Description
The simple project developed in this application note demonstrates the use of the color picker. When touched at a certain point the color picker sends a corresponding message to the external host controller. The two-byte value contained by the message from a color picker represents the 16 bit color value in 565 format (5 bits of Red, 6 bits of Green, and 5 bits of Blue). On the other hand, if the host controller sends a message to the color picker, the color value contained by the message is indicated on the display. A section of this application note discusses the format of the messages coming from and going to a color picker using the GTX Tool in Workshop.
Supported Processor PICASO, Diablo16
Supported Environment ViSi-Genie
Difficulty Medium

 

File Downloads
Files

Description

This application note provides a first hands-on example with ViSi-Genie and describes all the steps related to a project.

Before getting started, the following are required:

and other superseded modules which support the ViSi Genie environment

 

Visit www.4dsystems.com.au/products to see the latest display module products that use the Diablo16 processor. The display module used in this application note is the uLCD-32PTU, which is a Picaso display. This application note is applicable to Diablo16 display modules as well.

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

It is often difficult to design a graphical display without being able to see the immediate results of the application code. ViSi-Genie is the perfect software tool that allows users to see the instant results of their desired graphical layout with this large selection of gauges and meters (called objects or widgets).  The user can simply click on the desired widget to select it and click on the simulated display to place the widget. Below is the color picker widget.

 

The simple project developed in this application note demonstrates the use of the color picker. When touched at a certain point the color picker sends a corresponding message to the external host controller. The two-byte value contained by the message from a color picker represents the 16 bit color value in 565 format (5 bits of Red, 6 bits of Green, and 5 bits of Blue). On the other hand, if the host controller sends a message to the color picker, the color value contained by the message is indicated on the display. A section of this application note discusses the format of the messages coming from and going to a color picker using the GTX Tool in Workshop.

 

Setup Procedure

For instructions on how to launch Workshop 4, how to open a ViSi-Genie project, and how to change the target display, kindly refer to the section “Setup Procedure” of the application note:

 

ViSi Genie Getting Started – First Project for Picaso Displays (for Picaso)
or
ViSi Genie Getting Started – First Project for Diablo16 Displays (for Diablo16).

 

Create a New Project

Create a New Project

For instructions on how to create a new ViSi-Genie project, please refer to the section “Create a New Project” of the application note

 

ViSi Genie Getting Started – First Project for Picaso Displays (for Picaso)
or
ViSi Genie Getting Started – First Project for Diablo16 Displays (for Diablo16).

 

Design the Project

Everything is now ready to start designing the project. Workshop 4 displays an empty screen, called Form0. A form is like a page on the screen. The form can contain widgets or objects, like trackbars, sliders, displays or keyboards.

 

Below is an empty form.

 

Adding a Color Picker

To add a color picker, go to the Inputs pane then click on the color picker icon.

 

Click on the WYSIWYG (What-You-See-Is-What-You-Get) screen to put the object in place. The WYSIWYG screen simulates the actual appearance of the display module screen.

 

The object can be dragged to any desired location and resized to the desired dimensions. The Object Inspector on the right part of the screen displays all the properties of the newly created color picker object named Colorpicker0.

 

Take time to experiment with the different properties. The color picker used in this project has the following properties.

 

The updated appearance of the WYSIWYG screen is shown below.

 

Configuring the Color Picker

The color picker must be configured to report a message for it to be able to send hexadecimal color values to the external host controller. Go to the color picker’s object inspector and select the Events tab.

 

The On event selection window appears. Choose “Report Message” and click OK.

 

Naming of Objects

Naming is important to differentiate between objects of the same kind. For instance, suppose the user adds another color picker object to the WYSIWYG screen. This object will be given the name Colorpicker1– it being the second color picker object in the program. The third color picker will be given the name Colorpicker2, and so on. An object’s name therefore identifies its kind and its unique index number. It has an ID (or type) and an index.

 

Build and Upload the Project

For instructions on how to build and upload a ViSi-Genie project to the target display, please refer to the section “Build and Upload the Project” of the application note

 

ViSi Genie Getting Started – First Project for Picaso Displays (for Picaso)
or
ViSi Genie Getting Started – First Project for Diablo16 Displays (for Diablo16).

 

The uLCD-32PTU and/or the uLCD-35DT display modules are commonly used as examples, but the procedure is the same for other displays.

 

Identify the Messages

The display module is going to receive and send messages from and to an external host. This section explains to the user how to interpret these messages. An understanding of this section is necessary for users who intend to interface the display to a host. The ViSi Genie Reference Manual is recommended for advanced users.

Use the GTX Tool to Analyse the Messages

Using the GTX or Genie Test eXecutor tool is the first option to get the messages sent by the screen to the host. Here the PC will be the host. The GTX tool is a part of the Workshop 4 IDE. It allows the user to receive, observe, and send messages from and to the display module. It is an essential debugging tool.

 

Launch the GTX Tool

Under Tools menu click on the GTX tool button.

 

A new window appears, with the form and the color picker object created previously.

 

The Color Picker

Pick a Color

Pick a color by touching the color picker on the display module screen. A message is received from the display module.

 

The actual message bytes are those inside the brackets. These values are in hexadecimal. The figure preceding the actual message is the computer time at which the message is sent. A label is also included to tell the observer what the message represents.

 

The message received is formatted according to the following pattern:

 

The message is from Colorpicker0, and it contains the hexadecimal color value “0x5CB4”. The color picker box shows the color.

 

The checksum is a means for the host to verify if the message received is correct. This byte is calculated by XOR’ing all bytes in the message from (and including) the CMD or command byte to the last parameter byte. Then, the result is appended to the end to yield the checksum byte. If the message is correct, XOR’ing all the bytes (including the checksum byte) will give a result of zero. Checking the integrity of a message using the checksum byte shall be handled by the host.

 

Send a Color

In the GTX tool window, click on the Set button.

 

The Color window appears. Select the desired color and press OK.

 

Note that the color is indicated on the display module.

 

 In the GTX tool window, the white area on the right displays

  • in green the messages sent to the display module
  • and in red the messages received from the display module

 

 

The message sent is formatted according to the following pattern:

 

The message stands for “Write to the first color picker object on the display module the value 0xFFF0”.

ACK = 0x06 as shown below

 

is an acknowledgment from the display module which means that it has understood the message.

 

Poll the Color Picker

If the color picker was not configured to report a message when touched, it is still possible to know its current color. To do be able to do this, click on the Query button.

 

Messages are sent to and received from the display module.

 

The messages are formatted according to the following pattern:

 

The host sends a READ_OBJ command specifically asking for the value of the first color picker object. The display module then responds with the current value of that color picker. Communication between a 4D display module programmed with a ViSi-Genie application and an external host controller must follow the ViSi-Genie Communications Protocol, which is defined in the ViSi Genie Reference Manual.

 

Share: