This commit is contained in:
Robert Borzutzki 2022-10-19 10:21:21 +02:00
parent 13e0f74a93
commit 57c06967fc

View File

@ -26,7 +26,7 @@ try:
logging.info("init and Clear") logging.info("init and Clear")
epd.init() epd.init()
epd.Clear() epd.Clear()
time.sleep(1) time.sleep(0.5)
# Drawing on the image # Drawing on the image
logging.info("Drawing") logging.info("Drawing")
@ -35,16 +35,16 @@ try:
# Drawing on the Horizontal image # Drawing on the Horizontal image
logging.info("1.Drawing on the Horizontal image...") logging.info("1.Drawing on the Horizontal image...")
HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126
HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image HRedimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image
drawblack = ImageDraw.Draw(HBlackimage) drawblack = ImageDraw.Draw(HBlackimage)
drawry = ImageDraw.Draw(HRYimage) drawred = ImageDraw.Draw(HRedimage)
drawblack.text((5, 0), 'PV Produktion', font = font10, fill = 0) drawblack.text((5, 0), 'PV Produktion', font = font10, fill = 0)
drawblack.text((5, 15), 'Hausverbrauch', font = font10, fill = 0) drawblack.text((5, 15), 'Hausverbrauch', font = font10, fill = 0)
drawblack.text((5, 30), 'Strom Import/Export', font = font10, fill = 0) drawblack.text((5, 30), 'Strom Import/Export', font = font10, fill = 0)
drawblack.text((5, 45), 'Batterie %', font = font10, fill = 0) drawblack.text((5, 45), 'Batterie %', font = font10, fill = 0)
drawry.text((5, 60), 'Batterie Laden/Entladen', font = font10, fill = 0) drawblack.text((5, 60), 'Batterie Laden/Entladen', font = font10, fill = 0)
#epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) #epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage))
epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage))
time.sleep(2) time.sleep(2)
except IOError as e: except IOError as e:
@ -66,7 +66,12 @@ def on_connect(client, userdata, flags, rc):
print("Failed to connect, return code %d\n", rc) print("Failed to connect, return code %d\n", rc)
def on_message(client, userdata, msg): def on_message(client, userdata, msg):
drawblack.text((100, 0), '99', font = font10, fill = 0)
drawblack.text((100, 15), '99', font = font10, fill = 0)
drawblack.text((100, 30), '99', font = font10, fill = 0)
drawblack.text((100, 45), '99', font = font10, fill = 0)
drawblack.text((100, 60), '99', font = font10, fill = 0)
epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage))
print(f"`{msg.topic}`: `{msg.payload.decode()}`") print(f"`{msg.topic}`: `{msg.payload.decode()}`")
Connected = False #global variable for the state of the connection Connected = False #global variable for the state of the connection