import utime
import machine
from machine import I2C, Pin
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd
I2C_ADDR = 0x27
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16
#Test function for verifying basic functionality
print("Running test_main")
i2c = I2C(0, sda=machine.Pin(0), scl=machine.Pin(1), freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
lcd.putstr(" Eventos: 0000")
count = 0
btn1 = Pin(16, Pin.IN, Pin.PULL_UP)
btn2 = Pin(17, Pin.IN, Pin.PULL_UP)
def fun_b1(btn1):
global count
count += 1
if count > 1000:
count = 0
lcd.move_to(6,1)
lcd.putstr("{:04}".format(count))
def fun_b2(btn2):
global count
count = count - 1
if count < 0:
count = 1000
lcd.move_to(6,1)
lcd.putstr("{:04}".format(count))
btn1.irq(trigger = Pin.IRQ_FALLING,handler = fun_b1)
btn2.irq(trigger = Pin.IRQ_FALLING,handler = fun_b2)
while True:
pass