from machine import Pin, I2C
import ssd1306
import utime
import machine
import urequests
i2c = I2C(sda=Pin(21), scl=Pin(22))
display = ssd1306.SSD1306_I2C(128, 64, i2c)
timer = machine.Timer(0)
def interruptiontimer(timer):
global minute
minute = minute +1
timer.init(period=60000, mode=machine.Timer.PERIODIC, callback=interruptiontimer)
resp = urequests.get("/heuresysteme",data = "22", headers = {'content-type': "application/x-www-form-urlencoded"})
print("quelle heure est-il?")
print(resp.text)
#heures = resp.text[1:3]
#minutes = resp.text[4:6]
#print(heures,minutes)
while True:
current_time = utime.localtime(utime.time())
heure = current_time[3]
minute = current_time[4]
seconde = current_time[5]
print("Il est actuellement {}h{}m{}s".format(heure, minute,seconde))
display.fill(0)
utime.sleep(10)
display.text(str("{}h{}m{}s".format(heure, minute,seconde)), 30, 30)
display.show()