From 653257b787afbfd9cb52afae77de19a850305f2d Mon Sep 17 00:00:00 2001 From: jimmy Date: Wed, 21 Sep 2022 00:50:57 +1200 Subject: [PATCH] Production version --- printer/printer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/printer/printer.py b/printer/printer.py index b27e78e..f5a6c3f 100755 --- a/printer/printer.py +++ b/printer/printer.py @@ -46,7 +46,7 @@ def on_message(client, userdata, msg): lines = textwrap.wrap(text, width=23) - if len(lines) > 2: + if random.randint(0,1) == 0: im=Image.open("printer/image.jpg") else: im=Image.open("printer/image2.jpg") @@ -62,23 +62,23 @@ def on_message(client, userdata, msg): print(n) im.paste( ImageOps.colorize(w, (0,0,0), (0,0,0)), ( (n-5)*20 + 127, 5), w) - im.show() - im.save("image_tmp.jpg") + # im.show() + # im.save("image_tmp.jpg") raster = StarTSPImage.imageToRaster(im, cut=True) printer = open('/dev/usb/lp0', "wb") - #printer.write(raster) + printer.write(raster) client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message -client.connect("", 1883, 60) +client.connect("192.168.240.231", 1883, 60) # Blocking call that processes network traffic, dispatches callbacks and # handles reconnecting. # Other loop*() functions are available that give a threaded interface and a # manual interface. -client.loop_forever() \ No newline at end of file +client.loop_forever()