M5Unit-WEIGHT 0.1.0 git rev:dab2ce0
Loading...
Searching...
No Matches
m5::unit::UnitMiniScales Class Reference

MiniScales unit. More...

#include <unit_MiniScales.hpp>

Inheritance diagram for m5::unit::UnitMiniScales:
m5::unit::UnitWeightI2C

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitMiniScales (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual void update (const bool force=false) override
 
Settings for begin
config_t config ()
 Gets the configration.
 
void config (const config_t &cfg)
 Set the configration.
 
LED
bool readLEDColor (uint32_t &rgb32)
 Read the LED color as RGB32 (00RRGGBB HEX)
 
bool readLEDColor (uint8_t &r, uint8_t &g, uint8_t &b)
 Read the LED color as each colors.
 
bool writeLEDColor (const uint32_t rgb32)
 Write the LED color as RGB32 (00RRGGBB HEX)
 
bool writeLEDColor (const uint16_t rgb16)
 Write the LED color as RGB16 (RRRRRGGGGGGBBBBB BIN)
 
bool writeLEDColor (const uint8_t r, const uint8_t g, const uint8_t b)
 Write the LED color as each colors.
 
Button
bool readButtonStatus (bool &press)
 Read the button status.
 
bool isPressed () const
 Is button pressed?
 
bool wasPressed () const
 Was button pressed?
 
bool wasReleased ()
 Is button released?
 
- Public Member Functions inherited from m5::unit::UnitWeightI2C
 UnitWeightI2C (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
bool resetOffset ()
 Reset offset.
 
bool readRawADC (int32_t &value)
 Read the Raw ADC.
 
config_t config ()
 Gets the configration.
 
void config (const config_t &cfg)
 Set the configration.
 
float weight () const
 Oldest measured weight (float)
 
int32_t iweight () const
 Oldest measured weight (integer)
 
bool startPeriodicMeasurement (const weighti2c::Mode mode, const uint32_t interval=80)
 Start periodic measurement.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
bool measureSingleshot (weighti2c::Data &data, const weighti2c::Mode mode)
 Measurement single shot.
 
bool measureSingleshot (char *buf)
 Measurement single shot return as string.
 
bool readGap (float &gap)
 Read the gap value.
 
bool writeGap (const float gap, const uint32_t duration=100)
 Write the gap value.
 
bool isEnabledLPFilter (bool &enabled)
 Is enabled the Low-Pass Filter?
 
bool enableLPFilter (const bool enable)
 Enable the Low-Pass Filter.
 
bool readAvgFilterLevel (uint8_t &level)
 Read the Averaging Filter level.
 
bool writeAvgFilterLevel (const uint8_t level)
 Write the Averaging Filter level.
 
bool readEmaFilterAlpha (uint8_t &alpha)
 Read the Exponential Moving Average Filter alpha.
 
bool writeEmaFilterAlpha (const uint8_t alpha)
 Write the Exponential Moving Average Filter alpha.
 
bool readI2CAddress (uint8_t &i2c_address)
 Read the I2C address.
 
bool changeI2CAddress (const uint8_t i2c_address)
 Change unit I2C address.
 

Additional Inherited Members

- Protected Member Functions inherited from m5::unit::UnitWeightI2C
bool read_register (const uint8_t reg, uint8_t *buf, const size_t len)
 
bool read_register8 (const uint8_t reg, uint8_t &val)
 
bool start_periodic_measurement (const weighti2c::Mode mode, const uint32_t interval)
 
bool stop_periodic_measurement ()
 
bool read_measurement (weighti2c::Data &d, const weighti2c::Mode m)
 
bool read_filter (uint8_t *buf3)
 
bool write_filter (const uint8_t *buf3)
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitWeightI2C, weighti2c::Data)
 
- Protected Attributes inherited from m5::unit::UnitWeightI2C
weighti2c::Mode _mode {}
 
std::unique_ptr< m5::container::CircularBuffer< weighti2c::Data > > _data {}
 
config_t _cfg {}
 

Detailed Description

MiniScales unit.

Member Function Documentation

◆ isPressed()

bool m5::unit::UnitMiniScales::isPressed ( ) const
inline

Is button pressed?

Returns
True if pressed
Note
The state is managed by update

◆ readButtonStatus()

bool m5::unit::UnitMiniScales::readButtonStatus ( bool & press)

Read the button status.

Parameters
[out]presssePress if true
Returns
True if successful

◆ readLEDColor() [1/2]

bool m5::unit::UnitMiniScales::readLEDColor ( uint32_t & rgb32)

Read the LED color as RGB32 (00RRGGBB HEX)

Parameters
[out]rgb32color
Returns
True if successful

◆ readLEDColor() [2/2]

bool m5::unit::UnitMiniScales::readLEDColor ( uint8_t & r,
uint8_t & g,
uint8_t & b )

Read the LED color as each colors.

Parameters
[out]rR
[out]gG
[out]bB
Returns
True if successful

◆ update()

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

Reimplemented from m5::unit::UnitWeightI2C.

◆ wasPressed()

bool m5::unit::UnitMiniScales::wasPressed ( ) const
inline

Was button pressed?

Returns
True if pressed
Note
The state is managed by update

◆ wasReleased()

bool m5::unit::UnitMiniScales::wasReleased ( )
inline

Is button released?

Returns
True if released
Note
The state is managed by update

◆ writeLEDColor() [1/3]

bool m5::unit::UnitMiniScales::writeLEDColor ( const uint16_t rgb16)

Write the LED color as RGB16 (RRRRRGGGGGGBBBBB BIN)

Parameters
rgb16color
Returns
True if successful

◆ writeLEDColor() [2/3]

bool m5::unit::UnitMiniScales::writeLEDColor ( const uint32_t rgb32)
inline

Write the LED color as RGB32 (00RRGGBB HEX)

Parameters
rgb32color
Returns
True if successful

◆ writeLEDColor() [3/3]

bool m5::unit::UnitMiniScales::writeLEDColor ( const uint8_t r,
const uint8_t g,
const uint8_t b )

Write the LED color as each colors.

Parameters
rR
gG
bB
Returns
True if successful