task_ultrasonic module

task_ultrasonic.py

Cooperative scheduler task that wraps the UltrasonicSensor driver. On startup a 3-sample moving-average filter is enabled. Each scheduler tick calls sensor.loop() to advance the non-blocking measurement state machine, then publishes the latest distance (or 0 if no reading is available) to a shared variable.

class task_ultrasonic.task_ultrasonic(sensor, distanceShare)[source]

Bases: object

Scheduler task that continuously updates the ultrasonic distance measurement and publishes the result to a share.

run()[source]

Cooperative function for scheduler