Skip to content

examples: Replace test scripts with practical examples for wsen-hids. #187

@nedseb

Description

@nedseb

Description

The wsen-hids examples contained full_test.py (482 lines of PASS/FAIL assertions) which was a test suite, not a usage example. The other two examples (continuous_mode.py, one_shot_mode.py) were OK.

Previous state

File Type Lines
continuous_mode.py Practical example OK — kept
one_shot_mode.py Practical example OK — kept
full_test.py Test suite (PASS/FAIL) 482 — removed

What was done (PR #239)

  1. Removed full_test.py — replaced by tests/scenarios/wsen_hids.yaml for CI test coverage
  2. Added 6 practical examples focused on real-world applications and hardware features
  3. Updated README.md with a table listing all 8 examples

Final example set

Example Description Notes
one_shot_mode.py One-shot measurement on demand Existed before
continuous_mode.py Continuous mode with periodic reads Existed before
humidity_temperature.py Single read (beginner-friendly first example) New
comfort_monitor.py Comfort indicator (Dry/Comfortable/Humid) every 2 s New
data_logger.py CSV logging to DAPLink flash + serial. Erasure opt-in via flag New — reviewed: ERASE_FLASH_ON_START = False
dew_point.py Dew point calculation using Magnus formula New — reviewed: humidity clamped to avoid log(0)
heater_demo.py Built-in heater demo: compare readings before/after New
low_power_sampling.py One-shot every 10 s with power_off() between reads New — requires firmware >= v0.1.0 (#238)

Review notes

  • data_logger.py: clear_flash() made opt-in instead of unconditional (destructive operation)
  • low_power_sampling.py: depends on wsen_hids: one-shot measurement timeout after power cycle #238 fix for power_off()/power_on() cycle
  • dew_point.py: max(humidity, 0.01) clamp to prevent log(0) domain error
  • All test cases from full_test.py were verified to be covered in tests/scenarios/wsen_hids.yaml

Reference

  • Driver code: lib/wsen-hids/wsen_hids/device.py
  • Key methods: temperature(), humidity(), set_continuous(), power_off(), enable_heater(), read_one_shot(), trigger_one_shot()

Checklist

  • full_test.py removed from examples
  • 6 new practical examples added
  • Verify that all test cases from the removed test file(s) are covered in tests/scenarios/
  • ruff check passes
  • README updated with example table
  • Review feedback addressed (data_logger flag, low_power firmware ref, dew_point clamp)

Metadata

Metadata

Labels

documentationImprovements or additions to documentationreleased

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