Arduino Library for 4D Systems ViSi-Genie Environment
This library supports the following:
Support for neagative numbers, unsigned longs, unsigned integers with the WriteStr function.
Features enhanced String Writing capability, no longer is a character Array the only viable option.
Support for Workshop4 PRO features.
2+ displays connected to a single Arduino, and adds a Demo to illustrate how that is achieved.
New Internal and Inherent Widgets.
Much more...
Information
This library provides high level functions for the Arduino, to ease communication with 4D Systems modules when using the module configured with ViSi-Genie.
Workshop4 PRO adds additional features to ViSi-Genie, allowing the User to write 4DGL code which can be executed at will from ViSi-Genie, enabling many advanced features not previously possible.
Please refer to the 4D Systems website, namingly the Workshop4 Product Page, for documentation regarding Workshop4, and its environments.
Installation
Library folder should be placed in the C:\Users(User name)\My Documents\Arduino\Libraries\ folder, or equivalent. (restart the IDE if already open).
PLEASE ensure that the old library (if installed) has been removed completely so it does not conflict.
Open the ViSi-Genie project using Workshop4 and download to your display, connect the display to Arduino, reset the Arduino and it should work.
This library should be discoverable from the Arduino IDE Library Manager too.
Example Sketch
Inside the library are 4 example sketches, to assist with getting started using this library. Inside is also a ViSi-Genie Workshop4 project, which can be used on a range of 4D Systems displays (designed on a uLCD-32PTU however can be changed via Workshop4 menu). It illustrates how to use some of the commands in the library include Read Object, Write Object, Reported Messages, Write Contrast and Write String.
Tested with
This library has been tested on the Duemilanove, Uno, Mega 1280, Mega 2560, Leonardo, Chipkit Max32, Due, Intel Galileo, Teensy and Yun (Software Serial only on Yun).
Any problems discovered with this library, please contact technical support so fixes can be put in place, or seek support from our forum.
Compatible 4D Systems Display Modules
This library will work with all 4D Systems Modules which are capable of using the ViSi-Genie environment. This is therefore all Picaso, Pixxi-28, Pixxi-44 and Diablo16 Display Modules.
The demo included with this library was made for the gen4-uLCD-32DCT-CLB (3.2" Capacitive Touch gen4 module) however can easily be adapted to other size displays.
General Library Discussion
This section serves to give brief discussion about the constructor and functions included in the library. For functional examples on how to use these functions in a project, refer to the examples folder.
Genie()
This is the constructor for the library. It creates a unique instance that can be set to use the desired serial port.
Genie genie; // Creates a new instance named 'genie'
Begin(Stream &serial)
Creates an instance of ViSi Genie by assigning a serial stream
Parameters
Description
serial
Stream object that represents the UART hardware
Serial.begin(115200); // Open Serial @115200. Can use other Serial UART's (Serial1, Serial2...) depending on your Arduino.
genie.Begin(Serial); // Sets Serial/Serial0 to be used by the Genie instance 'genie'
WriteContrast(uint16_t value)
Sets the display contrast/brightness to a new value
Parameters
Description
value
New brightness/contrast value. The range of this value depends on the 4D display, Typically 0-15 Range
genie.WriteContrast(0); // Sets the contrast/brightness value to 0, effectively turning off the backlight
genie.WriteContrast(10); // Sets the contrast/brightness value to 10, about 2/3 max brightness
ReadObject(uint16_t object, uint16_t index)
Sends a request to read the value of the widget specified by object (ex: GENIE_OBJ_GAUGE) and index. The value will be sent as a GENIE_REPORT_OBJECT command.
A full list of available objects (ex: GENIE_OBJ_GAUGE, GENIE_OBJ_SLIDER etc) can be found at the bottom of this Readme.
Parameters
Description
object
Type of target widget
index
Index number of target widget
genie.ReadObject(GENIE_OBJ_GAUGE, 0); // Request a report of the widget Gauge0
Updates the widget, specified by object (ex: GENIE_OBJ_GAUGE) and index, to a new value specified by data
A full list of available objects (ex: GENIE_OBJ_GAUGE, GENIE_OBJ_SLIDER etc) can be found at the bottom of this Readme.
Parameters
Description
object
Type of target widget
index
Index number of target widget
data
New value for the target widget
genie.WriteObject(GENIE_OBJ_GAUGE, 0, 50); // Sets Gauge0 to 50
WriteIntLedDigits(uint16_t index, int16_t data)
Updates the Internal LedDigits specified by index to a new 16-bit value, specified by data. The widget parameter Format in ViSi Genie project should be set to Int16. Internal LedDigits are availble for Diablo and Pixxi displays.
Parameters
Description
index
Index number of target Internal LedDigits
data
New 16-bit integer value for the target Internal LedDigits
genie.WriteIntLedDigits(0, 50); // Sets ILedDigits0 to 50
WriteIntLedDigits(uint16_t index, float data)
Updates the Internal LedDigits specified by index to a new 32-bit float value, specified by data. The widget parameter Format in ViSi Genie project should be set to any Float option. Internal LedDigits are availble for Diablo and Pixxi displays.
Parameters
Description
index
Index number of target Internal LedDigits
data
New 32-bit float value for the target Internal LedDigits
genie.WriteIntLedDigits(0, 3.1416f); // Sets ILedDigits0 to 3.1416
WriteIntLedDigits(uint16_t index, int32_t data)
Updates the Internal LedDigits specified by index to a new 32-bit integer value, specified by data. The widget parameter Format in ViSi Genie project should be set to Int16. Internal LedDigits are availble for Diablo and Pixxi displays.
Parameters
Description
index
Index number of target Internal LedDigits
data
New 32-bit integer value for the target Internal LedDigits
genie.WriteIntLedDigits(0, 1000000L); // Sets ILedDigits0 to 1000000
WriteStr(uint16_t index, char * string)
Updates the String widget specified by index with a new character string specified by string
Parameters
Description
index
Index number of target String
string
Character pointer containing the text to print in the String widget
genie.WriteStr(0, "Sample String"); // Set text in String0 to "Sample String"
Updates the String widget specified by index with a string stored in program space (flash memory) specified by ifsh. This is only available for AVR boards.
Parameters
Description
index
Index number of target String
ifsh
Flash string containing the text to print in the String widget
// Writes the string stored in flash memory to String1
genie.WriteStr(1, F("Hello from Flash Memory")); // For AVR Arduinos only
WriteStr(uint16_t index, const String &s)
Updates the String widget specified by index with a String widget specified by s
Parameters
Description
index
Index number of target String
s
String object containing the text to print in the String widget
String str = "This is string class";
genie.WriteStr(0, Str); // Writes the String class 'str' to String0
WriteStrU(uint16_t index, uint16_t * string)
Updates the String widget specified by index with a new Unicode (16-bit) character string specified by string
Parameters
Description
index
Index number of target String
string
Character pointer containing the text to print in the String widget
Updates the Inherent Label widget specified by index with a string stored in program space (flash memory) specified by ifsh. This is only available for AVR boards.
Parameters
Description
index
Index number of target Inherent Label
ifsh
Flash string containing the text to print in the Inherent Label widget
// Writes the string stored in flash memory to ILabelB1
genie.WriteInhLabel(1, F("Hello from Flash Memory")); // For AVR Arduinos only
WriteInhLabel(uint16_t index, const String &s)
Updates the Inherent Label widget specified by index with a Inherent Label widget specified by s
Parameters
Description
index
Index number of target Inherent Label
s
String object containing the text to print in the Inherent Label widget
String str = "This is string class";
genie.WriteInhLabel(0, Str); // Writes the String class 'str' to ILabelB0
WriteInhLabel(uint16_t index, int n)
Updates the Inherent Label widget specified by index with a new integer value n with base 10
Parameters
Description
index
Index number of target Inherent Label
n
Signed short integer value that will be formatted with base 10 to a string and will be printed in the Inherent Label widget
genie.WriteInhLabel(0, 10000); // Writes the value 10000 to ILabelB0
WriteInhLabel(uint16_t index, int n, int base)
Updates the Inherent Label widget specified by index with a new integer value n with base specified by base
Parameters
Description
index
Index number of target Inherent Label
n
Signed short integer value that will be formatted to a string and will be printed in the Inherent Label widget
base
Custom base to used when formatting the value to a string
// Writes the value 10000 to ILabelB4 in hexadecimal
genie.WriteInhLabel(4, 10000, 16);
WriteInhLabel(uint16_t index, unsigned int n)
Updates the Inherent Label widget specified by index with a new unsigned integer value n with base 10
Parameters
Description
index
Index number of target Inherent Label
n
Unsigned short integer value that will be formatted with base 10 to a string and will be printed in the Inherent Label widget
unsigned int value = 40000;
genie.WriteInhLabel(2, value); // Writes the value 40000 to ILabelB2
WriteInhLabel(uint16_t index, unsigned int n, int base)
Updates the Inherent Label widget specified by index with a new unsigned integer value n with base specified by base
Parameters
Description
index
Index number of target Inherent Label
n
Unsigned short integer value that will be formatted to a string and will be printed in the Inherent Label widget
base
Custom base to used when formatting the value to a string
unsigned int value = 40000;
// Writes the value 40000 to ILabelB1 in hexadecimal
genie.WriteInhLabel(1, value, 16);
WriteInhLabel(uint16_t index, long n)
Updates the Inherent Label widget specified by index with a new long value n with base 10
Parameters
Description
index
Index number of target Inherent Label
n
Signed long integer value that will be formatted with base 10 to a string and will be printed in the Inherent Label widget
genie.WriteInhLabel(2, 100000L); // Writes the value 100000 to ILabelB2
WriteInhLabel(uint16_t index, long n, int base)
Updates the Inherent Label widget specified by index with a new long value n with base specified by base
Parameters
Description
index
Index number of target Inherent Label
n
Signed long integer value that will be formatted to a string and will be printed in the Inherent Label widget
base
Custom base to used when formatting the value to a string
// Writes the value 100000 to ILabelB3 in octal
genie.WriteInhLabel(3, 100000L, 8);
WriteInhLabel(uint16_t index, unsigned long n)
Updates the Inherent Label widget specified by index with a new unsigned long value n with base 10
Parameters
Description
index
Index number of target Inherent Label
n
Unsigned long integer value that will be formatted with base 10 to a string and will be printed in the Inherent Label widget
genie.WriteInhLabel(0, 3000000000UL); // Writes the value 3000000000 to ILabelB0
WriteInhLabel(uint16_t index, unsigned long n, int base)
Updates the Inherent Label widget specified by index with a new unsigned long value n with base specified by base
Parameters
Description
index
Index number of target Inherent Label
n
Unsigned long integer value that will be formatted to a string and will be printed in the Inherent Label widget
base
Custom base to used when formatting the value to a string
// Writes the value 3000000000 to ILabelB1 in hexadecimal
genie.WriteInhLabel(1, 3000000000UL, 16);
WriteInhLabel(uint16_t index, double n)
Updates the Inherent Label widget specified by index with a new 64-bit float value n with 2 decimal digits
Parameters
Description
index
Index number of target Inherent Label
n
Signed 64-bit float value that will be formatted to a string with 2 decimal places and will be printed in the Inherent Label widget
double value = 175.3456;
// Writes the 64-bit float value 175.3456 to ILabelB0
genie.WriteInhLabel(0, value); // with 2 decimal places (175.34)
请发表评论