M5UnitUnified 0.0.2 git rev:a353e8c
Loading...
Searching...
No Matches
m5::unit::Component Class Reference

Base class of unit component. More...

#include <M5UnitComponent.hpp>

Classes

struct  component_config_t
 Component basic settings for begin. More...
 

Public Member Functions

bool generalCall (const uint8_t *data, const size_t len)
 General call for I2C.
 
virtual std::string debugInfo () const
 Output information for debug.
 
Constructor
Warning
COPY PROHIBITED
 Component (const uint8_t addr=0x00)
 
 Component (const Component &)=delete
 
 Component (Component &&) noexcept=default
 
Assignment
Warning
COPY PROHIBITED
Componentoperator= (const Component &)=delete
 
Componentoperator= (Component &&) noexcept=default
 
Component settings
component_config_t component_config ()
 Gets the common configurations in each unit.
 
void component_config (const component_config_t &cfg)
 Set the common configurations in each unit.
 
Functions that must be inherited
virtual bool begin ()
 Begin unit.
 
virtual void update (const bool force=false)
 Update unit.
 
Properties
const char * deviceName () const
 Gets the device name.
 
types::uid_t identifier () const
 Gets the identifier.
 
types::attr_t attribute () const
 Gets the attributes.
 
uint32_t order () const
 Gets the registered order (== 0 means not yet)
 
int16_t channel () const
 Gets the channel if connected to another unit.
 
bool isRegistered () const
 Is the unit registered with the manager?
 
uint8_t address () const
 Address used to access the device.
 
Adapteradapter () const
 Gets the access adapter.
 
Periodic measurement
bool inPeriodic () const
 In periodic measurement?
 
bool updated () const
 Periodic measurement data updated?
 
types::elapsed_time_t updatedMillis () const
 Time elapsed since start-up when the measurement data was updated in update()
 
types::elapsed_time_t interval () const
 Gets the periodic measurement interval.
 
Bus assignment
virtual bool assign (m5::hal::bus::Bus *bus)
 Assgin m5::hal::bus.
 
virtual bool assign (TwoWire &wire)
 Assgin TwoWire.
 
Parent-children relationship
Note
For daisy-chaining units such as hubs
bool hasParent () const
 Has parent unit?
 
bool hasSiblings () const
 Are there any other devices connected to the same parent unit besides yourself?
 
bool hasChildren () const
 Are there other devices connected to me?
 
size_t childrenSize () const
 Number of units connected to me.
 
bool existsChild (const uint8_t ch) const
 Is there an other unit connected to the specified channel?
 
Componentchild (const uint8_t chhanle) const
 Gets the deviceconnected to the specified channel.
 
bool add (Component &c, const int16_t channel)
 Connect the unit to the specified channel.
 
bool selectChannel (const uint8_t ch=8)
 Select valid channel if exists.
 
Read/Write
m5::hal::error::error_t readWithTransaction (uint8_t *data, const size_t len)
 

Static Public Attributes

Fixed parameters for class
Warning
Define the same name and type in the derived class.
static const types::uid_t uid {0}
 Unique identifier.
 
static const types::attr_t attr {0}
 Attributes.
 
static const char name [] = ""
 Device name string.
 

Iterator for children

using child_iterator = iterator<Component>
 
using const_child_iterator = iterator<const Component>
 
child_iterator childBegin () noexcept
 
child_iterator childEnd () noexcept
 
const_child_iterator childBegin () const noexcept
 
const_child_iterator childEnd () const noexcept
 

Detailed Description

Base class of unit component.

Member Function Documentation

◆ adapter()

Adapter * m5::unit::Component::adapter ( ) const
inline

Gets the access adapter.

Warning
Ownership is retained by the unit and should not be released

◆ begin()

virtual bool m5::unit::Component::begin ( )
inlinevirtual

Begin unit.

Initiate functions based on component config and unit config

◆ interval()

types::elapsed_time_t m5::unit::Component::interval ( ) const
inline

Gets the periodic measurement interval.

Returns
interval time (Unit: ms)

◆ update()

virtual void m5::unit::Component::update ( const bool force = false)
inlinevirtual

Update unit.

Parameters
forceForced communication for updates if true

◆ updatedMillis()

types::elapsed_time_t m5::unit::Component::updatedMillis ( ) const
inline

Time elapsed since start-up when the measurement data was updated in update()

Returns
Updated time (Unit: ms)