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 Microsoft Visual C# 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 side
materials needed to make it work nicely as a small demo.
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
ConsoleApplication1
{
class
Program
{
static
void
usage
()
{
string
execname
=
System
.
AppDomain
.
CurrentDomain
.
FriendlyName
;
Console
.
WriteLine
(
execname
+
" <serial_number> "
);
Console
.
WriteLine
(
execname
+
" <logical_name>"
);
Console
.
WriteLine
(
execname
+
" any "
);
System.
Threading
.
Thread
.
Sleep
(
2500
);
Environment
.
Exit
(
0
);
}
static
void
Main
(
string
[]
args
)
{
string
errmsg
=
""
;
string
target
;
YDisplay
disp
;
YDisplayLayer
l0, l1
;
int
h, w, y, x, vx, vy
;
if
(
args
.
Length
<
1
)
usage
();
target
=
args
[
0
].
ToUpper
();
// API init
if
(
YAPI
.
RegisterHub
(
"usb"
,
ref
errmsg
)
!=
YAPI
.
SUCCESS
)
{
Console
.
WriteLine
(
"RegisterHub error: "
+
errmsg
);
Environment
.
Exit
(
0
);
}
// find the display according to command line parameters
if
(
target
==
"ANY"
)
{
disp
=
YDisplay
.
FirstDisplay
();
if
(
disp
==
null)
{
Console
.
WriteLine
(
"No module connected (check USB cable) "
);
Environment
.
Exit
(
0
);
}
}
else
disp
=
YDisplay
.
FindDisplay
(
target
+
".display"
);
if
(!
disp
.
isOnline
())
{
Console
.
WriteLine
(
"Module not connected (check identification and USB cable) "
);
Environment
.
Exit
(
0
);
}
//clean up
disp
.
resetAll
();
// retreive the display size
w
=
disp
.
get_displayWidth
();
h
=
disp
.
get_displayHeight
();
// reteive the first layer
l0
=
disp
.
get_displayLayer
(
0
);
// display a text in the middle of the screen
14. Using Yocto-Display with C#
www.yoctopuce.com
81
Содержание 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...