
yocto_lightSensor,
yocto_temperature;
Procedure
Usage
()
;
var
exe :
string
;
begin
exe:=
ExtractFileName
(
paramstr
(
0
))
;
WriteLn
(
exe+
' <serial_number>'
)
;
WriteLn
(
exe+
' <logical_name>'
)
;
WriteLn
(
exe+
' any'
)
;
sleep
(
2500
)
;
halt
;
End
;
var
rf : TYRangeFinder;
ir : TYLightSensor;
tmp : TYTemperature;
m : TYModule;
errmsg,target :
string
;
done :
boolean
;
begin
if
(
paramcount<
1
)
then
usage
()
;
// Setup the API to use local USB devices
if
yRegisterHub
(
'usb'
, errmsg
)
<>YAPI_SUCCESS
then
begin
Write
(
'RegisterHub error: '
+errmsg
)
;
exit
;
end
;
target :=
paramstr
(
1
)
;
if
target=
'any'
then
begin
// search for the first available light sensor
rf := yFirstRangeFinder
()
;
if
rf =
nil
then
begin
writeln
(
'No module connected (check USB cable)'
)
;
halt
;
end
;
m := rf.
get_module
()
;
target := m.
get_serialNumber
()
;
end
else
// or use the one specified on command line
rf := YFindRangeFinder
(
'.rangeFinder1'
)
;
ir := YFindLightSensor
(
'.lightSensor1'
)
;
tmp := YFindTemperature
(
'.temperature1'
)
;
// lets poll the sensor
done :=
false
;
repeat
if
(
rf.
isOnline
())
then
begin
Writeln
(
'Distance : '
+
FloatToStr
(
rf.
get_currentValue
()))
;
Writeln
(
'Ambiant IR : '
+
FloatToStr
(
ir.
get_currentValue
()))
;
Writeln
(
'Temperature : '
+
FloatToStr
(
tmp.
get_currentValue
()))
;
Writeln
(
' (press Ctrl-C to exit)'
)
;
YSleep
(
1000
,errmsg
)
;
end
else
begin
Writeln
(
'Module not connected (check identification and USB cable)'
)
;
done :=
true
;
end
;
until
done;
yFreeAPI
()
;
end
.
There are only a few really important lines in this sample example. We will look at them in details.
14. Using Yocto-RangeFinder with Delphi
86
www.yoctopuce.com
Summary of Contents for Yocto-RangeFinder
Page 1: ...Yocto RangeFinder User s guide...
Page 2: ......
Page 18: ...12 www yoctopuce com...
Page 26: ...20 www yoctopuce com...
Page 42: ...36 www yoctopuce com...
Page 70: ...gcc lyocto lm lpthread lusb 1 0 lstdc 10 Using Yocto RangeFinder with C 64 www yoctopuce com...
Page 90: ...84 www yoctopuce com...
Page 120: ...114 www yoctopuce com...
Page 130: ...124 www yoctopuce com...
Page 484: ...478 www yoctopuce com...
Page 488: ...482 www yoctopuce com...
Page 490: ...23 Characteristics 484 www yoctopuce com...
Page 491: ......
Page 492: ......