-
Notifications
You must be signed in to change notification settings - Fork 0
/
smartClock.py
60 lines (49 loc) · 1.21 KB
/
smartClock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import RPi.GPIO as GPIO
import time
import datetime
from LCD import LCD
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
def get_date():
now = datetime.datetime.now()
return (now.strftime("%a ") + now.strftime("%b ") + now.strftime("%d, ") + now.strftime("%Y"))
def get_time():
now = datetime.datetime.now()
return (now.strftime("%I:") + now.strftime("%M ") + now.strftime("%p"))
def start():
display.write(get_time())
display.new_line()
display.write(get_date())
now = datetime.datetime.now()
sec = int(now.strftime("%S"))
time.sleep(60-sec)
display.clear_display()
display.write(get_time())
display.new_line()
display.write(get_date())
def update():
display.clear_display()
display.write(get_time())
display.new_line()
display.write(get_date())
display = LCD(12, 16, 18, 22, 24, 26, 32, 36, 10, 8)
display.function_set()
display.init_cursor()
display.clear_display()
#start()
#while True:
#time.sleep(60)
#date = get_date()
#time1 = get_time()
#display.clear_display()
#display.write(time1)
#display.new_line()
#display.write(date)
# update()
current_time = ''
while True:
t = get_time()
if t != current_time:
current_time = t
update()
time.sleep(1)