ILI9340 SPI 2.2 inch color ASCII serial terminal on ProMicro 32U4

This is very much a work in progress, but the code is working but not optimized. At present, I have the BAUD set for 9600 and I am using Serial1 physical USART on the 32U4 for communications.

The main idea of this code is to “respect” carriage returns. The sketch keeps track of characters, lines, rows, and columns so that positioning and clear-new-line can operate properly.

Also note, I am running the 32U4 at 3.3V and 16MHz but bench testing indicates that (this particular unit) has no issues with this voltage & clock frequency. Note that Atmel does not recommend this setting… but it surely does make the SPI interface to the GLCD easy !!

Adafruit libraries are taken from GITHUB … google for them.

There is lots of Serial1 transmit debug code in this source, but you can delete it. You can change the terminal font color in code as well as the BAUD. Ideally these would be soft settings input and stored in EEPROM. There are lots of comments, I may not have updated each as I modified the base… regrets if I overlooked anything. Removing the debug output (or wrapping it in a conditional compile) will lean the code significantly.

Ray

Code here: http://www.hackster.io/rayburne/color-glcd-terminal-26-ch-x-15-ln
I’ll drop in forum after I evolve it more, for now 1 copy is easier for me.

NOTES

// These are the pins used for the UNO and Pro Micro

              UNO LEO  // J2 header pin # on GLCD
#define _sclk 13   15  // 7
#define _miso 12   14  // 9
#define _mosi 11   16  // 6
#define _cs   10   10  // 3
#define _dc    9    9  // 5
#define _rst   8    8  // 4

                                                               
             Color definitions for TFT SPI 2.2" Display
                    ILI9340_BLACK   0x0000
                    ILI9340_BLUE    0x001F
                    ILI9340_RED     0xF800
                    ILI9340_GREEN   0x07E0
                    ILI9340_CYAN    0x07FF
                    ILI9340_MAGENTA 0xF81F
                    ILI9340_YELLOW  0xFFE0  
                    ILI9340_WHITE   0xFFFF

 

0        1         2         =  26 x 15 =   390 char/display    
12345678901234567890123456   = 240 x 320 (landscape) = 76,800 pixels
___display characters_____/ line#  character#
12345678901234567890123456    1     1 -  26
12345678901234567890123456    2    27 -  52
12345678901234567890123456    3    53 -  78
12345678901234567890123456    4    79 - 104
12345678901234567890123456    5   105 - 130
12345678901234567890123456    6   131 - 156
12345678901234567890123456    7   157 - 182
12345678901234567890123456    8   183 - 208
12345678901234567890123456    9   209 - 234
12345678901234567890123456    10  235 - 260
12345678901234567890123456    11  261 - 286
12345678901234567890123456    12  287 - 312
12345678901234567890123456    13  313 - 338
12345678901234567890123456    14  339 - 364
12345678901234567890123456    15  365 - 390
--------------------------/

Ray,
I like that display.
Got a couple from eBay at $3 each.

I like them so much that I'm going to use it in my new synth.

janost:
... I like that display.
Got a couple from eBay at $3 each. ...

Nice price, I paid a little more, free shipping, and delivery in about 10 days. I thought the delivery was extremely fast, but they beat it by a day on my second order!

Your source still have 'em at $3?

Ray

I haven’t received them yet.

It was on ebay.co.uk
I saw they were at 2.2 GBP at the moment.

janost:
I haven't received them yet.
It was on ebay.co.uk
I saw they were at 2.2 GBP at the moment.

Wow. Maybe a short report when they arrive, seems like a great price if that included the shipping. Also, would be interesting to know if J2 connector is standard Chinese variety or if it is the Adafruit pinout. Trying to keep track of the different pinouts for LCD's is a major pain. I have started to just build a "notes.h" section into every program sketch where I use ASCII to draw out the pinouts used in the sketch. The entire tab is a bit comment, /* ... */, and is a very useful way to evolve notes as sketches get modified from a basic 328P-PU to a Mini to a Micro to a 2560, etc.

Ray