perif::LidarMap class

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

DevMap data
list<function<void(DevMap&)>> hooks

Protected functions

auto begin() -> bool override
auto getTimer() -> Timer&

Protected variables

uint8_t address
Timer timer

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

Returns if the I2C port is initialized

Whether this I2C port is initialized.

void perif::LidarMap::update()

Performs a manual update of peripheral data and notifies observers.

void perif::LidarMap::registerHook(function<void(DevMap&)>&& hook)

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

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

The key-value mapping of peripheral data.

list<function<void(DevMap&)>> perif::LidarMap::hooks

Hooks registered to this peripheral so observers can be notified of any necessary changes.

uint8_t perif::LidarMap::address protected

the address for this i2c device

Timer perif::LidarMap::timer protected

A timer for managing peripheral updates.