aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorD Delmar Davis <don@suspectdevices.com>2025-07-10 14:56:35 -0700
committerD Delmar Davis <don@suspectdevices.com>2025-07-10 14:56:35 -0700
commit8095666d219d8122361257be32c19cb0f1b16c8e (patch)
treef428da364cb2328cabbc46ffe40a3e6f964b1087 /bin
parent5abd65fc6367a7fb8138e7cf27872d048c48d9ea (diff)
Works for me.
Diffstat (limited to 'bin')
-rw-r--r--bin/bigclock.py81
1 files changed, 59 insertions, 22 deletions
diff --git a/bin/bigclock.py b/bin/bigclock.py
index ac09ca7..6d9e950 100644
--- a/bin/bigclock.py
+++ b/bin/bigclock.py
@@ -1,43 +1,80 @@
!#/usr/bin/python3
-
-
import board
import busio
import adafruit_character_lcd.character_lcd_i2c as character_lcd
+from datetime import datetime
+
i2c = busio.I2C(board.SCL, board.SDA)
lcd = character_lcd.Character_LCD_I2C(i2c, 20, 4)
lcd.backlight = True
#lcd.message = "Hello there welcom\nCircuitPython\nwho knows if \nthis is too bright"
customchars=[
- bytes([0x01, 0x07, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F]), # char 1: bottom right triangle
- bytes([0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F]), # char 2: bottom block
- bytes([0x10, 0x1C, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F]), # char 3: bottom left triangle
- bytes([0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00]), # char 4: top right triangle
- bytes([0x1F, 0x1E, 0x1C, 0x10, 0x00, 0x00, 0x00, 0x00]), # char 5: top left triangle
- bytes([0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00]), # char 6: upper block
- bytes([0x1F, 0x1F, 0x1E, 0x1C, 0x18, 0x18, 0x10, 0x10]), # char 7: full top right triangle
- bytes([0x01, 0x07, 0x0F, 0x1F, 0x00, 0x00, 0x00, 0x00]) # char 8: top right triangle
-];
-for ch in range(0,7):
+ bytes([0x01, 0x07, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F]), # char 0: top left triangle
+ bytes([0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F]), # char 1: bottom block
+ bytes([0x10, 0x1C, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F]), # char 2: top right triangle
+ bytes([0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x07, 0x01]), # char 3: bottom left triangle
+ bytes([0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1E, 0x1C, 0x10]), # char 4: bottom right triangle
+ bytes([0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00]), # char 5: upper block
+ bytes([0x1F, 0x1F, 0x1E, 0x1C, 0x18, 0x18, 0x10, 0x10]), # char 6: full bottom right triangle
+ bytes([0x01, 0x07, 0x0F, 0x1F, 0x00, 0x00, 0x00, 0x00]) # char 7: top left triangle
+]
+for ch in range(8):
lcd.create_char(ch, customchars[ch])
mess=""
-for ch in range(0,7):
+for ch in range(8):
mess+=chr(ch)
lcd.message=mess
bn4 = [ # 4-line numbers
-# 0 1 2 3 4 5 6 7 8 9
- [0x01,0x06,0x03, 0x08,0xFF,0xFE, 0x08,0x06,0x03, 0x08,0x06,0x03, 0xFF,0xFE,0xFF, 0xFF,0x06,0x06, 0x01,0x06,0x03, 0x06,0x06,0xFF, 0x01,0x06,0x03, 0x01,0x06,0x03],
- [0xFF,0xFE,0xFF, 0xFE,0xFF,0xFE, 0x02,0x02,0xFF, 0xFE,0x02,0xFF, 0xFF,0x02,0xFF, 0xFF,0x02,0x02, 0xFF,0x02,0x02, 0xFE,0x01,0x07, 0xFF,0x02,0xFF, 0xFF,0x02,0xFF],
- [0xFF,0xFE,0xFF, 0xFE,0xFF,0xFE, 0xFF,0xFE,0xFE, 0xFE,0xFE,0xFF, 0xFE,0xFE,0xFF, 0xFE,0xFE,0xFF, 0xFF,0xFE,0xFF, 0xFE,0xFF,0xFE, 0xFF,0xFE,0xFF, 0xFE,0xFE,0xFF],
- [0x04,0x06,0x05, 0xFE,0x06,0xFE, 0x06,0x06,0x06, 0x04,0x06,0x05, 0xFE,0xFE,0x06, 0x04,0x06,0x05, 0x04,0x06,0x05, 0xFE,0x06,0xFE, 0x04,0x06,0x05, 0x04,0x06,0x05]
+# 0 1 2 3 4 5 6 7 8 9
+ ["\x00\x05\x02","\x07\xFF\xFE","\x07\x05\x02","\x07\x05\x02","\xff\xFE\xff","\xff\x05\x05","\x00\x05\x02","\x05\x05\xff","\x00\x05\x02","\x00\x05\x02"],
+ ["\xFF\xFE\xFF","\xFE\xFF\xFE","\xfe\x2f\x06","\xFE\x01\x04","\xff\x01\xFF","\xFf\x01\xa4","\xFF\xFE\xFE","\xFE\x2f\x06","\x03\x01\x04","\x03\x01\xff"],
+ ["\xFF\xFE\xFF","\xFE\xFF\xFE","\x2F\x06\xFE","\xFE\xfe\x02","\xfe\xfe\xFF","\xfe\xfe\xff","\xFF\x05\x02","\xFE\xff\xfe","\x00\xfe\x02","\xfe\xfe\xFF"],
+ ["\x03\x01\x04","\xFE\xFF\xFE","\xff\x01\x01","\x03\x01\x04","\xfe\xFE\xFF","\x03\x01\x04","\x03\x01\x04","\xfe\xff\xFe","\x03\x01\x04","\x03\x01\x04"],
+
]
def printNum4(digit, leftAdjust):
- for row in range(0,3):
- lcd.cursor_position(leftAdjust,row);
- i = digit*3
- lcd.message=chr(bn4[row][i])+chr(bn4[row][i+1])+chr(bn4[row][i+2])
+ for row in range(4):
+ lcd.cursor_position(leftAdjust,row);
+ lcd.message=bn4[row][digit]
+
+def printShort1(clear=False ):
+ for row in range(4):
+ lcd.cursor_position(0,row);
+ if (clear):
+ lcd.message="\xfe\xfe"
+ else:
+ lcd.message=bn4[row][1][0:2]
+
+def printColon(leftAdjust):
+ clearCollumn(leftAdjust)
+ lcd.cursor_position(leftAdjust,1)
+ lcd.message="\xa5"
+ lcd.cursor_position(leftAdjust,2)
+ lcd.message="\xa5"
+
+def clearCollumn(col=6):
+ for row in range(4):
+ lcd.cursor_position(col,row)
+ lcd.message="\xfe"
+
+
+def printTime():
+ date_string = f'{datetime.now():%H%M}'
+ if (date_string[0] == '1'):
+ printShort1()
+ else:
+ printShort1(clear=True)
+ clearCollumn(2)
+ printNum4(int(date_string[1]),3)
+ printColon(6);
+ printNum4(int(date_string[2]),7)
+ clearCollumn(10)
+ printNum4(int(date_string[3]),11)
+ lcd.cursor_position(15,0)
+ lcd.message=datetime.now().strftime("%d%b")
+ \ No newline at end of file