LCD works

This commit is contained in:
Martin Brodbeck 2022-04-28 22:05:52 +02:00
parent ef66e0cfd6
commit 65111340cf

View file

@ -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)