I2C Read with GTT43

GTT TFT Support

Moderator: Mods

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

I2C Read with GTT43

Post by iotexpert.com »

I have a GTT43... and I am able to read and write successfully with UART

I am able to successfully WRITE with I2C

However, when I try to read with I2C I get crazy data back.

For instance if I am trying to read the protocol version... I have tried
I2C Start, address + write 254 0 stop
i2c start address read read read read read read stop

I have tried
i2c start, address + write 254 0 restart address+read read read read read read read stop

I have tried i2c start, address+ write 254 0 stop
i2c start address, read stop

With all of the different combinations of reads that I have tried... the 254 0 I always get (in hex)
FC+ FA+ 00+ 03+ 01+ 0D+

I am supposed to get
FC 00 00 02 02 08

Do I need to configure something special in the LCD to get the read responses to work correctly? I notice that there is a command 254 5 (set communication channel)... but that doesnt seem to be it.

.... so I suppose that I must not understand how to do the I2C read responses from a write... any help would be appreciated.

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: I2C Read with GTT43

Post by Daniel Divino »

Hi iotexpert,

Welcome to the forums!

Have you designed your screens in the GTT Designer?

Cheers,
Daniel Divino
Daniel Divino
Technical Support
Matrix Orbital

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com »

Yes... but I guess that I dont understand why having or not having screens in there would impact the I2C interaction.

In other words... it seems to me that I would be able to do a "protocol version" read regardless of anything?

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com »

Is there an I2C protocol timing diagram in some document? If so I haven't been able to find it... but I would love to see it.

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: I2C Read with GTT43

Post by Daniel Divino »

Hi iotexpert,

Thanks for the added details about your project.

Designing your project in the GTT Designer won't prevent the use of any GTT Commands.

The GTT Designer Suite simply converts your screens into scripts and images, and uploads those files to the GTT. Upon boot, the GTT will start executing the autoexec script as if it were receiving commands from a host. Any return messages generated during this time will be sent to the Communication Channel, in this case I2C. All of the return messages generated during this time will be held within the GTT's return buffer until read via I2C. This is why you are seeing FC FA 00 03 01 0D messages rather than the expected FC 00 00 02 02 08.

There are two methods around this issue:
-You can continuously read the GTT's I2C buffer to ensure that all of the return messages generated upon startup do not interfere with future read operations
-You can set the default Communication Channel to None in your GTT Designer project and add a post load script to set the Communication Channel to I2C once the first screen has been loaded and drawn. This will ensure that you don't get the long list of return messages when the autoexec is being executed, but you will still be able to read data from the GTT once the screen is drawn.

Either of those methods should keep your I2C buffer clear, allowing you to immediately read the proper data from your display.

Cheers,
Daniel Divino
Daniel Divino
Technical Support
Matrix Orbital

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com »

OK. I understand... I think.

I think you are saying that I can setup things with GTT designer and set the communication to none... then after the system boots, I can send an I2C command to set the channel to I2C

Or I can read the data until the buffer is clear.

Is there a command to clear the I2C buffer?

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com »

I tried reading bytes to try to clear out the buffer...

Looks like after I read about 25 bytes the buffer is clear...

And then my commands work correctly (this is good).

1) is there a way to know how many bytes are in the buffer?

2) are there always complete responses in the buffer (meaning I could parse them all until the buffer is empty)?

Thanks,
Alan

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: I2C Read with GTT43

Post by Daniel Divino »

Hi Alan,

I'm glad to hear you're able to properly read all of your commands via I2C now.

At the moment, there is no way to know how many bytes are in the GTT's return buffer, nor is there a single command to clear the buffer.

The buffer will only house complete responses, so you can run a parser loop that will read all of the messages until the buffer is empty.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com »

Thank you that is helpful. Having complete messages is good.

One more question... what happens if the display needs to over-run the buffer? Does it throw out earlier stuff? Or not write into it?

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: I2C Read with GTT43

Post by Daniel Divino »

Hi Alan,

Once the return buffer is full, the GTT will not be able to continue operating until it's data is read. It will wait until there is more space in the return buffer before executing any more commands. This is to prevent data loss, and ensures that all events registered by the GTT are reported to the host.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com »

Awesome. Thank you that helps a lot.

Haz
LCD Geek
Posts: 38
Joined: Wed Jun 28, 2017 8:52 am

Re: I2C Read with GTT43

Post by Haz »

I am working with IoTexpert, and have an additional comment now that the code is implemented with the rest of the hardware.
This is my startup code:

Code: Select all

Log_Message(info, "Flushing the init buffer\r\n");
                    while(!gtt_parser_process(&gtt1)){};
                    Log_Message(info, "Init buffer Flushed\r\n");
                    /* Setup the first screen */
                    gtt_run_script(&gtt1, "MustangElectronicDisplay_SystemManagement\\Screen_Login\\Screen_Login.bin");
                    uiParameters.screenId = SCREEN_LOGIN;
                    Log_Message(info, "Flushing the Screen buffer\r\n");
                    while(!gtt_parser_process(&gtt1)){};
                    Log_Message(info, "Screen buffer Flushed\r\n");
                     /* Set the default channel to I2C */
                    gtt_set_default_channel(&gtt1, eChannel_I2C); 
I am trying to flush the buffer once the startup sequence is done. I have about 7 screens and multiple objects, and i assume that the buffer is pretty full or close to it just starting up. I keep reading the parser_process until it returns a false, so nothing left, and I move to the startup screen which i have. Which is called the Screen_Login.
This code above never gets out of the first while(!gtt_parser_process(&gtt1)){};. It never goes to the screen login.
If i replace the while loops with just a 2sec delay, it works sometimes. But i cannot have this lock up undeterministically. I need a way to know the LCD is powered up, buffer empty, and ready to take commands from the host.

I also tried to put an Echo as a post load event, and then wait for command. Also did not work.

Any direction will help. I am stuck without a UI to control the Hardware.

Thanks,
H-

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: I2C Read with GTT43

Post by Daniel Divino »

Hi Haz,

After talking to a few colleagues, I believe the problem has to do with the while loop that you have in your code. The gtt_parser_process is meant to return asynchronous data, such as touch or keypad inputs. This might be the reason why you aren't receiving the false value you are looking for.

A better option might be to set the default communication channel to none in the GTT Designer. Then, add a post-load script that sets the communication channel to the protocol you are using, and issues a Get_Backlight command. That way, none of the messages are generated during boot up. Then, once the display is fully booted and all assets have been loaded and drawn on screen, the display will return a brightness value indicating that it is ready to receive commands.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

Haz
LCD Geek
Posts: 38
Joined: Wed Jun 28, 2017 8:52 am

Re: I2C Read with GTT43

Post by Haz »

Daniel,
I implemented the post-load script as you mentioned, and i already had the communication set to none.
I am using I2C, so i have to initiate the communication with the LCD to get the data, even to get the backlighting. But if i ping the LCD before it is ready, I am getting a lock up.
So i have to have a way to know the LCD is ready, to even read the backlighting data from the buffer given the LCD is a slave.

I will send you the project on the email per the other thread.

Thanks,
H-

Haz
LCD Geek
Posts: 38
Joined: Wed Jun 28, 2017 8:52 am

Re: I2C Read with GTT43

Post by Haz »

Also, do I need to call the gtt_set_default_channel(&gtt1, eChannel_I2C); every time I load a screen or is it global?
It seems that if i don't, when a new screen is loaded, it does not sent anything on the bus, so no events trigger.

Post Reply