AccelGyro class
Contents
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
- AccelGyro(uint8_t address = 0x68) explicit
Public functions
- auto begin() -> bool override
- auto getAcceleration() -> const int16_t*
- auto getRotation() -> const int16_t*
- 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:: AccelGyro:: AccelGyro(uint8_t address = 0x68) explicit
| Parameters | |
|---|---|
| address | the I2C device address |
Constructor with sda and scl pins.
bool perif:: AccelGyro:: begin() override
| Returns | whether the peripheral initialization succeeded |
|---|
Performs initialization of a peripheral. Necessary to avoid initialization in the constructor which causes many side effects.
const int16_t* perif:: AccelGyro:: getAcceleration()
| Returns | acceleration coords (x, y, z) |
|---|
Obtains the acceleration data.
const int16_t* perif:: AccelGyro:: getRotation()
| Returns | rotation coords (x, y, z) |
|---|
Obtains the gyroscope rotation data.
bool perif:: AccelGyro:: isConnected() override
#include <main/perif/I2CPerif.hpp>
| Returns | if the I2C port is initialized |
|---|
Whether this I2C port is initialized.
void perif:: AccelGyro:: update()
#include <main/perif/Perif.hpp>
Performs a manual update of peripheral data and notifies observers.
void perif:: AccelGyro:: 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.
Timer& perif:: AccelGyro:: getTimer() protected
#include <main/perif/Perif.hpp>
| Returns | a timer reference |
|---|
Obtains a reference to this peripheral's timer.
void perif:: AccelGyro:: updateData() override private
Gets both acceleration and rotation data. (Magnetometer WIP).
void perif:: AccelGyro:: representData() override private
The representation of this peripheral's data in a meaningful way for debugging, caching, and database operations.
Variable documentation
list<function<void(DevMap&)>> perif:: AccelGyro:: hooks
#include <main/perif/Perif.hpp>
Hooks registered to this peripheral so observers can be notified of any necessary changes.
uint8_t perif:: AccelGyro:: address protected
#include <main/perif/I2CPerif.hpp>
the address for this i2c device
Timer perif:: AccelGyro:: timer protected
#include <main/perif/Perif.hpp>
A timer for managing peripheral updates.