micronEC/micronec.py

28 lines
686 B
Python
Raw Normal View History

from lcd_driver import I2C_LCD
from machine import I2C, Pin
from welcome import WelcomeScreen
from counter import CounterArray
from lcd_screen import CounterScreen
I2C_ADDR = 0x27
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16
WELCOME_CYCLES = 1
COUNTER_NUMBER = 2
COUNTER_NAMES = ["Counter 1", "Counter 2"]
COUNTER_PINS = {0:2,1:3}
_i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
lcd = I2C_LCD(_i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
counterArray = CounterArray(COUNTER_NUMBER, COUNTER_NAMES)
ws = WelcomeScreen(lcd)
cs = CounterScreen(lcd, counterArray)
# Real program
ws.show_welcome(WELCOME_CYCLES)
cs.show_screen()
counterArray.register_listener(COUNTER_PINS, cs.show_screen)