Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Visi-Genie Password Implementation With An Arduino Host: Document Date: Document Revision

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

APPLICATION NOTES

ViSi-Genie Password Implementation


with an Arduino Host

DOCUMENT DATE: 25th APRIL 2019


DOCUMENT REVISION: 1.1

W W W . 4 D S Y S T E M S . C O M . A U
APPLICATION NOTES 4D-AN-00188

Description module used in this application note is the uLCD-32PTU, which is a


Picaso display. This application note is applicable to Diablo16 display
This application note shows how to write a sketch for an Arduino program modules as well.
that prints characters on string object from keyboard object to create a  4D Programming Cable / uUSB-PA5/uUSB-PA5-II
simple Password Implemented Application . The host is an AVR-ATmega328- for non-gen4 displays(uLCD-xxx)
microcontroller-based Arduino Uno board. The host can also be an Arduino  4D Programming Cable & gen4-PA, / gen4-IB / 4D-UPA
Mega 2560 or Due. Ideally, the applications described in this document for gen4 displays (gen4-uLCD-xxx)
should work with any Arduino board with at least one UART serial port. See  micro-SD (µSD) memory card
specifications of Aduino boards here.  Workshop 4 IDE (installed according to the installation document)
 Any Arduino board with a UART serial port
This application note requires:  4D Arduino Adaptor Shield (optional) or connecting wires
 Any of the following 4D Picaso and gen4 Picaso display modules:  Arduino IDE
When downloading an application note, a list of recommended application
gen4-uLCD-24PT gen4-uLCD-28PT gen4-uLCD-32PT notes is shown. It is assumed that the user has read or has a working
uLCD-24PTU uLCD-32PTU uVGA-III knowledge of the topics presented in these recommended application
notes.
and other superseded modules which support the ViSi Genie
environment

 The target module can also be a Diablo16 display

gen4-uLCD-24D series gen4-uLCD-28D series gen4-uLCD-32D series


gen4-uLCD-35D series gen4-uLCD-43D series gen4-uLCD-50D series
gen4-uLCD-70D series
uLCD-35DT uLCD-43D series uLCD-70DT

Visit www.4dsystems.com.au/products to see the latest display


module products that use the Diablo16 processor. The display

Page 2 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

Content Application Overview


Description ..................................................................................................... 2 The application developed in this document works in two forms. First form
Content ........................................................................................................... 3 is to Set/Save a desired password, the second form compares any inputted
Application Overview ..................................................................................... 3 password to the saved password in the first form.
Setup Procedure ............................................................................................. 4
Create a New Project ..................................................................................... 4 The Arduino host is programmed in the Arduino IDE to perform gathering of
input from Keyboard object and then stores it in array. The input is also
Create a New Project .................................................................. 4
written on a string object. The arduino then compares two arrays and if
Design the Application ................................................................................... 5
correct it will print "Correct Password" in the string object, and if not it will
Create a new Form............................................................................... 5 print "Incorrect Password".
Object Properties ........................................................................ 6
StaticText0 and Statictext2 6 This application note comes with a ViSi Genie program and an Arduino
sketch. The process of creating the ViSi Genie program is first shown. Then
StaticText1 7
the flow of the Arduino sketch is discussed. The sketch can be used to
Strings 7
develop more complex applications.
Keyboard 8
Build and Upload the Project ......................................................................... 8
Writing the Host Code .................................................................................... 9
The Main Loop – Writing Data to the Display .............................. 9
Event Handler ............................................................................. 9
Keyboard Object 0 10
Keyboard Object 1 10
Set Up the Project ........................................................................................ 11
Proprietary Information ............................................................................... 12
Disclaimer of Warranties & Limitation of Liability ...................................... 12

Page 3 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

OUTPUT: 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).

Page 4 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

Design the Application


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

Keyboard
Object

Create a new Form


The Form object will create a new Form. To add a FORM object, go to the
At the end of this section, the user will able to create a form with four System/Media pane and select the third icon.
objects. The final form will look like as shown below, with the labels
excluded.

Page 5 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

At the end of this section, the user will able to create a form with four Object Properties
objects. The final form will look like as shown below, with the labels
excluded. The images shown below are the properties of the objects that are used in
the project included in this application note.
Static
texts StaticText0 and Statictext2

String
Objects

Keyboard
Object

Page 6 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

StaticText1 Strings

Page 7 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

Keyboard 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.

For in depth details on customizing a Keyboard object : ViSi-Genie Customised


Keyboard

Page 8 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

Writing the Host Code The Main Loop – Writing Data to the Display

A thorough understanding of the application note ViSi-Genie Connecting a The data or message is received and queued by:
4D Display to an Arduino Host is required before attempting to proceed
further beyond this point. ViSi-Genie Connecting a 4D Display to an Arduino
Host provides all the basic information that a user needs to be able to get Another function (to be written by the user) is needed to process the
started with ViSi-Genie and Arduino. The following is a list of the topics received data. This function is the user's event handler, which was arbitrarily
discussed in ViSi-Genie Connecting a 4D Display to an Arduino Host. given the name myGenieEventHandler(). This function is called from inside
the function genie.DoEvents().
 How to download and install the ViSi-Genie-Arduino library
 How to open a serial port for communicating with the display and
how to set the baud rate
 The genieAttachEventHandler() function Event Handler
 How to reset the host and the display
 How to set the screen contrast
 How to send a text string
 The main loop
 Receiving data from the display
 The use of a non-blocking delay in the main loop
 How to change the status of an object
 How to know the status of an object
 The user’s event handler
This part of the code is the event handler. The image above checks if the
report message comes from a keyboard object.
Discussion of any of these topics is avoided in other ViSi-Genie-Arduino
application notes unless necessary. Users are encouraged to read ViSi-Genie
Connecting a 4D Display to an Arduino Host first.

Page 9 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

Keyboard Object 0 ASCII Code. This will write to FORM1 so the display will display FORM1
where keyboard1 exist and AUTHENTICATION starts.

Keyboard Object 1

If the Key is pressed in keyboard0 object this part of the program will
execute. This simply prints to the string objects the key that is pressed from
the keyboard while storing it in an array.
If the Key is pressed in keyboard1 object this part of the program will
execute. Same process with keyboard 1 if a key/number or Back is pressed.
If "Back" is pressed then the value that will be received from
Their difference is that when a key is pressed in keyboard2 the number will
"genie.GetEventData(&Event)" is 8, decumal value of backspace in ASCII
be printed on the string object and will be replaced by '*' asterisk after.
Code. The array Index will be decremented and NULL will be printed.

If "Enter" is pressed then the value that will be received from


"genie.GetEventData(&Event)" is 13, decimal value of carriage return in

Page 10 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

The difference in operation between keyboard0 and keyboard1 is when


"Enter" key is pressed. The code presented compares the arrays that holds
the value inputted in keyboard0 and keyboard1. If the password is correct
then it will write on the string object "CORRECT PASSWORD" else if the
password inputted is incorrect it will write on the string object "INCORRRECT
PASSWORD".

Set Up the Project


Refer to the section “Connect the Display Module to the Arduino Host” of
the application note “ViSi-Genie Connecting a 4D Display to an Arduino
Host” for the following topics:

 Using the New 4D Arduino Adaptor Shield (Rev 2.00)


o Definition of Jumpers and Headers
o Default Jumper Settings
o Change the Arduino Host Serial Port
o Power the Arduino Host and the Display Separately
 Using the Old 4D Arduino Adaptor Shield (Rev 1)
 Connection Using Jumper Wires
 Changing the Serial port of the Genie Program
 Changing the Maximum String Length

Page 11 of 12 www.4dsystems.com.au
APPLICATION NOTES 4D-AN-00188

Proprietary Information
The information contained in this document is the property of 4D Systems Pty. Ltd. and may be the subject of patents pending or granted, and must not be
copied or disclosed without prior written permission.
4D Systems endeavours to ensure that the information in this document is correct and fairly stated but does not accept liability for any error or omission. The
development of 4D Systems products and services is continuous and published information may not be up to date. It is important to check the current position
with 4D Systems.
All trademarks belong to their respective owners and are recognised and acknowledged.

Disclaimer of Warranties & Limitation of Liability


4D Systems makes no warranty, either expresses or implied with respect to any product, and specifically disclaims all other warranties, including, without
limitation, warranties for merchantability, non-infringement and fitness for any particular purpose.
Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates.
It is your responsibility to ensure that your application meets with your specifications.
In no event shall 4D Systems be liable to the buyer or to any third party for any indirect, incidental, special, consequential, punitive or exemplary damages
(including without limitation lost profits, lost savings, or loss of business opportunity) arising out of or relating to any product or service provided or to be
provided by 4D Systems, or the use or inability to use the same, even if 4D Systems has been advised of the possibility of such damages.
4D Systems products are not fault tolerant nor designed, manufactured or intended for use or resale as on line control equipment in hazardous environments
requiring fail – safe performance, such as in the operation of nuclear facilities, aircraft navigation or communication systems, air traffic control, direct life
support machines or weapons systems in which the failure of the product could lead directly to death, personal injury or severe physical or environmental
damage (‘High Risk Activities’). 4D Systems and its suppliers specifically disclaim any expressed or implied warranty of fitness for High Risk Activities.
Use of 4D Systems’ products and devices in 'High Risk Activities' and in any other application is entirely at the buyer’s risk, and the buyer agrees to defend,
indemnify and hold harmless 4D Systems from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or
otherwise, under any 4D Systems intellectual property rights.

Page 12 of 12 www.4dsystems.com.au

You might also like