You then have the choice between simply adding these files to your project, or to add them as links
(the
Add
button is in fact a scroll-down menu). In the first case, Visual Studio copies the selected
files into your project. In the second case, Visual Studio simply keeps a link on the original files. We
recommend you to use links, which makes updates of the library much easier.
Then add in the same manner the
yapi.dll
DLL, located in the
Sources/dll
directory
4
. Then,
from the
Solution Explorer
window, right click on the DLL, select
Properties
and in the
Properties
panel, set the
Copy to output folder
to
always
. You are now ready to use your Yoctopuce modules
from Visual Studio.
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.
14.3. Control of the Display function
A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a C# code snipplet to
use the Display function.
[...]
string
errmsg
=
""
;
YDisplay
display
;
// 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.
4
Remember to change the filter of the selection window, otherwise the DLL will not show.
14. Using Yocto-Display with C#
80
www.yoctopuce.com
Содержание 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...