
const
serial =
'YD128X32-123456'
;
// use serial number or logical name
procedure
refresh
(
module:Tymodule
)
;
begin
if
(
module.
isOnline
())
then
begin
Writeln
(
''
)
;
Writeln
(
'Serial : '
+ module.
get_serialNumber
())
;
Writeln
(
'Logical name : '
+ module.
get_logicalName
())
;
Writeln
(
'Luminosity : '
+
intToStr
(
module.
get_luminosity
()))
;
Write(
'Beacon :'
)
;
if
(
module.
get_beacon
()
=Y_BEACON_ON
)
then
Writeln
(
'on'
)
else
Writeln
(
'off'
)
;
Writeln
(
'uptime : '
+
intToStr
(
module.
get_upTime
()
div
1000
)
+
's'
)
;
Writeln
(
'USB current : '
+
intToStr
(
module.
get_usbCurrent
())
+
'mA'
)
;
Writeln
(
'Logs : '
)
;
Writeln
(
module.
get_lastlogs
())
;
Writeln
(
''
)
;
Writeln
(
'r : refresh / b:beacon ON / space : beacon off'
)
;
end
else
Writeln
(
'Module not connected (check identification and USB cable)'
)
;
end
;
procedure
beacon
(
module:Tymodule;state:
integer
)
;
begin
module.
set_beacon
(
state
)
;
refresh
(
module
)
;
end
;
var
module : TYModule;
c :
char
;
errmsg :
string
;
begin
// Setup the API to use local USB devices
if
yRegisterHub
(
'usb'
, errmsg
)
<>YAPI_SUCCESS
then
begin
Write(
'RegisterHub error: '
+errmsg
)
;
exit
;
end
;
module := yFindModule
(
serial
)
;
refresh
(
module
)
;
repeat
read(
c
)
;
case
c
of
'r'
: refresh
(
module
)
;
'b'
: beacon
(
module,Y_BEACON_ON
)
;
' '
: beacon
(
module,Y_BEACON_OFF
)
;
end
;
until
c =
'x'
;
yFreeAPI
()
;
end
.
Each property
xxx
of the module can be read thanks to a method of type
get_xxxx()
, and
properties which are not read-only can be modified with the help of the
set_xxx()
method. For
more details regarding the used functions, refer to the API chapters.
Changing the module settings
When you want to modify the settings of a module, you only need to call the corresponding
set_xxx()
function. However, this modification is performed only in the random access memory
(RAM) of the module: if the module is restarted, the modifications are lost. To memorize them
persistently, it is necessary to ask the module to save its current configuration in its permanent
memory. To do so, use the
saveToFlash()
method. Inversely, it is possible to force the module to
forget its current settings by using the
revertFromFlash()
method. The short example below
allows you to modify the logical name of a module.
program
savesettings;
{$APPTYPE CONSOLE}
uses
16. Using Yocto-Display with Delphi
98
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...