import machine
import ssd1306
import utime
import network
import time
import ntptime
print("Connecting to WiFi", end="")
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('Wokwi-GUEST', '')
while not wlan.isconnected():
print(".", end="")
time.sleep(0.1)
print(" Connected!")
ImagenParadia = bytearray(b'')
ImagenParatarde = bytearray(b'')
ImagenParaNoche = bytearray(b'')
ntptime.settime()
while True:
oled.fill(0)
hora_actual = utime.localtime()
hora = hora_actual[3] * 3600 + hora_actual[4] * 60 + hora_actual[5]
hora_str = "{:02d}:{:02d}:{:02d}".format(hora_actual[3], hora_actual[4], hora_actual[5])
oled.text(hora_str, 0, 0)
if hora >= 6 * 3600 and hora < 18 * 3600:
oled.blit(ssd1306.Image(128, 64, ImagenParadia), 0, 16)
elif hora >= 18 * 3600 and hora < 21 * 3600:
oled.blit(ssd1306.Image(128, 64, ImagenParatarde), 0, 16)
else:
oled.blit(ssd1306.Image(128, 64, ImagenParaNoche), 0, 16)
oled.show()
utime.sleep(1)