ViSi-Genie: Arduino Form Navigation
Introduction
This codebase example presents a working application that illustrates the handling of REPORT_EVENT messages coming from the display module. The display module can send a REPORT_EVENT message to the host every time that the status of an object on it has changed. Input objects such as the winbutton, DIP switch, rocker switch, etc, can be configured to send a REPORT_EVENT message when they are touched. Even forms can be configured to send a REPORT_EVENT message when they are activated.
This code example presents an application that demonstrates the above.
Note
REPORT_EVENT vs REPORT_OBJ
A REPORT_EVENT message is sent by the display module to the host as triggered primarily by touch detected on an object on the screen. A REPORT_EVENT message is not requested by the host.
A REPORT_OBJ, on the other hand, is a message sent by the display module to the host in response to a query. For instance, if the host specifically wants to know the index of the active form, it sends a READ_OBJ message to the display module. The display module then sends a REPORT_EVENT message in response to the READ_OBJ message. The list below can be used to differentiate between REPORT_EVENT and REPORT_OBJ messages.
| REPORT_EVENT | REPORT_OBJ |
|---|---|
| "not polled" | "polled" |
| "not queried" | "queried" |
| "not requested" | "requested" |
The table above explains the difference between this code example which deals with REPORT_EVENT and ViSi-Genie: Arduino Form Request which basically illustrates the handling and use of REPORT_OBJ messages instead.
This code example has two parts - the ViSi-Genie project and the Arduino sketch. The ViSi-Genie project is found in the attached folder "Genie Project". The sketch is found in the attached folder "Arduino Sketch".
Prerequisites
This codebase example assumes the reader can program the 4D Systems display module using Workshop4 IDE ViSi-Genie environment. Beginners are advised to read the following aplication notes.
- ViSi-Genie: Getting Started with PICASO Displays
- ViSi-Genie: Getting Started with DIABLO-16 Displays
- ViSi-Genie: Getting Started with PIXXI Displays
- ViSi-Genie: Connecting a 4D Display to an Arduino
Instructions
Below were the steps involved in creating this code example:
-
Compile the ViSi-Genie project and upload the program to a uLCD-32PTU or any 4D Systems displays with PICASO, DIABLO-16, PIXXI-28 and PIXXI-44 graphics processors. Copy the supporting files to a uSD card mounted to the PC. Properly unmount the uSD card from the PC and mount it to the target display.
Below are the main objects of the project.
-
Form0 - configured to send a REPORT_EVENT message using the object inspector.
- 4Dbutton0 - configured to send a REPORT_EVENT message using the object inspector
- Dipswitch0 - configured to send a REPORT_EVENT message using the object inspector
- Leddigits0 - for displaying the counter value
- Winbutton0 - for navigating to Form1
-
Form1 - configured to send a REPORT_EVENT message using the object inspector
- Leddigits1 - for displaying the counter value
- Rockerswitch0 - configured to send a REPORT_EVENT message using the object inspector
- Slider0 - configured to send a REPORT_EVENT message using the object inspector
- Winbutton1 - for navigating to Form2
-
Form2 - configured to send a REPORT_EVENT message using the object inspector
- 4Dbutton1 - configured to send a REPORT_EVENT message using the object inspector
- 4Dbutton2 - configured to send a REPORT_EVENT message using the object inspector
- Leddigits2 - for displaying the counter value
- Winbutton2 - for navigating to Form0
-
-
Compile and upload the attached sketch to an Arduino Uno. The sketch uses a software serial port for the display. See the program flow summary further below.
-
Properly connect the Arduino Uno to the target display. See the application notes ViSi-Genie: Connecting a 4D Display to an Arduino for this.
-
A screenshot image file of the expected serial terminal output below.

If without an Arduino host, you can still run this code example by performing step 1. Then use the GTX tool to monitor the messages coming from the display module.
Below is the logic used in writing the Arduino sketch for this code example.
Process:
- Wait for REPORT_EVENT messages from the display.
- Keep writing the value of the counter to the LED digits object of the current form.
- If a new form has been activated, change the index of the LED digits object to which the counter value is to be written.
- If an object has changed its status, print its index and status. Back to Step 1.
Setup:
curFormIx = prevFormIx = 0; // assume that the current form index is zero initially
counter = 0; // increments at each iteration of the 500-ms loop
main loop:
DoEvents() - this executes myGenieEventHandler(...){...} and other internal processes. The event handler evaluates messages coming from the display as follows:
- if a REPORT_EVENT message is received, the source of the event as well as the value for the event is evaluated:
- if it is from a Form, it means a new form has been activated. Code prints a message if a new form is activated.
- if it is from a 4Dbutton, Slider, RockerSwitch or DipSwitch, the source widget and new value is printed
500-ms loop: this is the conditional block "if (millis() >= waitPeriod){...}" inside the main loop
- this simply evaluates the current Form and writes the counter value to the appropriate LedDigits widget