From 816ac7af2197d162e3d897b8739b2880c0f89330 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 2 Feb 2024 14:16:18 +0100 Subject: [PATCH] re-order --- examples/solar-monitoring.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/examples/solar-monitoring.py b/examples/solar-monitoring.py index 76813d9..74d4839 100644 --- a/examples/solar-monitoring.py +++ b/examples/solar-monitoring.py @@ -17,7 +17,6 @@ import traceback # Import MQTT client. from paho.mqtt import client as mqtt_client - logging.basicConfig(level=logging.DEBUG) # MQTT credentials @@ -66,6 +65,19 @@ topic6 = { topics = {0:topic0,1:topic1,2:topic2,3:topic3,4:topic4,5:topic5,6:topic6} +#Define Display +epd = epd2in13b_V3.EPD() +epd.init() + +#Set fonts +font16 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 16) +font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) + +#Init Image +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 +drawblack = ImageDraw.Draw(HBlackimage) +#drawry = ImageDraw.Draw(HRYimage) def connect_mqtt(): def on_connect(client, userdata, flags, rc): @@ -93,26 +105,18 @@ def subscribe(client: mqtt_client, topic): def init_monitor(topics): logging.info("epd2in13b_V3 Demo") - logging.info(libdir) - logging.info(picdir) - - epd = epd2in13b_V3.EPD() - #epd = epaper.epaper('epd2in13b_V3').EPD() - #logging.info("init and Clear") - epd.init() + + #epd = epd2in13b_V3.EPD() + #epd.init() #epd.Clear() # Drawing on the image - logging.info("Drawing") - font16 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 16) - font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) + #logging.info("Drawing") + #font16 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 16) + #font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) # Drawing on the Horizontal image logging.info("1.Drawing on the Horizontal image...") - 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 - drawblack = ImageDraw.Draw(HBlackimage) - drawry = ImageDraw.Draw(HRYimage) drawblack.text((4, 0), 'PV Production', font = font16, fill = 0) drawblack.text((4, 16), 'Hausverbrauch', font = font16, fill = 0) drawblack.text((4, 32), 'Strom Import', font = font16, fill = 0) @@ -163,8 +167,6 @@ def run(): print(topic_info["line"]) print(topic_info["value"]) drawblack.text((160, int(topic_info["line"])), str(topic_info["value"]), font = font16, fill = 0) - - if __name__ == '__main__': run() \ No newline at end of file