M5Unit-INFRARED 0.1.0 git rev:aed3018
Loading...
Searching...
No Matches
m5::unit::UnitSTHS34PF80 Class Reference

STHS34PF80 unit. More...

#include <unit_STHS34PF80.hpp>

Inheritance diagram for m5::unit::UnitSTHS34PF80:

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitSTHS34PF80 (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
virtual void update (const bool force=false) override
 
bool softReset ()
 Software reset.
 
Settings for begin
config_t config ()
 Gets the configration.
 
void config (const config_t &cfg)
 Set the configration.
 
Properties
uint16_t sensitivity () const
 Gets the inner sensitivity.
 
Measurement data by periodic
int16_t object () const
 Oldest TOBJECT.
 
float objectTemperature () const
 Oldest object temperature.
 
int16_t ambient () const
 Oldest TAMBIENT.
 
float ambientTemperature () const
 Oldest ambient temperature.
 
int16_t compensated_object () const
 Oldest TOBJ_COMP.
 
float compensatedObjectTemperature () const
 Oldest compensated object temperature.
 
int16_t presence () const
 Oldest TPRESENCE.
 
int16_t motion () const
 Oldest TMOTION.
 
int16_t ambient_shock () const
 Oldest TAMB_SHOCK.
 
bool isPresence () const
 Oldest presence detefction.
 
bool isMotion () const
 Oldest motion detefction.
 
bool isAmbientShock () const
 Oldest ambient shock detefction.
 
Periodic measurement
bool startPeriodicMeasurement (const sths34pf80::Gain mode, const sths34pf80::ODR odr, const bool comp_type=true, const bool abs=false)
 Start periodic measurement.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
Single shot measurement
bool measureSingleshot (sths34pf80::Data &data, const sths34pf80::AmbientTemperatureAverage avg_t, const sths34pf80::ObjectTemperatureAverage avg_tmos)
 Measurement single shot.
 
Settings
bool readAverageTrim (sths34pf80::AmbientTemperatureAverage &avg_t, sths34pf80::ObjectTemperatureAverage &avg_tmos)
 Read the avarage trim.
 
bool writeAverageTrim (const sths34pf80::AmbientTemperatureAverage avg_t, const sths34pf80::ObjectTemperatureAverage avg_tmos)
 Write the avarage trim.
 
bool readGainMode (sths34pf80::Gain &mode)
 Read the gain mode.
 
bool writeGainMode (const sths34pf80::Gain mode)
 Write the gain mode.
 
bool readSensitivityRaw (int8_t &raw)
 Read the raw sensitivity.
 
bool readSensitivity (uint16_t &value)
 Read the raw sensitivity.
 
bool writeSensitivityRaw (const int8_t raw)
 Write the raw sensitivity.
 
bool writeSensitivity (const uint16_t value)
 Write the sensitivity.
 
bool readObjectDataRate (sths34pf80::ODR &odr)
 Read the ODR.
 
Algorithm settings
Warning
Call to resetAlgorithm() is required to apply the value
bool resetAlgorithm ()
 Reset the algorithm.
 
bool readLowPassFilter (sths34pf80::LowPassFilter &lpf_p_m, sths34pf80::LowPassFilter &lpf_m, sths34pf80::LowPassFilter &lpf_p, sths34pf80::LowPassFilter &lpf_a_t)
 Read the low pass filter.
 
bool writeLowPassFilter (const sths34pf80::LowPassFilter lpf_p_m, const sths34pf80::LowPassFilter lpf_m, const sths34pf80::LowPassFilter lpf_p, const sths34pf80::LowPassFilter lpf_a)
 Write the low pass filter.
 
bool readPresenceThreshold (uint16_t &thres)
 Read the threshold for presence detection.
 
bool writePresenceThreshold (const uint16_t thres)
 Write the threshold for presence detection.
 
bool readMotionThreshold (uint16_t &thres)
 Read the threshold for motion detection.
 
bool writeMotionThreshold (const uint16_t thres)
 Write the threshold for motion detection.
 
bool readAmbientShockThreshold (uint16_t &thres)
 Read the threshold for ambient shock detection.
 
bool writeAmbientShockThreshold (const uint16_t thres)
 Write the threshold for ambient shock detection.
 
bool readPresenceHysteresis (uint8_t &hyst)
 Read the hysteresis for presence detection.
 
bool writePresenceHysteresis (const uint8_t hyst)
 Write the hysteresis for presence detection.
 
bool readMotionHysteresis (uint8_t &hyst)
 Read the hysteresis for motion detection.
 
bool writeMotionHysteresis (const uint8_t hyst)
 Write the hysteresis for motion detection.
 
bool readAmbientShockHysteresis (uint8_t &hyst)
 Read the hysteresis for ambient shock detection.
 
bool writeAmbientShockHysteresis (const uint8_t hyst)
 Write the hysteresis for ambient shock detection.
 
bool readAlgorithmConfig (uint8_t &v)
 Read the algorithm configuration.
 

Static Public Member Functions

static sths34pf80::ODR maximum_odr (const sths34pf80::ObjectTemperatureAverage avg_tmos)
 Get the maximum ODR value that can be set.
 

Protected Member Functions

bool read_embedded_register (const uint8_t ereg, uint8_t *rbuf, const uint32_t len)
 
bool write_embedded_register (const uint8_t ereg, const uint8_t *buf, const uint32_t len)
 
bool read_embedded_register8 (const uint8_t ereg, uint8_t &v)
 
bool write_embedded_register8 (const uint8_t ereg, const uint8_t v)
 
bool read_embedded_register16LE (const uint8_t ereg, uint16_t &v)
 
bool write_embedded_register16LE (const uint8_t ereg, const uint16_t v)
 
bool start_periodic_measurement ()
 
bool start_periodic_measurement (const sths34pf80::Gain mode, const sths34pf80::ODR odr, const bool comp_type, const bool abs)
 
bool stop_periodic_measurement ()
 
bool write_odr (const sths34pf80::ODR odr)
 
bool write_algorithm_config (const uint8_t v)
 
bool is_data_ready ()
 
bool read_measurement (sths34pf80::Data &d, const bool full=true)
 
bool guard_in_periodic (const char *fname)
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitSTHS34PF80, sths34pf80::Data)
 

Detailed Description

STHS34PF80 unit.

Member Function Documentation

◆ measureSingleshot()

bool m5::unit::UnitSTHS34PF80::measureSingleshot ( sths34pf80::Data & data,
const sths34pf80::AmbientTemperatureAverage avg_t,
const sths34pf80::ObjectTemperatureAverage avg_tmos )

Measurement single shot.

Parameters
[out]dataMeasuerd data
avg_tThe number of averaged samples for ambient temperature
avg_tmosThe number of averaged samples for object temperature
Returns
True if successful
Note
Using current SENS_DATA Only TOBJECT, TAMBIENT, and TOBJ_COMP are valid data for single-shot measurement Blocked until measurement ends or timeout occurs Measurement time depends on avg_tmos
Warning
During periodic detection runs, an error is returned

◆ readAlgorithmConfig()

bool m5::unit::UnitSTHS34PF80::readAlgorithmConfig ( uint8_t & v)

Read the algorithm configuration.

Parameters
[out]vValue
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ readAmbientShockHysteresis()

bool m5::unit::UnitSTHS34PF80::readAmbientShockHysteresis ( uint8_t & hyst)

Read the hysteresis for ambient shock detection.

Parameters
[out]hystHysteresis
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ readAmbientShockThreshold()

bool m5::unit::UnitSTHS34PF80::readAmbientShockThreshold ( uint16_t & thres)

Read the threshold for ambient shock detection.

Parameters
[out]thresThreshold
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ readAverageTrim()

bool m5::unit::UnitSTHS34PF80::readAverageTrim ( sths34pf80::AmbientTemperatureAverage & avg_t,
sths34pf80::ObjectTemperatureAverage & avg_tmos )

Read the avarage trim.

Parameters
[out]avg_tThe number of averaged samples for ambient temperature
[out]avg_tmosThe number of averaged samples for object temperature
Returns
True if successful

◆ readGainMode()

bool m5::unit::UnitSTHS34PF80::readGainMode ( sths34pf80::Gain & mode)

Read the gain mode.

Parameters
[out]modeGain
Returns
True if successful

◆ readLowPassFilter()

bool m5::unit::UnitSTHS34PF80::readLowPassFilter ( sths34pf80::LowPassFilter & lpf_p_m,
sths34pf80::LowPassFilter & lpf_m,
sths34pf80::LowPassFilter & lpf_p,
sths34pf80::LowPassFilter & lpf_a_t )

Read the low pass filter.

Parameters
[out]lp_p_mFor presence and motion detection
[out]lpf_mFor motion detection
[out]lpf_pFor presence detection
[out]lpf_a_tFor ambient temperature shock detection
Returns
True if successful

◆ readMotionHysteresis()

bool m5::unit::UnitSTHS34PF80::readMotionHysteresis ( uint8_t & hyst)

Read the hysteresis for motion detection.

Parameters
[out]hystHysteresis
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ readMotionThreshold()

bool m5::unit::UnitSTHS34PF80::readMotionThreshold ( uint16_t & thres)

Read the threshold for motion detection.

Parameters
[out]thresThreshold
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ readObjectDataRate()

bool m5::unit::UnitSTHS34PF80::readObjectDataRate ( sths34pf80::ODR & odr)

Read the ODR.

Parameters
odrODR
Returns
True if successful

◆ readPresenceHysteresis()

bool m5::unit::UnitSTHS34PF80::readPresenceHysteresis ( uint8_t & hyst)

Read the hysteresis for presence detection.

Parameters
[out]hystHysteresis
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ readPresenceThreshold()

bool m5::unit::UnitSTHS34PF80::readPresenceThreshold ( uint16_t & thres)

Read the threshold for presence detection.

Parameters
[out]thresThreshold
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ readSensitivity()

bool m5::unit::UnitSTHS34PF80::readSensitivity ( uint16_t & value)

Read the raw sensitivity.

Parameters
[out]valueSensitivity
Returns
True if successful

◆ readSensitivityRaw()

bool m5::unit::UnitSTHS34PF80::readSensitivityRaw ( int8_t & raw)

Read the raw sensitivity.

Parameters
[out]rawRaw value
Returns
True if successful

◆ resetAlgorithm()

bool m5::unit::UnitSTHS34PF80::resetAlgorithm ( )

Reset the algorithm.

Apply each value to the embedded linear algorithm for compensate for ambient temperature variations in the object temperature

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

◆ startPeriodicMeasurement()

bool m5::unit::UnitSTHS34PF80::startPeriodicMeasurement ( const sths34pf80::Gain mode,
const sths34pf80::ODR odr,
const bool comp_type = true,
const bool abs = false )
inline

Start periodic measurement.

Parameters
modeGain mode
odrObject data rate
comp_typeEnables the embedded linear algorithm if true (Valid only in default gain mode)
absSelects the absolute value in the presence detection algorithm if true
Returns
True if successful
Note
Object data rate maximum configurable value depends on AVG_TMOS
ObjectTemperatureAverage(AVG_TMOS) Maximum ODR
Samples2 ODR30
Samples8 ODR30
Samples32 ODR30
Samples128 ODR8
Samples256 ODR4
Samples512 ODR2
Samples1024 ODR1
Samples2048 ODR0_5

◆ stopPeriodicMeasurement()

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

Stop periodic measurement.

To be PowerDown mode

Returns
True if successful

◆ writeAmbientShockHysteresis()

bool m5::unit::UnitSTHS34PF80::writeAmbientShockHysteresis ( const uint8_t hyst)

Write the hysteresis for ambient shock detection.

Parameters
[out]hystHysteresis
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeAmbientShockThreshold()

bool m5::unit::UnitSTHS34PF80::writeAmbientShockThreshold ( const uint16_t thres)

Write the threshold for ambient shock detection.

Parameters
[out]thresThreshold
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeAverageTrim()

bool m5::unit::UnitSTHS34PF80::writeAverageTrim ( const sths34pf80::AmbientTemperatureAverage avg_t,
const sths34pf80::ObjectTemperatureAverage avg_tmos )

Write the avarage trim.

Parameters
avg_tThe number of averaged samples for ambient temperature
avg_tmosThe number of averaged samples for object temperature
Returns
True if successful
Note
The maximum ODR that can be set varies depending on avg_trim value
Warning
During periodic detection runs, an error is returned

◆ writeGainMode()

bool m5::unit::UnitSTHS34PF80::writeGainMode ( const sths34pf80::Gain mode)

Write the gain mode.

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

◆ writeLowPassFilter()

bool m5::unit::UnitSTHS34PF80::writeLowPassFilter ( const sths34pf80::LowPassFilter lpf_p_m,
const sths34pf80::LowPassFilter lpf_m,
const sths34pf80::LowPassFilter lpf_p,
const sths34pf80::LowPassFilter lpf_a )

Write the low pass filter.

Parameters
lp_p_mFor presence and motion detection
lpf_mFor motion detection
lpf_pFor presence detection
lpf_a_tFor ambient temperature shock detection
Returns
True if successful
Warning
The value of ODR/n for lpf_p_m must be greater than the value of ODR/n for lpf_m and lpf_p
During periodic detection runs, an error is returned

◆ writeMotionHysteresis()

bool m5::unit::UnitSTHS34PF80::writeMotionHysteresis ( const uint8_t hyst)

Write the hysteresis for motion detection.

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

◆ writeMotionThreshold()

bool m5::unit::UnitSTHS34PF80::writeMotionThreshold ( const uint16_t thres)

Write the threshold for motion detection.

Parameters
thresThreshold (15 bits)
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writePresenceHysteresis()

bool m5::unit::UnitSTHS34PF80::writePresenceHysteresis ( const uint8_t hyst)

Write the hysteresis for presence detection.

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

◆ writePresenceThreshold()

bool m5::unit::UnitSTHS34PF80::writePresenceThreshold ( const uint16_t thres)

Write the threshold for presence detection.

Parameters
thresThreshold (15 bits)
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeSensitivity()

bool m5::unit::UnitSTHS34PF80::writeSensitivity ( const uint16_t value)

Write the sensitivity.

Parameters
valueSensitivity (0 - 4080)
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeSensitivityRaw()

bool m5::unit::UnitSTHS34PF80::writeSensitivityRaw ( const int8_t raw)

Write the raw sensitivity.

Parameters
rawRaw value
Returns
True if successful
Warning
During periodic detection runs, an error is returned