Skip to content

Commit 7a1b1c1

Browse files
authored
Update code.py
1 parent 374daa0 commit 7a1b1c1

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

  • CircuitPython_Simple_Wordclock

CircuitPython_Simple_Wordclock/code.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,27 @@ def writetime(the_hr, the_min):
5252
if (the_hr == 12) and (the_min == 0):
5353
return NOON
5454
# set minute
55-
if (the_min > 4) and (the_min < 10):
55+
if (the_min > 4) and (the_min < 8):
5656
value = value | FIVEMIN
57-
if (the_min > 9) and (the_min < 15):
57+
if (the_min > 7) and (the_min < 13):
5858
value = value | TENMIN
59-
if (the_min > 14) and (the_min < 20):
59+
if (the_min > 14) and (the_min < 18):
6060
value = value | QUARTER
61-
if (the_min > 19) and (the_min < 25):
61+
if (the_min > 17) and (the_min < 23):
6262
value = value | TWENTY
63-
if (the_min > 25) and (the_min < 30):
63+
if (the_min > 22) and (the_min < 28):
6464
value = value | TWENTY | FIVEMIN
65-
if (the_min > 29) and (the_min < 35):
65+
if (the_min > 27) and (the_min < 33):
6666
value = value | HALF
67-
if (the_min > 34) and (the_min < 40):
67+
if (the_min > 32) and (the_min < 38):
6868
value = value | TWENTY | FIVEMIN
69-
if (the_min > 39) and (the_min < 45):
69+
if (the_min > 37) and (the_min < 43):
7070
value = value | TWENTY
71-
if (the_min > 44) and (the_min < 50):
71+
if (the_min > 42) and (the_min < 48):
7272
value = value | QUARTER
73-
if (the_min > 49) and (the_min < 55):
73+
if (the_min > 47) and (the_min <= 53):
7474
value = value | TENMIN
75-
if the_min > 54:
75+
if the_min => 54:
7676
value = value | FIVEMIN
7777
# before or after
7878
if the_min <= 30:
@@ -114,6 +114,7 @@ def writetime(the_hr, the_min):
114114

115115
# Main loop
116116
LEDstate = 0
117+
FirstLoop = True
117118

118119
while True:
119120
t = rtc.datetime
@@ -123,8 +124,8 @@ def writetime(the_hr, the_min):
123124
hour = t.tm_hour
124125
minute = t.tm_min
125126
second = t.tm_sec
126-
if second == 59:
127-
print("The time is {}:{:02}".format(t.tm_hour, t.tm_min))
127+
if second == 59 or FirstLoop:
128+
# print("The time is {}:{:02}".format(t.tm_hour, t.tm_min))
128129
pixels.fill((0, 0, 0)) # blank all pixels for change
129130
the_time = writetime(hour, minute)
130131
for i in range(1, 21): # Check all 30 bits
@@ -137,4 +138,5 @@ def writetime(the_hr, the_min):
137138
else:
138139
LED13.value = False
139140
LEDstate = 0
141+
Firstloop = False
140142
time.sleep(1) # wait a second

0 commit comments

Comments
 (0)