Connecting Adafruit 2.8" TFT Touch Shield to a Photon


#18

Just to make sure the SD-Slot doesn’t interfere, you might also want to explicitly deactivate it via TF_CS (odd name for an SD slot ;-)) at pin D4 on the board by adding this to your setup()

#define SD_CS D0  // accroding to your white wire in the pic above

void setup()
{
  ...
  pinMode(SD_CS, INPUT_PULLUP);
  // or if you intend to use the SD slot some time
  pinMode(SD_CS, OUTPUT);
  digitalWrite(SD_CS, HIGH);  // since it's an active LOW logic
  ...
}

Or just remove any card that might be in the slot :sunglasses:


According to the LinkSprite schematics there seems to be a not-marked RESET pin on the board you could also try pulling this pin high.
And could you also provide a pic how you’ve powered the shield?


#19

@rossdeane, I’ve just realized that there is also a v2 of that board which has more pins

(source of pic http://www.adafruit.com/products/1651)

This is the pinout of an Arduino shield (seen from the top - needs to be flipped to fit the above pic)

(source of pic https://cdn.sparkfun.com)

Could it be that you’ve got this one?
If so, your wiring would be two pins off, which would explain a lot :wink:


#20

Hey guys, I have read this discussion and I find it really interesting. But, because I’m totally new at this. I still don’t know what pins are wired to which and what wire. Can someone please guide me step to step on the wire and placement on the board? Thank you :grin:


#21

To answer that, you’d need to give us some info.
As mentioned in my last post - there are two versions of that shied, which one have you got?
Are you using the Photon Shield Shield or not?
Do you want/need to use the SD slot?


#22

Hey ScruffR! I figured how to connect to my 2.8" TFT Touch Shield with the help of a teacher. However I don’t know how to change the code of arduino to be able to use to the Photon. This will in turn make the TFT shield display a clock. The guide I was using is here: http://makezine.com/projects/s-m-a-r-t-alarm-clock/. I don’t know how to change the code they gave at step 5 and 10. When I try to test the code it tells me there is a error that says " air/pgmspace.h: No such file or directory.


#23

There already is a library ported for Particle
https://build.particle.io/libs/54e60eba88e2af9209001345

There are also some threads that deal with porting from Arduino to Particle
e.g
Porting from Arduino to Particle.io (Simplified-Hopefully)
http://community.spark.io/t/library-list-porting-how-to/8927

And there even is a github repo with some basic tips (including PGMSPACE)
https://github.com/harrisonhjones/Spark-Ported-Libraries

Although some info got obsolete already since some things have been incorporated in the framework already
e.g.
pgmspace.h: No such file or directory can easily be cured with

#ifdef __AVR__
#include <avr/pgmspace.h>
#else
/* this block is not required anymore
 * #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
 * #define pgm_read_byte_near(addr) (*(const unsigned char *)(addr))
 * #define pgm_read_word(addr) (*(const unsigned short *)(addr))
 * #define pgm_read_word_near(addr) (*(const unsigned short *)(addr))
 */
#endif

Same for the F() macro - it’s already there.


Arduino Yun code to Photon code help
#24

This is my
Display Pinout
Photon TFT touch shield
A2 D10
A3 D13
A4 D12
A5 D11
TX D7
GND GND
Vin 5V
D4 D9
D5 Reset pin
Thanks for the help! After rereading and trail and error I figured it out :smiley:


#25

Thanks for the help! I solved that error… But now I have another error. :frowning: The error is: expected ‘=’ ’ ’ ’ ’ ‘asm’ or ‘attribute’ before 'PROGMEN’
How would you solve this issue?
Here is part of my code:

/*
  ST7781R TFT Library.

  2011 Copyright (c) Seeed Technology Inc.

*/


#ifdef __AVR__
#include <avr/pgmspace.h>
#else
/* this block is not required anymore
 * #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
 * #define pgm_read_byte_near(addr) (*(const unsigned char *)(addr))
 * #define pgm_read_word(addr) (*(const unsigned short *)(addr))
 * #define pgm_read_word_near(addr) (*(const unsigned short *)(addr))
 */
#endif

const unsigned char simpleFont[][8] PROGMEM=
{
  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
  {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
  {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
  {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
  {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
  {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
  {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},
  {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
  {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
  {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
  {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
  {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
  {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
  {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
  {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
  {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
  {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
  {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
  {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
  {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},
  {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
  {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
  {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
  {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
  {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
  {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},
  {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
  {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
  {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
  {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
  {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
  {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
  {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
  {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
  {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},
  {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
  {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
  {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
  {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
  {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
  {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
  {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
  {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
  {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
  {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
  {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
  {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
  {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
  {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
  {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
  {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
  {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
  {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
  {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
  {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
  {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
  {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
  {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
  {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
  {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
  {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
  {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
  {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
  {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
  {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
  {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
  {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
  {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},
  {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
  {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
  {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
  {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
  {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
  {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
  {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
  {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},
  {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
  {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
  {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
  {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
  {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
  {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
  {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
  {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
  {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
  {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
  {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
  {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
  {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},
  {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
  {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
  {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},
  {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
  {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},
  {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
  {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00}
};

#26

Now I have 51 errors :stuck_out_tongue:. All of them tell me that ‘x’ was not declare in this scope. Is this because I got the code from Arduino and I need to change somethings before using Particle dev?


#27

@Question, try adding #include "Particle.h" at the top, before theifdef AVR` to see if the errors go away. :wink:


#28

What @peekay123 said :wink:

In the GitHub link I provided above was this

#if defined (SPARK)
  #include "application.h"  // <-- this used to be what's now better called "Particle.h"
#else
  #if defined(ARDUINO) && ARDUINO >= 100
    #include "Arduino.h"
  #else
    #include "WProgram.h"
  #endif
  // here could follow some of the includes only needed on Arduino
  // see bellow
#endif

After adding this the other error: expected '=' ' ' ' ' 'asm' or 'attribute' before 'PROGMEM' should be gone too.
Otherwise just add

#ifdef PROGMEM
#  undef PROGMEM
#endif
#define PROGMEM

after the Particle.h include.


#29

Is the wiring for this different if you want to have your TFT touch shield have touch screen instead of just displaying. Would you have to wire the Photon to the shield differently?


#30

Does that code work with particle dev? Because when they say pgmspace.h: No such file or directory. Your solution only works when you are using Arduino right? Because the software for Arduino already has those files preinstalled. However, in the Particle dev I don’t have the files installed and don’t know where is it.


#31

Have you actually looked at and read the link I even quoted above?

I can repost the same thing

This solution works when it is an Arduino with __AVR__ declared by including that header and #else by exactly not including it.
You won’t need that since the non-AVR processors don’t have the distinction between accessing pgmspace or normal RAM, so no need for any special treatment.
Since you are not including pgmspace.h you definetly won’t get the no such file error for that not needed file.

Or as said in the linked GitHub page


That depends on the exact shield you’re using?
Got a link?


#32

I’m using the TFT touch shield 2.8" version 2. Link: https://www.adafruit.com/product/1651


#33

That link clearly states

and on the board you see a silk note TS CS #8 - that’s the SPI chip select for the touch screen.
So you only need one extra pin to control the CS pin on the display to actually talk to the touch controler.

Here yo can find the wiring info for TFT, resistive TouchScreen & SD

Note that the first three pins are always the same (SPI CLK, MOSI, MISO), only the CS pins need to be seperate (and the TFT also wants a D/C pin).


Porting Adafruit STMPE610 resistive touch screen controller
#34

So, there is only a pin difference between touchscreen and display on the TFT touch shield? What is a silk note? What pin do I have to connect to? I’m really sorry if I’m wasting your time. I just don’t understand much because I am new to everything


#35

The white printing on the bottom of the PCB is called silk screen and the text informs (notes) about pin mapping and other things.

You could use any free IO pin on the Photon (connected to pin #8 on the shield) for that, you’d just inform the library that does the talking to the touch controler which pin to use.

(image source: https://www.adafruit.com/product/1651 )


#36

What is a IO pin? So I can wire any female female jumper wire on the Photon to pin #8 on the TFT shield and there will be Touchscreen? If I inform my library?


#37

Hmm, that’s very basic tho’
IO stands for Input/Output and in connectino with the Photon it refers to the pins marked with D0~D7, A0~A5 & DAC, WKP, RX, TX.
These are pins that can be used in code by use off commands like pinMode(), digitalRead(), digitalWrite(), analogRead(), analogWrite() and via specialized interface libraries like SPI, Serial1, Wire - just to name a few.

Generally yes, but with not any background in programming micro controllers that might be a big chunk to chew without a tutor.