18. Using the Yocto-Display with Java
Java is an object oriented language created by Sun Microsystem. Beside being free, its main
strength is its portability. Unfortunately, this portability has an excruciating price. In Java, hardware
abstraction is so high that it is almost impossible to work directly with the hardware. Therefore, the
Yoctopuce API does not support native mode in regular Java. The Java API needs a Virtual Hub to
communicate with Yoctopuce devices.
18.1. Getting ready
Go to the Yoctopuce web site and download the following items:
• The Java programming library
1
• The VirtualHub software
2
for Windows, Mac OS X or Linux, depending on your OS
The library is available as source files as well as a
jar
file. Decompress the library files in a folder of
your choice, connect your modules, run the VirtualHub software, and you are ready to start your first
tests. You do not need to install any driver.
In order to keep them simple, all the examples provided in this documentation are console
applications. Naturally, the libraries function in a strictly identical manner if you integrate them in an
application with a graphical interface.
18.2. Control of the Display function
A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a Java code snippet
to use the Display function.
[
...
]
// Get access to your device, connected locally on USB for instance
YAPI
.
RegisterHub
(
"127.0.0.1"
);
display
=
YDisplay
.
FindDisplay
(
"YD128X32-123456.display"
);
// Hot-plug is easy: just check that the device is online
if
(
display.
isOnline
())
{
// Use display.get_displayLayer()
[
...
]
1
www.yoctopuce.com/EN/libraries.php
2
www.yoctopuce.com/EN/virtualhub.php
www.yoctopuce.com
107
Содержание Yocto-Display
Страница 1: ...Yocto Display User Manual...
Страница 2: ......
Страница 40: ...34 www yoctopuce com...
Страница 52: ...46 www yoctopuce com...
Страница 84: ...78 www yoctopuce com...
Страница 92: ...86 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...22 High level API Reference 152 www yoctopuce com On failure throws an exception or returns a negative error code...
Страница 422: ...416 www yoctopuce com...
Страница 424: ...24 Characteristics 418 www yoctopuce com...