![Yoctopuce Yocto-Display User Manual Download Page 108](http://html1.mh-extra.com/html/yoctopuce/yocto-display/yocto-display_user-manual_3418946108.webp)
[
...
]
errmsg
=
YRefParam
()
#Get access to your device, connected locally on USB for instance
YAPI
.
RegisterHub
(
"usb"
,
errmsg
)
display
=
YDisplay
.
FindDisplay
(
"YD128X32-123456.display"
)
# Hot-plug is easy: just check that the device is online
if
display.
isOnline
()
:
#Use display.get_displayLayer()
...
[
...
]
Let's 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. When used with the parameter
"usb"
, it will use the modules locally
connected to the computer running the library. If the initialization does not succeed, this function
returns a value different from
YAPI.SUCCESS
and
errmsg
contains the error message.
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 Python and open the corresponding sample script 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 side
materials needed to make it work nicely as a small demo.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import
os
,
sys
from
yocto_api
import
*
from
yocto_display
import
*
def
usage
()
:
17. Using the Yocto-Display with Python
102
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...