|
|
|
@ -71,10 +71,10 @@ def trapsignal(signalnum, frame):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getData():
|
|
|
|
|
info(f"requesting data from {octoprint}...")
|
|
|
|
|
debug(f"requesting data from {octoprint}...")
|
|
|
|
|
jsondata=requests.get(fullurl, verify=False).json()
|
|
|
|
|
jsondatatwo=requests.get(fullurltwo, verify=False).json()
|
|
|
|
|
info(f"Data received. Porgcessing.")
|
|
|
|
|
info(f"Received data from {octoprint}")
|
|
|
|
|
state=""
|
|
|
|
|
if jsondatatwo["state"]["flags"]["paused"]:
|
|
|
|
|
state="paused"
|
|
|
|
@ -105,7 +105,7 @@ def getData():
|
|
|
|
|
return (jobdata,datetime.datetime.now())
|
|
|
|
|
|
|
|
|
|
def drawData(jobdata,lastupdate):
|
|
|
|
|
info(f"Loading fonts and images")
|
|
|
|
|
debug(f"Loading fonts and images")
|
|
|
|
|
font14 = ImageFont.truetype(os.path.join(imgdir, 'Font.ttc'), 14)
|
|
|
|
|
font16 = ImageFont.truetype(os.path.join(imgdir, 'Font.ttc'), 16)
|
|
|
|
|
font18 = ImageFont.truetype(os.path.join(imgdir, 'Font.ttc'), 18)
|
|
|
|
@ -113,7 +113,7 @@ def drawData(jobdata,lastupdate):
|
|
|
|
|
font24 = ImageFont.truetype(os.path.join(imgdir, 'Font.ttc'), 24)
|
|
|
|
|
# LOAD OUR BACKGROUND
|
|
|
|
|
bg = Image.open(os.path.join(imgdir, 'backgroundv2.bmp'))
|
|
|
|
|
info(f"Initializing ePaper display")
|
|
|
|
|
debug(f"Initializing ePaper display")
|
|
|
|
|
epd.init()
|
|
|
|
|
paper = Image.new('1', (epd.width, epd.height), 255) # Blank canvas
|
|
|
|
|
draw = ImageDraw.Draw(paper)
|
|
|
|
@ -127,7 +127,7 @@ def drawData(jobdata,lastupdate):
|
|
|
|
|
# lastlayer (125,162) lastlayertime
|
|
|
|
|
# lastupdate (117,250)
|
|
|
|
|
# lastrefresh (117,278)
|
|
|
|
|
info(f"Preparing job data on canvas...")
|
|
|
|
|
debug(f"Preparing job data on canvas...")
|
|
|
|
|
if len(jobdata['file']) < 20:
|
|
|
|
|
draw.text((60, 6), jobdata['file'], font = font18, fill = 0)
|
|
|
|
|
else:
|
|
|
|
@ -159,7 +159,6 @@ try:
|
|
|
|
|
info("Octopi print monitor starting...")
|
|
|
|
|
# INIT
|
|
|
|
|
epd = epd4in2.EPD()
|
|
|
|
|
info("init and Clear")
|
|
|
|
|
epd.init()
|
|
|
|
|
epd.Clear()
|
|
|
|
|
|
|
|
|
@ -168,7 +167,7 @@ try:
|
|
|
|
|
(jobdata,lastupdate)=getData()
|
|
|
|
|
drawData(jobdata,lastupdate)
|
|
|
|
|
if jobdata['percent'] == "100" or jobdata['bedtarget'] == jobdata['target']:
|
|
|
|
|
info("Jobs idle - sleeping for 5 minutes")
|
|
|
|
|
info("Printer idle - sleeping for 5 minutes")
|
|
|
|
|
delay=10
|
|
|
|
|
while delay>0:
|
|
|
|
|
time.sleep(30)
|
|
|
|
@ -180,14 +179,14 @@ try:
|
|
|
|
|
else:
|
|
|
|
|
debug(f"30s sleep loop hupped: {hupped}")
|
|
|
|
|
else:
|
|
|
|
|
info("Print in progress - sleeping for 30 seconds")
|
|
|
|
|
info("Printer active - sleeping for 30 seconds")
|
|
|
|
|
time.sleep(30)
|
|
|
|
|
|
|
|
|
|
except IOError as e:
|
|
|
|
|
error(e)
|
|
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
critical("ctrl + c:")
|
|
|
|
|
critical("Caught interrupt - cleanly exiting")
|
|
|
|
|
epd.init()
|
|
|
|
|
epd4in2.epdconfig.module_exit()
|
|
|
|
|
exit()
|
|
|
|
|