diff --git a/wetter_gui.py b/wetter_gui.py index ec36d0d..e69ed58 100755 --- a/wetter_gui.py +++ b/wetter_gui.py @@ -10,14 +10,17 @@ from board import SCK, MOSI, MISO, D8, D24, D23, D18 from adafruit_rgb_display import color565 import adafruit_rgb_display.ili9341 as ili9341 -from raspyrfm import * -import sensors -from sensors import rawsensor +#from raspyrfm import * +#import sensors +#from sensors import rawsensor import sys import threading from PIL import Image, ImageDraw, ImageFont, ImageColor +import requests + + class TextBox: def __init__(self, pos, size, max_jitter, color, background, fitting_text): self.color = color @@ -91,22 +94,22 @@ backlight.direction = digitalio.Direction.OUTPUT backlight.value = True -if raspyrfm_test(5, RFM69): - print("Found RaspyRFM mod") - rfm = RaspyRFM(5, RFM69) #when using the RaspyRFM twin -else: - print("No RFM69 module found!") - exit() +#if raspyrfm_test(5, RFM69): +# print("Found RaspyRFM mod") +# rfm = RaspyRFM(5, RFM69) #when using the RaspyRFM twin +#else: +# print("No RFM69 module found!") +# exit() -rfm.set_params( - Freq = 868.30, #MHz center frequency - Datarate = 17.241, #kbit/s baudrate - ModulationType = rfm69.FSK, #modulation - Deviation = 30, #kHz frequency deviation - SyncPattern = [0x2d, 0xd4], #syncword - Bandwidth = 150, #kHz bandwidth - RssiThresh = -105, #dBm RSSI threshold -) +#rfm.set_params( +# Freq = 868.30, #MHz center frequency +# Datarate = 17.241, #kbit/s baudrate +# ModulationType = rfm69.FSK, #modulation +# Deviation = 30, #kHz frequency deviation +# SyncPattern = [0x2d, 0xd4], #syncword +# Bandwidth = 150, #kHz bandwidth +# RssiThresh = -105, #dBm RSSI threshold +#) mean_temp = 0 @@ -127,10 +130,16 @@ def update_temp(): if temps: mean_temp = sum(temps) / len(temps) +def fetch_temp(bridge, user, sensor): + r=requests.get(f"http://{bridge}/api/{user}/sensors/{str(sensor)}") + if r: + return r.json()["state"]["temperature"]/100 + return None -temp_thread = threading.Thread(target=update_temp, name="Temp Thread") -temp_thread.start() +#temp_thread = threading.Thread(target=update_temp, name="Temp Thread") + +#temp_thread.start() #display.vline(0,clock_box.size[1],1,color565(LINE_COLOR)) @@ -147,7 +156,10 @@ old_temp="" display.fill(color565(BKGND_COLOR)) try: while True: - check_pixel = display.read((0,0) + cur_temp = fetch_temp("philips-hue", "GQ03rw1saUS0n88G5yj9j7-TsteFIE1yxtlBOgzD", 71) + if cur_temp: + mean_temp = cur_temp + #display.reset() #time.sleep(0.5) @@ -157,7 +169,11 @@ try: time_str = time.strftime(CLOCK_FORMAT, now_parts) temp_str = TEMP_FORMAT % mean_temp - if time_str != old_time: +# display.reset() + display.init() +# display.fill(color565(BKGND_COLOR)) + + if True: #time_str != old_time: clock_box.draw_text(display, time_str, jitter_pos) old_time = time_str @@ -168,7 +184,7 @@ try: # backlight.duty_cycle = DAY_BRIGHT # else: # backlight.duty_cycle = NIGHT_BRIGHT - if temp_str != old_temp: + if True: #temp_str != old_temp: time.sleep(0.1) temp_box.draw_text(display, temp_str, jitter_pos) old_temp = temp_str @@ -178,7 +194,7 @@ try: except KeyboardInterrupt: clock_box.draw_text(display, "off" ,(0,0)) - temp_box.draw_text(display,"",(0,0)) +# temp_box.draw_text(display,"",(0,0)) shutdown=True - temp_thread.join() +# temp_thread.join()