Implements functions for maxbotix ultrasonic sensors and senix toughsonic sensors subroutines.
More...
#include <device.h>
#include <stdlib.h>
#include <string.h>
#include "sensors_uart_control.h"
#include "strlib.h"
Go to the source code of this file.
Implements functions for maxbotix ultrasonic sensors and senix toughsonic sensors subroutines.
- Author
- Brandon Wong, Matt Bartos, Ivan Mondragon, Alec Beljanski
- Version
- TODO
- Date
- 2017-06-19
| uint8 ultrasonic_get_reading |
( |
UltrasonicReading * |
reading, |
|
|
uint8_t |
which_ultrasonic |
|
) |
| |
Takes a reading with the ultrasonic sensor selected by which_ultrasonic.
- Parameters
-
| reading | Structure to store results into. Depth in millimeters. |
| which_ultrasonic | Which ultrasonic sensor to use to take reading:
- 0: First ultrasonic sensor
- 1: Second ultrasonic sensor
- 2: Senix toughsonic sensor
|
- Returns
- 1 on success, 0 otherwise.
| uint8 ultrasonic_power_off |
( |
uint8 |
which_ultrasonic | ) |
|
Powers off the ultrasonic sensor.
- Parameters
-
| which_ultrasonic | Which ultrasonic sensor to power off:
- 0: First ultrasonic sensor
- 1: Second ultrasonic sensor
- 2: Senix toughsonic sensor
|
- Returns
- 0 on success
| uint8 ultrasonic_power_on |
( |
uint8 |
which_ultrasonic | ) |
|
Powers on the ultrasonic sensor.
- Parameters
-
| which_ultrasonic | Which ultrasonic sensor to power on:
- 0: First ultrasonic sensor
- 1: Second ultrasonic sensor
- 2: Senix toughsonic sensor
|
- Returns
- 1 on success
| uint8 zip_ultrasonic |
( |
char * |
labels[], |
|
|
float |
readings[], |
|
|
uint8 * |
array_ix, |
|
|
uint8 |
which_ultrasonic, |
|
|
uint8 |
take_average, |
|
|
int |
ultrasonic_loops, |
|
|
uint8 |
max_size |
|
) |
| |
Inserts current values of ultrasonic_reading into labels and readings arrays.
- Parameters
-
| labels | Array to store labels corresponding to each sensor reading |
| readings | Array to store sensor readings as floating point values |
| array_ix | Array index to label and readings |
| which_ultrasonic | Which ultrasonic to take reading with:
- 0: First ultrasonic sensor
- 1: Second ultrasonic sensor
- 2: Senix toughsonic sensor
|
| take_average | Whether to take average or not
- 0: Take first valid reading
- 1: Take average of valid readings
|
| ultrasonic_loops | Number of readings taken on each call. |
| max_size | Maximum size of label and reading arrays (number of entries) |
- Returns
- (*array_ix) + number of entries filled