<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
<FORM method='get'>
<?php
include(
'yocto_api.php'
);
include(
'yocto_display.php'
);
// Use explicit error handling rather than exceptions
yDisableExceptions
();
// Setup the API to use the VirtualHub on local machine
if(
yRegisterHub
(
'http://127.0.0.1:4444/'
,
$errmsg
)
!=
YAPI_SUCCESS
)
{
die
(
"Cannot contact VirtualHub on 127.0.0.1"
);
}
@
$serial
=
$_GET
[
'serial'
];
if
(
$serial
!=
''
)
{
// Check if a specified module is available online
$disp
=
yFindDisplay
(
"
$serial
.display"
);
if
(!
$disp
->
isOnline
())
{
die
(
"Module not connected (check serial and USB cable)"
);
}
}
else
{
// or use any connected module suitable for the demo
$disp
=
yFirstDisplay
();
if(
is_null
(
$disp
))
{
die
(
"No module connected (check USB cable)"
);
}
}
$serial
=
$disp
->
get_module
()->
get_serialNumber
();
Print(
"Module to use: <input name='serial' value='
$serial
'><br>"
);
$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
);
yFreeAPI
();
?>
<br><input type='submit' value="Refresh">
</FORM>
</BODY>
</HTML>
10.3. 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.
<HTML>
<HEAD>
<TITLE>Module Control</TITLE>
</HEAD>
<BODY>
<FORM method='get'>
<?php
include(
'yocto_api.php'
);
10. Using Yocto-Display with PHP
www.yoctopuce.com
49
Содержание 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...