Page 1 of 1

Controlling I2C lcd character display

Posted: Mon Nov 19, 2018 1:12 pm
by Acexbe
Most character displays have one or two rows of 8, 16, 20, 40 characters.
Driving them is parallel 4 or 8 bit plus a number of control lines.
A of the shelf I2C interface PCB can be attached, but these are rather slow.
The contrast needs to be adjusted by a variable resistor.

Some weeks ago, I discovered a firm on buydisplay.com
They had one type that drew my attention, a two row by 16 characters backlit display that can be driven I2C or SPI.
A special feature is the fact that the two rows can be merged to display one row of 16 big characters.
And with the right configuration, you can adjust the contrast by software.
So I ordered one:

https://www.buydisplay.com/default/i2c- ... lack-on-yg

The datasheet was a big help.(also on their site)
Next code is very basic but controls this display without any problem.

Future experiment will be the same display, but with SPI commands, this should even go faster.


I2CINIT(100000)
I2CTIME(10)

'driving I2C lcd display, quick and dirty method

DIM init(9)=0x38,0x39,0x14,0x78,0x5E,0x6A,0x0C,0x01,0x06

'initialisation of the display
FOR i =1 TO 9
wr$=CHR$(init(i))
I2CWR(0x7C,0,wr$,1)
NEXT i


REPEAT

'send text to line 1
I2CWR(0x7C,0,CHR$(0x02),1)
I2CWR(0x7C,0x40,"Line 1 ",7)
WAIT(2000)

'send numbers to line 1
FOR c =1 TO 9
WR$=STR$(c)
I2CWR(0x7c,0x40,wr$,1)
NEXT c
WAIT(2000)

'send text to line 2 2
I2CWR(0x7C,0,CHR$(0xC0),1)
I2CWR(0x7C,0x40,"-- Lijn 2 --",12)
WAIT(2000)

'switch to big characters (1 line)
I2CWR(0x7C,0,CHR$(0x34),1)
I2CWR(0x7C,0x40,"XYZ",3)
WAIT(4000)

'go back to two lines
I2CWR(0x7C,0,CHR$(0x38),1)
I2CWR(0x7C,0,CHR$(0xC0),1)
I2CWR(0x7C,0,CHR$(0x02),1)
WAIT(4000)

'send 'abcdefgh' to the startposition
I2CWR(0x7C,0x40,"abcdefgh",8)
WAIT(2000)

'display off
I2CWR(0x7C,0,CHR$(0x08),1)
WAIT(2000)

'display on underline cursor
I2CWR(0x7C,0,CHR$(0x0E),1)
WAIT(5000)

'display on character cursor
I2CWR(0x7C,0,CHR$(0x0D),1)
WAIT(5000)

'display on no cursor
I2CWR(0X7C,0,CHR$(0x0C),1)
WAIT(1000)

'test writespeed with big characters
I2CWR(0x7C,0,CHR$(0x34),1)
I2CWR(0x7C,0,CHR$(0x02),1)
FOR x=1 TO 16
I2CWR(0x7C,0,CHR$(0x02),1)
I2CWR(0x7C,0x40,"0123456789123456",16)
WAIT(x*70)
I2CWR(0x7C,0,CHR$(0x02),1)
I2CWR(0x7C,0x40,"abcdefghijklmnop",16)
WAIT(x*70)
NEXT x

WAIT(2000)
'clear display
I2CWR(0x7c,0,CHR$(0x38),1)

UNTIL 0