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
--------------------------/