![Yoctopuce Yocto-Display User Manual Download Page 114](http://html1.mh-extra.com/html/yoctopuce/yocto-display/yocto-display_user-manual_3418946114.webp)
}
[
...
]
Let us look at these lines in more details.
YAPI.RegisterHub
The
yAPI.RegisterHub
function initializes the Yoctopuce API and indicates where the modules
should be looked for. The parameter is the address of the Virtual Hub able to see the devices. If the
initialization does not succeed, an exception is thrown.
YDisplay.FindDisplay
The
YDisplay.FindDisplay
function allows you to find a display from the serial number of the
module on which it resides and from its function name. You can use logical names as well, as long
as you have initialized them. Let us imagine a Yocto-Display module with serial number
YD128X32-123456
which you have named "
MyModule
", and for which you have given the
display
function the name "
MyFunction
". The following five calls are strictly equivalent, as long as
"
MyFunction
" is defined only once.
display
=
YDisplay
.
FindDisplay
(
"YD128X32-123456.display"
)
display
=
YDisplay
.
FindDisplay
(
"YD128X32-123456.MyFunction"
)
display
=
YDisplay
.
FindDisplay
(
"MyModule.display"
)
display
=
YDisplay
.
FindDisplay
(
"MyModule.MyFunction"
)
display
=
YDisplay
.
FindDisplay
(
"MyFunction"
)
YDisplay.FindDisplay
returns an object which you can then use at will to control the display.
isOnline
The
isOnline()
method of the object returned by
YDisplay.FindDisplay
allows you to
know if the corresponding module is present and in working order.
get_displayLayer
The
get_displayLayer()
method of the object returned by
YDisplay.FindDisplay
allows
you to retrieve the object corresponding to one of the screen layers. This object implements all the
graphical routines.
A real example
Launch you Java environment and open the corresponding sample project provided in the directory
Examples/Doc-GettingStarted-Yocto-Display
of the Yoctopuce library.
In this example, you will recognize the functions explained above, but this time used with all the side
materials needed to make it work nicely as a small demo.
import
com.yoctopuce.YoctoAPI.*
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
public
class
Demo
{
private
static
void
disp
(
YDisplay
display,
String
text,
YDisplayLayer
.
ALIGN
al
)
throws
YAPI_Exception
{
YDisplayLayer
layer0
=
display.
get_displayLayer
(
0
);
int
l
=
(
int
)
display.
get_displayWidth
();
int
h
=
(
int
)
display.
get_displayHeight
();
int
mx
=
l
/
2
;
int
my
=
h
/
2
;
layer0.
clear
();
layer0.
moveTo
(
mx,
0
);
layer0.
lineTo
(
mx, h
);
layer0.
moveTo
(
0
, my
);
layer0.
lineTo
(
l, my
);
layer0.
drawText
(
mx, my, al, text
);
}
18. Using the Yocto-Display with Java
108
www.yoctopuce.com
Summary of Contents for Yocto-Display
Page 1: ...Yocto Display User Manual...
Page 2: ......
Page 40: ...34 www yoctopuce com...
Page 52: ...46 www yoctopuce com...
Page 84: ...78 www yoctopuce com...
Page 92: ...86 www yoctopuce com...
Page 130: ...124 www yoctopuce com...
Page 422: ...416 www yoctopuce com...