|
2 | 2 |
|
3 | 3 | Methods used to read data from the connected TMF882X device. |
4 | 4 |
|
5 | | -## Message Callback Functions |
| 5 | +## Data Callback Functions |
6 | 6 |
|
7 | 7 | The TMF882X SDK returns data via a message structure passed to a user provided C function. This library allows the user to register callback functions that are called during the measurement operation. |
8 | 8 |
|
@@ -219,3 +219,82 @@ void setErrorHandler(TMF882XErrorHandler handler) |
219 | 219 | | handler | `TMF882XErrorHandler` | The message handler callback C function | |
220 | 220 |
|
221 | 221 | ## Measurement Methods |
| 222 | +
|
| 223 | +### startMeasuring() |
| 224 | +
|
| 225 | +Start measuring distance/data on the TMF882X device. This method returns after one measurement is performed. |
| 226 | +
|
| 227 | +Measurement data is returned in the provided measurement struct. |
| 228 | +
|
| 229 | +```c++ |
| 230 | +int startMeasuring(struct tmf882x_msg_meas_results results, uint32_t timeout = 0) |
| 231 | +``` |
| 232 | + |
| 233 | +| Parameter | Type | Description | |
| 234 | +| :--- | :--- | :--- | |
| 235 | +| results| `struct tmf882x_msg_meas_results` | The results of the measurement | |
| 236 | +| timeout| `uint32_t` | [OPTIONAL] The time, in milliseconds, to take measurements. A value of zero [default value] indicates no timeout set | |
| 237 | +| return value| `int` | The number of measurements taken (1), or -1 on error. | |
| 238 | + |
| 239 | +### startMeasuring() |
| 240 | + |
| 241 | +Start measuring distance/data on the TMF882X device. This method won't return until the measurement activity ends. |
| 242 | + |
| 243 | +Measurement data is passed to the library user via a callback function, which is set using one of the set<type>Handler() methods on this object. |
| 244 | + |
| 245 | +Measurements continue, until one of the following conditions occurs: |
| 246 | + |
| 247 | +* The specified number of measurements took place (set via reqMeasurements) |
| 248 | +* The specified timeout value expires |
| 249 | +* The stopMeasuring() method was called in a Handler function. |
| 250 | + |
| 251 | +This method won't start measuring if a measurement limit isn't set, a timeout isn't set and no callback handlers are not set. |
| 252 | + |
| 253 | +This method returns the number of measurements taken |
| 254 | + |
| 255 | +```c++ |
| 256 | +int startMeasuring(uint32_t reqMeasurements = 0, uint32_t timeout = 0) |
| 257 | +``` |
| 258 | +
|
| 259 | +| Parameter | Type | Description | |
| 260 | +| :--- | :--- | :--- | |
| 261 | +| reqMeasurements| `uint32_t` | [OPTIONAL] The number of measurements desired. A value of zero [the default value] indicates no limit | |
| 262 | +| timeout| `uint32_t` | [OPTIONAL] The time, in milliseconds, to take measurements. A value of zero [default value] indicates no timeout set | |
| 263 | +| return value| `int` | The number of measurements taken, or -1 on error. | |
| 264 | +
|
| 265 | +### stopMeasuring() |
| 266 | +
|
| 267 | +Called to stop the device measuring loop. Normally called in a message handler function. |
| 268 | +
|
| 269 | +```c++ |
| 270 | +void stopMeasuring(void) |
| 271 | +``` |
| 272 | + |
| 273 | +| Parameter | Type | Description | |
| 274 | +| :--- | :--- | :--- | |
| 275 | +| None| | | |
| 276 | + |
| 277 | + |
| 278 | +### setSampleDelay() |
| 279 | + |
| 280 | +Set the delay used in the libraries sample loop used when processing samples/reading from the device. |
| 281 | + |
| 282 | +```c++ |
| 283 | +void setSampleDelay(uint16_t delay) |
| 284 | +``` |
| 285 | +
|
| 286 | +| Parameter | Type | Description | |
| 287 | +| :--- | :--- | :--- | |
| 288 | +| delay| `uint16_t` | The delay to use, in milli-seconds. | |
| 289 | +
|
| 290 | +### getSampleDelay() |
| 291 | +
|
| 292 | +Returns the current value of the library processing loop delay. The value is ib milliseconds.. |
| 293 | +
|
| 294 | +```c++ |
| 295 | +uint16_t getSampleDelay(void) |
| 296 | +``` |
| 297 | + |
| 298 | +| Parameter | Type | Description | |
| 299 | +| :--- | :--- | :--- | |
| 300 | +| return value| `uint16_t` | The current delay, in milli-seconds. | |
0 commit comments