-
Hi, I'd like some feedback on my while True:
t = time.localtime()
hrs.value(hstart * uv(-t[3]*pi/6 - t[4]*pi/360), YELLOW)
mins.value(mstart * uv(-t[4] * pi/30), YELLOW)
secs.value(sstart * uv(-t[5] * pi/30), RED)
dial.text('{} {} {}'.format(days[t[6]], t[2], months[t[1] - 1]))
refresh(ssd)
hh = t[3]
mm = t[4]
ss = t[5]
if hh == 0 and mm == 0 and ss == 0:
my_first_function()
if hh == 14 and mm == 0 and ss == 0:
my_second_function()
if hh != current_hour:
my_third_function()
current_hour = hh
time.sleep(1) I have a feeling that this is not so effective. How can I improve my code? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
There is just little room for improvement. The |
Beta Was this translation helpful? Give feedback.
-
This is a primitive way to schedule stuff though. Better to use something like mcron or micropython async crontab. |
Beta Was this translation helpful? Give feedback.
or it could be something like:
The check for mm and ss is not needed, since
current_hour != hh
is only valid at the start of an hour.