
YRangeFinder f = YRangeFinder.
FirstRangeFinder
()
;
f.
set_reportFrequency
(
"4/m"
)
;
f.
registerTimedReportCallback
(
periodicCallback
)
;
As for value change callbacks, each module function can thus have its own distinct timed report
callback.
Generic callback functions
It is sometimes desirable to use the same callback function for various types of sensors (e.g. for a
generic sensor graphing application). This is possible by defining the callback for an object of class
YSensor
rather than
YRangeFinder
. Thus, the same callback function will be usable with any
subclass of
YSensor
(and in particular with
YRangeFinder
). With the callback function, you can
use the method
get_unt()
to get the physical unit of the sensor, if you need to display it.
A complete example
You can find a complete example implemented in your favorite programming language in the
Examples/Prog-EventBased
directory of the corresponding library.
18.2. The data logger
Your Yocto-RangeFinder is equipped with a data logger able to store non-stop the measures
performed by the module. The maximal frequency is 100 times per second (i.e. "100/s"), and the
minimal frequency is 1 time per hour (i.e. "1/h"). When the frequency is higher than or equal to 1/s,
the measure represents an instant value. When the frequency is below, the measure will include
distinct minimal, maximal and average values based on a sampling performed automatically by the
device.
The data logger flash memory can store about 500'000 instant measures, or 125'000 averaged
measures. When the memory is about to be saturated, the oldest measures are automatically
erased.
Make sure not to leave the data logger running at high speed unless really needed: the flash memory
can only stand a limited number of erase cycles (typically 100'000 cycles). When running at full
speed, the datalogger can burn more than 100 cycles per day ! Also be aware that it is useless to
record measures at a frequency higher than the refresh frequency of the physical sensor itself.
Starting/stopping the datalogger
The data logger can be started with the
set_recording()
method.
YDataLogger l = YDataLogger.
FirstDataLogger
()
;
l.
set_recording
(
YDataLogger.
RECORDING_ON
)
;
It is possible to make the data recording start automatically as soon as the module is powered on.
YDataLogger l = YDataLogger.
FirstDataLogger
()
;
l.
set_autoStart
(
YDataLogger.
AUTOSTART_ON
)
;
l.
get_module
()
.
saveToFlash
()
;
// do not forget to save the setting
Note: Yoctopuce modules do not need an active USB connection to work: they start working as soon
as they are powered on. The Yocto-RangeFinder can store data without necessarily being connected
to a computer: you only need to activate the automatic start of the data logger and to power on the
module with a simple USB charger.
Erasing the memory
The memory of the data logger can be erased with the
forgetAllDataStreams()
function. Be
aware that erasing cannot be undone.
YDataLogger l = YDataLogger.
FirstDataLogger
()
;
l.
forgetAllDataStreams
()
;
18. Advanced programming
118
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: ......