diff options
Diffstat (limited to 'epaperisslow.py')
| -rw-r--r-- | epaperisslow.py | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/epaperisslow.py b/epaperisslow.py index 30516b9..524b718 100644 --- a/epaperisslow.py +++ b/epaperisslow.py @@ -1,6 +1,6 @@ #---------------------------------------------------------------epaperisslow.py # playing around with 2.13" HD mono pi hat. -# +# references adafruit example code. # screen drawing takes 9-10 seconds per update. @@ -53,8 +53,8 @@ display.rotation = 1 # Make sure to create image with mode '1' for 1-bit color. width = display.width height = display.height -image = Image.new("RGB", (width, height)) -splashimage = Image.new("RGB", (width, height)) +lightimage = Image.new("RGB", (width, height)) +darkimage = Image.new("RGB", (width, height)) WHITE = (0xFF, 0xFF, 0xFF) BLACK = (0x00, 0x00, 0x00) @@ -65,15 +65,15 @@ display.fill(Adafruit_EPD.WHITE) display.display() # Get drawing object to draw on image. -draw = ImageDraw.Draw(image) -splash = ImageDraw.Draw(splashimage) +light = ImageDraw.Draw(lightimage) +dark = ImageDraw.Draw(darkimage) # empty it -draw.rectangle((0, 0, width, height), fill=WHITE) -splash.rectangle((0, 0, width, height), fill=BLACK) +light.rectangle((0, 0, width, height), fill=WHITE) +dark.rectangle((0, 0, width, height), fill=BLACK) print("drawing box") # Draw an outline box -draw.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE) +light.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE) # Draw some shapes. # First define some constants to allow easy resizing of shapes. padding = 5 @@ -88,48 +88,50 @@ x = padding font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 80) text_origin=(7,top+15) -draw.text(text_origin, TimeString(), font=font, fill=BLACK) -splash.text(text_origin, TimeString(), font=font, fill=WHITE) +light.text(text_origin, TimeString(), font=font, fill=BLACK) +dark.text(text_origin, TimeString(), font=font, fill=WHITE) print("entering the loops") -#display.image(splashimage) +#display.image(darkimage) #display.display() old_ticks = time.monotonic() - 50.0 -image2display=splashimage +image2display=darkimage while True: - ticks = time.monotonic() - + # if programmer is bored: move this section to an interrupt if not switch1.value: print("Switch 1") - image2display=image + image2display=lightimage display.image(image2display) display.display() - while not switch1.value: - time.sleep(0.01) - + #No point in debouncing after the display takes 9 seconds + #while not switch1.value: + # time.sleep(0.01) + if not switch2.value: print("Switch 2") - image2display=splashimage + image2display=darkimage display.image(image2display) display.display() - while not switch2.value: - time.sleep(0.01) - + #No point in debouncing after the display takes 9 seconds + #while not switch2.value: + # time.sleep(0.01) + # print( ticks - old_ticks) - + + # Update the time on both dark and light images. if(( ticks - old_ticks) >= 50.0): #current_time=datetime.now().strftime("%H:%M ") print("updating "+TimeString()) - draw.rectangle((0, 0, width, height), fill=WHITE) - splash.rectangle((0, 0, width, height), fill=BLACK) - draw.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE) - draw.text(text_origin,TimeString(),font=font, fill=BLACK) - splash.text(text_origin,TimeString(), font=font, fill=WHITE) + light.rectangle((0, 0, width, height), fill=WHITE) + dark.rectangle((0, 0, width, height), fill=BLACK) + light.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE) + light.text(text_origin,TimeString(),font=font, fill=BLACK) + dark.text(text_origin,TimeString(), font=font, fill=WHITE) display.image(image2display) display.display() old_ticks=time.monotonic() - + |
