![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
A class for managing the SHARP GP2Y distance sensor. More...
#include <SHARPGP2Y.h>
Public Member Functions | |
SHARPGP2Y (uint8_t pin) | |
Constructs a SHARPGP2Y instance with the specified pin. | |
float | GetDistance () |
Retrieves the current distance measurement. | |
float | Update () |
Updates the distance measurement by reading the sensor. | |
Private Member Functions | |
float | ReadingToDistance (uint8_t reading) |
Converts a raw sensor reading to a distance value. | |
Private Attributes | |
RunningAverageFilter< 25 > | rAF = RunningAverageFilter<25>(0.1f) |
Running average filter for smoothing sensor readings. | |
float | distance = 0.0f |
Current distance measurement. | |
uint8_t | pin |
Analog pin connected to the sensor. | |
A class for managing the SHARP GP2Y distance sensor.
The SHARPGP2Y class provides methods for reading distance measurements from the sensor and applying filtering for noise reduction.
Definition at line 24 of file SHARPGP2Y.h.
Constructs a SHARPGP2Y instance with the specified pin.
pin | The analog pin connected to the SHARP GP2Y sensor. |
Definition at line 3 of file SHARPGP2Y.cpp.
References pin.
float GetDistance | ( | ) |
Retrieves the current distance measurement.
Definition at line 16 of file SHARPGP2Y.cpp.
References distance.
Converts a raw sensor reading to a distance value.
reading | The raw analog reading from the sensor. |
Definition at line 7 of file SHARPGP2Y.cpp.
Referenced by Update().
float Update | ( | ) |
Updates the distance measurement by reading the sensor.
Definition at line 20 of file SHARPGP2Y.cpp.
References distance, RunningAverageFilter< memory >::Filter(), pin, rAF, and ReadingToDistance().
Referenced by GammaAnimation::Update().
|
private |
Current distance measurement.
Definition at line 27 of file SHARPGP2Y.h.
Referenced by GetDistance(), and Update().
|
private |
Analog pin connected to the sensor.
Definition at line 28 of file SHARPGP2Y.h.
Referenced by SHARPGP2Y(), and Update().
|
private |
Running average filter for smoothing sensor readings.
Definition at line 26 of file SHARPGP2Y.h.
Referenced by Update().