Adafruit ILI9340 library [PORTED]


I’ve ported Adafruit ILI9340 library for Spark Core. You can find it at Original is at:
“Ported” is a strong word, it was mostly removing of AVR related code. I’ve got one of these strange screens with SD port on the back (like Libraries for 9341 revision of the chip were not working. Well, unless you define solid white screen as “working” :). graphicstest.ino from original library passes with no issues. I did not try spitftbitmap.ino yet.

Hope it can be useful for someone else!


laz, looks great! I can see an opportunity for some optimizations by using direct bit manipulation vs digitalWrite(). I have a working arduinio library for the ILI9341 for that exact display so I’ll take a look to see if there are any tweaks to the display setup or commands.

By connecting the SD pins on the board to the SPI bus and using a separate CS line you could use the SD library that BDub and I worked on and posted on his github.

Hi, thanks!

Indeed, direct bit manipulation will be faster, but that’s too ninja for me. I’ll be more than happy to adjust the code based on your feedback. Looks like the screen is a bit dim compared to photos I’ve seen on Adafruit. Do you think it is normal or the screen does need 5V on LED pin for full brightness?

1 Like

laz, I “blew” a backlight by powering it off 5V directly. It’s not blown but it is now dimmer than it was when I first got it. If you do use 5V, use a current limiting resistor (200 ohms or so). The specs call for 3.3V on the LEDs with an 80ma draw. I will pull my units out and do some testing.

I’ll play with the code you posted and do some tuning. Would having software SPI be useful to you?

Hi, I was just curious about the brightness. It is not that bad anyway. As I hooked the same screen to Arduino, it is possible that I also killed back-lit (not my fault, the site I bought it said “it is ok” :)) In regard of software SPI - original library had support for it, but as Spark Core has hardware SPI, I’ve removed it. I can put software SPI part back if someone needs it.

laz, I noticed slight differences in the ILI9141 initialization code from the one I have. I will hook up a display and see if the sequence I have works any better. The only reason I ask about software SPI is I have a “fast” version and for some people, they want to use different pins. So it’s all good if you don’t need it. :smile:

laz, it turns out the differences were negligible. One thing to note is that I was able to set the SPI clock to DIV2 without any problems except for the fact that it wast FAST! :smile:

You’ve just hit the turbo button sir! :slight_smile: Thank you very much! Some stats:

Using DIV16:
Benchmark Time (microseconds) Screen fill 2649590 Text 345942 Lines 3698732 Horiz/Vert Lines 225707 Rectangles (outline) 152025 Rectangles (filled) 4240818675 Circles (filled) 1281985 Circles (outline) 1616929 Triangles (outline) 1173144 Triangles (filled) 2050812 Rounded rects (outline) 582258 Rounded rects (filled) 6141673

Using DIV2:
Benchmark Time (microseconds) Screen fill 1621998 Text 297614 Lines 3240247 Horiz/Vert Lines 141711 Rectangles (outline) 98613 Rectangles (filled) 3370528 Circles (filled) 989122 Circles (outline) 1416433 Triangles (outline) 1027712 Triangles (filled) 1359627 Rounded rects (outline) 484583 Rounded rects (filled) 3821779

Hello @laz and @peekay123,
do you know weather your library does also work for the ILI9341?
(since the registers seems to be pretty similar…)
I bought some of these displays and I would love to use them with my spark core…
I someone in the awesome spark-community may help me :wink:

@tooold, I have an ILI9341 library designed to work with the Adafruit_mfGFX library. I will post it on a github repo for you later today. :smile:

UPDATE: Here is the link to the repo. Don’t forget that you also need the Adafruit_mfGFX library.

Awesome! Thank you very much!

Just wondering if this ILI9341 repo
has software SPI and the touch panel functions?


@peekay123, I looked at the code so this is hardware SPI only, I’m starting to run low on pins to use with the P1. Do you know if the reset for the lcd is needed? If not, what functionality is lost if not used?

Also do you know if the spare 1-6 pins on the P1 will be built out to be available for use?

@wesner0019, that repo does not support software SPI or a touch panel.

Can I ask which display module you plan to use so I can advise accordingly?

@peekay123 Its the ILI9341 driver, below is the link to the display. I plan to incorporate this directly into my pcb.

Here’s some other interesting libraries for touch calibration about midway down:

@wesner0019, @mtnscott has ported the due DMA library for the ILI9341 (I have begged him to post it!). Do you plan on using a touchscreen i/f like the STMPE610? The buydisplay unit you selected does not come with any touch interface.

@peekay123 That would be great to see the due DMA library. Do you know if it works with the Adafruit_mfGFX library or is it stand alone?

I have not yet started looking for touch controllers. I would likey use what is readily available and that has librarys already built if possible.


@wesner0019, I believe the DMA library is not based on mfGFX though it could be adapted I suspect. A good project to look at is the fantastic BrewPi by @elco. He uses a 2.2" ILI9341 touchscreen display (using the STMPE610). You can find his Spark project libraries here. :smile:

@peekay123 Thanks. The 4 wire resistive touch can be connected directly to the spark is my understanding. Do you know the benefits of using the STMPE610?

@wesner0019, if you have 4 analog inputs to spare then yes, you can do that. The main benefits of the STMPE610 is the SPI interface and the extra I/O it offers. :smiley:

1 Like