Highly optimized ILI9341 (320x240 TFT color display) library

You have 256KB available, you're using less than 1/4.
:confused:

But that is only for the fonts. Adding all the other stuff, including FFT etc I am at 208 K already and there is still something to add. Since I have added the fonts compiling has become hit and miss, often giving me a "exit status 1 Error compiling" error. Knocking off the letters may solve that problem because I would likely gain back in excess of 25 K. :)
 
Wow, this is a very long thread and I confess not having read it in its entirety. The fonts are great and work well with both the 2.2 and 2.8 inch displays from PJRC. They do take a lot of memory though, especially when the larger ones are being used.

In my case I am using only font_LiberationSansNarrowBold and have restricted it to 4 sizes. Still the combined memory hit was about 50 K for the sizes 12, 16, 48 and 96. I am using the small ones to display some descriptions and explanations, i.e. letters are used but the big ones only display numbers - measurements and parameters. This may be the case for many applications not just mine.

Large memory saving could be achieved, if numerics (in my case just numbers and a decimal) would be available as a separate library, which could be called font_LiberationSansNarrowBoldNumbers as an example.

I had this problem myself and modified the font converter in extras to take an option to generate a Fontname_Digits.c/.h file that only had the digits and some punctuation.

I pushed my changes to my branch here: https://github.com/blackketter/ILI9341_t3

For example running:

./ttf_to_ili9341.pl -digits Arial

Generates a font file roughly one quarter the size of the full font. Let me know if this helps!
 
Thanks for your note, it is what I was referring to. That is even more memory savings than I expected. However I am using the Liberation Narrow Bold font, it fits just the right amount of digits at 96 point size. I have not tried a conversion on my Mac, but having just digits would be a good feature overall.
 
Hi Blackletter, apart from a message (below) during compile, which I am ignoring at this time, it worked. It saved about to 30 K in my case using 48 and 96 points. Now that it is back down to 173 K program storage the "exit status 1 Error compiling" error has disappeared as well.

Thanks.

..............libraries/ILI9341_fonts-master/font_LiberationSansNarrow-Bold_Digits.h:1:46: warning: extra tokens at end of #ifndef directive [enabled by default]
#ifndef _ILI9341_t3_font_LiberationSansNarrow-Bold_Digits_
^
...............libraries/ILI9341_fonts-master/font_LiberationSansNarrow-Bold_Digits.h:2:46: warning: ISO C99 requires whitespace after the macro name [enabled by default]
#define _ILI9341_t3_font_LiberationSansNarrow-Bold_Digits_

Edit: Added extra info
 
Last edited:
Glad it's working! I'm not seeing those warnings. What build environment are you using?

..............libraries/ILI9341_fonts-master/font_LiberationSansNarrow-Bold_Digits.h:1:46: warning: extra tokens at end of #ifndef directive [enabled by default]
#ifndef _ILI9341_t3_font_LiberationSansNarrow-Bold_Digits_
^
...............libraries/ILI9341_fonts-master/font_LiberationSansNarrow-Bold_Digits.h:2:46: warning: ISO C99 requires whitespace after the macro name [enabled by default]
#define _ILI9341_t3_font_LiberationSansNarrow-Bold_Digits_
 
Edit:
Ha! That was far more easy than thought :)
I'll upload a video and the source tomorrow.. (too late now, midnight...)
 

Here's the video.
Sound is from headphones, recorded with my cellphone :( so, the qualtiy is not good..

I can upload the sourcecode if anyone wants it...
The music is from the file "pp_hammer.dmp" (for the reSID SID Emulation).
Additional audio-obbject is "AudioAnalyzeRMS"
 
Last edited:
I am trying to use your ILI9341_t3 library with Arduino ver 1.6.6 and trying verify and compile the Graphictest.ino using Mega 2560 and the
following errors are generated:

Arduino: 1.6.6 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\Charles\Documents\Arduino\libraries" -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10606 -build-path "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3\examples\graphicstest\graphicstest.ino"
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\Charles\Documents\Arduino\libraries" -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10606 -build-path "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3\examples\graphicstest\graphicstest.ino"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\sketch\graphicstest.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\sketch\graphicstest.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\sketch\graphicstest.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\sketch\graphicstest.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\SPI.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3\ILI9341_t3.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3\font_Arial.c"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3\font_ArialBold.c"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3\glcdfont.c"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -M -MG -MP -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\sketch\graphicstest.ino.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\sketch\graphicstest.ino.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino2/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\preproc\ctags_target.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino2/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\preproc\ctags_target.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI" "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\sketch\graphicstest.ino.cpp" -o "C:\Users\Charles\AppData\Local\Temp\buildaf5f2bab8fb20608c06c3376031ce0af.tmp\sketch\graphicstest.ino.cpp.o"
In file included from C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3\examples\graphicstest\graphicstest.ino:18:0:

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::waitFifoNotFull()':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:219:9: error: 'KINETISK_SPI0' was not declared in this scope

sr = KINETISK_SPI0.SR;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::waitFifoEmpty()':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:227:9: error: 'KINETISK_SPI0' was not declared in this scope

sr = KINETISK_SPI0.SR;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::waitTransmitComplete()':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:233:12: error: 'KINETISK_SPI0' was not declared in this scope

while (!(KINETISK_SPI0.SR & SPI_SR_TCF)) ; // wait until final output done

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:233:31: error: 'SPI_SR_TCF' was not declared in this scope

while (!(KINETISK_SPI0.SR & SPI_SR_TCF)) ; // wait until final output done

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:234:9: error: 'KINETISK_SPI0' was not declared in this scope

tmp = KINETISK_SPI0.POPR; // drain the final RX FIFO word

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::waitTransmitComplete(uint32_t)':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:239:18: error: 'KINETISK_SPI0' was not declared in this scope

uint32_t sr = KINETISK_SPI0.SR;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:240:13: error: 'SPI_SR_EOQF' was not declared in this scope

if (sr & SPI_SR_EOQF) break; // wait for last transmit

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:243:3: error: 'KINETISK_SPI0' was not declared in this scope

KINETISK_SPI0.SR = SPI_SR_EOQF;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:243:22: error: 'SPI_SR_EOQF' was not declared in this scope

KINETISK_SPI0.SR = SPI_SR_EOQF;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:244:3: error: 'SPI0_MCR' was not declared in this scope

SPI0_MCR = mcr;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writecommand_cont(uint8_t)':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:250:3: error: 'KINETISK_SPI0' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:250:67: error: 'SPI_PUSHR_CTAS' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:250:71: error: 'SPI_PUSHR_CONT' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writedata8_cont(uint8_t)':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:254:3: error: 'KINETISK_SPI0' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:254:64: error: 'SPI_PUSHR_CTAS' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:254:68: error: 'SPI_PUSHR_CONT' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writedata16_cont(uint16_t)':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:258:3: error: 'KINETISK_SPI0' was not declared in this scope

KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:258:64: error: 'SPI_PUSHR_CTAS' was not declared in this scope

KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:258:68: error: 'SPI_PUSHR_CONT' was not declared in this scope

KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writecommand_last(uint8_t)':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:262:18: error: 'SPI0_MCR' was not declared in this scope

uint32_t mcr = SPI0_MCR;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:263:3: error: 'KINETISK_SPI0' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:263:67: error: 'SPI_PUSHR_CTAS' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:263:71: error: 'SPI_PUSHR_EOQ' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writedata8_last(uint8_t)':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:267:18: error: 'SPI0_MCR' was not declared in this scope

uint32_t mcr = SPI0_MCR;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:268:3: error: 'KINETISK_SPI0' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:268:64: error: 'SPI_PUSHR_CTAS' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:268:68: error: 'SPI_PUSHR_EOQ' was not declared in this scope

KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::writedata16_last(uint16_t)':

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:272:18: error: 'SPI0_MCR' was not declared in this scope

uint32_t mcr = SPI0_MCR;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:273:3: error: 'KINETISK_SPI0' was not declared in this scope

KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_EOQ;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:273:64: error: 'SPI_PUSHR_CTAS' was not declared in this scope

KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_EOQ;

^

C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3/ILI9341_t3.h:273:68: error: 'SPI_PUSHR_EOQ' was not declared in this scope

KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_EOQ;

^

Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Using library ILI9341_t3 at version 1.0 in folder: C:\Users\Charles\Documents\Arduino\libraries\ILI9341_t3
exit status 1
Error compiling.
Invalid library found in C:\Users\Charles\Documents\Arduino\libraries\examples: C:\Users\Charles\Documents\Arduino\libraries\examples

I am using 2.8 Adafruit TFT and need to adjust the font size for a project, their library only has 1, 2 3 , 5 for font sizes. thanks in advance for any help.
 
Last edited:
Arduino: 1.6.6 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

For Arduino Mega, you have to use Adafruit's (slow) library.

The optimized ILI9341_t3 lib only works on Teensy 3.x. It doesn't even work on Teensy LC or 2.0. The optimizations use the FIFO and chip select hardware on Teensy 3.0, 3.1, 3.2. No other boards are supported.
 
errors

For Arduino Mega, you have to use Adafruit's (slow) library.

The optimized ILI9341_t3 lib only works on Teensy 3.x. It doesn't even work on Teensy LC or 2.0. The optimizations use the FIFO and chip select hardware on Teensy 3.0, 3.1, 3.2. No other boards are supported.


Thanks for the quick reply, is there any other library that supports different fonts for this controller?
 
Hi Paul,
hopefully the code below will help.

The bug shows whether or not I add 2.2K pull up resistors to the CS lines of the TFT display and of the EEPROM in your audio shield.

The first incarnation of the bug shows up performing a simple flash_read_id(id_tab), i think this is really all you need.
You would need to pre-load the first few bytes of the EEPROM if you want to see the second manifestation of the bug - which I think is the same bug, still related to a read function.
I did not test writing to EEPROM while using ILI9341

While I am able to get going with the project, I already miss the speed of ILI9341_t3 ....

Thank you
alfa66


//#include "Adafruit_GFX.h"
//#include "Adafruit_ILI9341.h"
#include "ILI9341_t3.h"
#include "flash_spi.h"
#include "SPI.h"


#define PAGE 256 //dimension of 1 EEPROM page (in bytes)

unsigned char buf2[PAGE]; // we are using this buffer for reading from the EEPROM
unsigned char id_tab[32];

// Set DC and CS, no conflict with Paul's Audio Adapter
#define TFT_DC 20
#define TFT_CS 21

// Use hardware SPI and the above for CS/DC. Reset is tied to 3.3V, no need for a 3rd pin
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);


void setup() {

Serial.begin(19200);
while (!Serial) {;}

// Needed when using ILI9341 with the Audio Board, also needed for reading W25Q128
SPI.setMOSI(7);
SPI.setSCK(14);

tft.begin();

// About the following line
// if not commented out and compiled with t3 library, we miss reading the id_tab correctly. Also we miss reading the first byte on the first page
// if it is commented out it works fine
// It also works if not commented out and compiled with the Adafruit version of ILI9341
//tft.drawLine( 0, 0, 100, 100, ILI9341_YELLOW);

flash_init();
int flashstatus = flash_read_status();
flash_read_id(id_tab);
Serial.printf("Flash Status: 0x%X, ID:0x%X,0x%X,0x%X,0x%X ", flashstatus , id_tab[0], id_tab[1], id_tab[2], id_tab[3]);

if (id_tab[0]!=0xef || id_tab[1]!=0x40 || id_tab[2]!=0x18 || id_tab[3]!=0x00)
{Serial.println(" is not ok."); goto end;}
else Serial.println("");

end:

// this is what caused the buzz sound in my code. The first byte of page 0 always reads zero
// you would have to pre-load the first page of the EEPROM to check on this one
// I used Frank B code SD2SerialFlash to pre-load the EEPROM

flash_read_pages(buf2, 0, 1);
for (int i=0; i<PAGE; i++) {
Serial.print(buf2, HEX);
Serial.print(" ");
}
Serial.println("Done");

}

void loop(void) {
int i;

}


Hi Paul,
Since I was not able to get this to work, I reverted back to the Adafruit library, but i really need more speed for my project.
I noticed that, in the meantime, you released a new purple board for the display.
I was familiar with the power fix, but can you please tell me what has changed with the reset? I wonder if the issue above is related to the interaction with the purple board.
Thank you in advance,
 
Looks like you're using this:

Code:
// Needed when using ILI9341 with the Audio Board, also needed for reading W25Q128
SPI.setMOSI(7);
SPI.setSCK(14);

But you have only this for the display:

Code:
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);

You need to use this:

Code:
#define TFT_DC      20
#define TFT_CS      21
#define TFT_RST    255  // 255 = unused, connect to 3.3V
#define TFT_MOSI     7
#define TFT_SCLK    14
#define TFT_MISO    12
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);

For more info, read the ILI9341 page:

http://www.pjrc.com/store/display_ili9341.html

Scroll down to the "Usage With Audio Board Connections" section.
 
Thank you Paul!
I will give it another try.

Also, I will look at the code example for the display + SD card.

I saw the tutorial, well done - it helped me moving forward with my project.

Thanks again!
 
Hey Guys,

I was just wondering if there is a way to either force the new fonts to display as fixed width or when they are generated, adjust the parameters so they are a fixed width font?
The new fonts work really well just the fixed width is kind of tripping me up.

Cheers
 
Hey Guys,

I was just wondering if there is a way to either force the new fonts to display as fixed width or when they are generated, adjust the parameters so they are a fixed width font?
The new fonts work really well just the fixed width is kind of tripping me up.

Cheers

Did you try using the Courier font? It should be fixed width.
 
Hey, I submitted a pull request with some library updates.

I added:
Gradient support
fillRectVGradient - fills area with vertical gradient
fillRectHGradient - fills area with horizontal gradient
fillScreenVGradient - fills screen with vertical gradient
fillScreenHGradient - fills screen with horizontal gradient

Additional Color Support
color565toRGB - converts 565 format 16 bit color to RGB
color565toRGB14 - converts 16 bit 565 format color to 14 bit RGB (2 bits clear for math and sign)
RGB14tocolor565 - converts 14 bit RGB back to 16 bit 565 format color

Low Memory Bitmap Support
writeRect8BPP - write 8 bit per pixel paletted bitmap
writeRect4BPP - write 4 bit per pixel paletted bitmap
writeRect2BPP - write 2 bit per pixel paletted bitmap
writeRect1BPP - write 1 bit per pixel paletted bitmap

String Pixel Length support
strPixelLen - gets pixel length of given ASCII string

and I fixed the text routines so that linefeed would actually work.

I ended up submitting it in two separate patches because I couldn't determine how to merge the changes (I am a Git newbie.)
https://github.com/PaulStoffregen/ILI9341_t3/pull/24
https://github.com/PaulStoffregen/ILI9341_t3/pull/25

Please give it a shot and let me know if there are any problems.

-- Tim --
SoftEgg
 
Any way to make this library work with the Teensy LC? Or does that have too little memory to make the attempt. The code currently uses KINETISK_SPI0, which is not defined on the Teensy LC (being a KINETISL processor). Or should KINETISK_SPI0.SR be replaced with SPSR in the code (in readcommand8, for example)? What about KINETISK_SPI0.PUSHR and KINETISK_SPI0.POPR?

How much rewriting is needed to get the display to work on the Teensy LC?
 
Back
Top