static
void
usage
(
void
)
{
cout
<<
"Wrong command line arguments"
<<
endl
;
cout
<<
"usage: demo <serial_number>"
<<
endl
;
cout
<<
" demo <logical_name>"
<<
endl
;
cout
<<
" demo any (use any discovered device)"
<<
endl
;
u64
now
=
yGetTickCount
();
while
(
yGetTickCount
()
-
now
<
3000
)
{
// wait 3 sec to show the message
}
exit
(
1
);
}
int
main
(
int
argc,
const
char
*
argv
[])
{
string
errmsg
;
string
target
;
YDisplay
*
disp
;
YDisplayLayer
*
l0,
*
l1
;
int
w, h, x, y, vx, vy
;
if(
argc
<
2
)
{
usage
();
}
// Setup the API to use local USB devices
if
(
yRegisterHub
(
"usb"
, errmsg
)
!=
YAPI_SUCCESS
)
{
cerr
<<
"RegisterHub error: "
<<
errmsg
<<
endl
;
usage
();
return
1
;
}
target
=
(
string
)
argv
[
1
];
if
(
target
==
"any"
)
{
disp
=
yFirstDisplay
();
if
(
disp
==
NULL
)
{
cout
<<
"No module connected (check USB cable)"
<<
endl
;
usage
();
return
1
;
}
}
else
{
disp
=
yFindDisplay
(
target
+
".display"
);
}
if
(!
disp
->
isOnline
())
{
cout
<<
"Module is offline (check USB cable)"
<<
endl
;
usage
();
return
1
;
}
disp
->
resetAll
();
// retreive the display size
w
=
disp
->
get_displayWidth
();
h
=
disp
->
get_displayHeight
();
// reteive the first layer
l0
=
disp
->
get_displayLayer
(
0
);
l0
->
clear
();
// display a text in the middle of the screen
l0
->
drawText
(
w
/
2
, h
/
2
,
YDisplayLayer
::
ALIGN_CENTER
,
"Hello world!"
);
// visualize each corner
l0
->
moveTo
(
0
,
5
);
l0
->
lineTo
(
0
,
0
);
l0
->
lineTo
(
5
,
0
);
l0
->
moveTo
(
0
, h
-
6
);
l0
->
lineTo
(
0
, h
-
1
);
l0
->
lineTo
(
5
, h
-
1
);
l0
->
moveTo
(
w
-
1
, h
-
6
);
l0
->
lineTo
(
w
-
1
, h
-
1
);
l0
->
lineTo
(
w
-
6
, h
-
1
);
l0
->
moveTo
(
w
-
1
,
5
);
l0
->
lineTo
(
w
-
1
,
0
);
l0
->
lineTo
(
w
-
6
,
0
);
// draw a circle in the top left corner of layer 1
l1
=
disp
->
get_displayLayer
(
1
);
11. Using Yocto-Display with C++
www.yoctopuce.com
59
Содержание 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...