from machine import Pin, I2C, Timer
import ssd1306
from time import sleep
i2cdisplay = I2C(0, scl=Pin(23), sda=Pin(21))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2cdisplay)
timer_0 = Timer(0)
minutes= 0
heures= 0
def handleInterrupt(timer):
global minutes
minutes+=1
timer_0.init(period=10000, mode=Timer.PERIODIC, callback=handleInterrupt)
while True:
oled.fill(0)
#if minutes>0:
#state = machine.disable_irq()
#interruptCounter = interruptCounter-1
#minutes-=1
#machine.enable_irq(state)
# totalInterruptsCounter = totalInterruptsCounter+1
#print("Interrupt has occurred: " + str(totalInterruptsCounter))
# secondes=secondes +1
if minutes > 59 :
minutes = 0
heures=heures +1
if heures == 24:
minutes = 0
heures = 0
message= str(heures)+":"+str(minutes) #+":"+str(secondes)
oled.text(message,55, 30) #,":",minutes,":",secondes)
oled.show()
#totalInterruptsCounter = totalInterruptsCounter+1
#print("Interrupt has occurred: " + str(totalInterruptsCounter))
Loading
ssd1306
ssd1306