
yocto_api and yocto_rangefinder
These two units provide access to the functions allowing you to manage Yoctopuce modules.
yocto_api
must always be used,
yocto_rangefinder
is necessary to manage modules
containing a range finder, such as Yocto-RangeFinder.
yRegisterHub
The
yRegisterHub
function initializes the Yoctopuce API and specifies where the modules should
be looked for. When used with the parameter
'usb'
, it will use the modules locally connected to the
computer running the library. If the initialization does not succeed, this function returns a value
different from
YAPI_SUCCESS
and
errmsg
contains the error message.
yFindRangeFinder
The
yFindRangeFinder
function allows you to find a range finder from the serial number of the
module on which it resides and from its function name. You can also use logical names, as long as
you have initialized them. Let us imagine a Yocto-RangeFinder module with serial number
YRNGFND1-123456
which you have named "
MyModule
", and for which you have given the
rangeFinder
function the name "
MyFunction
". The following five calls are strictly equivalent, as long
as "
MyFunction
" is defined only once.
rangefinder := yFindRangeFinder
(
"YRNGFND1-
123456
.
rangeFinder
"
)
;
rangefinder := yFindRangeFinder
(
"YRNGFND1-
123456
.
MyFunction
"
)
;
rangefinder := yFindRangeFinder
(
"MyModule.
rangeFinder
"
)
;
rangefinder := yFindRangeFinder
(
"MyModule.
MyFunction
"
)
;
rangefinder := yFindRangeFinder
(
"MyFunction"
)
;
yFindRangeFinder
returns an object which you can then use at will to control the range finder.
isOnline
The
isOnline()
method of the object returned by
yFindRangeFinder
allows you to know if
the corresponding module is present and in working order.
get_currentValue
The
get_currentValue()
method of the object returned by
yFindRangeFinder
allows you
to obtain the distance measured by the sensor, in mm or in inches depending on the sensor
configuration.
14.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.
program
modulecontrol;
{$APPTYPE CONSOLE}
uses
SysUtils,
yocto_api;
const
serial =
'YRNGFND1-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'
)
;
14. Using Yocto-RangeFinder with Delphi
www.yoctopuce.com
87
Содержание Yocto-RangeFinder
Страница 1: ...Yocto RangeFinder User s guide...
Страница 2: ......
Страница 18: ...12 www yoctopuce com...
Страница 26: ...20 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 70: ...gcc lyocto lm lpthread lusb 1 0 lstdc 10 Using Yocto RangeFinder with C 64 www yoctopuce com...
Страница 90: ...84 www yoctopuce com...
Страница 120: ...114 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...21 High level API Reference On failure throws an exception or returns a negative error code 152 www yoctopuce com...
Страница 484: ...478 www yoctopuce com...
Страница 488: ...482 www yoctopuce com...
Страница 490: ...23 Characteristics 484 www yoctopuce com...
Страница 491: ......
Страница 492: ......