Visual Studio projects contain numerous files, and most of them are not linked to the use of the
Yoctopuce library. To simplify reading the code, we regrouped all the code that uses the library in the
Demo
class, located in the
demo.cs
file. Properties of this class correspond to the different fields
displayed on the screen, and the
Run()
method contains the code which is run when the "Start"
button is pushed.
In this example, you can recognize the functions explained above, but this time used with all the side
materials needed to make it work nicely as a small demo.
using
System
;
using
System.Diagnostics
;
using
System.Threading.Tasks
;
using
Windows.UI.Xaml.Controls
;
using
com.yoctopuce.YoctoAPI
;
namespace
Demo
{
public
class
Demo
:
DemoBase
{
public
string
HubURL
{
get;
set;
}
public
string
Target
{
get;
set;
}
public
string
Message
{
get;
set;
}
public
override
async
Task
<
int
>
Run
()
{
try
{
await
YAPI
.
RegisterHub
(
HubURL
);
YDisplay
disp
;
YDisplayLayer
l0, l1
;
int
h, w, y, x, vx, vy
;
// find the display according to command line parameters
if
(
Target
.
ToLower
()
==
"any"
)
{
disp
=
YDisplay
.
FirstDisplay
();
if
(
disp
==
null)
{
WriteLine
(
"No module connected (check USB cable) "
);
return
-
1
;
}
}
else
{
disp
=
YDisplay
.
FindDisplay
(
Target
+
".display"
);
}
if
(!await
disp
.
isOnline
())
{
WriteLine
(
"Module not connected (check identification and USB cable) "
);
return
-
1
;
}
//clean up
await
disp
.
resetAll
();
// retreive the display size
w
=
await
disp
.
get_displayWidth
();
h
=
await
disp
.
get_displayHeight
();
// reteive the first layer
l0
=
await
disp
.
get_displayLayer
(
0
);
// display a text in the middle of the screen
await
l0
.
drawText
(
w
/
2
, h
/
2
,
YDisplayLayer
.
ALIGN
.
CENTER
, Message
);
// visualize each corner
await
l0
.
moveTo
(
0
,
5
);
await
l0
.
lineTo
(
0
,
0
);
await
l0
.
lineTo
(
5
,
0
);
await
l0
.
moveTo
(
0
, h
-
6
);
await
l0
.
lineTo
(
0
, h
-
1
);
await
l0
.
lineTo
(
5
, h
-
1
);
await
l0
.
moveTo
(
w
-
1
, h
-
6
);
await
l0
.
lineTo
(
w
-
1
, h
-
1
);
await
l0
.
lineTo
(
w
-
6
, h
-
1
);
await
l0
.
moveTo
(
w
-
1
,
5
);
await
l0
.
lineTo
(
w
-
1
,
0
);
await
l0
.
lineTo
(
w
-
6
,
0
);
// draw a circle in the top left corner of layer 1
15. Using the Yocto-Display with Universal Windows Platform
90
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...