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 onewire import OneWire
from ds18x20 import DS18X20 from ds18x20 import DS18X20
from time import sleep_ms from time import sleep_ms
#from machine_i2c_lcd import I2cLcd from machine_i2c_lcd import I2cLcd
from lcd_api import LcdApi from lcd_api import LcdApi
from i2c_lcd import I2cLcd #from pico_i2c_lcd import I2cLcd
# Relais # Relais
relais = Pin(15, machine.Pin.OUT, value = 1) relais = Pin(15, machine.Pin.OUT, value = 1)
@ -19,12 +19,14 @@ sensor_id = temp_sensor.scan()[0]
#lcd = I2cLcd(i2c, 0x27, 2, 16) #lcd = I2cLcd(i2c, 0x27, 2, 16)
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000) i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
lcd_addr = 39 lcd_addr = 39
i2c.writeto(lcd_addr, '\x7C') I2C_ADDR = 0x27
i2c.writeto(lcd_addr, '\x2D') I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
# Text in Zeilen # Text in Zeilen
line_top = 'Temp. (Soll):' line_top = 'Soll: '
line_bot = 'Temp. (Ist) :' line_bot = 'Ist : '
def ctrl_relais(active = True): def ctrl_relais(active = True):
if active: if active:
@ -38,9 +40,9 @@ def ctrl_relais(active = True):
while True: while True:
temp_sensor.convert_temp() temp_sensor.convert_temp()
sleep_ms(750) sleep_ms(750)
print(temp_sensor.read_temp(sensor_id), " °C") temp_curr = str(temp_sensor.read_temp(sensor_id))
#i2c.writeto(lcd_addr, line_top + "\n" + line_bot) lcd.move_to(0, 0)
i2c.writeto(lcd_addr, "Hello world") lcd.putstr(line_top + "\n" + line_bot + temp_curr + " °C")
sleep_ms(2000) sleep_ms(2000)
#ctrl_relais(True) #ctrl_relais(True)