Install Arduino Libraries
We have example code ready to go for use with these TFTs. It's written for Arduino, which should be portable to any microcontroller by adapting the C++ source.
Four libraries need to be installed using the Arduino Library Manager…this is the preferred and modern way. From the Arduino “Sketch” menu, select “Include Library” then “Manage Libraries…”
Type “gfx” in the search field to quickly find the first library — Adafruit_GFX:
Repeat the search and install steps, looking for the Adafruit BusIO, Adafruit Zero DMA, Adafruit ST7735 and ST7789, and Adafruit SPIFlash libraries.
After restarting the Arduino software, you should see a new example folder called Adafruit ST7735 and ST7789 Library, and inside, an example called graphicstest_tft_gizmo.
Now upload the sketch to your Circuit Playground board. You may need to press the Reset button to reset the Circuit Playground and TFT. You should see a collection of graphical tests draw out on the TFT.
Running in Software SPI mode
If you have a CircuitPlayground Classic or just want to run it as Software SPI for whatever reason, it's pretty easy to change. Due to the nature of the circular bolt-on style board that the gizmo is, physically changing pins isn't so easy, but we can change to software SPI, which is a bit slower. Find these lines:
// OPTION 1 (recommended) is to use the HARDWARE SPI pins, which are unique // to each board and not reassignable. Adafruit_ST7789 tft = Adafruit_ST7789(spi, TFT_CS, TFT_DC, TFT_RST); // OPTION 2 lets you interface the display using ANY TWO or THREE PINS, // tradeoff being that performance is not as fast as hardware SPI above. //#define TFT_MOSI PIN_WIRE_SDA // Data out //#define TFT_SCLK PIN_WIRE_SCL // Clock out //Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
Comment out option 1, and uncomment option 2 Then you can change the TFT_ pins to whatever pins you'd like!
Text editor powered by tinymce.