diff options
| author | D Delmar Davis <don@suspectdevices.com> | 2026-04-18 20:50:23 -0700 |
|---|---|---|
| committer | D Delmar Davis <don@suspectdevices.com> | 2026-04-18 20:50:23 -0700 |
| commit | e9a2d2bea83688a0b7ad3516d5c119b7e5a5cec1 (patch) | |
| tree | b7d29f89865b911f9fd357b50e9ad7d3b45ca100 | |
| parent | 4c315c56a679bef99f722b3e6092219af7cd3cdb (diff) | |
Display temps on rainbowhat
| -rwxr-xr-x | bin/timetemp.py | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/bin/timetemp.py b/bin/timetemp.py index 7b8de40..03f147b 100755 --- a/bin/timetemp.py +++ b/bin/timetemp.py @@ -22,26 +22,48 @@ except FileNotFoundError: print("'Rainbow HAT'?" + str(hat_is_a_rainbow_hat) ) -from adafruit_ht16k33 import segments # type: ignore - -# Create the I2C interface. -i2c = busio.I2C(board.SCL, board.SDA) - -# Create the LED segment class. -# This creates a 7 segment 4 character display: -display = segments.Seg7x4(i2c) - -# Clear the display. -display.fill(0) -while True: - display.print(time.strftime("%H:%M")) - time.sleep(5) - file=open('/var/lib/prometheus/node-exporter/temp.prom') - display.colon = False - for line in file.readlines(): - values=line.split()[0:2] - if values[0]=='home_temperature_farenheit': - display.print(str(values[1])[0:4]+'f') - file.close() - time.sleep(5) +if hat_is_a_rainbow_hat: + import rainbowhat as rh + + while True: + rh.display.print_str(time.strftime("%H%M")) + rh.display.show() + # display.print(time.strftime("%H:%M")) + time.sleep(5) + file=open('/var/lib/prometheus/node-exporter/temp.prom') + # display.colon = False + for line in file.readlines(): + values=line.split()[0:2] + if values[0]=='home_temperature_farenheit': + rh.display.print_str(str(values[1])[0:3]+'f') + rh.display.show() + # display.print(str(values[1])[0:3]+'f') + file.close() + time.sleep(5) + + +else: + from adafruit_ht16k33 import segments # type: ignore + + # Create the I2C interface. + i2c = busio.I2C(board.SCL, board.SDA) + + # Create the LED segment class. + # This creates a 7 segment 4 character display: + display = segments.Seg7x4(i2c) + + # Clear the display. + display.fill(0) + while True: + display.print(time.strftime("%H:%M")) + time.sleep(5) + file=open('/var/lib/prometheus/node-exporter/temp.prom') + display.colon = False + for line in file.readlines(): + values=line.split()[0:2] + if values[0]=='home_temperature_farenheit': + display.print(str(values[1])[0:4]+'f') + file.close() + time.sleep(5) + |
