7 inch TFT - Capacitive Touch Application Help Needed

Status
Not open for further replies.
sumotoy -- out of curiosity, are you saying the "300mA ( VDD=5.0V)" max figure isn't to be trusted?
For 7" at 100% luminosity not! I cannot measure now but for sure it's between 450 to 700ma. The USB it's not enough to power up
 
Hello,

I have found that older thread. It is matching what I am trying to do... I have ordered the same display and want to used it with Teensy 3.2 and Audio. So, my problem is, that the PINs that are used for that TFT are allready used for Audio... What can I do?
 
Hello,

I have found that older thread. It is matching what I am trying to do... I have ordered the same display and want to used it with Teensy 3.2 and Audio. So, my problem is, that the PINs that are used for that TFT are allready used for Audio... What can I do?
It depends on what pins.

The Audio shield uses 18/A4 and 19/A5 for the i2c bus, which allows other devices to be connected to the bus, assuming they have a different i2c bus than the devices already in use. The Audio board uses addresses 0x0A and 0x1A.

The Audio shield also uses the SPI bus, but you have to use two alternate pins (you have to use pin 7 instead of pin 11, and pin 14/A0 instead of 13). In addition, you need to change the CS pin (chip select) to be a pin that isn't used by anything else. Some devices need to use the special hardware chip select pins, and you would need to use 20/A6 or 21/A7 if the display has the special optimizations.
 
ah, OK.... yes, I understand... so, I2C is able to drive some more devices on the same Bus... so I can use the same PINs... But that is not possible for SPI... so thats why I need to use different SPI- PINs 1 and 14 and CS PIN 20...

thank you very much for your quick answer.

Edit: and if I am right... I should use PIN 9 instead of PIN 2 when I am using Teensy 3.2 instead of Teensy 3.1 ?
 
Last edited:
Sorry to ask again.. have not solved the problem till. Display stays all time black.

So on Teensy 3.2 I use is available PIN 0, 1, 2, 3, 4, 5, 8, 16, 17, 20, 21, 22 and all above...

For I2C communication I can use PIN 18 and 19, cause it can work together with Audio-Board....

For SPI I have to find different PINs- for CS PINs 9, 10, 15, 20 and 21 can be used... so 20 should work
- for Din 8 and 12 could be used- but both are used by Audio-Board
- for Dout 7 and 11 could be used... both are used by Audio-Board...

So what could I do?
 
The audio board uses pin 14 as SCLK (instead of 13), pin 7 for DOUT/MOSI (instead of pin 11), pin 12 for DIN/MISO as SPI pins. You can share SPI devices, using SCLK, DOUT/MOSI, and DIN/MISO for all devices, providing each device has a separate chip select (CS) pin. If you are not using the standard pins, you have to tell SPI about the alternate pin usage.

There are some devices (normally displays) that must use a specific subset of CS pins. On Teensy 3.2:
  • Pin 10 or Pin 2 (if you use pin 10 for one device's CS pin, you cannot use pin 2 as another SPI CS pin);
  • Pin 9 or Pin 6 (if you use pin 9 for one device's CS pin, you cannot use pin 6 for another SPI CS pin);
  • Pin 15/A1;
  • Pin 20/A6 or Pin 23/A9 (if you use pin 20 for one device's CS pin, you cannot use pin 23 for another SPI CS pin);
  • Pin 21/A7 or Pin 22/A8 (if you use pin 21 for one device's CS pin, you cannot use pin 22 for another SPI CS pin).

In addition, most of the displays have a second pin (D/C) that flips between data/command, and this pin also must be a special CS pin. In the displays I've looked at (ST7753, SSD1351), there is a reset pin, but that pin does not have to be one of the special pins.

The Audio boards defines 2 SPI devices:
  • Pin 6 is the CS for the flash memory controller;
  • Pin 10 is the CS for the SD card.

This means of the special pins, you have only pins 20/A6 and 21/A7 (pins 9, 11, 13, 22, and 23 are used for i2s; pin 15/A1 has resistors/etc. for soldering a volume switch to the board).

See this post for more details: https://forum.pjrc.com/threads/33014-SPI-Chip-Selects-(Teensy-3-1-vs-3-2)?p=96072#post96072.
 
Last edited:
Just like to say thank you to sumotoy. I've got the 7" screen with capacitive touch working in no time. Excellent library.

C031hbmXcAIzYDY.jpg-large.jpeg
 
The only problem I've found with the 7" display is the pixels are not square, so when you draw a circle it is not completely round. Makes displaying gauges not look right.
 
That means that you'll simply have to add a #define for the aspect ratio and to tweak the drawing functions in the library for a simple linear correction.
 
Hello together,

its me again... So display is working very nice.... :) But when I am trying to add some code (what is in /* */ in setup() ) for Audio-shield the display stopps working... So what is going wrong?

Attached you will find my code - it is not so nice... I am working on it...

Code:
#include <SPI.h>
#include <RA8875.h>
#include <SD.h>
#include <Encoder.h>
#include <Bounce2.h>
#include <Wire.h>
#include <SerialFlash.h>
#include <Audio.h>

Encoder Oben(0, 1);
Encoder Unten(5, 4);
byte positionOben  = 255;
byte positionUnten = 15;
byte MenuObenKnopf;
byte MenuObenZaehler = 0;
byte MenuObenZaehleralt;
byte MenuObenEbene = 0;
byte MenuObenEbenealt;
byte MenuUntenKnopf;
byte MenuUntenZaehler = 0;
byte MenuUntenZaehleralt;
byte MenuUntenEbene = 0;
byte MenuUntenEbenealt;
byte aktiverBildSchirm;

#define KnopfObenPIN 2
#define KnopfUntenPIN 21
Bounce debouncer1 = Bounce(); 
Bounce debouncer2 = Bounce(); 

#define RA8875_CS 9
#define RA8875_RESET 20
#define RA8875_MOSI 7
#define RA8875_SCLK 14
#define RA8875_MISO 8
#define SD_DEC     29 //in

RA8875 tft = RA8875(RA8875_CS,RA8875_RESET,RA8875_MOSI,RA8875_SCLK,RA8875_MISO);//Teensy using alternative SPI pin + alt miso

AudioInputI2S            i2s1;           //xy=200,69
AudioOutputI2S           i2s2;           //xy=365,94
AudioConnection          patchCord1(i2s1, 0, i2s2, 0);
AudioConnection          patchCord2(i2s1, 1, i2s2, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=302,184
const int myInput = AUDIO_INPUT_LINEIN;

void setup() 
{
  Serial.begin(115200);
  Serial.println("RA8875 start");
  
  tft.begin(RA8875_800x480);
  tft.println("starte Radio.... na, was sagst du nun?");
  tft.brightness(25);
  tft.setRotation(2);

  pinMode(KnopfObenPIN,INPUT_PULLUP);
  debouncer1.attach(KnopfObenPIN);
  debouncer1.interval(20);
  
  pinMode(KnopfUntenPIN,INPUT_PULLUP);
  debouncer2.attach(KnopfUntenPIN);
  debouncer2.interval(20);
  
  AudioMemory(12);
  
  /*sgtl5000_1.enable();
  sgtl5000_1.inputSelect(myInput);
  sgtl5000_1.volume(0.7);*/
}

elapsedMillis volmsec=0;

void loop() 
{
 DrehEncoder();
 MenuWahl();
 //Kalender();
 //SDCardPlayer();
 //Sonnenberechnung();
 //Uhr();
}

void StartBildSchirm()
{
  tft.clearScreen();
  tft.setCursor(0, 60);
  tft.setTextColor(RA8875_BLUE);
  tft.setFontScale(2);
  tft.print("StartBildschirm "); 
  aktiverBildSchirm = 0;  
}

void MenuBildSchirm()
{
  tft.clearScreen(); 
  tft.drawRoundRect( 5,  60, 250, 40, 5, RA8875_DARK_ORANGE); 
  tft.fillRoundRect( 6,  61, 248, 38, 4, RA8875_LIGHT_GREY); 
  tft.drawRoundRect( 5, 110, 250, 40, 5, RA8875_DARK_ORANGE); 
  tft.fillRoundRect( 6, 111, 248, 38, 4, RA8875_LIGHT_GREY);  
  tft.drawRoundRect( 5, 160, 250, 40, 5, RA8875_DARK_ORANGE); 
  tft.fillRoundRect( 6, 161, 248, 38, 4, RA8875_LIGHT_GREY);  
  tft.drawRoundRect( 5, 210, 250, 40, 5, RA8875_DARK_ORANGE); 
  tft.fillRoundRect( 6, 211, 248, 38, 4, RA8875_LIGHT_GREY);  
  tft.drawRoundRect( 5, 260, 250, 40, 5, RA8875_DARK_ORANGE); 
  tft.fillRoundRect( 6, 261, 248, 38, 4, RA8875_LIGHT_GREY);  
  tft.drawRoundRect( 5, 310, 250, 40, 5, RA8875_DARK_ORANGE); 
  tft.fillRoundRect( 6, 311, 248, 38, 4, RA8875_LIGHT_GREY);
  tft.setTextColor(RA8875_BLUE);
  tft.setFontScale(1);
  tft.setCursor(20, 60);
  tft.print("zurueck ");  
  tft.setCursor(20, 110);
  tft.print("Radio ");  
  tft.setCursor(20, 160);
  tft.print("eigene Musik ");  
  tft.setCursor(20, 210);
  tft.print("einschlafen ");  
  tft.setCursor(20, 260);
  tft.print("wecken ");
  tft.setCursor(20, 310);
  tft.print("Uhr ");   
  aktiverBildSchirm = 1; 
}

void RadioBildSchirm()
{
  tft.clearScreen();
  tft.setCursor(0, 60);
  tft.setTextColor(RA8875_BLUE);
  tft.setFontScale(1);
  tft.print("Radio ");   
  aktiverBildSchirm = 2; 
}

void SDBildSchirm()
{
  tft.clearScreen();
  tft.setCursor(0, 60);
  tft.setTextColor(RA8875_BLUE);
  tft.setFontScale(1);
  tft.print("eigene Musik "); 
  aktiverBildSchirm = 3;   
}

void EinschlafTimerBildSchirm()
{
  tft.clearScreen();
  tft.setCursor(0, 60);
  tft.setTextColor(RA8875_BLUE);
  tft.setFontScale(1);
  tft.print("Schlafen ");
  aktiverBildSchirm = 4;    
}

void WeckerBildSchirm()
{
  tft.clearScreen();
  tft.setCursor(0, 60);
  tft.setTextColor(RA8875_BLUE);
  tft.setFontScale(1);
  tft.print("Wecker ");
  aktiverBildSchirm = 5;    
}

void UhrBildSchirm()
{
  tft.clearScreen();
  tft.setCursor(0, 60);
  tft.setTextColor(RA8875_BLUE);
  tft.setFontScale(1);
  tft.print("Uhr   "); 
  aktiverBildSchirm = 6;      
}

void MenuWahl()
{
  if ( MenuUntenEbene == 0 && debouncer2.rose() )
     { MenuUntenEbene = 1; Unten.write(0); MenuBildSchirm(); }
  
  if ( MenuUntenEbene == 1 )
     {
       if ( MenuUntenZaehler > 6 ) { Unten.write(0); }
      
       if ( MenuUntenZaehler == 0 )
          { if ( MenuUntenZaehler != MenuUntenZaehleralt )
             { tft.drawRoundRect( 5,  60, 250, 40, 5, RA8875_YELLOW); 
               tft.drawRoundRect( 5, 110, 250, 40, 5, RA8875_DARK_ORANGE);
               tft.drawRoundRect( 5, 160, 250, 40, 5, RA8875_DARK_ORANGE);
               tft.drawRoundRect( 5, 210, 250, 40, 5, RA8875_DARK_ORANGE);
               tft.drawRoundRect( 5, 260, 250, 40, 5, RA8875_DARK_ORANGE);
               tft.drawRoundRect( 5, 310, 250, 40, 5, RA8875_DARK_ORANGE);
               MenuUntenZaehleralt = MenuUntenZaehler; } 

          if ( debouncer2.fell() ) { MenuUntenEbene = 0;  Unten.write(0); tft.fillWindow(); StartBildSchirm(); } }
      
       if ( MenuUntenZaehler == 1 )
          { if ( MenuUntenZaehler != MenuUntenZaehleralt )
            { tft.drawRoundRect( 5,  60, 250, 40, 5, RA8875_DARK_ORANGE); 
              tft.drawRoundRect( 5, 110, 250, 40, 5, RA8875_YELLOW);
              tft.drawRoundRect( 5, 160, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 210, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 260, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 310, 250, 40, 5, RA8875_DARK_ORANGE);
              MenuUntenZaehleralt = MenuUntenZaehler; }
     
          if ( debouncer2.rose() ) { MenuUntenEbene = 2;  Unten.write(0); tft.fillWindow(); RadioBildSchirm(); RadioAktiv();} }
           
       if ( MenuUntenZaehler == 2 )
          { if ( MenuUntenZaehler != MenuUntenZaehleralt )
            { tft.drawRoundRect( 5,  60, 250, 40, 5, RA8875_DARK_ORANGE); 
              tft.drawRoundRect( 5, 110, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 160, 250, 40, 5, RA8875_YELLOW);
              tft.drawRoundRect( 5, 210, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 260, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 310, 250, 40, 5, RA8875_DARK_ORANGE);
              MenuUntenZaehleralt = MenuUntenZaehler; }
            
          if ( debouncer2.rose() ) { MenuUntenEbene = 3;  Unten.write(0); tft.fillWindow(); SDBildSchirm(); } }
      
       if ( MenuUntenZaehler == 3 )
          { if ( MenuUntenZaehler != MenuUntenZaehleralt )
            { tft.drawRoundRect( 5,  60, 250, 40, 5, RA8875_DARK_ORANGE); 
              tft.drawRoundRect( 5, 110, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 160, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 210, 250, 40, 5, RA8875_YELLOW);
              tft.drawRoundRect( 5, 260, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 310, 250, 40, 5, RA8875_DARK_ORANGE);
              MenuUntenZaehleralt = MenuUntenZaehler; }
            
          if ( debouncer2.rose() ) { MenuUntenEbene = 4;  Unten.write(0); tft.fillWindow(); EinschlafTimerBildSchirm(); } }
      
       if ( MenuUntenZaehler == 4 )
          { if ( MenuUntenZaehler != MenuUntenZaehleralt )
            { tft.drawRoundRect( 5,  60, 250, 40, 5, RA8875_DARK_ORANGE); 
              tft.drawRoundRect( 5, 110, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 160, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 210, 250, 40, 5, RA8875_DARK_ORANGE);
              tft.drawRoundRect( 5, 260, 250, 40, 5, RA8875_YELLOW);
              tft.drawRoundRect( 5, 310, 250, 40, 5, RA8875_DARK_ORANGE);
              MenuUntenZaehleralt = MenuUntenZaehler; } 
            
          if ( debouncer2.rose() ) { MenuUntenEbene = 5;  Unten.write(0); tft.fillWindow(); WeckerBildSchirm(); } }
      
       if ( MenuUntenZaehler == 5 )
          { if ( MenuUntenZaehler != MenuUntenZaehleralt )
          { tft.drawRoundRect( 5,  60, 250, 40, 5, RA8875_DARK_ORANGE); 
            tft.drawRoundRect( 5, 110, 250, 40, 5, RA8875_DARK_ORANGE);
            tft.drawRoundRect( 5, 160, 250, 40, 5, RA8875_DARK_ORANGE);
            tft.drawRoundRect( 5, 210, 250, 40, 5, RA8875_DARK_ORANGE);
            tft.drawRoundRect( 5, 260, 250, 40, 5, RA8875_DARK_ORANGE);
            tft.drawRoundRect( 5, 310, 250, 40, 5, RA8875_YELLOW);
            MenuUntenZaehleralt = MenuUntenZaehler; }
            
          if ( debouncer2.rose() ) { MenuUntenEbene = 6;  Unten.write(0); tft.fillWindow(); UhrBildSchirm(); } }
     }   
 
  if ( MenuUntenEbene == 2 && MenuUntenZaehler == 0 && debouncer2.rose() )
     { MenuUntenEbene = 1; MenuBildSchirm();}
      
  if ( MenuUntenEbene == 3 && MenuUntenZaehler == 0 && debouncer2.rose() )
     { MenuUntenEbene = 1; MenuBildSchirm();}

  if ( MenuUntenEbene == 4 && MenuUntenZaehler == 0 && debouncer2.rose() )
     { MenuUntenEbene = 1; MenuBildSchirm();}

  if ( MenuUntenEbene == 5 && MenuUntenZaehler == 0 && debouncer2.rose() )
     { MenuUntenEbene = 1; MenuBildSchirm();}

  if ( MenuUntenEbene == 6 && MenuUntenZaehler == 0 && debouncer2.rose() )
     { MenuUntenEbene = 1; MenuBildSchirm();}
  
  //else { StartBildSchirm(); }
  if (  debouncer1.fell() || debouncer1.rose() )
  { Serial.print("Menu Ebene oben ");
    Serial.println(MenuObenEbene);}
    
  if (  debouncer2.fell() || debouncer2.rose() )
  { Serial.print("Menu Ebene unten ");
    Serial.println(MenuUntenEbene);}
}

void DrehEncoder() 
{ 
  MenuObenZaehler = Oben.read()/4;
  MenuUntenZaehler = Unten.read()/4;
  debouncer1.update();
  debouncer2.update();
  
  if (MenuObenZaehler != positionOben)
  {
    positionOben = MenuObenZaehler;
  Serial.print("Menu Zaehler oben ");
  Serial.println(MenuObenZaehler);
  }  
  if (MenuUntenZaehler != positionUnten) 
  {
    positionUnten = MenuUntenZaehler;
  Serial.print("Menu Zaehler unten ");
  Serial.println(MenuUntenZaehler);
  }     
}

void RadioAktiv()
{
   
}
 
In the meanwhile I have tryed some things... and found out, that TFT- problems starts when SD- Card is in the Audio-shield-slot... w/o any changes in code...

And so I read some postings to that issue and found that there might be a problem with RA8875- SPI and other devices on the same line. So TFT is ussing PIN7 on teensy for MOSI, PIN8 for MISO and PIN14 for CLK.
Audio Board uses (?) PIN7 for MOSI too and PIN12 for MISO... PIN11 could also be used as MOSI, but is allready used from Audio-Board... so what can I do? Would it be better to use PIN11 for TFT? But what should I do with that connection to Audio-Board?
 
If you are going to use the Audio board, you need to use the same SPI pins for SCLK (i.e. pin 14/A0 instead of 13), MOSI (i.e. pin 7 instead of pin 11), and MISO (pin 12) for your device. You can't use either pins 6 or 10 for the CS since those are used by the Audio board. See this https://www.pjrc.com/teensy/td_libs_SPI.html and scroll down to the section on Alternate Pins.

Or if you have a Teensy 3.5, 3.6 or LC, there are alternate SPI ports that you could use. You would have to modify the library to use SPI1 or SPI2 instead of SPI.
 
Status
Not open for further replies.
Back
Top