From 65111340cf6fa8f2e6e5e41733e6c2e4bb53f569 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 28 Apr 2022 22:05:52 +0200 Subject: [PATCH] LCD works --- gbmanager.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gbmanager.py b/gbmanager.py index cf896bd..1b40e6f 100644 --- a/gbmanager.py +++ b/gbmanager.py @@ -2,9 +2,9 @@ from machine import Pin, I2C from onewire import OneWire from ds18x20 import DS18X20 from time import sleep_ms -#from machine_i2c_lcd import I2cLcd +from machine_i2c_lcd import I2cLcd from lcd_api import LcdApi -from i2c_lcd import I2cLcd +#from pico_i2c_lcd import I2cLcd # Relais relais = Pin(15, machine.Pin.OUT, value = 1) @@ -19,12 +19,14 @@ sensor_id = temp_sensor.scan()[0] #lcd = I2cLcd(i2c, 0x27, 2, 16) i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000) lcd_addr = 39 -i2c.writeto(lcd_addr, '\x7C') -i2c.writeto(lcd_addr, '\x2D') +I2C_ADDR = 0x27 +I2C_NUM_ROWS = 2 +I2C_NUM_COLS = 16 +lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS) # Text in Zeilen -line_top = 'Temp. (Soll):' -line_bot = 'Temp. (Ist) :' +line_top = 'Soll: ' +line_bot = 'Ist : ' def ctrl_relais(active = True): if active: @@ -38,9 +40,9 @@ def ctrl_relais(active = True): while True: temp_sensor.convert_temp() sleep_ms(750) - print(temp_sensor.read_temp(sensor_id), " °C") - #i2c.writeto(lcd_addr, line_top + "\n" + line_bot) - i2c.writeto(lcd_addr, "Hello world") + temp_curr = str(temp_sensor.read_temp(sensor_id)) + lcd.move_to(0, 0) + lcd.putstr(line_top + "\n" + line_bot + temp_curr + " °C") sleep_ms(2000) #ctrl_relais(True)