Dim data As Byte 'variable for storing EEPROM byte data
Dim bl As Byte
Dim rs As Byte
bl = 0x8
rs = 0x1
main: 'endless loop
Call i2clcdbegin()
Call printstr1()
Call cmdwrite(0x80)
Call printstr2()
Call cmdwrite(0x94)
Call printstr3()
Call cmdwrite(0xc0)
Call printstr4()
Call cmdwrite(0xd4)
End 'end program
Proc printstr1()
Dim x As Byte
Dim ch As Byte
For x = 0 To 16
ch = LookUp("Line-1 Test "), x
Call datawrite(ch)
Next x
End Proc
Proc printstr2()
Dim x As Byte
Dim ch As Byte
For x = 0 To 16
ch = LookUp("Line-2 Test "), x
Call datawrite(ch)
Next x
End Proc
Proc printstr3()
Dim x As Byte
Dim ch As Byte
For x = 0 To 16
ch = LookUp("Line-3 Test "), x
Call datawrite(ch)
Next x
End Proc
Proc printstr4()
Dim x As Byte
Dim ch As Byte
For x = 0 To 16
ch = LookUp("Line-4 Test "), x
Call datawrite(ch)
Next x
End Proc
Proc i2clcdbegin()
WaitMs 15
Call cmdwrite(0x33)
WaitMs 5
Call cmdwrite(0x32)
WaitMs 5
Call cmdwrite(0x2c)
WaitMs 1
Call cmdwrite(0xc)
WaitMs 1
Call cmdwrite(0x6)
WaitMs 1
Call cmdwrite(0x1)
End Proc
Proc datawrite(data As Byte)
Dim hi As Byte
Dim lo As Byte
lo = ShiftLeft(data, 4)
hi = data And 0xf0 '0xf0 was orgineel
lo = lo And 0xf0
data = hi + bl + rs
I2CWrite sda, scl, 0x4e, data, data
data = data + 0x4
I2CWrite sda, scl, 0x4e, data, data
data = data - 0x4
I2CWrite sda, scl, 0x4e, data, data
WaitMs 1
data = lo + bl + rs
I2CWrite sda, scl, 0x4e, data, data
data = data + 0x4
I2CWrite sda, scl, 0x4e, data, data
data = data - 0x4
I2CWrite sda, scl, 0x4e, data, data
End Proc
Proc cmdwrite(cmd As Byte)
Dim hi As Byte
Dim lo As Byte
lo = ShiftLeft(cmd, 4)
hi = cmd And 0xf0
lo = lo And 0xf0
cmd = hi + bl
I2CWrite sda, scl, 0x4e, cmd, cmd
cmd = cmd + 0x4
I2CWrite sda, scl, 0x4e, cmd, cmd
cmd = cmd - 0x4
I2CWrite sda, scl, 0x4e, cmd, cmd
WaitMs 1
cmd = lo + bl
I2CWrite sda, scl, 0x4e, cmd, cmd
cmd = cmd + 0x4
I2CWrite sda, scl, 0x4e, cmd, cmd
cmd = cmd - 0x4
I2CWrite sda, scl, 0x4e, cmd, cmd
End Proc