Loom_Multiplexer class

Multiplexer manager for interfacing with multiple I2C sensors.

Base classes

class LoomModule
Abstract root of Loom component modules inheritance hierarchy.

Protected variables

LoomI2CSensor** sensors
Array of I2C sensor objects.
byte i2c_address
The multiplexer's I2C address.
uint8_t num_ports
The number of ports on the multiplexer.
bool dynamic_list
Whether or not sensor list is dynamic (refresh sensor list periodically)
uint update_period
Interval to update sensor list at.
unsigned long last_update_time
When the sensor list was last updated.
std::vector<byte> i2c_conflicts
List of I2C address conflicts.

CONSTRUCTORS / DESTRUCTOR

Loom_Multiplexer(LoomManager* manager, const byte i2c_address = 0x71, const uint8_t num_ports = 8, const bool dynamic_list = true, const uint update_period = 5000)
Multiplexer module constructor.
Loom_Multiplexer(LoomManager* manager, JsonArrayConst p)
Constructor that takes Json Array, extracts args and delegates to regular constructor.
~Loom_Multiplexer()
Destructor.

OPERATION

void measure()
Call measure on all connected sensors.
void package(JsonObject json) override
Package a modules measurements or state.
auto dispatch(JsonObject json) -> bool override
Route command to driver.
void get_sensor_list(JsonObject json)
Populate a bundle with a list of sensors currently attached.
void refresh_sensors()
Update sensor list.
auto get_sensor(uint8_t port) const -> LoomI2CSensor*
Get the sensor object for sensor on provided port.
void power_up() override
Turn on any hardware.
void power_down() override
Turn off any hardware.

GETTERS

auto get_is_dynamic() const -> bool
Get whether or not sensors are updated dynamically.
auto get_update_period() const -> int
Get the sensor list update period.

SETTERS

void set_is_dynamic(const bool dynamic)
Set whether or not to periodically update list of attached sensors.
void set_update_period(const uint period)
Set the sensor list update period.

Function documentation

Loom_Multiplexer::Loom_Multiplexer(LoomManager* manager, const byte i2c_address = 0x71, const uint8_t num_ports = 8, const bool dynamic_list = true, const uint update_period = 5000)

Multiplexer module constructor.

Parameters
manager
i2c_address in Set(Int) | <0x71> | {0x71} | I2C address
num_ports in Int | <8> | [1-8] | Number of ports available
dynamic_list in Bool | <true> | {true, false} | Whether or not to automatically check for new sensors
update_period in Int | <5000> | [500-30000] | The time between sensor list updates (if dynamic_list enabled)

Loom_Multiplexer::Loom_Multiplexer(LoomManager* manager, JsonArrayConst p)

Constructor that takes Json Array, extracts args and delegates to regular constructor.

Parameters
manager
in The array of constuctor args to expand

void Loom_Multiplexer::package(JsonObject json) override

Package a modules measurements or state.

Parameters
json out Object to put data into

void Loom_Multiplexer::get_sensor_list(JsonObject json)

Populate a bundle with a list of sensors currently attached.

Parameters
json out Json object to populate with sensor list

void Loom_Multiplexer::refresh_sensors()

Update sensor list.

Polls all ports of multiplexer getting sensor on port (if any)

void Loom_Multiplexer::print_measurements() const

Prints measurements of all connected sensors.

Calls implementations of LoomI2CSensor::print_measurements() const

bool Loom_Multiplexer::get_is_dynamic() const

Get whether or not sensors are updated dynamically.

Returns True if dynamic

int Loom_Multiplexer::get_update_period() const

Get the sensor list update period.

Returns The update period

void Loom_Multiplexer::set_is_dynamic(const bool dynamic)

Set whether or not to periodically update list of attached sensors.

Parameters
dynamic in The setting to set

void Loom_Multiplexer::set_update_period(const uint period)

Set the sensor list update period.

Parameters
period in New update period

Requires dynamic_list to be enabled