0

TFT -SPI and ILI9341 on M0 Express
Moderators: adafruit_support_bill, adafruit

Forum rules
Adafruit MicroPython is currently EXPERIMENTAL and BETA - Please visit https://learn.adafruit.com/category/micropython and http://forum.micropython.org/ in addition to our section here!
Please be positive and constructive with your questions and comments.

TFT -SPI and ILI9341 on M0 Express

by jerryn on Sun Apr 16, 2017 6:15 pm

I have been trying to hook up a TFT screen to my M0 Express -
the screen is an older version of the https://www.adafruit.com/product/1983 (26 pin header ) but I have been able to get it working on an ESP8266 (via Arduino - have not tried Micropython)

In the Micro/CircuitPython tutorial for this type of display:
https://learn.adafruit.com/micropython-hardware-ili9341-tft-and-featherwing
there is a note that SPI and the ILI9341 are not working yet on the SAMD21 boards:
Note the beta SAMD21 MicroPython port currently has an issue with using the ILI9341 module & SPI interface. Stick with using the ESP8266 or other MicroPython boards for now!


This looks like a pretty clear statement that I should not expect it to work - and it doesn't ;-)

Is the current driver only working on the ESP8266?

I was just wondering if someone could confirm that this incompatibility still exists and is a known issue.
If so, I'll move onto other projects. If it should be working, I'll post some more gory details. It's not pretty....

Thanks for all the work and support on CircuitPython.

jerryn
 
Posts: 404
Joined: Sat Sep 14, 2013 9:05 am

Re: TFT -SPI and ILI9341 on M0 Express

by adafruit_support_rick on Mon Apr 17, 2017 9:29 am

I'll check with Tony for an update on this

adafruit_support_rick
 
Posts: 34563
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: TFT -SPI and ILI9341 on M0 Express

by jerryn on Mon Apr 17, 2017 4:59 pm

Just an FYI update:
I thought I'd give it a shot on an ESP8266 Huzzah Feather but when I executed
the example esp8266_tft_featherwing.py
The line:
Code: Select all | TOGGLE FULL SIZE
# Setup SPI bus using hardware SPI:
spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)


results in:
OSError: Pins not valid for SPI


In the interest of full disclosure, I have not connected the TFT yet - does this line require an SPI device to be connected in order to execute?

Any suggestions about how to proceed?

edited to add - CircuitPython 0.9.5 - lib bundle 0.3.1

jerryn
 
Posts: 404
Joined: Sat Sep 14, 2013 9:05 am

Re: TFT -SPI and ILI9341 on M0 Express

by tannewt2 on Mon Apr 17, 2017 7:36 pm

I'm not sure what the issue with the library was.

The OSError thrown by CircuitPython is a bug I introduced when I made it work with one of the data lines. I broke it for two data lines. I'll check in a fix shortly.

tannewt2
 
Posts: 361
Joined: Thu Oct 06, 2016 8:48 pm

Re: TFT -SPI and ILI9341 on M0 Express

by tdicola on Tue Apr 18, 2017 4:43 am

For the SAMD21 port you'll need to add a pure python implementation of the frambuffer module. We had to remove this module from the MicroPython firmware to save space, but we were able to port it over to a Python .mpy module you can load on the board's filesystem. Check out this video for an example using the SSD1306 OLED: https://www.youtube.com/watch?v=uuFm-mp2S64

For the ILI9341 the usage will be similar and you'll want to copy over and import the same framebuf.mpy as shown in the video and then it should work with the CircuitPython on the SAMD21. The display will be pretty slow though since it's all python code that's doing the pixel operations instead of C code in the python firmware. It's probably fast enough for very basic drawing, but not fast enough for games or other fast movement. If you want to draw text check out this text library too: https://learn.adafruit.com/micropython- ... t/overview Plug in the ILI9341 pixel drawing function to it and it can write simple text strings with a small bitmap font.

tdicola
 
Posts: 1064
Joined: Thu Oct 17, 2013 9:11 pm

Re: TFT -SPI and ILI9341 on M0 Express

by tannewt2 on Tue Apr 18, 2017 1:04 pm

Actually, I just pushed a commit to turn the internal framebuf on for Express boards. https://github.com/adafruit/circuitpyth ... 5b4b1d2214

So, the next release should be good. (I also pushed the SPI fix.)

tannewt2
 
Posts: 361
Joined: Thu Oct 06, 2016 8:48 pm

Re: TFT -SPI and ILI9341 on M0 Express

by jerryn on Tue Apr 18, 2017 4:26 pm

Whin I try to recompile for the M0 Express I get:
Code: Select all | TOGGLE FULL SIZE
make: *** No rule to make target `freetouch/adafruit_ptc.c', needed by `build-feather_m0_express/genhdr/qstr.i.last'.  Stop.

I am doing the following:
Code: Select all | TOGGLE FULL SIZE
git pull origin
make clean BOARD = feather_m0_express
make BOARD = feather_m0_express

Am I missing a step?
It builds OK for the ESP8266.

jerryn
 
Posts: 404
Joined: Sat Sep 14, 2013 9:05 am

Re: TFT -SPI and ILI9341 on M0 Express

by tannewt2 on Tue Apr 18, 2017 4:46 pm

For everyone else not on Gitter chat: freetouch is a new submodule so you'll need to do `git submodule update --init —recursive` to download it.

tannewt2
 
Posts: 361
Joined: Thu Oct 06, 2016 8:48 pm

Re: TFT -SPI and ILI9341 on M0 Express

by jerryn on Tue Apr 18, 2017 6:58 pm

Thanks for the help Scott! - the example runs on the esp8266 and with minor adjustments also now runs on the M0 Express!
The only changes necessary to esp8266_tft_featherwing.py for the M0 Express were:
CS_PIN = D9
DC_PIN = D10
BAUDRATE = 1000000

Now to experiment with writing text.....

jerryn
 
Posts: 404
Joined: Sat Sep 14, 2013 9:05 am

Re: TFT -SPI and ILI9341 on M0 Express

by jerryn on Wed Apr 19, 2017 4:13 pm

Just a brief update.
I was not able to get very far with the "compiled-in" framebuf on an M0 Express. I kept running out of memory.
I recompiled without it and used framebuf.mpy.
I was still running out of memory if I tried to use bitmapfont with the ILI9341.
I could not import bitmapkfont after initializing the display or I could not initialize the display after importing bitmapfont.
but:
I did get it all to work with the SSD1306.
I guess a 128x32 display is much more manageable than a 320x240 display.

So I have gotten framebuf.mpy and bitmapfont to allow me to write text to an SSD1306 on an M0 Express - WooHoo!!

Should I just be happy with the 128x32 OLED display for CircuitPython at this time or do you have any suggestions for using the ILI9341.

This is not a high priority issue but I just thought it would be fun to try it out the bigger display.

jerryn
 
Posts: 404
Joined: Sat Sep 14, 2013 9:05 am

Re: TFT -SPI and ILI9341 on M0 Express

by tannewt2 on Wed Apr 19, 2017 5:04 pm

Tony has done the most work with the ILI display. I don't know what to tell you about expectations because I haven't looked into it myself.

After dhalbert's memory problems I'm more interested in optimization. However, its still pretty low on my list. Its tough to focus on memory use when boards like the ESP8266 simply have more.

tannewt2
 
Posts: 361
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.