diff options
| author | D Delmar Davis <don@suspectdevices.com> | 2023-08-28 19:43:08 -0700 |
|---|---|---|
| committer | D Delmar Davis <don@suspectdevices.com> | 2023-08-28 19:43:08 -0700 |
| commit | c62f8498071455aae6f3ff57b162d842deb9e77b (patch) | |
| tree | f67c52a08b66c1ff56a6a2e6cdaab51ae6fa6380 | |
| parent | becf91195012690a1536d46b8734e89478a9a73c (diff) | |
add a shutoff.
| -rwxr-xr-x | clock.py | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -13,6 +13,9 @@ import busio import digitalio from PIL import Image, ImageDraw, ImageFont import adafruit_ssd1305 +from datetime import datetime + +displayIsOff = False; oled_reset = digitalio.DigitalInOut(D4) i2c = busio.I2C(SCL, SDA) @@ -37,7 +40,19 @@ x = 0 # Load default font. font = ImageFont.load_default() + while True: + thetime=datetime.now() + if(displayIsOff): + if (thetime.hour<=18 and thetime.hour>=6): + disp.poweron() + displayIsOff=False + else: + if (thetime.hour>18 or thetime.hour<6): + disp.poweroff() + displayIsOff=True + + # Draw a black filled box to clear the image. draw.rectangle((0, 0, width, height), outline=0, fill=0) |
