This repository was archived by the owner on Dec 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (37 loc) · 1.24 KB
/
main.py
File metadata and controls
40 lines (37 loc) · 1.24 KB
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
from segments import cleanup, display_number
import network
import urequests
from utime import sleep
hour, minute, second = 23, 30, 0
hostip = "10.42.0.1"
# Create a station interface and set your credentials
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect('raspberrypi')
while not station.isconnected():
continue
print('Network config:', station.ifconfig())
try:
while True:
if station.isconnected():
hour = int(urequests.get('http://{}:5000/time/hour'.format(hostip)).text)
minute = int(urequests.get('http://{}:5000/time/minute'.format(hostip)).text)
second = int(urequests.get('http://{}:5000/time/second'.format(hostip)).text)
else:
second += 1
if second == 60:
second = 0
minute += 1
if minute == 60:
minute = 0
hour += 1
hour_rem = 24 - hour
minute_rem = 60 - minute
second_rem = 60 - second
if hour == 23:
number = (minute_rem - 1) * 100 + (second_rem - 1)
else:
number = (hour_rem - 1) * 100 + (minute_rem - 1)
display_number(number, 200, 2)
except KeyboardInterrupt:
cleanup()