Skip to content

lis2mdl: Auto-trigger single conversion in idle mode. #70

@nedseb

Description

@nedseb

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdriverConcerne un driver spécifiqueenhancementNew feature or requestreleased

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions