LidarMap class
Contents
Wrapper around the Garmin LIDAR-Lite library.
Base classes
-
template<i2c_port_t port = I2C_NUM_0, bool sdaPullup = false, bool sclPullup = false, uint32_t frequency = 100000UL>class I2CPerif
Constructors, destructors, conversion operators
- LidarMap(uint8_t address = 0x62) explicit
Public functions
- auto getDistance(uint8_t count = 1) -> double
- auto measure(bool biasCorrection) -> double
- auto isConnected() -> bool override
- void update()
- void registerHook(function<void(DevMap&)>&& hook)
Public variables
Protected functions
Protected variables
Private functions
- void updateData() override
- void representData() override
Function documentation
perif:: LidarMap:: LidarMap(uint8_t address = 0x62) explicit
Constructor for Lidar. Sets up Lidar immediately.
double perif:: LidarMap:: getDistance(uint8_t count = 1)
Gets the distance (in cm) count times and returns the average.
double perif:: LidarMap:: measure(bool biasCorrection)
| Parameters | |
|---|---|
| biasCorrection | whether to perform bias correction (can be slow) |
| Returns | the measured distance |
Performs lidar distance measurement and bias correction.
bool perif:: LidarMap:: isConnected() override
#include <main/perif/I2CPerif.hpp>
| Returns | if the I2C port is initialized |
|---|
Whether this I2C port is initialized.
void perif:: LidarMap:: update()
#include <main/perif/Perif.hpp>
Performs a manual update of peripheral data and notifies observers.
void perif:: LidarMap:: registerHook(function<void(DevMap&)>&& hook)
#include <main/perif/Perif.hpp>
| Parameters | |
|---|---|
| hook | the observer function |
Registers a hook for obtaining sensor data on update in Json format.
bool perif:: LidarMap:: begin() override protected
| Returns | whether the peripheral initialization succeeded |
|---|
Performs initialization of a peripheral. Necessary to avoid initialization in the constructor which causes many side effects.
Timer& perif:: LidarMap:: getTimer() protected
#include <main/perif/Perif.hpp>
| Returns | a timer reference |
|---|
Obtains a reference to this peripheral's timer.
void perif:: LidarMap:: updateData() override private
Obtains distance data in centimeters.
void perif:: LidarMap:: representData() override private
Converts distance data to a String.
Variable documentation
DevMap perif:: LidarMap:: data
#include <main/perif/Perif.hpp>
The key-value mapping of peripheral data.
list<function<void(DevMap&)>> perif:: LidarMap:: hooks
#include <main/perif/Perif.hpp>
Hooks registered to this peripheral so observers can be notified of any necessary changes.
uint8_t perif:: LidarMap:: address protected
#include <main/perif/I2CPerif.hpp>
the address for this i2c device
Timer perif:: LidarMap:: timer protected
#include <main/perif/Perif.hpp>
A timer for managing peripheral updates.