import utime
import machine
from machine import I2C, Pin
from time import sleep
from lcd_api import LcdApi

from pico_i2c_lcd import I2cLcd

I2C_ADDR = 0x27
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16

print("Running test main")
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
lcd.putstr("    Eventos:          0000")

count = 0

b1 = Pin(14, Pin.IN, Pin.PULL_UP)
b2 = Pin(15, Pin.IN, Pin.PULL_UP)



def fun_b1(b1):
    global count

    count = count + 1
    if count == 1001:
        count = 0
    lcd.putstr("    ") 
    lcd.move_to(6, 1)
    lcd.putstr("{:04}".format(count))

def fun_b2(b2):
    global count

    count = count - 1
    if count < 0:
        count = 1000
    lcd.putstr("    ") 
    lcd.move_to(6, 1)
    lcd.putstr("{:04}".format(count))

b1.irq(trigger = Pin.IRQ_FALLING, handler=fun_b1)
b2.irq(trigger = Pin.IRQ_FALLING, handler=fun_b2)


while True:
    sleep(0.1)
    
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT