1.8" TFT on chipKIT uc32 (SPI)
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
1.8" TFT on chipKIT uc32 (SPI)
Hi,
Has anyone got a quick start for getting the 1.8" TFT working on my new shiney chipKIT uc32?
I've read a couple things:
http://forums.adafruit.com/viewtopic.ph ... 6&p=203608
http://forums.adafruit.com/viewtopic.ph ... 9&p=197878
http://forums.adafruit.com/viewtopic.ph ... 4&p=162929
(btw, did anyone ask if his "stripe" problem was the plastic screen cover? I thought that once...)
http://forums.adafruit.com/viewtopic.ph ... 9&p=160177
http://digital-diy.com/forum/electronic ... tml#p14564
http://www.chipkit.org/forum/viewtopic. ... 3&start=10
(btw, I finally found his CKTFT port here on Adafruit and it's using 8 bit parallel, not SPI)
So pretty much I need to convert the AVR-specific SPI instructions in Adafruit_GFX and Adafruit_ST7735 to either be abstracted or just plop in the chipKIT instructions for hardware SPI, which I'm only just starting to wrap my head around. (or I guess just go software SPI, but that seems more work?)
For references, I went here: http://www.digilentinc.com/Products/Det ... -IO-SHIELD then downloaded the reference manual and ZIP examples.
And I love the support reply on the one thread to get a Mega for more RAM. Sorry, I need MOAR than that! If I can't get the chipKIT working, I do have some I2C RAM coming to me for the Mega I'm trying to replace.
I did try UTFT library and it says it only does "serial" for the ST7735, and by serial, they mean I2C, not SPI. This guy got the 1.8" TFT Adafruit breakout working on chipKIT but his code did nothing for me... I'll look over it again at some point. I'm not sure if he's bitbanging or HW SPI or what.
My project: (full write up) (support post here)
Thanks!
Chris
Has anyone got a quick start for getting the 1.8" TFT working on my new shiney chipKIT uc32?
I've read a couple things:
http://forums.adafruit.com/viewtopic.ph ... 6&p=203608
http://forums.adafruit.com/viewtopic.ph ... 9&p=197878
http://forums.adafruit.com/viewtopic.ph ... 4&p=162929
(btw, did anyone ask if his "stripe" problem was the plastic screen cover? I thought that once...)
http://forums.adafruit.com/viewtopic.ph ... 9&p=160177
http://digital-diy.com/forum/electronic ... tml#p14564
http://www.chipkit.org/forum/viewtopic. ... 3&start=10
(btw, I finally found his CKTFT port here on Adafruit and it's using 8 bit parallel, not SPI)
So pretty much I need to convert the AVR-specific SPI instructions in Adafruit_GFX and Adafruit_ST7735 to either be abstracted or just plop in the chipKIT instructions for hardware SPI, which I'm only just starting to wrap my head around. (or I guess just go software SPI, but that seems more work?)
For references, I went here: http://www.digilentinc.com/Products/Det ... -IO-SHIELD then downloaded the reference manual and ZIP examples.
And I love the support reply on the one thread to get a Mega for more RAM. Sorry, I need MOAR than that! If I can't get the chipKIT working, I do have some I2C RAM coming to me for the Mega I'm trying to replace.
I did try UTFT library and it says it only does "serial" for the ST7735, and by serial, they mean I2C, not SPI. This guy got the 1.8" TFT Adafruit breakout working on chipKIT but his code did nothing for me... I'll look over it again at some point. I'm not sure if he's bitbanging or HW SPI or what.
My project: (full write up) (support post here)
Thanks!
Chris
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
This is that guy's code who got the 1.8" TFT breakout working:
I renamed the MOSI, etc to what I've got in my project's file. And all that reference about what pins do what, since I've been on a few different Unos and Megas with the couple of 1.8" TFT shields I've got.
I'm left with one thought: This guy is using the RS register select line from the breakout. Is this on the shield? The docs don't lend themselves to helping me know that as easily as my brain needs...
Yaay,
Chris
Code: Select all
// from https://gist.github.com/shahrulnizam/5779209
// DOESNT WORK
#include <UTFT.h>
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
//extern unsigned short icon1[0x400];
//extern unsigned short icon2[0x400];
//extern unsigned short tux[0x1000];
// MOSI MISO SCK CS/SS(slave)
// Uno or Duemilanove 11 or ICSP-4 12 or ICSP-1 13 or ICSP-3 10
// Mega1280 or Mega2560 51 or ICSP-4 50 or ICSP-1 52 or ICSP-3 53
// More about pinout for Mega: http://forums.adafruit.com/viewtopic.php?uid=115205&f=31&t=36738&start=0
#define ADA_SCLK 13
#define ADA_MOSI 11
#define ADA_CS 10
#define ADA_DC 8
#define ADA_RST -1
UTFT myGLCD(ST7735,ADA_MOSI,ADA_SCLK,ADA_CS,ADA_RST); //MOSI, SCLK, CS, RESET [, RS]
I'm left with one thought: This guy is using the RS register select line from the breakout. Is this on the shield? The docs don't lend themselves to helping me know that as easily as my brain needs...
Yaay,
Chris
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
OK I'm now slightly bitter that there is so much AVR-specific code in the Adafruit_ST7735 library and how genuinely absolutely nothing was done to abstract to an SPI layer.
I get being under the gun and trying to shove code out the door... as that is what I'm doing now, trying to port this **** to chipKIT.
grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Just sayin.
I get being under the gun and trying to shove code out the door... as that is what I'm doing now, trying to port this **** to chipKIT.
grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Just sayin.
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
I've got something that compiles... can someone that knows their way around the GFX code give this a look-see in the hopes I'm overlooking something simple?
It looks like I've got the steps from Adafruit_ST7735 done in ST7735 ... but of course nothing happens when I run it.
I'll probably have to pour over the code line-by-line to critique the init process; just hoping that something stands out to folks who haven't just opened the library files within the last week.
Yaay!
Chris
It looks like I've got the steps from Adafruit_ST7735 done in ST7735 ... but of course nothing happens when I run it.
I'll probably have to pour over the code line-by-line to critique the init process; just hoping that something stands out to folks who haven't just opened the library files within the last week.
Yaay!
Chris
- Attachments
-
- ada_tft_chipKit.7z
- (9.68 KiB) Downloaded 93 times
- adafruit_support_bill
- Posts: 89192
- Joined: Sat Feb 07, 2009 10:11 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
I'm afraid I don't know chipkit processors well enough to offer much advice on your port.
With regards to AVR specific code and abstraction layers, when working in a resource (CPU and Memory) constrained environment, you do have to consider both size and performance tradeoffs that may be associated with various levels of abstraction. The GFX abstraction layer gives us source-level portability across many displays. We optimize the individual display drivers for speed.
With regards to AVR specific code and abstraction layers, when working in a resource (CPU and Memory) constrained environment, you do have to consider both size and performance tradeoffs that may be associated with various levels of abstraction. The GFX abstraction layer gives us source-level portability across many displays. We optimize the individual display drivers for speed.
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
Cool... I'll post up the port when I'm done. My current plan:
1) In Arduino-land, with Arduinos (meaning with a shield to prove something works), I'm going to try and strip out all references to Adafruit_ in the classes and names of the two libraries I'm deriving from working. (more for my sanity, so I know what code I'm in)
2) Next, find and start removing the AVR program space code. <--- I'm a third thru this & already had to switch to a Mega
3) Work on making the inline AVR SPI hardware commands generic to either Arduino SPI functions or one SPI function internal to the class that I can replace / reprogram in chipKIT land.
4) Now, get it to compile in chipKIT... which means stripping out all references to uint8_t ... which I will try to do in both chipKIT and Arduino-land (since in there, I can still prove the code working on a shield).
5) Try to get it working on all chipKIT hardware...
I'm hoping that steps 1~4 will go easier than my mad drunken scramble last night just trying to get the libs compiling.
1) In Arduino-land, with Arduinos (meaning with a shield to prove something works), I'm going to try and strip out all references to Adafruit_ in the classes and names of the two libraries I'm deriving from working. (more for my sanity, so I know what code I'm in)
2) Next, find and start removing the AVR program space code. <--- I'm a third thru this & already had to switch to a Mega
3) Work on making the inline AVR SPI hardware commands generic to either Arduino SPI functions or one SPI function internal to the class that I can replace / reprogram in chipKIT land.
4) Now, get it to compile in chipKIT... which means stripping out all references to uint8_t ... which I will try to do in both chipKIT and Arduino-land (since in there, I can still prove the code working on a shield).
5) Try to get it working on all chipKIT hardware...
I'm hoping that steps 1~4 will go easier than my mad drunken scramble last night just trying to get the libs compiling.
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
Wow, I'm left with a really duh/obvious question...
What does pin 8 on the TFT shield have to do with SPI? It looks like / feels like the chipKIT code worries less about pins beyond MOSI/MISO/CLK/CS than Arduino does.
Everything I see makes me think this is a required additional input to the TFT which is outside of the SPI communications...
What does pin 8 on the TFT shield have to do with SPI? It looks like / feels like the chipKIT code worries less about pins beyond MOSI/MISO/CLK/CS than Arduino does.
Everything I see makes me think this is a required additional input to the TFT which is outside of the SPI communications...
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
YES!! Got it working in chipKIT!
Observations:
» Initially I thought Digilent DSPI library didn't work, so I developed on their SPI examples. I eventually noticed the LED for pin 13 blinking appropriately for what my loop() was doing... so I hit reset and it started working!!!
» I ended up removing ALL DELAYS from Arduino-land! And also running SPI at the fastest speed (40MHz?).
» Initially, with the SPI clock divider at 64 and all the delays, the code was slower than Arduino communicating with hardware SPI to the TFT shield. Now? It is obviously and appreciably faster -- so much that a fill screen is almost a blink, the curtain falling effect would be missed by anyone not looking for it.
» Attached zip archive has both my DSPI and SPI library examples. The current ST7735 library is the DSPI copy and is more recent than the SPI example. In the SPI version, I didn't remove any and all references to delay.
» When hitting RESET button on the shield, the sketch gets into loop() in approx 3 seconds.
» When powering up the chipKIT by plugging in the USB, the sketch gets into loop() in 6 or 7 seconds.
NOTICE: I did not perform complete and total tests of every feature and nuance of the code. I got it to print my text! All the Adafruit functions should work, given how everything is coded and structured...
To use my files, download Digilent's latest mpide IDE (which I put in Documents\mpide-0023-windows-20130715), make a Documents\mpide folder, unzip my file into there. It will make a Libraries and tft folders. Then make a desktop shortcut to mpide-0023-windows-20130715\mpide.exe Drag and drop the tft\tft.ino sketch onto the desktop shortcut and it should compile out-of-the-box. Mpide is a lot like Arduino IDE.
adafruit_support_bill: you are welcome to use the attached code in any way shape form or fashion to help support your products. I release it into the public domain. If you want a chipKIT UNO32 for developement for free, give me an address to send it to. When I bought it, I didn't realize it "only" had 16k of RAM. I need the uC32 and its 32K of RAM for my crazy TPS testbed with thermal printer.
(updated: edited to delete the older zip file)
Observations:
» Initially I thought Digilent DSPI library didn't work, so I developed on their SPI examples. I eventually noticed the LED for pin 13 blinking appropriately for what my loop() was doing... so I hit reset and it started working!!!
» I ended up removing ALL DELAYS from Arduino-land! And also running SPI at the fastest speed (40MHz?).
» Initially, with the SPI clock divider at 64 and all the delays, the code was slower than Arduino communicating with hardware SPI to the TFT shield. Now? It is obviously and appreciably faster -- so much that a fill screen is almost a blink, the curtain falling effect would be missed by anyone not looking for it.
» Attached zip archive has both my DSPI and SPI library examples. The current ST7735 library is the DSPI copy and is more recent than the SPI example. In the SPI version, I didn't remove any and all references to delay.
» When hitting RESET button on the shield, the sketch gets into loop() in approx 3 seconds.
» When powering up the chipKIT by plugging in the USB, the sketch gets into loop() in 6 or 7 seconds.
NOTICE: I did not perform complete and total tests of every feature and nuance of the code. I got it to print my text! All the Adafruit functions should work, given how everything is coded and structured...
To use my files, download Digilent's latest mpide IDE (which I put in Documents\mpide-0023-windows-20130715), make a Documents\mpide folder, unzip my file into there. It will make a Libraries and tft folders. Then make a desktop shortcut to mpide-0023-windows-20130715\mpide.exe Drag and drop the tft\tft.ino sketch onto the desktop shortcut and it should compile out-of-the-box. Mpide is a lot like Arduino IDE.
adafruit_support_bill: you are welcome to use the attached code in any way shape form or fashion to help support your products. I release it into the public domain. If you want a chipKIT UNO32 for developement for free, give me an address to send it to. When I bought it, I didn't realize it "only" had 16k of RAM. I need the uC32 and its 32K of RAM for my crazy TPS testbed with thermal printer.
(updated: edited to delete the older zip file)
Last edited by technerdchris on Wed Aug 28, 2013 6:16 pm, edited 1 time in total.
- adafruit_support_bill
- Posts: 89192
- Joined: Sat Feb 07, 2009 10:11 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
Thanks for sharing your code!
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
You're very welcome!
BTW, I just unzipped the zip at work in a fresh directory and there's an extra } in ST7735.cpp?! And then I compiled and re-uploaded into my uC32 and it didn't run. WTH. Worked great on the Win7 laptop ... but failed on my killer windblows workstation?
The zip file has working code for uC32 using the SPI library version of ST7735. I was going to put it on Github, but none of my tools for it are working so that's not happening.
Previously, I said:
BTW, I just unzipped the zip at work in a fresh directory and there's an extra } in ST7735.cpp?! And then I compiled and re-uploaded into my uC32 and it didn't run. WTH. Worked great on the Win7 laptop ... but failed on my killer windblows workstation?
The zip file has working code for uC32 using the SPI library version of ST7735. I was going to put it on Github, but none of my tools for it are working so that's not happening.
Previously, I said:
Update: Majenko has an Uno32 and it works fine on his board. We're assuming my Uno32 is defective.I didn't have the Uno32 at home last night, so I tried the code in it, and it won't run. I believe this would be some kind of error, as the difference between the boards is moar RAM. The Uno32 has 16k, so twice as much as the Mega. There's no way RAM is the problem. I'm posting on the chipKIT forums, too, maybe they'll shed some light on that.
- Attachments
-
- ada_spi_tft_chipKIT_v101.zip
- (29.35 KiB) Downloaded 133 times
Last edited by technerdchris on Fri Nov 01, 2013 3:23 am, edited 1 time in total.
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
BTW, The code is released to public domain and hosted on my Github:
https://github.com/cacycleworks/chipKIT_ST7735
Note that some astounding work has been done by ChipKIT guru majenko. Instead of copying the /Libraries files to your Libraries, go into Experimental and copy THOSE files into Libraries.
He's implemented a frame buffer method for display to the TFT and has 3 amazing demos: a picture gallery slider, a asteroids like game with sprites, and ummm, I forgot what #3 was. Genuinely impressive work and the TFT shield and uC32 are an awesome combination and works out-of-box with this Library.
https://github.com/cacycleworks/chipKIT_ST7735
Note that some astounding work has been done by ChipKIT guru majenko. Instead of copying the /Libraries files to your Libraries, go into Experimental and copy THOSE files into Libraries.
He's implemented a frame buffer method for display to the TFT and has 3 amazing demos: a picture gallery slider, a asteroids like game with sprites, and ummm, I forgot what #3 was. Genuinely impressive work and the TFT shield and uC32 are an awesome combination and works out-of-box with this Library.
- biomurph
- Posts: 18
- Joined: Fri Jun 20, 2014 4:39 pm
Re: 1.8" TFT on chipKIT uc32 (SPI)
Hey unexpectedly! Thanks for sharing your code!
I got the Adafruit_GFX and Adafruit_SharpMem libraries ported to work with chipKIT Uno32
Here's the repo:
https://github.com/biomurph/Adafruit_GFX---chipKIT_Port
Now waiting on delivery of EEPROM to store more complex animation frames.
I got the Adafruit_GFX and Adafruit_SharpMem libraries ported to work with chipKIT Uno32
Here's the repo:
https://github.com/biomurph/Adafruit_GFX---chipKIT_Port
Now waiting on delivery of EEPROM to store more complex animation frames.
- technerdchris
- Posts: 46
- Joined: Sun Nov 25, 2012 4:08 am
Re: 1.8" TFT on chipKIT uc32 (SPI)
Be sure to check out Majenko's libraries here:
https://github.com/majenkotech/chipKIT-TFT
He made an all OOP frame buffer library!
https://github.com/majenkotech/chipKIT-TFT
He made an all OOP frame buffer library!
Please be positive and constructive with your questions and comments.