Facebook Pixel

AN-00156 ViSi Genie Magic Main Loop Counter

Description This application note primarily shows how to add a counter in the main loop and print it using Magic Objects.. The Magic Code and Event is under the Genie Magic pane in Workshop 4 Pro. In this application it contains a 4DGL code that adds a counter in the main loop and then prints if a button is pressed.
Supported Processor PICASO, DIABLO16
Supported Environment ViSi-Genie
Difficulty Medium

 

File Downloads
Files

Description

This application note primarily shows how to add a counter in the main loop and print it using Magic Objects.. The Magic Code and Event is under the Genie Magic pane in Workshop 4 Pro. In this application, it contains a 4DGL code that adds a counter in the main loop and then prints if a button is pressed.

Note 1: The ViSi-Genie project for this application note is the demo “MainLoopCounter”, which is found in Workshop. Go to the File menu -> Samples ->ViSi Genie Magic (Picaso/Diablo16) ->MainLoopCounter.4DGenie.

Note 2: Workshop Pro is needed for this application.

 

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.

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

The application presented in this document primarily shows a loop counter if a button is pressed. In the past, this was not possible but through the use of magic objects this can be done now. The Magic Event object and Magic Code object was used here.

 

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

Add Winbutton0

A Fancy Button object is added to Form0. This is Winbutton0.

 

To know more about button objects, their properties, and how they are added to a project, refer to the application note ViSi-Genie Advanced Buttons.

 

Add Magic Event

A Magic Event is added to Form0. This is MagicEvent0.

 

Magic Event Properties:

 

Events are usually triggered when input objects such as winbutton objects on the display are pressed.

 

The code above prints the content of mainloopcount array if Winbutton0 is pressed.

 

Add Magic Code

A Magic Code is added to Form0. This is MagicCode0.

 

Magic Code Properties:

 

A Magic Code object allows the user to insert custom 4DGL code into specific locations inside the Genie project. For example, a counter variable can be declared and initialized in a Magic Code object inserted to the location “Constant/Global/Data”. This variable can then be accessed and used by another Magic Code object inserted at the location “MainLoop”.

 

The content of MagicCode0 is shown in the image above. This simply increments the content of mainlooopcount[0] and increments mainloopcount[1] if ++mainloopcount[0] is equal to 0.

 

Sample Output:

 

 

To know more about adding Magic Events and Magic Code refer to the application note ViSi-Genie How to Add Magic Objects

 

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.

Share: