from machine import Pin, I2C
from display_manager import DisplayManager
from boot_screen import BootScreen
import hx711
import time
from lcd_api import LcdApi
from lcd_i2c import I2cLcd
# ===== I2C setup =====
i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq=400000)
# Definizione pin
DT_PIN = 4
SCK_PIN = 12
# PESA
SCALE = 90
# ===== LCD driver minimal =====
# Solo per mostrare 2 righe su 16 colonne
# Versione ridotta per MicroPython
# Importa la libreria compatibile LCD1602
# Assicurati di avere lcd_api.py e i2c_lcd.py caricati sulla scheda
#hx = hx711.HX711(dout=Pin(DT_PIN, Pin.IN), pd_sck=Pin(SCK_PIN, Pin.OUT))
hx = hx711.HX711(DT_PIN, SCK_PIN)
display = DisplayManager()
boot = BootScreen(display)
boot.show_logo()
boot.show_progress()
display.clear()
display.center_text("Sistema pronto!", 1)
# Taratura (cambia in base al tuo sensore)
peso = hx.get_weight(SCALE)
print("Peso:", peso, "kg")
display.center_text(f"Peso: {peso:.2f} kg", 1)
#hx.tare()
# Lettura peso
#peso = hx.get_units(5)
#print("Peso:", peso, "kg")
while True:
time.sleep(1)