
l1
=
await
disp
.
get_displayLayer
(
1
);
await
l1
.
clear
();
await
l1
.
drawCircle
(
h
/
8
, h
/
8
, h
/
8
);
// and animate the layer
x
=
0
;
y
=
0
;
vx
=
1
;
vy
=
1
;
while
(await
disp
.
isOnline
())
{
x
+=
vx
;
y
+=
vy
;
if
((
x
<
0
)
||
(
x
>
w
-
(
h
/
4
)))
vx
=
-
vx
;
if
((
y
<
0
)
||
(
y
>
h
-
(
h
/
4
)))
vy
=
-
vy
;
await
l1
.
setLayerPosition
(
x, y,
0
);
await
YAPI
.
Sleep
(
5
);
}
WriteLine
(
"Module not connected (check identification and USB cable) "
);
}
catch
(
YAPI_Exception
ex
)
{
WriteLine
(
"error: "
+
ex
.
Message
);
}
YAPI
.
FreeAPI
();
return
0
;
}
}
}
15.6. Control of the module part
Each module can be controlled in a similar manner, you can find below a simple sample program
displaying the main parameters of the module and enabling you to activate the localization beacon.
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
bool
Beacon
{
get;
set;
}
public
override
async
Task
<
int
>
Run
()
{
YModule
m
;
string
errmsg
=
""
;
if
(await
YAPI
.
RegisterHub
(
HubURL
)
!=
YAPI
.
SUCCESS
)
{
WriteLine
(
"RegisterHub error: "
+
errmsg
);
return
-
1
;
}
m
=
YModule
.
FindModule
(
Target
+
".module"
);
// use serial or logical name
if
(await
m
.
isOnline
())
{
if
(
Beacon
)
{
await
m
.
set_beacon
(
YModule
.
BEACON_ON
);
}
else
{
await
m
.
set_beacon
(
YModule
.
BEACON_OFF
);
}
WriteLine
(
"serial: "
+
await
m
.
get_serialNumber
());
WriteLine
(
"logical name: "
+
await
m
.
get_logicalName
());
WriteLine
(
"luminosity: "
+
await
m
.
get_luminosity
());
Write
(
"beacon: "
);
if
(await
m
.
get_beacon
()
==
YModule
.
BEACON_ON
)
WriteLine
(
"ON"
);
else
WriteLine
(
"OFF"
);
15. Using the Yocto-Display with Universal Windows Platform
www.yoctopuce.com
91
Содержание 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...