ESP Line Following Buggy
2nd Year Embedded System Project (Group 48 - 2023/24)
|
Represents an array of sensors with corresponding LEDs for detection. More...
#include <sensor_array.h>
Public Member Functions | |
SensorArray (PinName sens0, PinName sens1, PinName sens2, PinName sens3, PinName sens4, PinName sens5, PinName led0, PinName led1, PinName led2, PinName led3, PinName led4, PinName led5, int sample_count, float detect_range, float angle_coefficient) | |
Constructs a new SensorArray object. | |
void | reset (void) |
Resets the sensor array. | |
void | update (void) |
Updates the sensor array. | |
bool | is_line_detected (void) |
Checks if a line is detected (in the last update). | |
void | set_all_led_on (bool status) |
Sets the status of all LEDs. | |
float | get_sens_output (int index) |
Gets the output value of a sensor at the specified index. | |
float * | get_sens_output_array (void) |
Gets an array of sensor output values. | |
float | get_array_output (void) |
Gets the output value of the sensor array. | |
float | get_filtered_output (void) |
void | calibrate_sensors (void) |
float * | get_calibration_constants (void) |
Represents an array of sensors with corresponding LEDs for detection.
This class provides functionality to read sensor values, detect lines, and control LEDs.
Definition at line 17 of file sensor_array.h.
SensorArray::SensorArray | ( | PinName | sens0, |
PinName | sens1, | ||
PinName | sens2, | ||
PinName | sens3, | ||
PinName | sens4, | ||
PinName | sens5, | ||
PinName | led0, | ||
PinName | led1, | ||
PinName | led2, | ||
PinName | led3, | ||
PinName | led4, | ||
PinName | led5, | ||
int | sample_count, | ||
float | detect_range, | ||
float | angle_coefficient ) |
Constructs a new SensorArray object.
sens0-sens5 | Pin names for the sensors. |
led0-led5 | Pin names for the LEDs. |
sample_count | The number of samples to take for averaging sensor readings. |
detect_range | The detection threshold for line detection. |
angle_coefficient | The gain at which the sensor output is multiplied to represent the angle. |
Definition at line 9 of file sensor_array.cpp.
void SensorArray::calibrate_sensors | ( | void | ) |
float SensorArray::get_array_output | ( | void | ) |
Gets the output value of the sensor array.
Definition at line 156 of file sensor_array.cpp.
float * SensorArray::get_calibration_constants | ( | void | ) |
float SensorArray::get_filtered_output | ( | void | ) |
float SensorArray::get_sens_output | ( | int | index | ) |
Gets the output value of a sensor at the specified index.
index | The index of the sensor. |
Definition at line 142 of file sensor_array.cpp.
float * SensorArray::get_sens_output_array | ( | void | ) |
Gets an array of sensor output values.
Definition at line 151 of file sensor_array.cpp.
bool SensorArray::is_line_detected | ( | void | ) |
Checks if a line is detected (in the last update).
Definition at line 136 of file sensor_array.cpp.
void SensorArray::reset | ( | void | ) |
Resets the sensor array.
This function resets the internal state of the sensor array.
Definition at line 22 of file sensor_array.cpp.
void SensorArray::set_all_led_on | ( | bool | status | ) |
Sets the status of all LEDs.
status | The status to set (true for on, false for off). |
Definition at line 35 of file sensor_array.cpp.
void SensorArray::update | ( | void | ) |
Updates the sensor array.
This function updates the sensor readings.
Definition at line 44 of file sensor_array.cpp.