Page 1 of 2

I2C GLT to GTT

Posted: Tue Dec 10, 2013 11:12 pm
by tvoglund
I have C code written for my GLT model LCD. Now I have a new GTT and trying to convert code to get it to work. I can clear screen but anytime I try any other commands it does not work. For draw line we have to use a signed short for the coordinates, but after that change draw line still did not work. Does it have to do with the following quote:

"Finally, when the display detects the command prefix character 254, it will enter a command processing state and await the command number and its parameters. Multiple bytes are transferred in Big Endian format. Once the command is finished, the display will automatically return to displaying all bytes sent."

To be clear, Multiple bytes are transferred in Big Endian format? Do I need to convert commands or the x,y coords to big endian before I add to buffer?

What are the major differences that I need to be aware of. I did notice in manual that the use of Big Endian is used in GTT but did not see any comments of Big Endian in the GLT manual?

Thanks for any help.

Re: I2C GLT to GTT

Posted: Wed Dec 11, 2013 9:16 am
by Tino
Hi tvoglund

There is some differences between the GLT and the GTT. The GTT uses Big Endian where as the GLT uses Little Endian.

You are right you will need to convert your commands to Big Endian format.

Please find below a link to some App notes for the GTT. It is in C# but should give you a good idea.
http://www.matrixorbital.ca/appnotes/GTT20CSharpSerial/

If you have any other questions or concerns please feel free to ask.
Thank you
Martino

Re: I2C GLT to GTT

Posted: Wed Dec 18, 2013 10:31 pm
by tvoglund
Martino,

I am able to write to the data buffer at addess 0x50. Then when i try to read from 0x51, I am unsuccessful. I am a little stumped.

I write to 0x50 the following 0xFE 0x7A

Next I read from data buffer doing the following:

0x51 (read 1 byte) (read 1 byte) (read 1 byte) etc...

The response is 0x00 0xFF 0xFF 0xFF etc...

But unfortunately I should be getting 0xFC 0x7A 0x00

Any ideas on what I can try to debug?

Thanks,

Truby

Re: I2C GLT to GTT

Posted: Thu Dec 19, 2013 10:43 am
by Tino
Hi Truby,

Just to confirm, this is for your new GTT display correct?

We have an App note on I2C communication with the GTT that you can find here:
http://www.matrixorbital.ca/appnotes/GTT20ArduinoI2C/

What program are you using to communicate to your display?

Regards
Martino

Re: I2C GLT to GTT

Posted: Thu Dec 19, 2013 3:56 pm
by tvoglund
Martino,

Yes this is for a my new GTT display. I have a PIC controller that I am programming using C. I had all the code working for a GLK display and we decided to go with the GTT. In converting the code, reading from data buffer is where I am hung up and not receiving what I expect.

Any info would help.

Truby

Re: I2C GLT to GTT

Posted: Thu Dec 19, 2013 4:12 pm
by Tino
Hi Truby,

Please refer to the I2C App Notes section here:
http://www.matrixorbital.ca/appnotes/GTT20ArduinoI2C/

The App note uses Arduino but should give you an idea as to how the display works with I2C.

If you could post a little bit of your code showing how you have your read function is setup I could take a look and see if there is anything within the code.

There are no pull ups on the GTT as well so you will need pull ups on the host side.

Is the display giving an ACK or NACK? If so where?

Thank you
Martino

Re: I2C GLT to GTT

Posted: Sat Jan 25, 2014 8:25 pm
by Lenny
tvoglund wrote:Martino,

I am able to write to the data buffer at addess 0x50. Then when i try to read from 0x51, I am unsuccessful. I am a little stumped.

I write to 0x50 the following 0xFE 0x7A

Next I read from data buffer doing the following:

0x51 (read 1 byte) (read 1 byte) (read 1 byte) etc...

The response is 0x00 0xFF 0xFF 0xFF etc...

But unfortunately I should be getting 0xFC 0x7A 0x00

Any ideas on what I can try to debug?

Thanks,

Truby
I've managed to read multiple bytes from my GTT480272A using this C code:
What threw me for a while, was that I wasn't looking for the ack bit (even thought the LCD doesn't ack you still need to check anyway).
As soon as I added in the line to call my ack routine, I got my 6 bytes, repeatable, and as expected.

unsigned char Read_I2C_data(void)
{
[tab=30]unsigned char _data = 0;
[tab=30]l=0;
[tab=30]I2C_delay(500);
[tab=30]
//this loop converts serial data to parallel data
[tab=30]while (l < 8)
[tab=30]{
[tab=30][tab=30]_data = _data | SDA;
[tab=30][tab=30]if (l < 7) _data = _data << 1;
[tab=30][tab=30]I2C_delay(10);
[tab=30][tab=30]SCL = TRUE;
[tab=30][tab=30]I2C_delay(10);
[tab=30][tab=30]SCL = FALSE;
[tab=30][tab=30]l++;
[tab=30]}
[tab=30]l = 0;
[tab=30]ack = I2C_ack();
[tab=30]return _data;
}


I call Read_I2C_data() using other code in my program, like this:
StartI2C();
Write_I2C_data(LCD_READ);
//LCD read address 0x51
SCL = FALSE; //must make SCL low before we start to read
i = 0;
while (i < 6)
{
[tab=30]com_buffer = Read_I2C_data();
[tab=30]i++;
}
StopI2C();

Hope that helps. :)

Re: I2C GLT to GTT

Posted: Sun Jan 26, 2014 12:29 pm
by Lenny
Actually, the algorithm above isn't quite correct. The main C code that calls Read_I2C_data() should be:

//Get 6 bytes of data from the LCD - in this case Touch region events from a GTT
a = 0;
while (a < 6)
{
[tab=30]StartI2C();
[tab=30]Write_I2C_data(LCD_READ);
[tab=30]SCL = FALSE;
[tab=30]com_buffer[a] = Read_I2C_data();
[tab=30]
//make sure first valid byte is stored in 0
[tab=30]if (com_buffer[a] == 0xFC)
[tab=30]{
[tab=30][tab=30]com_buffer[0] = com_buffer[a];
[tab=30][tab=30]a = 0;
[tab=30]}
[tab=30]a++;
[tab=30]StopI2C();
}

//Now that you have your bytes, determine what to do with them...
command(com_buffer[0],com_buffer[1],com_buffer[2],com_buffer[3],com_buffer[4],com_buffer[5]);

Read_I2C_data remains the same (repeated below):

unsigned char Read_I2C_data(void)
{
[tab=30]unsigned char _data = 0;
[tab=30]l=0;
[tab=30]I2C_delay(500);

[tab=30]//this loop converts serial data to parallel data
[tab=30]while (l < 8)
[tab=30]{
[tab=30][tab=30]_data = _data | SDA;
[tab=30][tab=30]if (l < 7) _data = _data << 1;
[tab=30][tab=30]I2C_delay(10);
[tab=30][tab=30]SCL = TRUE;
[tab=30][tab=30]I2C_delay(10);
[tab=30][tab=30]SCL = FALSE;
[tab=30][tab=30]l++;
[tab=30]}
[tab=30]l = 0;
[tab=30]ack = I2C_ack();
[tab=30]return _data;
}

Re: I2C GLT to GTT

Posted: Fri Jan 31, 2014 7:49 pm
by tvoglund
Ok, sorry this is late. I am writing my commands from a pic controller using C. My problem was how i was reading the responses. I was not reading the buffer correctly. here is what works...


//below tells lcd that I am done reading bye
SSP2CON2bits.ACKDT = 0;
SSP2CON2bits.ACKEN = 1;
if(I2CWaitComplete(I2C_TIMEOUT_BIT))
return(1);


//Set RCEN bit to tell the master to read in a byte, wait for completion, then read byte
SSP2CON2bits.RCEN = 1;
if(I2CWaitComplete(I2C_TIMEOUT_BYTE))
return(1);
length1 = SSP2BUF; //read byte


then keep doing that for each byte then the last byte read do the following...


SSP2CON2bits.ACKDT = 0;
SSP2CON2bits.ACKEN = 1;
if(I2CWaitComplete(I2C_TIMEOUT_BIT))
return(1);


//Set RCEN bit to tell the master to read in a byte, wait for completion, then read byte
SSP2CON2bits.RCEN = 1;
if(I2CWaitComplete(I2C_TIMEOUT_BYTE))
return(1);
b = SSP2BUF;

//Do ACK, wait for completion
SSP2CON2bits.ACKDT = 1;
SSP2CON2bits.ACKEN = 1;
if(I2CWaitComplete(I2C_TIMEOUT_BIT))
return(1);


Then send stop bit and completed my read response.

Re: I2C GLT to GTT

Posted: Fri Jan 31, 2014 7:56 pm
by tvoglund
Martino,

Now I am trying to read the response of a touch. I am doing the same thing as when I read response of a command. Unfortunately, I am getting no responses. Nothing., just 0x00 0xff 0xff 0xff 0xff ...... To configure my touch region I do the following:

1. Set Touch reporting style
2. Set Input Input feedback
3. Create my touch region


When I touch the button I created I see the two images, the active and inactive pngs. But then I loop looking for a response and receive nothing. Is there anything I am forgetting?

Thanks for any ideas,

Truby

Re: I2C GLT to GTT

Posted: Fri Jan 31, 2014 9:26 pm
by Lenny
Hi Truby,

I was getting the exact same problem as you, lots of 0xFF's.

I figured out that it was because I was doing this:

Start I2C
send LCD read address
read byte
read byte
read byte
read byte
read byte
read byte
Stop I2C

The above is the wrong way to read multiple bytes.

The correct way is:

Start I2C
send LCD read address
read byte
Stop I2C
Start I2C
send LCD read address
read byte
Stop I2C
Start I2C
send LCD read address
read byte
Stop I2C
Start I2C
send LCD read address
read byte
Stop I2C
Start I2C
send LCD read address
read byte
Stop I2C
Start I2C
send LCD read address
read byte
Stop I2C

That is, you have to start and stop the I2C bus with each byte read

My read code, posted earlier, follows the correct way of reading multiple bytes. Feel free to use it. :)

Re: I2C GLT to GTT

Posted: Mon Feb 03, 2014 8:32 am
by Clark
Hi Lenny,

We appreciate the algorithm posted, hopefully it helps out Truby, and other developers as well.

For anyone interested, I have posted your full I2C "Bit Bash" SDCC code for C8051F005 implementation on our support site as requested, here.

Thanks again for sharing your insight, and code,
Troy

Re: I2C GLT to GTT

Posted: Wed Feb 05, 2014 1:11 am
by tvoglund
Thank you for the code supplied. I believe it is not for the GTT LCD because some of the commands are different. But it pointed me in the right direction. I Set the Communication Channel to I2C in the autoexec.bin file and now all my touch regions are working as expected.

Now I have one bug left. When i set a font size, the text just moves with a padding, but the text size doesnt change. Why wouldnt the Set Font Size command not work?

Any ideas would be great.

And could I get a brief description of the buffers I load animations, nine-slices, bitmaps and fonts into. i.e. I tihnk I have 256 buffer indexes, but not sure. And, if I load a font into index 0, then can index 0 be given to a touch region?

Thanks for all the great help.

Truby

Re: I2C GLT to GTT

Posted: Wed Feb 05, 2014 9:00 am
by Tino
Hey Truby,

When setting the Font Size please make sure you set the Font first then set the size. If you do not set the font the size will not save to that font.

In the GTT there is a separate buffer for 9-Slices, Bitmaps, Fonts and Animations. Each buffer has 256 slots.

If you load a font into Index '0' this will be loaded into the "Font Buffer". Loading a touch Region into index '0' will not effect the font with the index '0' because they are in two separate buffers.

You can find more on your buffers here in the manual for the GTT:
http://www.matrixorbital.ca/manuals/GTT ... 2.0%29.pdf

If you have any other questions feel free to ask.
Thank you
Martino

Re: I2C GLT to GTT

Posted: Wed Mar 05, 2014 11:36 pm
by tvoglund
Martino,

Thank you for all the help. I have one more question, I have Touch Report Style 2, and Input feed back of 9 set. Therefore, for each touch region I get a beep and a byte of the region code that was pushed. I checked the Out of Region setting and it is 0. I have one bug I'm trying to fix, and that is when one region is touched and somewhere else on the lcd that is not in a region is touched I get really odd behavour and the screens get all scrambled.

Do you have any ideas on what would be a solution to this issue.

Thanks again,

Truby