Sub-issue of #44.
Problem
read_magnet(), read_magnet_uT(), read_temperature_c() and all other read methods read data registers directly without checking if the sensor is in idle mode. The init sets the sensor to continuous mode, but if the user calls power_down() then read_magnet(), stale data is returned.
Solution
Add the _ensure_data() pattern (same as WSEN-PADS, WSEN-HIDS, HTS221):
_is_idle() already exists (checks MD1..0 == 11 in CFG_REG_A)
- Add
trigger_single(): set mode to "single" (MD=01), wait for data ready
- Add
_ensure_data(): if idle, trigger single conversion before reading
- Call
_ensure_data() in read_magnet(), read_temperature_c(), etc.
- Add necessary constants to
const.py if missing
Reference
Sub-issue of #44.
Problem
read_magnet(),read_magnet_uT(),read_temperature_c()and all other read methods read data registers directly without checking if the sensor is in idle mode. The init sets the sensor to continuous mode, but if the user callspower_down()thenread_magnet(), stale data is returned.Solution
Add the
_ensure_data()pattern (same as WSEN-PADS, WSEN-HIDS, HTS221):_is_idle()already exists (checks MD1..0 == 11 in CFG_REG_A)trigger_single(): set mode to "single" (MD=01), wait for data ready_ensure_data(): if idle, trigger single conversion before reading_ensure_data()inread_magnet(),read_temperature_c(), etc.const.pyif missingReference
_ensure_data()pattern (PR wsen-pads: Add pressure sensor driver. #3)