Oh, Entschuldigung, sind hier in C-Basic, das Programm läuft auf ner C-Control PRO per I2C über einen PCF8574.
Hier etwas mehr Code:
Code:
Sub main()
I2C_Init(I2C_100kHz)
LCD_Init_I2C(abInitOptions)
LCD_Clear_I2C()
LCD_Locate_I2C(2, 1)
LCD_WriteText_I2C("Hälli hällo!")
End Sub
Sub LCD_WriteText_I2C(ByRef cText As Char)
Dim i As Integer
i = 0
'Übergebenes Char-Array ausgeben.
Do While cText(i) > 0
If cText(i) = "ä" Then
LCD_Write_I2C(1, 238)
Else
LCD_Write_I2C(1, cText(i))
End If
i = i + 1
End While
End Sub
Sub LCD_Write_I2C(bIsData As Byte, bData As Byte)
Dim bDataOut As Byte
'RS high setzen falls Datenausgabe gewünscht (bRS = 1).
If bIsData > 0 Then : bIsData = LCD_RS : End If
'*** High Nibble ***
bDataOut = bIsData Or (bData >> 4)
I2C_Out(bDataOut, 1)
'*** Low Nibble ***
bDataOut = bIsData Or (bData And 0x0F)
I2C_Out(bDataOut, 1)
End Sub
Sub I2C_Out(bData As Byte, bPulseE As Byte)
If bPulseE > 0 Then
I2C_Start()
I2C_Write(I2C_PCF_ADDR)
I2C_Write(bData Or LCD_EN)
I2C_Stop()
AbsDelay(1)
End If
I2C_Start()
I2C_Write(I2C_PCF_ADDR)
I2C_Write(bData)
I2C_Stop()
End Sub
Lesezeichen