Commit febcd1fa authored by Rahix's avatar Rahix
Browse files

fix(bhi160-app): Only open the currently displayed sensor

Don't open all 4 virtual sensors all time time; only open the one which
is actually displayed.  This prevents the storm of queue-full message on
the serial terminal.

Signed-off-by: Rahix's avatarRahix <>
parent 23b4a9ed
......@@ -14,19 +14,23 @@ STATUS_COLORS = [
with contextlib.ExitStack() as cx:
disp = cx.enter_context(
def sensors(**args):
while True:
with bhi160.BHI160Orientation(**args) as s:
yield s, "Orientation"
with bhi160.BHI160Accelerometer(**args) as s:
yield s, "Accel"
with bhi160.BHI160Gyroscope(**args) as s:
yield s, "Gyro"
with bhi160.BHI160Magnetometer(**args) as s:
yield s, "Magnetic"
with as disp:
args = {"sample_rate": 10, "sample_buffer_len": 20}
sensor_iter = itertools.cycle(
(cx.enter_context(bhi160.BHI160Orientation(**args)), "Orientation"),
(cx.enter_context(bhi160.BHI160Accelerometer(**args)), "Accel"),
(cx.enter_context(bhi160.BHI160Gyroscope(**args)), "Gyro"),
(cx.enter_context(bhi160.BHI160Magnetometer(**args)), "Magnetic"),
sensor_iter = sensors(**args)
sensor, sensor_name = next(sensor_iter)
for ev in simple_menu.button_events(timeout=0.1):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment