M5UnitUnified 0.6.3 git rev:e38fc73
Loading...
Searching...
No Matches
m5::unit::UnitUnified Class Reference

For managing and leading units. More...

#include <M5UnitUnified.hpp>

Public Types

using container_type = std::vector<Component*>
 

Public Member Functions

bool begin ()
 Begin all units under management.
 
void update (const bool force=false)
 Update all units under management.
 
std::string debugInfo () const
 Output information for debug.
 
Constructor
Warning
COPY PROHIBITED
 UnitUnified (const UnitUnified &)=delete
 
 UnitUnified (UnitUnified &&) noexcept=default
 
Assignment
Warning
COPY PROHIBITED
UnitUnified & operator= (const UnitUnified &)=delete
 
UnitUnified & operator= (UnitUnified &&) noexcept=default
 
Add unit(I2C)
bool add (Component &u, TwoWire &wire)
 Add unit to be managed (I2C via TwoWire)
 
bool add (Component &u, i2c_master_bus_handle_t bus)
 Adding unit to be managed (I2C, ESP-IDF native driver)
 
bool add (Component &u, i2c_master_bus_handle_t bus, const i2c_port_t port, const gpio_num_t sda, const gpio_num_t scl)
 Adding unit to be managed (I2C, ESP-IDF native driver, with the bus port and pins)
 
bool add (Component &u, const i2c_port_t port, const gpio_num_t sda, const gpio_num_t scl)
 Adding unit to be managed (I2C, ESP-IDF legacy driver)
 
bool add (Component &u, m5::I2C_Class &i2c)
 Add unit to be managed (I2C via I2C_Class)
 
Add unit(GPIO)
bool add (Component &u, const int8_t rx_pin, const int8_t tx_pin)
 Add unit to be managed (GPIO)
 
Add unit(UART)
bool add (Component &u, HardwareSerial &serial)
 Add unit to be managed (UART)
 
bool add (Component &u, const uart_port_t uart_num)
 Adding unit to be managed (UART, ESP-IDF native driver)
 
Add unit(SPI)
bool add (Component &u, SPIClass &spi, const SPISettings &settings)
 Add unit to be managed (SPI)
 
bool add (Component &u, spi_device_handle_t handle, const gpio_num_t cs=GPIO_NUM_NC)
 Adding unit to be managed (SPI, ESP-IDF native driver)
 
Add unit(M5HAL)
bool add (Component &u, m5::hal::bus::Bus *bus)
 Add unit to be managed (M5HAL bus)
 

Protected Member Functions

bool add_children (Component &u)
 
std::string make_unit_info (const Component *u, const uint8_t indent=0) const
 

Protected Attributes

container_type _units {}
 

Detailed Description

For managing and leading units.

Member Function Documentation

◆ add() [1/11]

bool m5::unit::UnitUnified::add ( Component & u,
const i2c_port_t port,
const gpio_num_t sda,
const gpio_num_t scl )

Adding unit to be managed (I2C, ESP-IDF legacy driver)

Parameters
uUnit Component
portI2C port (driver must be installed beforehand via i2c_param_config / i2c_driver_install)
sdaSDA GPIO
sclSCL GPIO
Returns
True if successful

◆ add() [2/11]

bool m5::unit::UnitUnified::add ( Component & u,
const int8_t rx_pin,
const int8_t tx_pin )

Add unit to be managed (GPIO)

Parameters
uUnit Component
rx_pinPin number to be used for RX
tx_pinPin number to be used for TX
Returns
True if successful
Note
ESP platform only

◆ add() [3/11]

bool m5::unit::UnitUnified::add ( Component & u,
const uart_port_t uart_num )

Adding unit to be managed (UART, ESP-IDF native driver)

Parameters
uUnit Component
uart_numUART port number (the driver must be installed beforehand via uart_driver_install / uart_param_config / uart_set_pin)
Returns
True if successful

◆ add() [4/11]

bool m5::unit::UnitUnified::add ( Component & u,
HardwareSerial & serial )

Add unit to be managed (UART)

Parameters
uUnit Component
serialHardwareSerial to be used
Returns
True if successful

◆ add() [5/11]

bool m5::unit::UnitUnified::add ( Component & u,
i2c_master_bus_handle_t bus )

Adding unit to be managed (I2C, ESP-IDF native driver)

Parameters
uUnit Component
busESP-IDF I2C master bus handle
Returns
True if successful

◆ add() [6/11]

bool m5::unit::UnitUnified::add ( Component & u,
i2c_master_bus_handle_t bus,
const i2c_port_t port,
const gpio_num_t sda,
const gpio_num_t scl )

Adding unit to be managed (I2C, ESP-IDF native driver, with the bus port and pins)

Parameters
uUnit Component
busESP-IDF I2C master bus handle
portI2C port the bus was created on
sdaSDA GPIO the bus was created on
sclSCL GPIO the bus was created on
Returns
True if successful
Note
The bus handle does not expose its pins; pass them so that AdapterI2C::sda() / scl() / port() report them

◆ add() [7/11]

bool m5::unit::UnitUnified::add ( Component & u,
m5::hal::bus::Bus * bus )

Add unit to be managed (M5HAL bus)

Parameters
uUnit Component
busBus to be used
Returns
True if successful

◆ add() [8/11]

bool m5::unit::UnitUnified::add ( Component & u,
m5::I2C_Class & i2c )

Add unit to be managed (I2C via I2C_Class)

Parameters
uUnit Component
i2cI2C_Class to be used (e.g. M5.In_I2C)
Returns
True if successful

◆ add() [9/11]

bool m5::unit::UnitUnified::add ( Component & u,
spi_device_handle_t handle,
const gpio_num_t cs = GPIO_NUM_NC )

Adding unit to be managed (SPI, ESP-IDF native driver)

Parameters
uUnit Component
handleESP-IDF SPI device handle (create with spics_io_num = -1; init bus with SPI_DMA_DISABLED)
csCS GPIO controlled manually by this library. If GPIO_NUM_NC (default), uses Component::address() as the CS pin (same convention as Arduino SPI)
Returns
True if successful

◆ add() [10/11]

bool m5::unit::UnitUnified::add ( Component & u,
SPIClass & spi,
const SPISettings & settings )

Add unit to be managed (SPI)

Parameters
uUnit Component
spiSPIClass to be used
settingsSPI settings to be applied
Returns
True if successful

◆ add() [11/11]

bool m5::unit::UnitUnified::add ( Component & u,
TwoWire & wire )

Add unit to be managed (I2C via TwoWire)

Parameters
uUnit Component
wireTwoWire to be used
Returns
True if successful

◆ begin()

bool m5::unit::UnitUnified::begin ( )

Begin all units under management.

Returns
True if all units began successfully

◆ debugInfo()

std::string m5::unit::UnitUnified::debugInfo ( ) const

Output information for debug.

Returns
String containing debug information

◆ update()

void m5::unit::UnitUnified::update ( const bool force = false)

Update all units under management.

Parameters
forceForced communication for updates if true