diff options
| author | D Delmar Davis <don@suspectdevices.com> | 2026-04-18 20:15:32 -0700 |
|---|---|---|
| committer | D Delmar Davis <don@suspectdevices.com> | 2026-04-18 20:15:32 -0700 |
| commit | 4c315c56a679bef99f722b3e6092219af7cd3cdb (patch) | |
| tree | adbfe21e0ecd29ff066f5622e957756f854d975f /bin/timetemp.py | |
| parent | 4dfe41eaaeb917340d938d3456027fc14ba5290a (diff) | |
detect rainbow hat
Diffstat (limited to 'bin/timetemp.py')
| -rwxr-xr-x | bin/timetemp.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/bin/timetemp.py b/bin/timetemp.py index 4063411..7b8de40 100755 --- a/bin/timetemp.py +++ b/bin/timetemp.py @@ -5,6 +5,23 @@ import time import board # type: ignore import busio # type: ignore + +hat_id_file_path = "/proc/device-tree/hat/product" +hat_is_a_rainbow_hat = False + +try: + file=open(hat_id_file_path, "r") + content = "" + for line in file.readlines(): + content += line + print(content) + if ('Rainbow HAT' in content): + hat_is_a_rainbow_hat = True +except FileNotFoundError: + print("The file was not found. Please check the path.") + +print("'Rainbow HAT'?" + str(hat_is_a_rainbow_hat) ) + from adafruit_ht16k33 import segments # type: ignore # Create the I2C interface. @@ -27,4 +44,4 @@ while True: display.print(str(values[1])[0:4]+'f') file.close() time.sleep(5) -
\ No newline at end of file + |
