M5Unit-THERMO 0.3.1 git rev:c2bfb11
Loading...
Searching...
No Matches
m5::unit::UnitThermal2 Class Reference

Unit Thermal2 (MLX90640 32x24 thermal camera, SKU:U149) More...

#include <unit_Thermal2.hpp>

Inheritance diagram for m5::unit::UnitThermal2:

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitThermal2 (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
virtual void update (const bool force=false) override
 
bool readFirmwareVersion (uint16_t &ver)
 Read the firmware version.
 
Settings for begin
config_t config ()
 Gets the configuration.
 
void config (const config_t &cfg)
 Set the configuration.
 
Periodic measurement
bool startPeriodicMeasurement (const thermal2::Refresh rate)
 Start periodic measurement.
 
bool startPeriodicMeasurement ()
 Start periodic measurement in the current settings.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
Single shot measurement
bool measureSingleshot (thermal2::Data &page0, thermal2::Data &page1)
 Measurement single shot.
 
Settings
bool readFunctionControl (uint8_t &value)
 Read the function control.
 
bool readBuzzerEnabled (bool &enabled)
 Read the buzzer enabled.
 
bool readLEDEnabled (bool &enabled)
 Reads the LED enabled.
 
bool writeFunctionControl (const uint8_t value, const bool verify=true)
 Write the function control.
 
bool writeBuzzerEnabled (const bool enabled)
 Write the buzzer enable status.
 
bool writeLEDEnabled (const bool enabled)
 Write the LED enable status.
 
bool readRefreshRate (thermal2::Refresh &rate)
 Read the refresh rate.
 
bool writeRefreshRate (const thermal2::Refresh rate)
 Write the refresh rate.
 
bool readNoiseFilterLevel (uint8_t &level)
 Read the noise filter level.
 
bool writeNoiseFilterLevel (const uint8_t level)
 Write the noise filter level.
 
bool readTemperatureMonitorSize (uint8_t &wid, uint8_t &hgt)
 Read the temperature monitor size.
 
bool writeTemperatureMonitorSize (const uint8_t wid, const uint8_t hgt)
 Write the temperature monitor size.
 
bool readTemeratureMonitorSize (uint8_t &wid, uint8_t &hgt)
 
bool writeTemeratureMonitorSize (const uint8_t wid, const uint8_t hgt)
 
Alarm
bool readAlarmEnabled (uint8_t &enabled_bits)
 Read the alarm control.
 
bool writeAlarmEnabled (const uint8_t enabled_bits)
 Read the alarm control.
 
bool readAlarmTemperature (const bool highlow, uint16_t &raw)
 Read the alarm temperature threshold.
 
bool readAlarmTemperature (const bool highlow, float &celsius)
 Read the alarm temperature threshold.
 
bool writeAlarmTemperature (const bool highlow, const uint16_t raw)
 Write the alarm temperature threshold.
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool writeAlarmTemperature (const bool highlow, const T celsius)
 Write the alarm temperature threshold.
 
bool readAlarmLED (const bool highlow, uint32_t &rgb)
 Read the alarm LED color.
 
bool writeAlarmLED (const bool highlow, const uint32_t rgb)
 Write the alarm LED color.
 
bool writeAlarmLED (const bool highlow, const uint8_t r, const uint8_t g, const uint8_t b)
 Write the alarm LED color.
 
bool readAlarmBuzzer (const bool highlow, uint16_t &freq, uint8_t &interval)
 Read the alarm buzzer settings.
 
bool writeAlarmBuzzer (const bool highlow, const uint16_t freq, const uint8_t interval)
 Write the alarm buzzer settings.
 
Buzzer
Warning
Value setting is invalid while buzzer is controlled by alarms
bool readBuzzer (uint16_t &freq, uint8_t &duty)
 Read the buzzer settings.
 
bool writeBuzzer (const uint16_t freq, const uint8_t duty, const bool verify=true)
 Write the buzzer settings.
 
bool writeBuzzerDuty (const uint8_t duty)
 Write the buzzer duty settings.
 
bool readBuzzerControl (bool &enabled)
 Read the Buzzer control.
 
bool writeBuzzerControl (const bool enabled)
 Write the Buzzer control.
 
LED
Warning
Value setting is invalid while LEDs are controlled by alarms
bool readLED (uint32_t &rgb)
 Read the LED color.
 
bool writeLED (const uint32_t rgb, const bool verify=true)
 Write the LED color.
 
bool writeLED (const uint8_t r, const uint8_t g, const uint8_t b, const bool verify=true)
 Write the LED color.
 
Button
bool readButtonStatus (uint8_t &bs)
 Read the button status.
 
bool isPressed () const
 Is button pressed?
 
bool wasPressed () const
 Was button pressed?
 
bool wasReleased () const
 Was button released?
 
bool wasClicked () const
 Was button clicked?
 
bool wasHold () const
 Was button hold?
 
bool isHolding () const
 Is button holding?
 
I2C Address
Warning
Handling warning
bool changeI2CAddress (const uint8_t i2c_address)
 Change device I2C address.
 
bool readI2CAddress (uint8_t &i2c_address)
 Read device I2C address.
 

Protected Member Functions

bool read_function_control_bit (const uint8_t bit, bool &enabled)
 
bool write_function_control_bit (const uint8_t bit, const bool enabled)
 
bool request_data ()
 
bool read_data_status (uint8_t s[2])
 
bool read_data (thermal2::Data &data)
 
bool start_periodic_measurement (const thermal2::Refresh rate)
 
bool start_periodic_measurement ()
 
bool stop_periodic_measurement ()
 
bool read_register (const uint8_t reg, uint8_t *v, const uint32_t len)
 
bool read_register8 (const uint8_t reg, uint8_t &v)
 
bool read_register16LE (const uint8_t reg, uint16_t &v)
 
bool read_register16BE (const uint8_t reg, uint16_t &v)
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitThermal2, thermal2::Data)
 

Detailed Description

Unit Thermal2 (MLX90640 32x24 thermal camera, SKU:U149)

Member Function Documentation

◆ changeI2CAddress()

bool m5::unit::UnitThermal2::changeI2CAddress ( const uint8_t i2c_address)

Change device I2C address.

Parameters
i2c_addressI2C address
Returns
True if successful
Warning
When the power is turned back on, it will operate at the new address

◆ isHolding()

bool m5::unit::UnitThermal2::isHolding ( ) const
inline

Is button holding?

Returns
True if holding
Note
The state is managed by update

◆ isPressed()

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

Is button pressed?

Returns
True if pressed
Note
The state is managed by update

◆ measureSingleshot()

bool m5::unit::UnitThermal2::measureSingleshot ( thermal2::Data & page0,
thermal2::Data & page1 )

Measurement single shot.

Parameters
[out]page0Measured data subpage 0
[out]page1Measured data subpage 1
Returns
True if successful
Note
Pixel temperature data is retrieved half at a time
Measure based on the current refresh rate
Warning
During periodic detection runs, an error is returned
Blocked until end of measurement

◆ readAlarmBuzzer()

bool m5::unit::UnitThermal2::readAlarmBuzzer ( const bool highlow,
uint16_t & freq,
uint8_t & interval )

Read the alarm buzzer settings.

Parameters
highlowTarget False:low True:high
[out]freqFrequency
[out]intervalInterval (10ms)
Returns
True if successful
Note
The interval valid range between 5 and 255 (50ms - 2550ms)

◆ readAlarmEnabled()

bool m5::unit::UnitThermal2::readAlarmEnabled ( uint8_t & enabled_bits)

Read the alarm control.

Parameters
[out]enabled_bitsEnabled temperature alarm bits
Returns
True if successful

◆ readAlarmLED()

bool m5::unit::UnitThermal2::readAlarmLED ( const bool highlow,
uint32_t & rgb )

Read the alarm LED color.

Parameters
highlowTarget False:low True:high
[out]rgbRGB24 color
Returns
True if successful

◆ readAlarmTemperature() [1/2]

bool m5::unit::UnitThermal2::readAlarmTemperature ( const bool highlow,
float & celsius )

Read the alarm temperature threshold.

Parameters
highlowTarget False:low True:high
[out]celsiusTemperature
Returns
True if successful

◆ readAlarmTemperature() [2/2]

bool m5::unit::UnitThermal2::readAlarmTemperature ( const bool highlow,
uint16_t & raw )

Read the alarm temperature threshold.

Parameters
highlowTarget False:low True:high
[out]rawTemperature (raw)
Returns
True if successful

◆ readButtonStatus()

bool m5::unit::UnitThermal2::readButtonStatus ( uint8_t & bs)

Read the button status.

Parameters
[out]bsButton status
Returns
True if successful

◆ readBuzzer()

bool m5::unit::UnitThermal2::readBuzzer ( uint16_t & freq,
uint8_t & duty )

Read the buzzer settings.

Parameters
[out]freqFrequency
[out]duty0 - 255
Returns
True if successful
Note
buzzer duty. 0~255 (default:128 : The loudest sound setting; the further away from 128, the quieter the sound)

◆ readBuzzerControl()

bool m5::unit::UnitThermal2::readBuzzerControl ( bool & enabled)
inline

Read the Buzzer control.

Parameters
[out]enabledTrue:enabled False: disabled
Returns
True if successful

◆ readFirmwareVersion()

bool m5::unit::UnitThermal2::readFirmwareVersion ( uint16_t & ver)

Read the firmware version.

Parameters
[out]verVersion high:major low:minor
Returns
True if successful

◆ readFunctionControl()

bool m5::unit::UnitThermal2::readFunctionControl ( uint8_t & value)

Read the function control.

Parameters
[out]valueFunction control value
Returns
True if successful
Note
bit0: buzzer enable. / bit1: neopixel enable. / bit2: auto refresh enable

◆ readI2CAddress()

bool m5::unit::UnitThermal2::readI2CAddress ( uint8_t & i2c_address)

Read device I2C address.

Parameters
[out]i2c_addressI2C address
Returns
True if successful

◆ readLED()

bool m5::unit::UnitThermal2::readLED ( uint32_t & rgb)

Read the LED color.

Parameters
[out]rgbRGB24 color
Returns
True if successful

◆ readNoiseFilterLevel()

bool m5::unit::UnitThermal2::readNoiseFilterLevel ( uint8_t & level)

Read the noise filter level.

Parameters
[out]levelFilter level
Returns
True if successful
Note
0:off - 15:maximum

◆ readRefreshRate()

bool m5::unit::UnitThermal2::readRefreshRate ( thermal2::Refresh & rate)

Read the refresh rate.

Parameters
[out]rateRefresh rate
Returns
True if successful

◆ readTemeratureMonitorSize()

bool m5::unit::UnitThermal2::readTemeratureMonitorSize ( uint8_t & wid,
uint8_t & hgt )
inline
Deprecated
Use readTemperatureMonitorSize instead

◆ readTemperatureMonitorSize()

bool m5::unit::UnitThermal2::readTemperatureMonitorSize ( uint8_t & wid,
uint8_t & hgt )

Read the temperature monitor size.

Parameters
[out]widWidth (0-15)
[out]hgtHeight (0-11)
Returns
True if successful

◆ startPeriodicMeasurement()

bool m5::unit::UnitThermal2::startPeriodicMeasurement ( const thermal2::Refresh rate)
inline

Start periodic measurement.

Parameters
rateRefresh rate
Returns
True if successful

◆ stopPeriodicMeasurement()

bool m5::unit::UnitThermal2::stopPeriodicMeasurement ( )
inline

Stop periodic measurement.

Returns
True if successful

◆ wasClicked()

bool m5::unit::UnitThermal2::wasClicked ( ) const
inline

Was button clicked?

Returns
True if clicked
Note
The state is managed by update

◆ wasHold()

bool m5::unit::UnitThermal2::wasHold ( ) const
inline

Was button hold?

Returns
True if hold
Note
The state is managed by update

◆ wasPressed()

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

Was button pressed?

Returns
True if pressed
Note
The state is managed by update

◆ wasReleased()

bool m5::unit::UnitThermal2::wasReleased ( ) const
inline

Was button released?

Returns
True if released
Note
The state is managed by update

◆ writeAlarmBuzzer()

bool m5::unit::UnitThermal2::writeAlarmBuzzer ( const bool highlow,
const uint16_t freq,
const uint8_t interval )

Write the alarm buzzer settings.

Parameters
highlowTarget False:low True:high
freqFrequency
intervalInterval (10ms)
Returns
True if successful
Note
The interval valid range between 5 and 255 (50ms - 2550ms)

◆ writeAlarmEnabled()

bool m5::unit::UnitThermal2::writeAlarmEnabled ( const uint8_t enabled_bits)

Read the alarm control.

Parameters
[out]enabled_bitsEnabled temperature alarm bits
Returns
True if successful

◆ writeAlarmLED() [1/2]

bool m5::unit::UnitThermal2::writeAlarmLED ( const bool highlow,
const uint32_t rgb )
inline

Write the alarm LED color.

Parameters
highlowTarget False:low True:high
rgbRGB24 color
Returns
True if successful

◆ writeAlarmLED() [2/2]

bool m5::unit::UnitThermal2::writeAlarmLED ( const bool highlow,
const uint8_t r,
const uint8_t g,
const uint8_t b )

Write the alarm LED color.

Parameters
highlowTarget False:low True:high
rRed
gGreen
bBlue
Returns
True if successful

◆ writeAlarmTemperature() [1/2]

template<typename T , typename std::enable_if< std::is_floating_point< T >::value, std::nullptr_t >::type = nullptr>
bool m5::unit::UnitThermal2::writeAlarmTemperature ( const bool highlow,
const T celsius )
inline

Write the alarm temperature threshold.

Parameters
highlowTarget False:low True:high
celsiusTemperature
Returns
True if successful

◆ writeAlarmTemperature() [2/2]

bool m5::unit::UnitThermal2::writeAlarmTemperature ( const bool highlow,
const uint16_t raw )

Write the alarm temperature threshold.

Parameters
highlowTarget False:low True:high
rawTemperature (raw)
Returns
True if successful
Note
Temperature value conversion formula: (celsius + 64) * 128 = value.
0x0000:-64.0f - 0xFFFF:+447.99f

◆ writeBuzzer()

bool m5::unit::UnitThermal2::writeBuzzer ( const uint16_t freq,
const uint8_t duty,
const bool verify = true )

Write the buzzer settings.

Parameters
freqFrequency
dutyDuty 0 - 255
verifyVerify the value is written if true (it is not reflected immediately)
Returns
True if successful
Note
buzzer duty. 0~255 (default:128 : The loudest sound setting; the further away from 128, the quieter the sound)

◆ writeBuzzerControl()

bool m5::unit::UnitThermal2::writeBuzzerControl ( const bool enabled)
inline

Write the Buzzer control.

Parameters
enabledTrue:enabled False: disabled
Returns
True if successful

◆ writeBuzzerDuty()

bool m5::unit::UnitThermal2::writeBuzzerDuty ( const uint8_t duty)

Write the buzzer duty settings.

Parameters
dutyDuty 0 - 255
Returns
True if successful
Note
buzzer duty. 0~255 (default:128 : The loudest sound setting; the further away from 128, the quieter the sound)

◆ writeFunctionControl()

bool m5::unit::UnitThermal2::writeFunctionControl ( const uint8_t value,
const bool verify = true )

Write the function control.

Parameters
valueFunction control value
verifyVerify the value is written if true (it is not reflected immediately)
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeLED() [1/2]

bool m5::unit::UnitThermal2::writeLED ( const uint32_t rgb,
const bool verify = true )
inline

Write the LED color.

Parameters
rgbRGB24 color
verifyVerify the value is written if true (it is not reflected immediately)
Returns
True if successful

◆ writeLED() [2/2]

bool m5::unit::UnitThermal2::writeLED ( const uint8_t r,
const uint8_t g,
const uint8_t b,
const bool verify = true )

Write the LED color.

Parameters
rRed
gGreen
bBlue
verifyVerify the value is written if true (it is not reflected immediately)
Returns
True if successful

◆ writeNoiseFilterLevel()

bool m5::unit::UnitThermal2::writeNoiseFilterLevel ( const uint8_t level)

Write the noise filter level.

Parameters
levelFilter level
Returns
True if successful
Note
0:off - 15:maximum

◆ writeRefreshRate()

bool m5::unit::UnitThermal2::writeRefreshRate ( const thermal2::Refresh rate)

Write the refresh rate.

Parameters
rateRefresh rate
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeTemeratureMonitorSize()

bool m5::unit::UnitThermal2::writeTemeratureMonitorSize ( const uint8_t wid,
const uint8_t hgt )
inline
Deprecated
Use writeTemperatureMonitorSize instead

◆ writeTemperatureMonitorSize()

bool m5::unit::UnitThermal2::writeTemperatureMonitorSize ( const uint8_t wid,
const uint8_t hgt )

Write the temperature monitor size.

Parameters
widWidth (0-15)
hgtHeight (0-11)
Returns
True if successful