I’m starting a new thread and hopefully (if we can resolve this) it will be helpful for others.
I bought a 1.8’’ TFT display on ebay: http://www.ebay.com/itm/1-8-Serial-128X160-SPI-TFT-LCD-Module-Display-Screen-PCB-Adapter-w-SD-Socket-/200764741074?pt=LH_DefaultDomain_0&hash=item2ebe82d5d2
This display uses SPI (and not I2C despite the confusing labels on the board)
After working on some issues, I’m pretty sure of my wiring which is as follows:
- display SDK -> A3 Spark (it’s confusing to have SDK, SCK, M_CLK… but
anyway it’s all Clocks) - display SDA (which is in fact MOSI, because
it’s SPI not I2C) -> A5 Spark (MOSI Pin for SPI) - display CS (Chip
Select) -> A2 Spark (SS Pin for SPI) - display A0 (which is the D/C Pin for choosing Data or Command) -> D6 Spark (avoiding D0 or D1 in case I need them for something else)
- display RST -> D2 Spark (also avoiding D0 or D1, can put it anywhere and managed through code)
- display VCC -> 3V3) Spark (the TFT has a jumper that can be shorter to use 3V3 instead of 5V, I soldered the little jumper in the back)
- display LED+ -> 3V3 Spark
- display LED- and GND -> GND
I have used the ported library from @peekay123 that he posted here: https://github.com/pkourany/Adafruit_ST7735_mfGFX
compiled the thing (I used the Spark Dev for the first time, pretty cool).
All I can get right now is a lighted up TFT and nothing else… The code runs fine, I can see some output using the serial connection (on USB) and can access the spark just fine, but I get no output.
I cannot tell if this is a ST7735R or ST7735B by the way…
Here is the code I use:
#define cs A2
#define dc D6
#define rst D2 // instead of 0
#define v 4
#include "Adafruit_GFX.h" // Core graphics library
#include "Adafruit_ST7735.h" // Hardware-specific library
#include "glcdfont.h"
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst); // hardware spi
void setup() {
Spark.function("version", version);
Serial.begin(9600);
Serial.println("TFT test!");
Serial.println("Version: ");
Serial.print(v);
tft.initR(INITR_BLACKTAB); //for the ST7735R, otherwise would be initB for the B version
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ST7735_WHITE);
tft.setTextWrap(true);
tft.print("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla");
tft.drawLine(0, 0, tft.width()-1, tft.height()-1, ST7735_YELLOW);
tft.drawLine(tft.width()-1, 0, 0, tft.height()-1, ST7735_YELLOW);
tft.drawPixel(0, tft.height()/2, ST7735_GREEN);
}
void loop() {
Serial.print("Going Black ");
tft.fillScreen(ST7735_BLACK);
delay(1000);
Serial.print("Going White ");
tft.fillScreen(ST7735_WHITE);
delay(1000);
}
int version(String s) {
return v;
}
The first thing for me would be to know if the display actually works… but not sure if there is anyway for me to do that. How can I track if commands are actually sent? I can I debug this thing?
Thanks for the help.
EDIT: Corrected the code to reflect the correct wiring.