Facebook Pixel

AN-00152 ViSi-Genie Magic Beep Bop

 

Description

This application note primarily shows how Magic Touch and Magic Release are used to implement a ViSi-Genie project that allows to play different sounds when touching different objects in the display. The Magic Touch and Magic Release objects are under the Genie Magic pane in Workshop 4 Pro. They contains a 4DGL code and they can be used when the detection of touch in an application is needed.

Supported Processor PICASO, DIABLO16
Supported Environment ViSi-Genie
Difficulty

Medium

 

File Downloads
Files

 

Description

This application note primarily shows how Magic Touch and Magic Release are used to implement a ViSi-Genie project that allows to play different sounds when touching different objects in the display. The Magic Touch and Magic Release objects are under the Genie Magic pane in Workshop 4 Pro. They contains a 4DGL code and they can be used when the detection of touch in an application is needed.

 

Note 1:The ViSi-Genie project for this application note is the demo “BeepBop”, which is found in Workshop. Go to the File menu -> Samples ->ViSi Genie Magic (Picaso/Diablo16) ->BeepBop.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.

 

  • 4D Programming Cable or µUSB-PA5
  • micro-SD (µSD) memory card
  • Workshop 4 IDE (installed according to the installation document)
  • 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

In the past it was not possible to detect touch pressed or released in ViSi Genie and also to be able to control a sound object and detect it's status if playing or not. The application shown in this document checks if a sound is not playing. If there is no sound playing then it will check what button is touched and then plays the corresponding sound. Three sounds are used here, first one is when 'BEEP' button is pressed, second one is when 'BOP' button is pressed and lastly when anywhere on the screen is pressed besides the buttons. If the touch is released then the sound will stop playing.

 

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 Static Text Objects

A static text object is added to Form0. This is Statictext0.

To know more about static text objects, their properties, and how they are added to a project, refer to the application note ViSi-Genie Labels, Text, and Strings

Add Two Fancy Buttons

Two fancy button objects are added to Form 0. These are Winbutton0 and Winbutton1.

Winbutton0

 

Winbutton1

 

Both Winbutton0 and Winbutton1 have their OnChanged Event set to NONE.

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

Add Sound Object

A sound object is added to Form0. This is Sounds0.

The sound Object contains 3 WAV files. As shown in the image above. How the wav files will be played will be explained later on.

To know more about Sound Object, it's properties, and how it is added to a project, refer to the application note ViSi-Genie Play Sound

Add Magic Touch Object

A Magic Touch Object is added to Form0. This is MagicTouch.

A Magic Touch object contains a 4DGL routine that is executed the moment that a “TOUCH_PRESSED” action is detected on the display.

The code shown above is the content of the MagicTouch.inc. The function 'snd_Playing()' is used to check  if the sound object is playing or not. It returns 0 if sound has finished playing, else returns number of 512 byte blocks to go. If sound is not playing then proceed to touch detection.

The variable 'ImageTouched' is the object currently being touched. It is compared to values such as iWinbutton0 to determine the object for which a touch has just been detected. If Winbutton0 is touched then the sound object will play the first wav file 'beep-01a.wav'. If Winbutton1 is touched then the sound object will play the second wav file 'button-7.wav'. Else if neither Winbutton0 nor Winbutton1 is pressed but the display is still touched then the program will play 'button-2.wav'.

The 'file_PlayWav(fname)' Open the wav file, decode the header to set the appropriate wave player parameters and set off the playing of the file as a background process. See “Sound Control Functions” in PICASO or DIABLO16 Internal functions for additional play control functions.

Add Magic Release

A Magic Release Object is added to Form0. This is MagicRelease.

A Magic Release object contains a 4DGL routine that is executed the moment that a “TOUCH_RELEASED” action is detected on the display.

The content of MagicRelease.inc is used to determine the object for which touch has just been released. If so then the sound playing will be stopped using 'snd_Stop()' function.

To know more about adding Magic Objects 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: