This commit is contained in:
Robert 2024-02-02 14:16:18 +01:00
parent fc7d944ce0
commit 816ac7af21
1 changed files with 19 additions and 17 deletions

View File

@ -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)
@ -164,7 +168,5 @@ def run():
print(topic_info["value"])
drawblack.text((160, int(topic_info["line"])), str(topic_info["value"]), font = font16, fill = 0)
if __name__ == '__main__':
run()