From 19f68971f26aedff743752fdbf1352de340c5021 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Sat, 26 Feb 2022 19:26:54 -0800 Subject: [PATCH] Move python-specific imports into a guard. --- chime/sensor.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/chime/sensor.py b/chime/sensor.py index b74d668..61d8408 100644 --- a/chime/sensor.py +++ b/chime/sensor.py @@ -1,14 +1,21 @@ import datetime - -import board -import busio import json -import adafruit_ms8607 as ms8607 +import platform from time import sleep DELAY = 0.1 +def is_raspberry_pi() -> bool: + return platform.machine() in ("armv7l", "armv6l") + + +if is_raspberry_pi(): + import board + import busio + import adafruit_ms8607 as ms8607 + + class Reading: def __init__(self, t, p, h, normal=False): if not normal: