<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Matrix Orbital &#8211; IoT Expert</title>
	<atom:link href="https://iotexpert.com/category/devkits/matrix-orbital/feed/" rel="self" type="application/rss+xml" />
	<link>https://iotexpert.com</link>
	<description>Engineering for the Internet of Things</description>
	<lastBuildDate>Tue, 12 Jan 2021 20:12:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://iotexpert.com/wp-content/uploads/2017/01/cropped-Avatar-32x32.jpg</url>
	<title>Matrix Orbital &#8211; IoT Expert</title>
	<link>https://iotexpert.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Matrix Orbital GTT43A: Driver Library &#8211; Part 2</title>
		<link>https://iotexpert.com/matrix-orbital-gtt43a-driver-library-part-2/</link>
					<comments>https://iotexpert.com/matrix-orbital-gtt43a-driver-library-part-2/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 20 Jun 2018 11:40:18 +0000</pubDate>
				<category><![CDATA[Matrix Orbital]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=5299</guid>

					<description><![CDATA[Summary In the previous article I showed you how to integrate the Matrix Orbital Driver into a PSoC4200M project.  I am planning on using this device on a bus with multiple displays, and using an RTOS.  The byte based driver in the previous example isn&#8217;t that great for this situation.  In one of the earlier [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the <a href="https://iotexpert.com/2018/06/18/matrix-orbital-gtt43a-driver-library-part-1/">previous article</a> I showed you how to integrate the Matrix Orbital Driver into a PSoC4200M project.  I am planning on using this device on a bus with multiple displays, and using an RTOS.  The byte based driver in the previous example isn&#8217;t that great for this situation.  In one of the earlier articles I showed you how to build a packet based interface instead of a byte-based interface.  Lets integrate that into the PSoC4200M project, and add some more commands.</p>
<p>In this article I will</p>
<ol>
<li>Integrate the packet driver</li>
<li>Add event handlers</li>
<li>Add some new commands</li>
<li>Fix a nasty little bug that is lurking in the driver</li>
</ol>
<h1>Integrate the Packet Driver</h1>
<p>In the file gtt_parser.c there is a big long function which reads a byte at a type every time that it is called.  It then assembles the packet into a buffer of bytes that the rest of the system can consume.  After the packet is completely read, it sets up pointers to the start and end of the packet and finally calls the function &#8220;gtt_process_packet&#8221;.  For me what I will do is read in a packet, then call this function to setup things and call the gtt_process_packet.</p>
<pre class="lang:c decode:true ">// This function process a whole packet at a time    
uint8_t gtt_parser_process(gtt_device *device)
{
    gtt_packet_error_t rval;
    rval = device-&gt;ReadPacket(device);
    if(rval == GTT_PACKET_NODATA)
        return 0;
    
    if(rval != GTT_PACKET_OK)
    {
#if DEBUG_PSOC        
        sprintf(buff,"GTT_PACKET_ERROR %d\r\n",rval);
        UART_UartPutString(buff);
#endif
        return 0; // No data
    }

    device-&gt;Parser.PacketStart = device-&gt;Parser.Index;
    device-&gt;Parser.Index += device-&gt;Parser.Length;
    
	uint8_t Result = gtt_process_packet(device, device-&gt;Parser.PacketStart);
	if (Result)
	    return 0;
	else
	    return 1;

}</pre>
<p>I use almost the same packet driver as I built in the earlier example.  Except that I need to modify it to read into the gtt buffers that the gtt driver library expects.  The biggest benefit of this whole thing is that it makes complete I2C transactions, rather than issuing a bunch of start/address/reads which makes it significantly more efficient.</p>
<pre class="lang:c decode:true">gtt_packet_error_t readPacketI2C(gtt_device *device)
{
    
    uint8_t data;
    uint32_t i2cerror;
    
    i2cerror = I2C_I2CMasterSendStart( ((i2cContext_t *)device-&gt;Context)-&gt;slaveAddress,I2C_I2C_READ_XFER_MODE , ((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    i2cerror |= I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA,&amp;data,((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    i2cerror |= I2C_I2CMasterSendStop(((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    
    
    // Something bad happened on the I2C Bus ....
    if(i2cerror)
    {
        sprintf(buff,"I2C Return Code %X\r\n",(unsigned int)i2cerror);
        UART_UartPutString(buff);
        return GTT_PACKET_I2CERROR;
    }
    
     // The screen returns a 0 when there is nothing in the buffer.
    if(data == 0)
    {
        return GTT_PACKET_NODATA;
    }

    // This is bad because there was something other than a packet start byte
    if(data != 252)
    {
        sprintf(buff,"bad data = %d\r\n",data);
        UART_UartPutString(buff);
        return GTT_PACKET_DATABAD;
    }
    
    // We know that we have a command
    i2cerror = I2C_I2CMasterSendStart( ((i2cContext_t *)device-&gt;Context)-&gt;slaveAddress,I2C_I2C_READ_XFER_MODE , ((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    i2cerror |= I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA,&amp;data,((i2cContext_t *)device-&gt;Context)-&gt;timeout); // command
    device-&gt;Parser.Command = data;

    // Read the Length
    i2cerror |= I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA,&amp;data,((i2cContext_t *)device-&gt;Context)-&gt;timeout); // length
    device-&gt;Parser.Length = data&lt;&lt;8;
    i2cerror |= I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA,&amp;data,((i2cContext_t *)device-&gt;Context)-&gt;timeout); // length
    device-&gt;Parser.Length += data;
    i2cerror |= I2C_I2CMasterSendStop(((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    
    if(i2cerror)
        return GTT_PACKET_I2CERROR;
    
    if(device-&gt;Parser.Length &gt; device-&gt;rx_buffer_size)
    {
        return GTT_PACKET_SIZE;
    }
    
    // If the packet has any data... then read it.
    if(device-&gt;Parser.Length != 0)
    {
        i2cerror |= I2C_I2CMasterSendStart( ((i2cContext_t *)device-&gt;Context)-&gt;slaveAddress,I2C_I2C_READ_XFER_MODE , ((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    
        for(uint32_t i=0;i &lt; device-&gt;Parser.Length-1; i++)
        {
            i2cerror |= I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA,&amp;data,((i2cContext_t *)device-&gt;Context)-&gt;timeout); // length
            device-&gt;rx_buffer[device-&gt;Parser.Index+i] = data;
        }

        // Read the last byte
        i2cerror |= I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA,&amp;data,((i2cContext_t *)device-&gt;Context)-&gt;timeout); // length
        device-&gt;rx_buffer[device-&gt;Parser.Index +device-&gt;Parser.Length - 1 ] = data;
        i2cerror |= I2C_I2CMasterSendStop(((i2cContext_t *)device-&gt;Context)-&gt;timeout);
        
        if(i2cerror)
            return GTT_PACKET_I2CERROR;
    }
      
    sprintf(buff,"command = %d length = %d bytes= ",device-&gt;Parser.Command,device-&gt;Parser.Length);
    UART_UartPutString(buff);
    for(uint32_t i=0;i&lt;device-&gt;Parser.Length;i++)
    {
        //sprintf(buff,"%d ",inbuff[i]);
        sprintf(buff,"%d ",device-&gt;rx_buffer[device-&gt;Parser.Index+i]);
        UART_UartPutString(buff);
    }
    UART_UartPutString("\r\n");
    return GTT_PACKET_OK;
}</pre>
<h1>Add Event Handlers</h1>
<p>I noticed when I looked at the gtt_device.h that the structure for the gtt_device has an member called &#8220;gtt_events&#8221;, but what is that?</p>
<pre class="lang:c decode:true">typedef struct gtt_device
{
	void* Context;            /* device depended storage */
	gtt_write Write;          /* Function for writing data */
	gtt_read Read;            /* Function for reading data */
    gtt_packet_error_t (*ReadPacket)(gtt_device *);

	uint8_t secured_packets;  /* 0 = regular protocol, 1 = wrap all outgoing packets with crc protection*/
	
	/* The fields below are internal and shall NOT be used by the read/write functions */
	
	gtt_parser Parser;        /* Protocol parser data */
	uint8_t *rx_buffer;       /* Buffer for incoming data */
	size_t rx_buffer_size;    /* size of the rx buffer in elements */
	uint8_t *tx_buffer;       /* Buffer for outgoing data */
	size_t tx_buffer_size;    /* size of the tx buffer in elements */
	size_t tx_index;          /* current index for the packet writer */
	gtt_events events;        /* Event Callbacks */
	size_t wait_idx;          /* Current Packet Index for the waitlist */
	gtt_waitlist_item waitlist[8]; /* Packet recieve waitlists */
} gtt_device;</pre>
<p>Well. the gtt_events structure is defined in gtt_events.h.  Basically it is a bunch of function pointers, which if you provide functions, it will call those functions when things happen on the screen.  For instance the function that gtt_event_slider_change is pointing to will be called when a slider changes.</p>
<pre class="lang:c decode:true">typedef void(*gtt_event_key)(gtt_device* device, uint8_t key, eKeypadRepeatMode type);
typedef void(*gtt_event_sliderchange)(gtt_device* device, eTouchReportingType type, uint8_t slider, int16_t value);
typedef void(*gtt_event_touch)(gtt_device* device, eTouchReportingType type, uint16_t x , uint16_t y);
typedef void(*gtt_event_regiontouch)(gtt_device* device, eTouchReportingType type, uint8_t region);
typedef void(*gtt_event_baseobject_on_property_change)(gtt_device* device, uint16_t ObjectID, uint16_t PropertyID);
typedef void(*gtt_event_visualobject_on_key)(gtt_device* device, uint16_t ObjectID, uint8_t Row, uint8_t Col, uint8_t ScanCode, uint8_t Down);
typedef void(*gtt_event_button_click)(gtt_device* device, uint16_t ObjectID, uint8_t State);

typedef struct gtt_events {
	gtt_event_key key;
	gtt_event_sliderchange sliderchange;
	gtt_event_touch touch;
	gtt_event_regiontouch regiontouch;
	gtt_event_baseobject_on_property_change baseobject_on_property_change;
	gtt_event_visualobject_on_key visualobject_on_key;
	gtt_event_button_click button_click;
} gtt_events;

</pre>
<p>To start with I just created stub functions that would just print out the information.  Here is an example of a function for the &#8220;gtt_event_button_click&#8221;</p>
<pre class="lang:c decode:true">void my_gtt_event_button_click(gtt_device* device, uint16_t ObjectID, uint8_t State)
{
    (void)device;
    (void)ObjectID;
    (void)State;
    UART_UartPutString("event button click\r\n");
}
</pre>
<p>Once you have those functions you need to add them to the gtt_device structure like this:</p>
<pre class="lang:c decode:true ">gtt_events myEvents = {
    .sliderchange = my_gtt_event_sliderchange,
    .touch = my_gtt_event_touch,
    .regiontouch = my_gtt_event_regiontouch,
    .baseobject_on_property_change = my_gtt_event_baseobject_on_property_change,
    .visualobject_on_key = my_gtt_event_visualobject_on_key,
    .button_click = my_gtt_event_button_click
};</pre>
<h1>Add New Commands</h1>
<p>Now we are ready to update the test project to add some more commands.  Here are a few examples which call the &#8220;gtt25&#8221; functions.</p>
<pre class="lang:c decode:true">            case 'q':
                UART_UartPutString("Set Text\r\n");
                gtt25_set_label_text(gtt,2,t);
            break;
                       
            case '2':
                gtt25_set_slider_value(gtt,3,2);
            break;
               
            case '9':
                gtt25_set_slider_value(gtt,3,9);
            break;
                    
            case 'I':
                gtt_set_default_channel(gtt, eChannel_I2C);
            break;
                    
            case '+':
                count += 1;
                if(count&gt;100)
                    count = 100;
                gtt25_set_gauge_value(gtt,9,count);
            break;    
                
            case '-':
                if(count &gt; 0)
                    count -= 1;
                gtt25_set_gauge_value(gtt,9,count);
            break;</pre>
<h1>Fix a Nasty Little Bug</h1>
<p>While I was debugging the library I found myself where the program was hung.  When I ran the debugger I found myself here.  This means that there was an ARM exception.  But why?</p>
<p><a href="https://iotexpert.com/2018/06/20/matrix-orbital-gtt43a-driver-library-part-2/screen-shot-2018-06-15-at-2-31-43-pm/" rel="attachment wp-att-5304"><img fetchpriority="high" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.31.43-PM.png" alt="" width="834" height="735" class="alignnone size-full wp-image-5304" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.31.43-PM.png 834w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.31.43-PM-600x529.png 600w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.31.43-PM-300x264.png 300w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.31.43-PM-768x677.png 768w" sizes="(max-width: 834px) 100vw, 834px" /></a></p>
<p>Then when you look at the call stack you find out that the exception is in the function &#8220;gtt_parser_getS16&#8221;</p>
<p><a href="https://iotexpert.com/2018/06/20/matrix-orbital-gtt43a-driver-library-part-2/screen-shot-2018-06-15-at-2-34-22-pm/" rel="attachment wp-att-5306"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.34.22-PM.png" alt="" width="712" height="166" class="alignnone size-full wp-image-5306" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.34.22-PM.png 712w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.34.22-PM-600x140.png 600w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.34.22-PM-300x70.png 300w" sizes="(max-width: 712px) 100vw, 712px" /></a></p>
<p>OK&#8230; but what in the world?  All this function is doing is taking the bytes and casting them into a uint16_t</p>
<p><a href="https://iotexpert.com/2018/06/20/matrix-orbital-gtt43a-driver-library-part-2/screen-shot-2018-06-15-at-2-36-23-pm/" rel="attachment wp-att-5307"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.36.23-PM.png" alt="" width="803" height="107" class="alignnone size-full wp-image-5307" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.36.23-PM.png 803w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.36.23-PM-600x80.png 600w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.36.23-PM-300x40.png 300w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-2.36.23-PM-768x102.png 768w" sizes="(max-width: 803px) 100vw, 803px" /></a></p>
<p>Well it turns out that if the address that is being read is ODD meaning not even aligned, you will endup with an ARM exception for an unaligned access of the memory.  This is why you need to be super careful with a pointer cast.  In this case you are casting a uint8_t pointer which can be byte aligned.</p>
<p>Here is a proper fix to this problem, assemble the composite type byte-by-byte.</p>
<pre class="lang:c decode:true">int16_t gtt_parser_getS16(gtt_device* device, size_t index, size_t *outIndex)
{
    
    int16_t data = (device-&gt;rx_buffer[index]&lt;&lt;8 | device-&gt;rx_buffer[index+1]);	    
	*outIndex = index + 2;
    return data;
  
}</pre>
<p>In the next article I will port all of this stuff to PSoC 6.</p>
<p><span><p>You can "git" these projects from</p>
<p>https://github.com/iotexpert/GTT43A</p>
<p>And the driver library from </p>
<p>https://github.com/iotexpert/GTT-Client-Library</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Title</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/">Matrix Orbital GTT43: A Cool Display</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/">Matrix Orbital GTT43A: Serial Interface</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/">Matrix Orbital GTT43A: GTT Scripts</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/24/matrix-orbital-gtt43a-psoc-4-interface/" target="_blank" rel="noopener">Matrix Orbital GTT43A: A PSoC 4 Interface</a></td>
</tr>

<tr><td >Matrix Orbital GTT43A: Debugging the I2C</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: PSoC 6 using RTOS and the GTT Driver Library</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/matrix-orbital-gtt43a-driver-library-part-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Matrix Orbital GTT43A: Driver Library &#8211; Part 1</title>
		<link>https://iotexpert.com/matrix-orbital-gtt43a-driver-library-part-1/</link>
					<comments>https://iotexpert.com/matrix-orbital-gtt43a-driver-library-part-1/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 18 Jun 2018 12:04:10 +0000</pubDate>
				<category><![CDATA[Matrix Orbital]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=5274</guid>

					<description><![CDATA[Summary In this article Im going to show you how to build a driver for the Matrix Orbital GTT43A that I have been talking about in the last several articles.  As you can see from the protocol manual, the Matrix Orbital Display has a bunch of different commands.  And I know that I need a [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In this article Im going to show you how to build a driver for the Matrix Orbital GTT43A that I have been talking about in the last several articles.  As you can see from the protocol manual, the Matrix Orbital Display has a bunch of different commands.  And I know that I need a driver.  But there isn&#8217;t (yet) one on the Matrix Orbital Website.  However, when I look at the pre-release of the GTT25 protocol guide, it seems clear that they are planning on one.  But what to do in the interim?  As usual Google is your friend and after looking around a little bit I found <a href="https://www.youtube.com/watch?v=A4d3_fNZMFM" target="_blank" rel="noopener">this YouTube video</a> of a Matrix Orbital Demo.  One more Google search lead me to this <a href="https://github.com/MatrixOrbital/GTT-Arduino-Thermometer-Demo" target="_blank" rel="noopener">Matrix Orbital GitHub repo</a> which appears to hold the driver that they wrote for this demo.</p>
<p>Clone it! Clone it! Good.</p>
<p>Now what?  In this article Ill show you:</p>
<ol>
<li>How to port the library to PSoC</li>
<li>How to implement the HAL as conceived by Matrix Orbital</li>
<li>How to make a test jig</li>
</ol>
<p>And in the next Article I will</p>
<ol>
<li>Replace the HAL and Parser with a Packet based HAL, much better</li>
<li>Show you how to fix some bugs in the library (nastiness)</li>
<li>Add more test code</li>
</ol>
<p>And in the one after that Ill port the whole thing to PSoC6 &amp; RTOS</p>
<h1>Port the GTT Client Library</h1>
<p>After running &#8220;git@github.com:MatrixOrbital/GTT-Arduino-Thermometer-Demo.git&#8221; I look around a little bit&#8230; and immediately find &#8220;GttClient&#8221;.  And when you look there, perfect a bunch of C and Header files.</p>
<p><a href="https://iotexpert.com/2018/06/18/matrix-orbital-gtt43a-driver-library-part-1/screen-shot-2018-06-14-at-4-44-11-pm/" rel="attachment wp-att-5277"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.44.11-PM.png" alt="" width="712" height="327" class="alignnone size-full wp-image-5277" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.44.11-PM.png 712w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.44.11-PM-600x276.png 600w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.44.11-PM-300x138.png 300w" sizes="auto, (max-width: 712px) 100vw, 712px" /></a></p>
<p>The first step is to make a new PSoC Creator project.  As I have done in the past, Ill drive the display with I2C, and Ill build a command line parser to talk to the system.  Here is the schematic:</p>
<p><a href="https://iotexpert.com/2018/06/18/matrix-orbital-gtt43a-driver-library-part-1/screen-shot-2018-06-14-at-4-47-37-pm/" rel="attachment wp-att-5279"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.47.37-PM.png" alt="" width="427" height="193" class="alignnone size-full wp-image-5279" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.47.37-PM.png 427w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.47.37-PM-300x136.png 300w" sizes="auto, (max-width: 427px) 100vw, 427px" /></a></p>
<p>Assign the Pins (I am using a PSoC 4200M, my favorite PSoC, development kit, specifically the CY8CKIT-044)</p>
<p><a href="https://iotexpert.com/2018/06/18/matrix-orbital-gtt43a-driver-library-part-1/screen-shot-2018-06-14-at-4-51-03-pm/" rel="attachment wp-att-5280"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.51.03-PM.png" alt="" width="583" height="147" class="alignnone size-full wp-image-5280" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.51.03-PM.png 583w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.51.03-PM-300x76.png 300w" sizes="auto, (max-width: 583px) 100vw, 583px" /></a></p>
<p>After running &#8220;Generate Application&#8221;, the next thing I do is pull in the library into PSoC Creator.  To do this</p>
<ol>
<li>Right click on the Source Files and make a new Folder, rename it &#8220;GTT&#8221;</li>
<li>Right click on the GTT Folder and do &#8220;Add Existing Item&#8230;&#8221;</li>
<li>Navigate to the GttClient directory, select all of the .h and .c files</li>
</ol>
<p>Your WorkSpace Explorer should look like this now:</p>
<p><a href="https://iotexpert.com/2018/06/18/matrix-orbital-gtt43a-driver-library-part-1/screen-shot-2018-06-14-at-4-52-00-pm/" rel="attachment wp-att-5281"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.52.00-PM.png" alt="" width="276" height="311" class="alignnone size-full wp-image-5281" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.52.00-PM.png 276w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.52.00-PM-266x300.png 266w" sizes="auto, (max-width: 276px) 100vw, 276px" /></a></p>
<p>Because those files are not in the normal build path, you next need to add the directory to the include path so that PSoC Creator can find the header files.  Right click on the project and pick &#8220;Build Settings&#8221;.</p>
<p><a href="https://iotexpert.com/2018/06/18/matrix-orbital-gtt43a-driver-library-part-1/screen-shot-2018-06-14-at-4-56-07-pm/" rel="attachment wp-att-5282"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.56.07-PM.png" alt="" width="440" height="546" class="alignnone size-full wp-image-5282" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.56.07-PM.png 440w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.56.07-PM-242x300.png 242w" sizes="auto, (max-width: 440px) 100vw, 440px" /></a></p>
<p>Then add a path to the library in the &#8220;Additional Include Directories&#8221;</p>
<p><a href="https://iotexpert.com/2018/06/18/matrix-orbital-gtt43a-driver-library-part-1/screen-shot-2018-06-14-at-4-56-27-pm/" rel="attachment wp-att-5283"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.56.27-PM.png" alt="" width="960" height="543" class="alignnone size-full wp-image-5283" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.56.27-PM.png 960w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.56.27-PM-600x339.png 600w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.56.27-PM-300x170.png 300w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-14-at-4.56.27-PM-768x434.png 768w" sizes="auto, (max-width: 960px) 100vw, 960px" /></a></p>
<p>Before we fix up the library to work, I always like to hit build to make sure everything is working.</p>
<h1>Implementing the Hardware Abstraction Layer</h1>
<p>In order to use the driver you need a Hardware Abstraction Layer.  After looking around a little bit I find the &#8220;.ino&#8221; file which is the Arduino main project file.  In that file, the first thing that they do is declare a structure of type &#8220;struct gtt_device&#8221;.  All of the function calls to the library take a pointer to this structure.  OK.  Lets have a look at the structure</p>
<ol>
<li>First it appears that they let you store some generic data via a &#8220;Context&#8221;</li>
<li>Then there are two functions to read and write data</li>
<li>Then some private stuff (which is used by the packet parser)</li>
</ol>
<pre class="lang:c decode:true">typedef struct gtt_device
{
	void* Context;            /* device depended storage */
	gtt_write Write;          /* Function for writing data */
	gtt_read Read;            /* Function for reading data */
  

	uint8_t secured_packets;  /* 0 = regular protocol, 1 = wrap all outgoing packets with crc protection*/
	
	/* The fields below are internal and shall NOT be used by the read/write functions */
	
	gtt_parser Parser;        /* Protocol parser data */
	uint8_t *rx_buffer;       /* Buffer for incoming data */
	size_t rx_buffer_size;    /* size of the rx buffer in elements */
	uint8_t *tx_buffer;       /* Buffer for outgoing data */
	size_t tx_buffer_size;    /* size of the tx buffer in elements */
	size_t tx_index;          /* current index for the packet writer */
	gtt_events events;        /* Event Callbacks */
	size_t wait_idx;          /* Current Packet Index for the waitlist */
	gtt_waitlist_item waitlist[8]; /* Packet recieve waitlists */
} gtt_device;
</pre>
<p>That means you need to provide a function called &#8220;Write&#8221; and one called &#8220;Read&#8221; which reads bytes from the serial interface.  Here is how they setup the structure for the Arduino Demo.  Apparently they are going to make two functions called i2cWrite and i2cRead.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">  gtt.Write = i2cWrite; //Set the write function
  gtt.Read = i2cRead; //Set the read function
  gtt.rx_buffer = rx_buffer; //Declare a buffer for input data
  gtt.rx_buffer_size = sizeof(rx_buffer); //Declare the size of the input buffer
  gtt.tx_buffer = tx_buffer; //Declare a buffer for output data
  gtt.tx_buffer_size = sizeof(tx_buffer); //Declare the size of the output buffer
</pre>
<p>So, what do those functions look like?</p>
<p>The I2C Write function just uses the Arduino Wire library to send bytes out the I2C.  And the I2C read function just reads one byte from the I2C and returns it.  OK I know how to do that on the PSoC</p>
<pre class="lang:c++ decode:true">}     

int i2cWrite(gtt_device* gtt_device, char* data, byte data_length) {//Write an array of bytes over i2c
  Wire.beginTransmission(I2C_Address);  
  for (int i = 0; i &lt; data_length; i++) {
    Wire.write(data[i]);        
  }
  Wire.endTransmission();  
  return 0;
}

byte i2cRead(gtt_device* gtt_device) { //Wait for one byte to be read over i2c  
  byte data;
  Wire.beginTransmission(I2C_Address);  
  Wire.requestFrom(I2C_Address, 1);     
  if(Wire.available()&lt;1) 
  {
    return -1;
  }
  else{
    data = Wire.read();  
    Serial.println(data);
    return data;
  } 
}
</pre>
<p>To do this exact same thing on the PSoC do this.  Notice that I put in a little bit of error checking.  I also make complete legal I2C transactions, Start, Address, R/W, bytes, Stop</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">int generic_write(gtt_device *device, uint8_t *data, size_t length)
{
    (void)device;
    uint32 returncode;
    
   
    sprintf(buff,"length = %d ",length);
    UART_UartPutString(buff);

            
    returncode = I2C_I2CMasterSendStart( ((i2cContext_t *)device-&gt;Context)-&gt;slaveAddress,I2C_I2C_WRITE_XFER_MODE , ((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    if(returncode != I2C_I2C_MSTR_NO_ERROR)
    {
        sprintf(buff,"error = %X\r\n",(unsigned int)returncode);
        UART_UartPutString(buff);
    }
    
    for(size_t i=0;i&lt;length;i++)
    {
        I2C_I2CMasterWriteByte(data[i],((i2cContext_t *)device-&gt;Context)-&gt;timeout);
        sprintf(buff,"%d ",data[i]);
        UART_UartPutString(buff);
    }
    
    I2C_I2CMasterSendStop(((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    UART_UartPutString("\r\n");
    return length;
        
}</pre>
<p>And to make the PSoC read one byte at a time from the I2C do this &#8230; notice for some reason I didnt put in error checking.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">int generic_read(gtt_device *device)
{
    (void)device;
     uint8 data;
     
    //uint32 returncode;
    I2C_I2CMasterSendStart( ((i2cContext_t *)device-&gt;Context)-&gt;slaveAddress,I2C_I2C_READ_XFER_MODE,((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA,&amp;data,((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    I2C_I2CMasterSendStop(((i2cContext_t *)device-&gt;Context)-&gt;timeout);
    return data;
}
</pre>
<h1>Matrix Orbital Parser</h1>
<p>The Matrix Orbital Parser is build around a function which you are supposed to call every time through your main loop.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">uint8_t gtt_parser_process(gtt_device *device)</pre>
<p>If you look in this function you will find a state machine that calls the Read function pointer, then based on the value read and the state of the state machine read in the packet.  Remember that there are two somewhat different packet formats, and this thing handles it.</p>
<pre class="lang:c decode:true ">uint8_t gtt_parser_process(gtt_device *device)
{
	int Res = device-&gt;Read(device);
	if (Res != -1)
	{
		switch (device-&gt;Parser.state)
		{
		case GTT_PARSER_IDLE:
			if (Res == 252)
				device-&gt;Parser.state = GTT_PARSER_COMMAND;
			else if (Res == 0) // Ignore 0's 
            {
                return 0;
            }
</pre>
<p>I notice in gtt_parser.h that they decided to use #defines for the states, which works, but would have been better done with an enumerated datatype.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">#define GTT_PARSER_IDLE       0
#define GTT_PARSER_COMMAND    1
#define GTT_PARSER_LENGTH_1   2
#define GTT_PARSER_LENGTH_2   3
#define GTT_PARSER_DATA       4
</pre>
<p>One thing that took a little but of looking at is how they handle the packets that come in.  Remember from the previous articles that there are three possible sources of packets that you might read from the buffer.</p>
<ol>
<li>Packets that were generated by the configuration scripts residing in the display</li>
<li>Packets that are generated from the user of the display doing something e.g. pressing a button</li>
<li>Packets that are responses to the application sending it packets (e.g. get slider value)</li>
</ol>
<p>They handle this by keeping a list of packets that are going to elicit a response.</p>
<p>The bottom line is that all of their code appears to do the right thing, and all you need to do is call the parser.</p>
<h1>Add Test Project Code to main.c</h1>
<p>I turns out that I am writing this Article after I already did all of the work for the next one where I replace the byte-by-byte parser with my own packet processor.  In order to make that work, I #ifdef to select which packet processor to use.</p>
<pre class="lang:c decode:true ">#ifdef GTT_ORIG_PARSER
// The original Matrix Orbital Byte Based Parser
    
uint8_t gtt_parser_process(gtt_device *device)</pre>
<p>PSoC Creator will allow you to add this to your project on the build settings dialog.  If you click on the compiler option, you can then add defines to the command line on the &#8220;Preprocessor Definitions&#8221; box.  Notice that I added &#8220;GTT_ORIG_PARSER&#8221;</p>
<p><a href="https://iotexpert.com/2018/06/18/matrix-orbital-gtt43a-driver-library-part-1/screen-shot-2018-06-15-at-7-46-24-am/" rel="attachment wp-att-5293"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-7.46.24-AM-1024x605.png" alt="" width="1024" height="605" class="alignnone size-large wp-image-5293" srcset="https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-7.46.24-AM-1024x605.png 1024w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-7.46.24-AM-600x355.png 600w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-7.46.24-AM-300x177.png 300w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-7.46.24-AM-768x454.png 768w, https://iotexpert.com/wp-content/uploads/2018/06/Screen-Shot-2018-06-15-at-7.46.24-AM.png 1682w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>OK now the punchline.  In the main loop you need to startup the I2C, UART and setup the GTT interface.  Then you loop infinitely.  Read a key from the keyboard and do something based on what they press.</p>
<p>You can see that I call a bunch of their driver functions which all start with &#8220;gtt_&#8221;.</p>
<pre class="lang:c decode:true">int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    I2C_Start();
    UART_Start();
    UART_UartPutString("Started\r\n");
    
    gtt_device *gtt = &amp;gtt_device_instance;
    char c;
    int16_t val;
    while (1)
    {
        c = UART_UartGetChar();
        switch(c)
        {
            case 0:  break;
            case 'l':   gtt_draw_line(gtt, 0, 0, 480, 272);  break; 
            case 'c': gtt_clear_screen(gtt);  break;
            case 'R':  gtt_reset(gtt);      break;                  
            case 'v':
                gtt25_get_gauge_value(gtt,9,&amp;val);
                sprintf(buff,"Gauge Value = %d\r\n",val);
                UART_UartPutString(buff);
                break;
            case 'z':
                UART_UartPutString("System Mode = IDLE\r\n");
                systemMode = MODE_IDLE;
                break;
            case 'Z':
                UART_UartPutString("System Mode = POLLING\r\n");
                systemMode = MODE_POLLING;
            break;
            case '?':
                UART_UartPutString("-------- GTT Display Functions -------\r\n");
                UART_UartPutString("l\tDraw a line\r\n");
                UART_UartPutString("c\tClear Screen\r\n");
                UART_UartPutString("R\tReset\r\n");
                UART_UartPutString("v\tGet and print value of gauge \r\n");
                UART_UartPutString("-------- System Control Functions -------\r\n");
                UART_UartPutString("z\tSystemMode = IDLE\r\n");
                UART_UartPutString("Z\tSystemMode = POLLING\r\n");
            break;    
        }
        if(systemMode == MODE_POLLING)
            gtt_parser_process(gtt);
                
    }
    return 0;
}
</pre>
<p>In the next article I am going to replace their &#8220;gtt_parser_process&#8221; with a complete packet reader.</p>
<p><span><p>You can "git" these projects from</p>
<p>https://github.com/iotexpert/GTT43A</p>
<p>And the driver library from </p>
<p>https://github.com/iotexpert/GTT-Client-Library</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Title</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/">Matrix Orbital GTT43: A Cool Display</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/">Matrix Orbital GTT43A: Serial Interface</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/">Matrix Orbital GTT43A: GTT Scripts</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/24/matrix-orbital-gtt43a-psoc-4-interface/" target="_blank" rel="noopener">Matrix Orbital GTT43A: A PSoC 4 Interface</a></td>
</tr>

<tr><td >Matrix Orbital GTT43A: Debugging the I2C</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: PSoC 6 using RTOS and the GTT Driver Library</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/matrix-orbital-gtt43a-driver-library-part-1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Matrix Orbital GTT43A: PSoC 4 Interface</title>
		<link>https://iotexpert.com/matrix-orbital-gtt43a-psoc-4-interface/</link>
					<comments>https://iotexpert.com/matrix-orbital-gtt43a-psoc-4-interface/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Thu, 24 May 2018 12:00:10 +0000</pubDate>
				<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[Matrix Orbital]]></category>
		<category><![CDATA[PSoC 4200]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=5143</guid>

					<description><![CDATA[Summary In the last several articles I have written about how to use and talk to the Matrix Orbital GTT43A.  Now it is time to write some code.  The PSoC4 program that I am going to show you has evolved over time as I added stuff to it.  For instance, while I was working on [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the last several articles I have written about how to use and talk to the <a href="https://www.matrixorbital.com/gtt43a" target="_blank" rel="noopener">Matrix Orbital GTT43A</a>.  Now it is time to write some code.  The PSoC4 program that I am going to show you has evolved over time as I added stuff to it.  For instance, while I was working on this program I ran into a problem where the I2C Bus would hang (the subject of the next article).  As such, some of the code that is in this program was written to help me debug that problem.  With that said, I wanted a program that:</p>
<ol>
<li>Is command line driven i.e. I can interact with my program via serial commands through the PC COM Port</li>
<li>Can read 1 byte at a time (like I do on the bridge control panel)</li>
<li>Can test the &#8220;read whole packet&#8221; code</li>
<li>Can selectively send commands via a I2C or the UART</li>
<li>Send test commands to the display e.g. reset, clear</li>
<li>Test the display generated messages (like button presses)</li>
</ol>
<p>All of this code was built to run on the <a href="http://www.cypress.com/documentation/development-kitsboards/cy8ckit-044-psoc-4-m-series-pioneer-kit" target="_blank" rel="noopener">CY8CKIT-044</a> which has a PSoC 4200M MCU</p>
<h1>Schematic &amp; Pin Assignment</h1>
<p>All PSoC 4 projects start with a schematic.  In my schematic I have a UART setup to talk to the KitProg (called UART) and serve as the command processor, an I2C which directly attaches to the I2C bus that drives the display, and a UART that is also attached to the display which I called SCRUART.</p>
<p>The I2CFAIL pin in the schematic I used to help me debug the I2C problem (the subject of the next article)</p>
<p><a href="https://iotexpert.com/?attachment_id=5254" rel="attachment wp-att-5254"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-21-at-12.29.07-PM.png" alt="PSoC 4200m Schematic" width="347" height="349" class="alignnone wp-image-5254 size-full" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-21-at-12.29.07-PM.png 347w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-21-at-12.29.07-PM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-21-at-12.29.07-PM-150x150.png 150w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-21-at-12.29.07-PM-298x300.png 298w" sizes="auto, (max-width: 347px) 100vw, 347px" /></a></p>
<p>The pin assignment has the UART attached to the KitProg UART, the I2C attached to KitProg and the Display.  The SCRUART is attached to UART on the Display.</p>
<p><a href="https://iotexpert.com/?attachment_id=5253" rel="attachment wp-att-5253"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-21-at-12.29.18-PM.png" alt="PSoC 4200M Pin Assignment" width="456" height="204" class="alignnone wp-image-5253 size-full" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-21-at-12.29.18-PM.png 456w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-21-at-12.29.18-PM-300x134.png 300w" sizes="auto, (max-width: 456px) 100vw, 456px" /></a></p>
<p>&nbsp;</p>
<h1>Main Event Loop</h1>
<p>The main event loop has the following parts</p>
<ol>
<li>Read a character from the keyboard</li>
<li>Process the keyboard command character</li>
<li>Read data from the screen
<ol>
<li>If you are in packet mode read a whole packet</li>
<li>If you are in streaming mode read one byte</li>
</ol>
</li>
</ol>
<p>There are three system modes.</p>
<ol>
<li>IDLE = Dont read from the screen</li>
<li>PACKET = Read whole packets (poll for complete packets)</li>
<li>STREAMING = read bytes (polling)</li>
</ol>
<p>I also have setup the program to read/write bytes to the UART and I2C.  This is called the &#8220;comInterface&#8221;.</p>
<p>The enumerated type systemMode is used to setup the polling mode (each time through the main loop, what does it do?).</p>
<pre class="start-line:18 lang:c decode:true">typedef enum {
    MODE_IDLE,
    MODE_PACKET,
    MODE_STREAMING
} systemMode_t;

systemMode_t systemMode=MODE_IDLE;

typedef enum {
    INTERFACE_I2C,
    INTERFACE_UART
} cominterface_t;

cominterface_t comInterface=INTERFACE_I2C;
</pre>
<p>The actual main section of the code</p>
<ol>
<li>Starts by initializing the UART, SCRUART and I2C.</li>
<li>On line 299 it reads a character, then switches on the character to figure out which command the user has type.</li>
</ol>
<p>You can see that &#8216;u&#8217; and &#8216;U&#8217; change the communication interface from UART to I2C and back.</p>
<pre class="start-line:285 lang:c decode:true">int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    uint32 returncode;
    
    UART_Start();
    UART_UartPutString("Started\r\n");
    I2C_Start();
    SCRUART_Start();
    
    char c;
     
    for(;;)
    {
        c = UART_UartGetChar();
        switch(c)
        {
            case 0:
            break;
            
            case 'u':
                UART_UartPutString("I2C Mode\r\n");
                comInterface = INTERFACE_I2C;
            break;
            
            case 'U':
                UART_UartPutString("UART Mode\r\n");
                comInterface = INTERFACE_UART;
            break;
</pre>
<p>The end of the loop handles the &#8220;?&#8221; case&#8230; in other words print out all of the commands.  Then based on the system mode, it either reads a whole message packet from the display or it reads only byte.</p>
<pre class="start-line:398 lang:c decode:true">           case '?':
                UART_UartPutString("------Communication Mode------\r\n");
                UART_UartPutString("u\tI2C Mode\r\n");
                UART_UartPutString("U\tUART Mode\r\n");
                
                UART_UartPutString("------GTT43A Commands------\r\n");
                UART_UartPutString("N\tDefault Comm None\r\n");
                UART_UartPutString("I\tDefault Comm I2C\r\n");
                UART_UartPutString("S\tDefault Comm Serial\r\n");
                
                UART_UartPutString("e\tEcho abc\r\n");
                UART_UartPutString("R\tReset\r\n");
                UART_UartPutString("c\tSend Clear Screen\r\n");
                
                UART_UartPutString("------Communcation Commands------\r\n");
                UART_UartPutString("r\tRead one byte if IDLE\r\n");
                UART_UartPutString("p\tRead Packet if IDLE\r\n");
                
                UART_UartPutString("------System Mode------\r\n");
                UART_UartPutString("0\tTurn I2C polling off \r\n");
                UART_UartPutString("1\tTurn on I2C packet polling\r\n");
                UART_UartPutString("2\tRead i2c bytes \r\n");
                
                UART_UartPutString("------I2C Debugging------\r\n");
                UART_UartPutString("s\tPrint SCB Status\r\n");
                UART_UartPutString("z\tSend I2C Reset Sequence\r\n");
                UART_UartPutString("x\tPrint I2C SCL and SDA value\r\n");
            break;
        }
        
        switch(systemMode)
        {
            case MODE_IDLE:
            break;
            
            case MODE_PACKET:
                readPacket();
            break;
                
            case MODE_STREAMING:
                readByte();
            break;
        }</pre>
<p>I created three keys (0,1,2) to change the system mode, from IDLE, to reading whole packets to reading bytes.</p>
<pre class="start-line:361 lang:c decode:true ">            // System Modes
            case '0':
                    I2CFAIL_Write(0);
                    UART_UartPutString("Packet Poling Off\r\n");
                    systemMode = MODE_IDLE;
                break;
               
            case '1':
                    I2CFAIL_Write(0);
                    UART_UartPutString("Packet Poling On\r\n");
                    systemMode = MODE_PACKET;
            break;
            case '2':
                    I2CFAIL_Write(0);
                    UART_UartPutString("Read continuous\r\n");
                    systemMode = MODE_STREAMING;
                    break;
</pre>
<p>While I was trying to figure out how things worked I wanted to be able to do one thing at a time. So I create &#8216;r&#8217; to read one byte (like Bridge Control Panel) and &#8216;p&#8217; to read a whole packet.  Notice that you really really only want to do this why you are not polling the display.</p>
<pre class="start-line:347 EnlighterJSRAW" data-enlighter-language="c" ">            // If you are IDLE you can read 1 byte with 'r' or read a whole packet with 'p'
            case 'r':  // Read byte
                if(systemMode != MODE_IDLE)
                    break;
                readByte(&amp;data);
                
            break;
            case 'p': // read packet
                if(systemMode == MODE_IDLE)
                    readPacketI2C();
            break;
</pre>
<p>The last section of commands send various GTT2.0 commands to the display.  Notice that the writePacket function knows which system interface to use (either I2C or UART).</p>
<p>First, I declare some commands, just an array of bytes.</p>
<pre class="start-line:6 lang:c decode:true ">// These commands come the GTT 2.0 and GTT2.5 Protocol Manuals
uint8 clearCMD[] = { 0x58 };
uint8 resetCMD[] = { 0x01};
uint8 comI2CCMD[] = { 0x05, 0x02};
uint8 comNONECMD[] = { 0x05, 0x00};
uint8 comSERIALCMD[] = { 0x05, 0x01};
uint8 comECHOCMD[] = {0xFF,'a','b','c', 0};
</pre>
<p>Then I use them:</p>
<pre class="start-line:318 EnlighterJSRAW" data-enlighter-language="c" ">            case 'e':
                UART_UartPutString("Send Echo Command\r\n");
                writePacket(sizeof(comECHOCMD) , comECHOCMD);
            break;
                
            case 'c':
                UART_UartPutString("Sent Clear String\r\n");
                writePacket(sizeof(clearCMD),clearCMD);
            break;
            case 'R':
                UART_UartPutString("Sent Reset String\r\n");
                writePacket(sizeof(resetCMD),resetCMD);
            break;
            case 'I':
                UART_UartPutString("I2C Communcation Channel\r\n");
                writePacket(sizeof(comI2CCMD),comI2CCMD);
            break;
            case 'N':
                UART_UartPutString("NONE Communcation Channel\r\n");
                writePacket(sizeof(comNONECMD),comNONECMD);
            break;</pre>
<h1>Read Byte</h1>
<p>In order to read one byte from the display I first determine which mode Im in, then call the appropriate sub-function.</p>
<pre class="start-line:269 lang:c decode:true ">uint32_t readByte(uint8_t *data)
{
    uint32_t returncode=0;
    switch(comInterface)
    {
        case INTERFACE_I2C:
            returncode = readByteI2C(data);
        break;
        case INTERFACE_UART:
            returncode = readByteUART(data);
        break;
    }
    sprintf(buff,"Returncode = %X Data=%d\r\n",(unsigned int)returncode,*data);
    UART_UartPutString(buff);

    return returncode;
}</pre>
<p>The first sub function to read bytes via I2C.  To read a byte with no error checking you have to</p>
<ol>
<li>Send a Start</li>
<li>Send the address</li>
<li>Send the Read bit</li>
<li>Clock it 8 times (this is exactly what the I2CMasterReadByte function does)</li>
<li>Send an NAK</li>
<li>Send a Stop</li>
</ol>
<p>I ran into an I2C issue which I will talk about in the next article, however, if I see an error from any of these commands Ill put the system into MODE_IDLE and throw an error.  In addition I write a 1 to the I2CFAIL pin, which I am using to trigger the Oscilliscope (so I can see what is happening)</p>
<pre class="start-line:221 lang:c decode:true ">uint32_t readByteI2C(uint8_t *data)
{
    uint32 returncode;
    returncode = I2C_I2CMasterSendStart(I2CADDR,I2C_I2C_READ_XFER_MODE , I2CTIMEOUT);
    if(returncode)
    {
        sprintf(buff,"send start error %lX status %lX\r\n",returncode,I2C_I2CMasterStatus());
        UART_UartPutString(buff);
        I2CFAIL_Write(1);
        systemMode = MODE_IDLE;
        goto cnt;
    }
            
    returncode = I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA,data,I2CTIMEOUT);
    if(returncode)
    {
        sprintf(buff,"read byte error %lX status %lX sda=%d scl =%d\r\n",returncode,I2C_I2CMasterStatus(),I2C_sda_Read(),I2C_scl_Read());
        UART_UartPutString(buff);
        I2CFAIL_Write(1);
        systemMode = MODE_IDLE;
        goto cnt;
    }
            
    returncode = I2C_I2CMasterSendStop(I2CTIMEOUT);
    if(returncode)
    {
        sprintf(buff,"send stop error %lX status %lX\r\n",returncode,I2C_I2CMasterStatus());
        UART_UartPutString(buff);
        I2CFAIL_Write(1);
        systemMode = MODE_IDLE;
        goto cnt;
    }
    
    cnt:
    return returncode;
}
</pre>
<h1>Read Packet</h1>
<p>For the packet read code I did the same thing as the byte read code.  Specifically I wrote an overall get packet, then called the correct read packet based on the</p>
<p>If you read the source code that Matrix Orbital gives you for drivers, you will find that it reads one byte at a time.  The problem with doing this is that you</p>
<ol>
<li>Send a start</li>
<li>Send an I2C address</li>
<li>Send a read bit</li>
<li>Read the ACK</li>
<li>Read a byte</li>
<li>Send a NAK</li>
<li>Send a stop</li>
</ol>
<p>The problem with this approach is that it uses 11 bit-times extra per byte of overhead (steps 1-4) which kinda sucks.  So I wanted to write a complete packet reader.  My packet reader will</p>
<ol>
<li>Send a start</li>
<li>Send an I2C address</li>
<li>Send a read bit</li>
<li>Read the ACK</li>
<li>Read a byte  [This is the 254 that marks the start of the packet]</li>
<li>ACK</li>
<li>Read a byte [This is the command which identifies the packet]</li>
<li>ACK</li>
<li>Read a byte [The MSB of the Length]</li>
<li>ACK</li>
<li>Read a byte [The LSB of the Length]</li>
<li>NAK</li>
<li>If there is a length then:</li>
<li>Send the start</li>
<li>Send an I2C address</li>
<li>Send a read bit</li>
<li>Read the ACK</li>
<li>read length -1 bytes</li>
<li>ACK</li>
<li>Read the last byte</li>
<li>Send a NAK</li>
<li>Send a stop</li>
</ol>
<p>By spec you are supposed to NAK your last read byte to indicate that your read transaction is over&#8230; that means you have to NAK the last Length byte because there could be 0 bytes to read, in which case you would need to stop.  It would have been nice if the protocol let you send only one start, but Im pretty sure it was designed for UART, which doesn&#8217;t suffer from this problem.  Also as a side note, Im pretty sure that the MCU they are using doesn&#8217;t really care, but Im not willing to implement it incorrectly.</p>
<p>Here is the code:</p>
<pre class="start-line:93 lang:c decode:true ">void readPacketI2C()
{
    int length;
    int command;
    uint8_t data;
    uint32_t returncode;
    
    returncode = I2C_I2CMasterSendStart(I2CADDR,I2C_I2C_READ_XFER_MODE , I2CTIMEOUT);
    returncode |= I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA,&amp;data,I2CTIMEOUT);
    returncode |= I2C_I2CMasterSendStop(I2CTIMEOUT);
    
    // Something bad happened on the I2C Bus ....
    if(returncode)
    {
        systemMode = MODE_IDLE; 
        sprintf(buff,"I2C Return Code %X\r\n",(unsigned int)returncode);
        UART_UartPutString(buff);
    }
 
    // The screen returns a 0 when there is nothing in the buffer.
    if(data == 0)
    {
        return;
    }

    // This is bad because there was something other than a packet start byte
    if(data != 252)
    {
        sprintf(buff,"bad data = %d\r\n",data);
        UART_UartPutString(buff);
        systemMode = MODE_IDLE; // put it into nothing mode...
        return;
    }
    
    // We know that we have a command
    returncode = I2C_I2CMasterSendStart(I2CADDR,I2C_I2C_READ_XFER_MODE , I2CTIMEOUT);
    returncode |= I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA,&amp;data,I2CTIMEOUT); // command
    command = data;
    
    returncode |= I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA,&amp;data,I2CTIMEOUT); // length
    length = data&lt;&lt;8;
    returncode |= I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA,&amp;data,I2CTIMEOUT); // length
    length = length + data;
    returncode |= I2C_I2CMasterSendStop(I2CTIMEOUT);
    
    // If the packet has any data... then read it.
    if(length != 0)
    {
        returncode |= I2C_I2CMasterSendStart(I2CADDR,I2C_I2C_READ_XFER_MODE , I2CTIMEOUT);
    
        for(int i=0;i&lt;length-1; i++)
        {
            I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA,&amp;data,I2CTIMEOUT); // length
            inbuff[i] = data;
        }

        // Read the last byte
        I2C_I2CMasterReadByte(I2C_I2C_NAK_DATA,&amp;data,I2CTIMEOUT); // length
        inbuff[length-1] = data;
        returncode |= I2C_I2CMasterSendStop(I2CTIMEOUT);
        
        I2C_I2CMasterSendStop(I2CTIMEOUT);
    }
      
    sprintf(buff,"command = %d length = %d bytes= ",command,length);
    UART_UartPutString(buff);
    for(int i=0;i&lt;length;i++)
    {
        sprintf(buff,"%d ",inbuff[i]);
        UART_UartPutString(buff);
    }
    UART_UartPutString("\r\n");
    
}
</pre>
<p><span><p>You can "git" these projects from</p>
<p>https://github.com/iotexpert/GTT43A</p>
<p>And the driver library from </p>
<p>https://github.com/iotexpert/GTT-Client-Library</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Title</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/">Matrix Orbital GTT43: A Cool Display</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/">Matrix Orbital GTT43A: Serial Interface</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/">Matrix Orbital GTT43A: GTT Scripts</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/24/matrix-orbital-gtt43a-psoc-4-interface/" target="_blank" rel="noopener">Matrix Orbital GTT43A: A PSoC 4 Interface</a></td>
</tr>

<tr><td >Matrix Orbital GTT43A: Debugging the I2C</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: PSoC 6 using RTOS and the GTT Driver Library</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/matrix-orbital-gtt43a-psoc-4-interface/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Matrix Orbital GTT43A: GTT Scripts</title>
		<link>https://iotexpert.com/matrix-orbital-gtt43a-gtt-scripts/</link>
					<comments>https://iotexpert.com/matrix-orbital-gtt43a-gtt-scripts/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 22 May 2018 10:25:43 +0000</pubDate>
				<category><![CDATA[Matrix Orbital]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=5194</guid>

					<description><![CDATA[Summary As I have been working my way through understanding the Matrix Orbital displays, I think that the whole scheme for programming them is very clever.  The bottom line of this article is that Matrix Orbital created a command language for making things work in the display, then the built the rest of their toolset [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>As I have been working my way through understanding the Matrix Orbital displays, I think that the whole scheme for programming them is very clever.  The bottom line of this article is that Matrix Orbital created a command language for making things work in the display, then the built the rest of their toolset around that language.  In this article Ill show you how it is all connected.</p>
<h1>A Buffer Full of Mystery</h1>
<p>While I was trying to understand how the GTT Support Tool works, I send a &#8220;Reset Module&#8221; also known as {254, 1}.  When I ran the script, the screen rebooted, and then the serial monitor dumped out a boat load of stuff.  You can see it in the picture below:</p>
<p><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/screen-shot-2018-05-15-at-3-26-28-pm/" rel="attachment wp-att-5200"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.26.28-PM-1024x404.png" alt="" width="1024" height="404" class="alignnone size-large wp-image-5200" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.26.28-PM-1024x404.png 1024w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.26.28-PM-600x237.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.26.28-PM-300x118.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.26.28-PM-768x303.png 768w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.26.28-PM.png 1133w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>This was not very different than when I first attached to the screen using the Bridge Control Panel.  Here are the first I2C reads after the reboot.</p>
<p><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/screen-shot-2018-05-15-at-3-23-02-pm/" rel="attachment wp-att-5199"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.23.02-PM.png" alt="" width="868" height="706" class="alignnone size-full wp-image-5199" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.23.02-PM.png 868w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.23.02-PM-600x488.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.23.02-PM-300x244.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.23.02-PM-768x625.png 768w" sizes="auto, (max-width: 868px) 100vw, 868px" /></a></p>
<p>So, what is all of this stuff?  The answer to that question resides in how this whole thing is put together.</p>
<h1>GTT Scripts</h1>
<p>All interactions with the display are done via the command language.  There are multiple paths for sending commands to the screen, the ones we have talked about so far, I2C, USB and UART.  And the one path that I have not specifically talked about but works exactly the same way, the mass storage sd-card.</p>
<p>When you design a screen in GTT Designer, what it does is take that screen, and spit out a text based command language.  Here is a screenshot of that for the test project that I am working on.</p>
<p><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/screen-shot-2018-05-15-at-3-37-04-pm/" rel="attachment wp-att-5201"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.37.04-PM.png" alt="" width="698" height="644" class="alignnone size-full wp-image-5201" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.37.04-PM.png 698w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.37.04-PM-600x554.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.37.04-PM-300x277.png 300w" sizes="auto, (max-width: 698px) 100vw, 698px" /></a></p>
<p>Then GTT Designer compiles the text into a binary file with the GTT2.0 and GTT2.5 commands.  You can look at the binary file with a binary file editor.  Here it is for Screen1.bin</p>
<p><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/screen-shot-2018-05-15-at-3-38-45-pm/" rel="attachment wp-att-5202"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.38.45-PM.png" alt="" width="637" height="503" class="alignnone size-full wp-image-5202" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.38.45-PM.png 637w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.38.45-PM-600x474.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.38.45-PM-300x237.png 300w" sizes="auto, (max-width: 637px) 100vw, 637px" /></a></p>
<p>And you should recognize the bytes you see.  Look at the top and you will see {FE, 05, 00} which in decimal is {254, 05, 00} and if you look in the GTT20 manual you will find that is &#8220;Set Communication Channel to None&#8221;.  Here is the screenshot from the manual.</p>
<p><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/screen-shot-2018-05-15-at-3-40-43-pm/" rel="attachment wp-att-5203"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.40.43-PM.png" alt="" width="811" height="411" class="alignnone size-full wp-image-5203" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.40.43-PM.png 811w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.40.43-PM-600x304.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.40.43-PM-300x152.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.40.43-PM-768x389.png 768w" sizes="auto, (max-width: 811px) 100vw, 811px" /></a></p>
<p>But, what happens when the device boots?  Well, they followed the lead from MS-DOS and created a file called &#8220;autoexec&#8221;.  And, if you look in that file they so graciously tell you what happens.</p>
<p><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/screen-shot-2018-05-15-at-3-42-19-pm/" rel="attachment wp-att-5204"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.42.19-PM.png" alt="" width="595" height="413" class="alignnone size-full wp-image-5204" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.42.19-PM.png 595w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-3.42.19-PM-300x208.png 300w" sizes="auto, (max-width: 595px) 100vw, 595px" /></a></p>
<p>How cool is that?  All of these commands are just the things that you did on the project setting and the display settings.  And the last line of the file launches just launches Screen1.bin, which is just the binary file of the commands it takes to load the Screen1.</p>
<p>Now back to the original question.  What is the buffer full of mystery?  Simple, it is the output of all of the commands (if they make output) that are in the autoexec binary and the screen1 binary.  If you had happened to set the default channel to &#8220;none&#8221; you will find that the buffer doesnt have anything in it&#8230; which should make sense.</p>
<p>So, when the manual says to delete the autoexec at the top level directory in order to reset the board.  All that does it remove all of the settings that you created in your project.</p>
<p>The only thing that I wish is that they gave you access to the txt&#8211;&gt;bin compiler.  But oh well.</p>
<p><span><p>You can "git" these projects from</p>
<p>https://github.com/iotexpert/GTT43A</p>
<p>And the driver library from </p>
<p>https://github.com/iotexpert/GTT-Client-Library</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Title</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/">Matrix Orbital GTT43: A Cool Display</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/">Matrix Orbital GTT43A: Serial Interface</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/">Matrix Orbital GTT43A: GTT Scripts</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/24/matrix-orbital-gtt43a-psoc-4-interface/" target="_blank" rel="noopener">Matrix Orbital GTT43A: A PSoC 4 Interface</a></td>
</tr>

<tr><td >Matrix Orbital GTT43A: Debugging the I2C</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: PSoC 6 using RTOS and the GTT Driver Library</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/matrix-orbital-gtt43a-gtt-scripts/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Matrix Orbital GTT43A: Serial Interface</title>
		<link>https://iotexpert.com/matrix-orbital-gtt43a-serial-interface/</link>
					<comments>https://iotexpert.com/matrix-orbital-gtt43a-serial-interface/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Thu, 17 May 2018 12:00:46 +0000</pubDate>
				<category><![CDATA[Matrix Orbital]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=5090</guid>

					<description><![CDATA[Summary In this article I will show you how to interact with the Matrix Orbital GTT43A display using the GTT Support Tool via the KitProg UART on a CY8CKIT-044  and the Bridge Control Panel via I2C.  This article will be broken up into four parts Building a Test Project in GTT Designer GTT Protocol 2.0 [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In this article I will show you how to interact with the Matrix Orbital <a href="https://www.matrixorbital.com/gtt43a" target="_blank" rel="noopener">GTT43A</a> display using the GTT Support Tool via the KitProg UART on a CY8CKIT-044  and the Bridge Control Panel via I2C.  This article will be broken up into four parts</p>
<ol>
<li>Building a Test Project in GTT Designer</li>
<li>GTT Protocol 2.0</li>
<li>GTT Protocol 2.5</li>
<li>GTT Support Tool</li>
<li>Bridge Control Panel</li>
</ol>
<h1>Build a Test Project</h1>
<p>In order to understand the whole serial interface, I will build a very simple project with two buttons.  You can find this project in my GitHub site at git@github.com:iotexpert/GTT43A</p>
<p>Start up a new project called &#8220;BasicTest&#8221;.  Accept the defaults for Project settings.  On the Display Settings screen change the &#8220;Default Channel&#8221; to Serial and the Flow Control to Off.  I am using the CY8CKIT-044 to talk to the screen.  On that development kit there is a KitProg which serves as a programmer (for the PSoC 4200M) and as a serial bridge.  That serial bridge does not have the flow control pins turned on.  If you leave the flow control on, the screen will never transmit and you will need to poke your eyeballs out trying to figure out why.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-09-44-pm/" rel="attachment wp-att-5153"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.09.44-PM.png" alt="" class="alignnone size-large wp-image-5153" width="286" height="594" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.09.44-PM.png 286w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.09.44-PM-144x300.png 144w" sizes="auto, (max-width: 286px) 100vw, 286px" />  </a><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-10-35-00-am/" rel="attachment wp-att-5170"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-10.35.00-AM.png" alt="" class="alignnone size-full wp-image-5170" width="285" height="593" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-10.35.00-AM.png 285w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-10.35.00-AM-144x300.png 144w" sizes="auto, (max-width: 285px) 100vw, 285px" /></a></p>
<p>Drag a Circle Button (GTT2.5) onto the screen.  Change the Text value (on the right panel) to &#8220;GTT25&#8221;</p>
<p><a href="https://iotexpert.com/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-10-55-pm/" rel="attachment wp-att-5151"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.10.55-PM-1024x718.png" alt="" class="alignnone wp-image-5151 size-large" width="1024" height="718" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.10.55-PM-1024x718.png 1024w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.10.55-PM-600x421.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.10.55-PM-300x210.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.10.55-PM-768x538.png 768w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.10.55-PM.png 1228w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a> <a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-03-38-pm/" rel="attachment wp-att-5149"></a></p>
<p>Now click on the &#8220;Legacy&#8221; tab and drag a &#8220;Circle Button&#8221; onto the screen.  Then change the text label to &#8220;Legacy&#8221;.  In addition change the &#8220;ID&#8221; from &#8220;Auto&#8221; to &#8220;2&#8221;.  I noticed that later in this article that if the button ID is &#8220;auto&#8221; it will not be identified in the messages.  Im not sure if this is a bug or my lack of understanding.</p>
<h1><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-03-38-pm/" rel="attachment wp-att-5149"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.03.38-PM-1024x664.png" alt="" class="alignnone size-large wp-image-5149" width="1024" height="664" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.03.38-PM-1024x664.png 1024w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.03.38-PM-600x389.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.03.38-PM-300x195.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.03.38-PM-768x498.png 768w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.03.38-PM.png 1246w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></h1>
<p>When I click &#8220;Deploy&#8221; I end up with this error message.  This appears to be a bug in the GTT Designer.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-12-22-pm/" rel="attachment wp-att-5154"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.12.22-PM.png" alt="" class="alignnone size-full wp-image-5154" width="422" height="270" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.12.22-PM.png 422w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.12.22-PM-300x192.png 300w" sizes="auto, (max-width: 422px) 100vw, 422px" /></a></p>
<p>Click on the &#8220;Font&#8221; and go to the directory where the Font is supposed to be&#8230; and find that it is actually empty.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-15-01-pm/" rel="attachment wp-att-5156"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.01-PM.png" alt="" class="alignnone size-large wp-image-5156" width="769" height="652" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.01-PM.png 769w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.01-PM-600x509.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.01-PM-300x254.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.01-PM-768x651.png 768w" sizes="auto, (max-width: 769px) 100vw, 769px" /></a></p>
<p>So.  I navigate up a directory and then down into &#8220;LibraSans&#8221; instead of &#8220;libra-sans-modern&#8221;.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-15-19-pm/" rel="attachment wp-att-5155"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.19-PM.png" alt="" class="alignnone size-full wp-image-5155" width="771" height="652" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.19-PM.png 771w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.19-PM-600x507.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.19-PM-300x254.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.15.19-PM-768x649.png 768w" sizes="auto, (max-width: 771px) 100vw, 771px" /></a></p>
<p>Once that is done press &#8220;Deploy&#8221;, and I get Success!</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-45-19-pm/" rel="attachment wp-att-5157"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.45.19-PM.png" alt="" class="alignnone size-full wp-image-5157" width="585" height="441" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.45.19-PM.png 585w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.45.19-PM-300x226.png 300w" sizes="auto, (max-width: 585px) 100vw, 585px" /></a></p>
<p>Now that I have the project built I need to wire the whole mess together.  I am going to use a <a href="http://www.cypress.com/documentation/development-kitsboards/cy8ckit-044-psoc-4-m-series-pioneer-kit" target="_blank" rel="noopener">CY8CKIT-044</a>.  This development kit has a PSoC4200M.  Although the project is using a PSoC6, I didnt have any level translators at my house (bad Alan) and I wanted to get going &#8230; so I used the 5V tolerant PSoC 4. [note: it turns out that the MCU used on the display has 5V tolerant serial I/Os but is a 3.3v MCU so I could have used it directly on the PSoC 6 without this work around]  On the far left of the development kit, right next to the USB is the KitProg connector.  This connector has an I2C Master and a UART Bridge.  In addition I can connect the I2C pins to PSoC, the Display and the Bridge.  Here is the schematic for the whole mess.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/schematic-5/" rel="attachment wp-att-5162"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/schematic-1024x595.png" alt="" class="alignnone size-large wp-image-5162" width="1024" height="595" srcset="https://iotexpert.com/wp-content/uploads/2018/05/schematic-1024x595.png 1024w, https://iotexpert.com/wp-content/uploads/2018/05/schematic-600x349.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/schematic-300x174.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/schematic-768x446.png 768w, https://iotexpert.com/wp-content/uploads/2018/05/schematic.png 1165w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>When you look on the back of the CY8CKIT-044 you can see the same wiring diagram on the silkscreen.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/img_5885/" rel="attachment wp-att-5164"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5885-1005x1024.jpg" alt="" class="alignnone size-large wp-image-5164" width="1005" height="1024" srcset="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5885-1005x1024.jpg 1005w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5885-600x611.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5885-294x300.jpg 294w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5885-768x783.jpg 768w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5885.jpg 1841w" sizes="auto, (max-width: 1005px) 100vw, 1005px" /></a></p>
<p>Here is a picture of the development kit.  You can see the top green/yellow wires go to P40/P41 (that is the I2C Bus) and the other green/yellow set goes to P12[6] and P12[7] that is the KitProg UART.  I suppose I should have used different colors for I2C and UART&#8230; oh well.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/img_5887/" rel="attachment wp-att-5165"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5887-e1526145924226-1024x768.jpg" alt="" class="alignnone wp-image-5165 size-large" width="1024" height="768" srcset="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5887-e1526145924226-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5887-e1526145924226-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5887-e1526145924226-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5887-e1526145924226-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>And finally the whole mess.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/img_5884/" rel="attachment wp-att-5160"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5884-768x1024.jpg" alt="" class="alignnone size-large wp-image-5160" width="768" height="1024" srcset="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5884-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5884-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5884-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5884-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<h1>GTT43A Protocol 2.0</h1>
<p>They way that the system works is you can send a command data packet to the display via one of the serial interfaces and then if there is a response required,  it will respond with a response data packet.  In addition when some event occurs on the display (like a touch screen button being pressed) it will send you a response data packet.</p>
<p>There are two GTT Protocols, one called 2.0 and one called 2.5.  First the <a href="https://www.matrixorbital.com/index.php?route=extension/module/product_downloads/get&amp;did=17" target="_blank" rel="noopener">2.0 protocol</a>.  You send messages in the GTT2.0 command data packet format.  That format is simple:</p>
<ol>
<li>254 &#8211; 1 byte</li>
<li>Message ID (look in the manual for all of the legal message codes) &#8211; 1 byte</li>
<li>Optional data 0-n bytes</li>
</ol>
<p>If there is a required response, the screen will respond with a data packet in the following format</p>
<ol>
<li>252 &#8211; 1 byte</li>
<li>Message ID &#8211; 1 byte</li>
<li>Length MSB &#8211; 1 byte</li>
<li>Length LSB &#8211; 1 byte</li>
<li>Optional Data &#8211; 0&#8211;&gt;65535 bytes</li>
</ol>
<p>The total length of the response will be (length msb) &lt;&lt; 8 | length lsb &#8211; big endian.</p>
<p>For example a command with no optional data &#8230;. like reset will look like this { 252, 1 }. [obviously dont send the braces or the comma]</p>
<p>A command with some optional data is &#8220;Set Backlight Brightness&#8221;. If you want the brightness set to 23% you would send is {252, 153, 23}.</p>
<p>An example of a command that will respond with a response data packet is &#8220;Get Module Type&#8221; where you would send {254, 55 } and the screen would respond with {252, 55, 00 02 147 01}.  Here is the picture from the manual.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-10-55-02-am/" rel="attachment wp-att-5171"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-10.55.02-AM.png" alt="" class="alignnone size-full wp-image-5171" width="817" height="365" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-10.55.02-AM.png 817w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-10.55.02-AM-600x268.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-10.55.02-AM-300x134.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-10.55.02-AM-768x343.png 768w" sizes="auto, (max-width: 817px) 100vw, 817px" /></a></p>
<p>When you look at the picture above there are several things to be <strong>VERY</strong> careful about.</p>
<p>First, the Matrix Orbital people appear to think in decimal not hex.  So they show you {252,55,00,02,147,01) instead of (0xFE, 0x37, 0x00, 0x02, 0x93, 0x01}.  Notice that my GTT43A value is decimal 37633 which is also known as Hex 0x9301.  I  often found myself typing hex when I mean decimal and vice versa.</p>
<p>The second thing to be careful about is that they send values in big endian&#8230; so if you are using an ARM processor be aware as ARM is almost always little endian.</p>
<p>The third thing to be careful about is that the length parameter in the message is always 16-bit Big Endian even though the documentation often shortens this to &#8220;Length&#8221;</p>
<p>Lastly, if they send you a 16-bit value it will show up as big endian, and they will probably show it to you in decimal (like table 14 above).  Which can look kinda weird in decimal as it is two bytes.</p>
<h1>GTT43A Protocol 2.5</h1>
<p>As I worked on understanding what the screen is doing, I noticed that I was getting message codes that were not documented in the GTT2.0 Manual.  For example when you press a button you will get {252,235,0,5,21,0,0,1,1}.  When you look at this packet you can recognize the 252&#8230; and the message code 235 &#8230; and the length seems to make sense 5 &#8230; but the rest of the message is less clear.</p>
<p>So I called technical support, which is excellent, and Daniel agreed to send me a prerelease of the new manual.  When you look at the manual you will find:</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-11-23-41-am/" rel="attachment wp-att-5173"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-11.23.41-AM.png" alt="" class="alignnone size-full wp-image-5173" width="421" height="293" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-11.23.41-AM.png 421w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-11.23.41-AM-300x209.png 300w" sizes="auto, (max-width: 421px) 100vw, 421px" /></a></p>
<p>Which makes good sense as I pressed a button, and the object ID was &#8220;1&#8221;.  The pre release version of the manual that I got seems to be missing information, but Im hopeful they will get it done and released soon.  But for now, I can work with it.  If you need a copy of the manual you will need to contact them directly.</p>
<h1>GTT Support Tool</h1>
<p>When you install GTT Designer, it will also install a program called the GTT Support Tool.  This tool will allow you to send and receive GTT messages to/from the screen.   I have the screen attached to the UART on the KitProg Serial bridge (with jumper wires).  This means I will see the screen in the Device Manger under the Ports-&gt;KitProg (see the COM5)</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-14-47-pm/" rel="attachment wp-att-5178"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.14.47-PM.png" alt="" class="alignnone size-full wp-image-5178" width="349" height="572" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.14.47-PM.png 349w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.14.47-PM-183x300.png 183w" sizes="auto, (max-width: 349px) 100vw, 349px" /></a></p>
<p>You can run the GTT Support Tool from the Start menu or from the Tools menu on the GTT Designer.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-09-46-pm/" rel="attachment wp-att-5177"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.09.46-PM.png" alt="" class="alignnone size-large wp-image-5177" width="437" height="303" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.09.46-PM.png 437w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.09.46-PM-300x208.png 300w" sizes="auto, (max-width: 437px) 100vw, 437px" /></a></p>
<p>When the tool starts you can pick out which ComPort to talk to and setup the Flow Control (meaning use or not CTS/RTS).  The KitProg on the 4200M does not have the CTS/RTS so you need to disable it or things will not work.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-10-14-pm/" rel="attachment wp-att-5176"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.10.14-PM.png" alt="" class="alignnone size-large wp-image-5176" width="752" height="560" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.10.14-PM.png 752w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.10.14-PM-600x447.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.10.14-PM-300x223.png 300w" sizes="auto, (max-width: 752px) 100vw, 752px" /></a></p>
<p>When you press the &#8220;Test Connection&#8221; it will send a message via the UART/ComPort and wait for a response. I am not sure, but I suspect that it is sending a &#8220;Get Module&#8221; command.  In the picture below you can see that I got both the send and the receive message to work.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-10-32-pm/" rel="attachment wp-att-5175"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.10.32-PM.png" alt="" class="alignnone size-full wp-image-5175" width="755" height="559" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.10.32-PM.png 755w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.10.32-PM-600x444.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.10.32-PM-300x222.png 300w" sizes="auto, (max-width: 755px) 100vw, 755px" /></a></p>
<p>I was struggling over the weekend to get the communication to work correctly.  Specifically I was not getting return messages.  It turned out that the project that you build in the GTT Designer must have &#8220;Flow Control&#8221; turned off and the Default Channel set to Serial or the serial communication responses will not work.  Remember you can set this on the &#8220;Display Settings&#8221;</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-26-36-pm/" rel="attachment wp-att-5180"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.26.36-PM.png" alt="" class="alignnone size-full wp-image-5180" width="281" height="214" /></a></p>
<p>You can also send the commands to set the communication channel and flow control, but I found it easier to get the project to the correct settings in the GTT Designer.</p>
<p>One you have a functional connection you can click on the &#8220;Commands&#8221; tab.  On the left of the screen you will see a list of commands (well&#8230; actually on GTT2.0 commands).  On the right side of the screen you will see your &#8220;script&#8221;, which obviously starts blank.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-29-50-pm/" rel="attachment wp-att-5181"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.29.50-PM.png" alt="" class="alignnone size-full wp-image-5181" width="714" height="746" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.29.50-PM.png 714w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.29.50-PM-600x627.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.29.50-PM-287x300.png 287w" sizes="auto, (max-width: 714px) 100vw, 714px" /></a></p>
<p>The first thing that you should do is press the little split screen button just to the right of the red &#8220;X&#8221;.  When you do this it will bring up a new window that will show what is sent, and what is received.  Obviously it starts blank.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-32-44-pm/" rel="attachment wp-att-5182"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.32.44-PM.png" alt="" class="alignnone size-full wp-image-5182" width="639" height="441" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.32.44-PM.png 639w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.32.44-PM-600x414.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.32.44-PM-300x207.png 300w" sizes="auto, (max-width: 639px) 100vw, 639px" /></a></p>
<p>Now you can double click on a command, like &#8220;Get Module Version&#8221; and it will bring up the command.  When you press &#8220;OK&#8221; it will add it to the script.  You CAN change the command and it will add it the script (but with a misleading name)</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-31-37-pm/" rel="attachment wp-att-5184"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.31.37-PM.png" alt="" class="alignnone size-full wp-image-5184" width="711" height="742" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.31.37-PM.png 711w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.31.37-PM-600x626.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.31.37-PM-287x300.png 287w" sizes="auto, (max-width: 711px) 100vw, 711px" /></a></p>
<p>Here is what the window looks like after I add the &#8220;Get Module Type&#8221; command.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-37-29-pm/" rel="attachment wp-att-5185"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.37.29-PM.png" alt="" class="alignnone size-full wp-image-5185" width="716" height="209" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.37.29-PM.png 716w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.37.29-PM-600x175.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.37.29-PM-300x88.png 300w" sizes="auto, (max-width: 716px) 100vw, 716px" /></a></p>
<p>In order to Run the command, you need to click in the script window and then press the green run button.  If you have not clicked in the script window it will not run. Once you have run the command your viewer window will look like this.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-40-35-pm/" rel="attachment wp-att-5187"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.40.35-PM.png" alt="" class="alignnone size-full wp-image-5187" width="639" height="443" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.40.35-PM.png 639w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.40.35-PM-600x416.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.40.35-PM-300x208.png 300w" sizes="auto, (max-width: 639px) 100vw, 639px" /></a></p>
<p>In the window above you can see that I wrote to the serial port a {254,55} and the screen responded {252,55,0,2,147,14}.  When you decode this message don&#8217;t forget that the data above is in decimal.  In this the example the message the 147,14 is actually 0x930E which is 37646.  Unfortunately 37646 is not documented in the GTT 2.0 protocol manual (but my screen is a GTT43A).</p>
<p>Another cool thing that that happens in the Debug view is that it shows events that are initiated from the screen.  For instance in the picture below I pressed the &#8220;GTT25&#8221; button from my example project.  It show the button press and the button release.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-15-at-12-57-06-pm/" rel="attachment wp-att-5192"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.57.06-PM.png" alt="" class="alignnone size-full wp-image-5192" width="328" height="342" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.57.06-PM.png 328w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-15-at-12.57.06-PM-288x300.png 288w" sizes="auto, (max-width: 328px) 100vw, 328px" /></a></p>
<p>&nbsp;</p>
<h1>Bridge Control Panel</h1>
<p>For my real project I want to interact with the GTT43A via I2C.  For this kind of thing I always like to use the Bridge Control Panel first. I have written a bunch of <a href="https://iotexpert.com/?s=bridge+control+panel" target="_blank" rel="noopener">articles</a> about using BCP to debug.  This allows me to act as an I2C Master and see how the device acts as a slave.  The first thing that I do is press &#8220;List Devices&#8221; on the BCP.  It shows me that there are a number of things connected to the I2C bus.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-16-at-10-21-07-am/" rel="attachment wp-att-5209"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.21.07-AM.png" alt="" class="alignnone size-full wp-image-5209" width="867" height="703" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.21.07-AM.png 867w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.21.07-AM-600x487.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.21.07-AM-300x243.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.21.07-AM-768x623.png 768w" sizes="auto, (max-width: 867px) 100vw, 867px" /></a></p>
<p>You might recall that from the Display Settings that the default I2C address is 80.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-16-at-10-25-45-am/" rel="attachment wp-att-5210"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.25.45-AM.png" alt="" class="alignnone size-full wp-image-5210" width="284" height="274" /></a></p>
<p>That 80 is also known as 0x50 (here we go with the Hex / Decimal thing again).  Moreover that 80 (0x50) is an 8-Bit address, in other words shifted left 1 from the 7-bit address of 0x28.</p>
<p>After I verified that the screen was attached to the bridge control panel.  The next thing to do was to set the default communication via I2C.  Here is the section of the documentation</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-01-40-pm/" rel="attachment wp-att-5147"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.01.40-PM.png" alt="" class="alignnone size-full wp-image-5147" width="755" height="375" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.01.40-PM.png 755w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.01.40-PM-600x298.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.01.40-PM-300x149.png 300w" sizes="auto, (max-width: 755px) 100vw, 755px" /></a></p>
<p>This means that I need to send {0xFE, ox05, 0x02}.  When I send that command I get ACKs &#8230; good.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-12-at-12-00-25-pm/" rel="attachment wp-att-5146"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.00.25-PM.png" alt="" class="alignnone size-large wp-image-5146" width="867" height="760" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.00.25-PM.png 867w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.00.25-PM-600x526.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.00.25-PM-300x263.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-12-at-12.00.25-PM-768x673.png 768w" sizes="auto, (max-width: 867px) 100vw, 867px" /></a></p>
<p>The next thing that I do is test to make sure that the legacy button is working correctly.  When I press it and then read some bytes I get</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-16-at-10-31-33-am/" rel="attachment wp-att-5211"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.31.33-AM.png" alt="" class="alignnone size-full wp-image-5211" width="868" height="703" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.31.33-AM.png 868w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.31.33-AM-600x486.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.31.33-AM-300x243.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.31.33-AM-768x622.png 768w" sizes="auto, (max-width: 868px) 100vw, 868px" /></a></p>
<p>Then I press the GTT 25 Button and get {FC,EB,00,05,15,00,00,01,01} and then {FC,EB,00,05,14,00,00,01,00} in other words a press of button ID 1 and then a release of button ID 1.</p>
<p><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/screen-shot-2018-05-16-at-10-33-27-am/" rel="attachment wp-att-5212"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.33.27-AM.png" alt="" class="alignnone size-full wp-image-5212" width="860" height="805" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.33.27-AM.png 860w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.33.27-AM-600x562.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.33.27-AM-300x281.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-16-at-10.33.27-AM-768x719.png 768w" sizes="auto, (max-width: 860px) 100vw, 860px" /></a></p>
<p>Now that we understand the command protocol and we know how to talk to the screen, in the next article Ill talk about GTT Scripts.</p>
<p><span><p>You can "git" these projects from</p>
<p>https://github.com/iotexpert/GTT43A</p>
<p>And the driver library from </p>
<p>https://github.com/iotexpert/GTT-Client-Library</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Title</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/">Matrix Orbital GTT43: A Cool Display</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/">Matrix Orbital GTT43A: Serial Interface</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/">Matrix Orbital GTT43A: GTT Scripts</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/24/matrix-orbital-gtt43a-psoc-4-interface/" target="_blank" rel="noopener">Matrix Orbital GTT43A: A PSoC 4 Interface</a></td>
</tr>

<tr><td >Matrix Orbital GTT43A: Debugging the I2C</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: PSoC 6 using RTOS and the GTT Driver Library</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/matrix-orbital-gtt43a-serial-interface/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Matrix Orbital GTT43A: A Cool Display</title>
		<link>https://iotexpert.com/matrix-orbital-gtt43a-a-cool-display/</link>
					<comments>https://iotexpert.com/matrix-orbital-gtt43a-a-cool-display/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 15 May 2018 11:19:42 +0000</pubDate>
				<category><![CDATA[Matrix Orbital]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=5088</guid>

					<description><![CDATA[Summary I have recently found myself way way down a rabbit hole on a project that uses a Matrix Orbital GTT43A.   This display is a super cool, though expensive, intelligent touch screen display.  Here is a picture: I call it intelligent because it has a fully featured CPU that runs all of the display [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>I have recently found myself way way down a rabbit hole on a project that uses a Matrix Orbital <a href="https://www.matrixorbital.com/gtt43a" target="_blank" rel="noopener">GTT43A</a>.   This display is a super cool, though expensive, intelligent touch screen display.  Here is a picture:</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/img_5882/" rel="attachment wp-att-5105"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5882-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-5105" srcset="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5882-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5882-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5882-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5882-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>I call it intelligent because it has a fully featured CPU that runs all of the display and touch functions for you.  Basically you build all of the screens with GTT GUI elements (sliders, buttons, text etc.) using the Matrix Orbital design tool called GTT Designer.  Then you program that configuration into an sd-card that is attached to the display.  When you power up the display, your configuration comes up and you are off to the races.  Then, in your system you can then simply interact with the display via I2C, UART, USB or SPI.</p>
<p>I know that it seems simple, but I will say that this has turned into quite an adventure which has, in turn, been an awesome learning experience.</p>
<h1>Matrix Orbital GTT43A</h1>
<p>The Matrix Orbital GTT43A is a 4.3&#8243; backlit LCD display with a capacitive touch screen.  Here is a screenshot from the Matrix Orbital website.  Yes, you read the price right, it is $155.84&#8230;. well actually $165.84 with capacitive touch.</p>
<p>&nbsp;</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-10-33-52-am/" rel="attachment wp-att-5097"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-10.33.52-AM-1024x649.png" alt="" width="1024" height="649" class="alignnone size-large wp-image-5097" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-10.33.52-AM-1024x649.png 1024w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-10.33.52-AM-600x380.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-10.33.52-AM-300x190.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-10.33.52-AM-768x487.png 768w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-10.33.52-AM.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is a picture of the back of the screen.</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/img_5880/" rel="attachment wp-att-5094"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5880-e1526054522894-1024x768.jpg" alt="" width="1024" height="768" class="alignnone wp-image-5094 size-large" srcset="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5880-e1526054522894-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5880-e1526054522894-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5880-e1526054522894-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5880-e1526054522894-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>On the far left you can see the connector labeled &#8220;Keyboard Power&#8221;.  This is a place where you can plug in a matrix keyboard that looks like the next picture.  Though I am not exactly sure why you would make a nice touch screen interface and then use a mechanical button interface?</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/keypad4x4-300x300/" rel="attachment wp-att-5098"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/keypad4x4-300x300.png" alt="" width="300" height="300" class="alignnone size-full wp-image-5098" srcset="https://iotexpert.com/wp-content/uploads/2018/05/keypad4x4-300x300.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/keypad4x4-300x300-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2018/05/keypad4x4-300x300-150x150.png 150w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>In the middle of the picture you can see a micro-sd card which holds all of your screen configuration information.  The sd-card is a normal mass storage card and you can drag and drop your configuration, or new firmware for the screen using normal Windows.  You can also put the display into mass-storage mode and then access the card via the mini-usb-b connector that is in the upper left.</p>
<p>The display also supports 6 digital GPIOs (which you can see on the lower left of the picture).  It also has a piezoelectric buzzer and a haptic vibrator.</p>
<p>In order to talk to the display with your system controller you can use I2C, UART, SPI or USB.  It is interesting that you seem to be able to use multiple interfaces at the same time, which is pretty convenient for debugging.</p>
<p>The display requires a decent amount of juice.  Here is a picture on my desk, 5V and 375mA,  which is more than the development kit I was using will provide.  In fact it, will sort of work for a while off the devkit power supply, but when you push a button on the screen it will reboot the display.</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/img_5881/" rel="attachment wp-att-5099"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5881-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-5099" srcset="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5881-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5881-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5881-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5881-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>GTT Designer</h1>
<p>GTT Designer is a Windows GUI building tool.  It is straight forward to use.  When you start up the software it will give you a choice of displays to build for.  In the picture below you can see that it detected that I had a GTT43A attached to my computer via USB.</p>
<p>&nbsp;</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-2-48-07-pm/" rel="attachment wp-att-5109"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.07-PM.png" alt="" width="982" height="710" class="alignnone size-large wp-image-5109" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.07-PM.png 982w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.07-PM-600x434.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.07-PM-300x217.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.07-PM-768x555.png 768w" sizes="auto, (max-width: 982px) 100vw, 982px" /></a></p>
<p>After setting up the name of my project and clicking &#8220;New Project&#8221; I am given the choice of customizing the global settings for the display.</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-2-48-27-pm/" rel="attachment wp-att-5108"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.27-PM.png" alt="" width="283" height="592" class="alignnone size-large wp-image-5108" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.27-PM.png 283w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.27-PM-143x300.png 143w" sizes="auto, (max-width: 283px) 100vw, 283px" /></a></p>
<p>Once the project is setup, you are now given the ability to configure the display settings.  On this screen you can setup a number of things, including the I2C address of the display.  Also, on the screen below you can see &#8220;Default Channel&#8221; is set to none.  What this means is that any GUI thing that happens will send messages to the default channel.  In this case none.  But that isnt what I want so I change it to I2C (next picture)</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-2-48-47-pm/" rel="attachment wp-att-5107"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.47-PM.png" alt="" width="282" height="593" class="alignnone size-large wp-image-5107" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.47-PM.png 282w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.48.47-PM-143x300.png 143w" sizes="auto, (max-width: 282px) 100vw, 282px" /></a></p>
<p>What I really want it all of the output to go to the I2C.  But given that the screen is an I2C slave, and it cant send out data, what does that really mean?  What it means is that all of the output goes into a buffer, that slowly fills up until you read the data out of it via I2C.  If you setup the Default channel as Serial, the data will go directly out via UART.</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-2-49-05-pm/" rel="attachment wp-att-5106"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.49.05-PM.png" alt="" width="283" height="592" class="alignnone size-full wp-image-5106" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.49.05-PM.png 283w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.49.05-PM-143x300.png 143w" sizes="auto, (max-width: 283px) 100vw, 283px" /></a></p>
<p>Once the display settings are done you will end up with a screen that looks like this.  On the left side of the screen you can pick out the different GUI elements (buttons, text labels, sliders, images etc) and the drag them onto the screen.  Notice that there are four tabs, Tools, Legacy Tools, Assets, Overview.  At some point very recently Matrix Orbital did a massive re-engineering project to make things simpler to interact with the screen.  When they did this, the created a who new set of widgets called &#8220;GTT2.5&#8221; widgets.  You can still use the old widgets which they now call &#8220;Legacy&#8221;</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-3-19-56-pm/" rel="attachment wp-att-5110"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.19.56-PM-1024x609.png" alt="" width="1024" height="609" class="alignnone size-large wp-image-5110" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.19.56-PM-1024x609.png 1024w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.19.56-PM-600x357.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.19.56-PM-300x178.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.19.56-PM-768x456.png 768w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.19.56-PM.png 1442w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>On the screen below you can see that I placed a bunch of different GUI elements for my test project.  When you click on an element, the right hand side of the screen will let you update properties of the object e.g. color, size, name.  You can also create events (more on that in the next article)</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-2-39-17-pm/" rel="attachment wp-att-5103"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.39.17-PM-1024x680.png" alt="" width="1024" height="680" class="alignnone size-large wp-image-5103" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.39.17-PM-1024x680.png 1024w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.39.17-PM-600x398.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.39.17-PM-300x199.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.39.17-PM-768x510.png 768w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-2.39.17-PM.png 1347w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>One you have drawn your screen you then want to build and program the project.  Or in their language generate and deploy.  To do this you can either click generate then click deploy, or just click deploy.  When you do this it will first build all of your project into a directory on your computer called &#8220;Output&#8221;.  There are three interesting things in the output directory.</p>
<ol>
<li>autoexec.txt/bin &#8211; files that contains a script that runs when the display turns on (more on that in the next article)</li>
<li>Report.txt &#8211; a file that contains information about the objects, names, ids etc (this is important for your software)</li>
<li>GTTProject1 &#8211; a directory with all of the files required for your project.</li>
</ol>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-3-27-54-pm/" rel="attachment wp-att-5111"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.27.54-PM.png" alt="" width="740" height="362" class="alignnone size-full wp-image-5111" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.27.54-PM.png 740w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.27.54-PM-600x294.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.27.54-PM-300x147.png 300w" sizes="auto, (max-width: 740px) 100vw, 740px" /></a></p>
<p>When you look in the GTTProject1 directory you will see that it contains a directory for &#8220;Screen1&#8221;.  If I had made multiple screens it would have made multiple directories.  It also has a directory called &#8220;Fonts&#8221;, which big surprise, contains the Fonts that are used by the project.</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-3-34-01-pm/" rel="attachment wp-att-5113"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.34.01-PM.png" alt="" width="933" height="550" class="alignnone size-full wp-image-5113" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.34.01-PM.png 933w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.34.01-PM-600x354.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.34.01-PM-300x177.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.34.01-PM-768x453.png 768w" sizes="auto, (max-width: 933px) 100vw, 933px" /></a></p>
<p>In the &#8220;Screen1&#8221; directory you will see a bunch of bitmap files, text files etc.</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-3-31-25-pm/" rel="attachment wp-att-5112"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.31.25-PM.png" alt="" width="942" height="555" class="alignnone size-full wp-image-5112" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.31.25-PM.png 942w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.31.25-PM-600x354.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.31.25-PM-300x177.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-3.31.25-PM-768x452.png 768w" sizes="auto, (max-width: 942px) 100vw, 942px" /></a></p>
<p>Screen1.txt contains a textual version of the &#8220;program&#8221; that creates the screen.  Here is a snapshot of the top of the file.</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-4-16-52-pm/" rel="attachment wp-att-5114"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.16.52-PM.png" alt="" width="809" height="380" class="alignnone size-full wp-image-5114" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.16.52-PM.png 809w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.16.52-PM-600x282.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.16.52-PM-300x141.png 300w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.16.52-PM-768x361.png 768w" sizes="auto, (max-width: 809px) 100vw, 809px" /></a></p>
<p>And &#8220;Screen1.bin&#8221; which is the compiled version of the &#8220;Screen1.txt&#8221;- more on this in the next article.</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-4-23-27-pm/" rel="attachment wp-att-5115"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.23.27-PM.png" alt="" width="724" height="508" class="alignnone size-full wp-image-5115" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.23.27-PM.png 724w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.23.27-PM-600x421.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.23.27-PM-300x210.png 300w" sizes="auto, (max-width: 724px) 100vw, 724px" /></a></p>
<p>When you click the deploy button, it sends a command to the screen to put it into mass storage mode which just turns the screen into a flash disk which can be written/read by your PC.  Here is what the screen looks like when it is in mass storage mode:</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/img_5883/" rel="attachment wp-att-5117"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5883-e1526071213801-1024x768.jpg" alt="" width="1024" height="768" class="alignnone wp-image-5117 size-large" srcset="https://iotexpert.com/wp-content/uploads/2018/05/IMG_5883-e1526071213801-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5883-e1526071213801-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5883-e1526071213801-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2018/05/IMG_5883-e1526071213801-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After the device is in mass storage mode, GTT Designer copies all of the file onto the sd-card of the display and the reboots the display to run the program.</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-4-41-15-pm/" rel="attachment wp-att-5118"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.41.15-PM.png" alt="" width="636" height="662" class="alignnone size-full wp-image-5118" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.41.15-PM.png 636w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.41.15-PM-600x625.png 600w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.41.15-PM-288x300.png 288w" sizes="auto, (max-width: 636px) 100vw, 636px" /></a></p>
<p>When you are running GTT Designer you can switch the display back and forth between Mass Storage mode and Display mode on the Tools menu by selecting &#8220;Switch Mode&#8221;</p>
<p><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/screen-shot-2018-05-11-at-4-52-19-pm/" rel="attachment wp-att-5121"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.52.19-PM.png" alt="" width="486" height="243" class="alignnone size-full wp-image-5121" srcset="https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.52.19-PM.png 486w, https://iotexpert.com/wp-content/uploads/2018/05/Screen-Shot-2018-05-11-at-4.52.19-PM-300x150.png 300w" sizes="auto, (max-width: 486px) 100vw, 486px" /></a></p>
<p>In the next several articles Ill show you how to build firmware to talk to the screen.</p>
<p><span><p>You can "git" these projects from</p>
<p>https://github.com/iotexpert/GTT43A</p>
<p>And the driver library from </p>
<p>https://github.com/iotexpert/GTT-Client-Library</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Title</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2018/05/15/matrix-orbital-gtt43a-a-cool-display/">Matrix Orbital GTT43: A Cool Display</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/17/matrix-orbital-gtt43a-serial-interface/">Matrix Orbital GTT43A: Serial Interface</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/22/matrix-orbital-gtt43a-gtt-scripts/">Matrix Orbital GTT43A: GTT Scripts</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2018/05/24/matrix-orbital-gtt43a-psoc-4-interface/" target="_blank" rel="noopener">Matrix Orbital GTT43A: A PSoC 4 Interface</a></td>
</tr>

<tr><td >Matrix Orbital GTT43A: Debugging the I2C</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: GTT Driver Library - Part 1</td>
</tr>

<tr><td >Matrix Orbital GTT43A: PSoC 6 using RTOS and the GTT Driver Library</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/matrix-orbital-gtt43a-a-cool-display/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
