aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD Delmar Davis <don@suspectdevices.com>2023-08-28 19:43:08 -0700
committerD Delmar Davis <don@suspectdevices.com>2023-08-28 19:43:08 -0700
commitc62f8498071455aae6f3ff57b162d842deb9e77b (patch)
treef67c52a08b66c1ff56a6a2e6cdaab51ae6fa6380
parentbecf91195012690a1536d46b8734e89478a9a73c (diff)
add a shutoff.
-rwxr-xr-xclock.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/clock.py b/clock.py
index ea36648..9f68c35 100755
--- a/clock.py
+++ b/clock.py
@@ -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)