|
M5Unit-LIGHT 0.0.2 git rev:6d734f0
|
Digital ambient light sensor. More...
#include <unit_BH1750FVI.hpp>
Classes | |
| struct | config_t |
| Settings for begin. More... | |
Public Member Functions | |
| UnitBH1750FVI (const uint8_t addr=DEFAULT_ADDRESS) | |
| Constructor. | |
| virtual | ~UnitBH1750FVI () |
| Destructor. | |
| virtual bool | begin () override |
| Begin the unit. | |
| virtual void | update (const bool force=false) override |
| Update the unit. | |
Settings for begin | |
| config_t | config () const |
| Gets the configuration. | |
| void | config (const config_t &cfg) |
| Set the configuration. | |
Measurement data by periodic | |
| float | lux () const |
| Latest illuminance (lx) | |
| uint16_t | raw () const |
| Latest raw value. | |
| bh1750fvi::Resolution | resolution () const |
| Resolution currently in effect. | |
| uint8_t | mtreg () const |
| MTreg currently in effect. | |
Periodic measurement | |
| bool | startPeriodicMeasurement () |
| Start periodic measurement in the current settings. | |
| bool | startPeriodicMeasurement (const bh1750fvi::Resolution resolution, const uint8_t mtreg) |
| Start periodic measurement. | |
| bool | stopPeriodicMeasurement () |
| Stop periodic measurement. | |
Single shot measurement | |
| bool | measureSingleShot (bh1750fvi::Data &data, const bh1750fvi::Resolution resolution=bh1750fvi::Resolution::High, const uint8_t mtreg=bh1750fvi::MTREG_DEFAULT) |
| Measure single-shot. | |
MTreg (sensitivity) control | |
| bool | writeMTreg (const uint8_t mtreg) |
| Write MTreg as raw value (31..254) | |
| bool | writeSensitivityFactor (const float factor) |
| Write MTreg as sensitivity factor (0.45..3.68) | |
| uint8_t | readMTreg () const |
| Gets the current MTreg cache. | |
Power management | |
| bool | powerOn () |
| Write POWER_ON opcode. | |
| bool | powerDown () |
| Write POWER_DOWN opcode. | |
| bool | softReset () |
| Write RESET opcode (clears data register; requires POWER_ON state) | |
Static Public Attributes | |
| static constexpr uint8_t | ALT_ADDRESS {0x5C} |
| Alternate I2C address when ADDR pin is tied high. | |
Protected Member Functions | |
| bool | start_periodic_measurement () |
| bool | start_periodic_measurement (const bh1750fvi::Resolution resolution, const uint8_t mtreg) |
| bool | stop_periodic_measurement () |
| bool | read_measurement (bh1750fvi::Data &data) |
| bool | write_opcode (const uint8_t opcode) |
| bool | write_mtreg_opcodes (const uint8_t mtreg) |
| uint8_t | opcode_for (const bh1750fvi::Mode mode, const bh1750fvi::Resolution resolution) const |
| void | apply_interval (const bh1750fvi::Resolution resolution, const uint8_t mtreg) |
| M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitBH1750FVI, bh1750fvi::Data) | |
Protected Attributes | |
| std::unique_ptr< m5::container::CircularBuffer< bh1750fvi::Data > > | _data {} |
| config_t | _cfg {} |
| bh1750fvi::Resolution | _resolution {bh1750fvi::Resolution::High} |
| uint8_t | _mtreg {bh1750fvi::MTREG_DEFAULT} |
Digital ambient light sensor.
Shared between UnitDLight (SKU:U136) and HatDLight (SKU:U134).
|
inlineexplicit |
Constructor.
| addr | I2C address |
|
overridevirtual |
Begin the unit.
|
inline |
Gets the configuration.
|
inline |
Set the configuration.
| cfg | Configuration to apply |
|
inline |
Latest illuminance (lx)
| bool m5::unit::UnitBH1750FVI::measureSingleShot | ( | bh1750fvi::Data & | data, |
| const bh1750fvi::Resolution | resolution = bh1750fvi::Resolution::High, | ||
| const uint8_t | mtreg = bh1750fvi::MTREG_DEFAULT ) |
Measure single-shot.
| [out] | data | Measured data |
| resolution | Resolution to use (default: High) | |
| mtreg | MTreg value (default: 69) |
|
inline |
MTreg currently in effect.
| bool m5::unit::UnitBH1750FVI::powerDown | ( | ) |
Write POWER_DOWN opcode.
| bool m5::unit::UnitBH1750FVI::powerOn | ( | ) |
Write POWER_ON opcode.
|
inline |
Latest raw value.
|
inline |
Gets the current MTreg cache.
|
inline |
Resolution currently in effect.
| bool m5::unit::UnitBH1750FVI::softReset | ( | ) |
Write RESET opcode (clears data register; requires POWER_ON state)
|
inline |
Start periodic measurement in the current settings.
|
inline |
Start periodic measurement.
| resolution | Resolution |
| mtreg | MTreg value (31..254) |
|
inline |
Stop periodic measurement.
|
overridevirtual |
Update the unit.
| force | If true, force a read regardless of the interval |
| bool m5::unit::UnitBH1750FVI::writeMTreg | ( | const uint8_t | mtreg | ) |
Write MTreg as raw value (31..254)
| mtreg | MTreg |
| bool m5::unit::UnitBH1750FVI::writeSensitivityFactor | ( | const float | factor | ) |
Write MTreg as sensitivity factor (0.45..3.68)
| factor | Sensitivity factor (1.0 corresponds to mtreg=69) |