2.8 TFT Breakout board

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

2.8 TFT Breakout board

Postby scoopthepoop » Fri May 04, 2012 10:50 am

Can someone explain to me the way that the sharing of digital pins 8 and 9 works within the code (what does 8 and 9 do in the standard program for the TFT screen)? What are the penalties for doing this? Would I be better off using a mega board with extra pins so that I don't need to share? Currently i am using a nano for communication.

I see in the code that you have to change the pins output/input callout to get the touchscreen to work, how does this effect the function of the TFT?

I want to create a menu where there are buttons created with the fillroundrect function and when the user presses the screen over the button, the button changes color, then when the user releases the button the screen changes to the next menu list. So if I do the shared pins can I do this?

I hope this makes sense in what I am asking.

Thank you.

Josh
scoopthepoop
 
Posts: 26
Joined: Sat Mar 10, 2012 8:54 am

Re: 2.8 TFT Breakout board

Postby adafruit » Fri May 04, 2012 5:08 pm

yes you can use the touch screen and the TFT with shared pins simultaneously.
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: 2.8 TFT Breakout board

Postby scoopthepoop » Fri May 04, 2012 9:27 pm

For the application I mentioned in my first post, it seems that I cannot. As soon as I touch the screen the fillroundrect that I have on screen go away and the screen fills with junk. Also, I was displaying the time from the chronodot and it does not update on the screen anymore.

Since I am using a Nano I have unused D0 and D1, as well as A6 and A7, can I switch to those pins? Would that solve this problem?

I still have no idea what D8 and D9 are doing and why you can supposedly share that pin. The tutorial just says that they are data lines. But how often do they need to communicate (as in when you are drawing a fillroundrect)?

Thank you

Code: Select all
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <Wire.h>
#include <stdint.h>
#include "TouchScreen.h"

// The control pins can connect to any pins but we'll use the
// analog lines since that means we can double up the pins
// with the touch screen (see the TFT paint example)
#define LCD_CS A3    // Chip Select goes to Analog 3
#define LCD_CD A2    // Command/Data goes to Analog 2
#define LCD_WR A1    // LCD Write goes to Analog 1
#define LCD_RD A0    // LCD Read goes to Analog 0
/* For the 8 data pins:
Duemilanove/Diecimila/UNO/etc ('168 and '328 chips) microcontoller:
D0 connects to digital 8
D1 connects to digital 9
D2 connects to digital 2
D3 connects to digital 3
D4 connects to digital 4
D5 connects to digital 5
D6 connects to digital 6
D7 connects to digital 7

For Mega's use pins 22 thru 29 (on the double header at the end)
*/

// For Arduino Uno/Duemilanove, etc
//  connect the SD card with DI going to pin 11, DO going to pin 12 and SCK going to pin 13 (standard)
//  Then pin 10 goes to CS (or whatever you have set up)
#define SD_CS 10     // Set the chip select line to whatever you use (10 doesnt conflict with the library)

// In the SD card, place 24 bit color BMP files (be sure they are 24-bit!)
// There are examples in the sketch folder

#define YP A2  // must be an analog pin, use "An" notation!
#define XM A3  // must be an analog pin, use "An" notation!
#define YM 8   // can be a digital pin
#define XP 9   // can be a digital pin

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

// our TFT wiring
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, 0);

#define DS3231_IC2_Address 0x68

byte read_second;
byte read_minute;
byte read_hour;
byte read_day;
byte read_date;
byte read_month;
byte read_year;
int count = 0;
int AMPM;
int new_menu = 0;

byte read_second_old;
byte read_minute_old;
byte read_hour_old;

void setup()
{
  Serial.begin(9600);

  tft.reset();
 
  // find the TFT display
  uint16_t identifier = tft.readRegister(0x0);
  if (identifier == 0x9325) {
    Serial.println("Found ILI9325");
  } else if (identifier == 0x9328) {
    Serial.println("Found ILI9328");
  } else {
    Serial.print("Unknown driver chip ");
    Serial.println(identifier, HEX);
    while (1);
  } 

  tft.begin(identifier);
 

  tft.fillScreen(0xFFFF);
  tft.reset();
  Wire.begin();
  tft.setRotation(1);
}

void loop()
{
  Wire.beginTransmission(DS3231_IC2_Address);
  Wire.write((uint8_t) 0x00);
  Wire.endTransmission();
 
  Wire.requestFrom(DS3231_IC2_Address, 7);
  read_second = Wire.read();
  read_minute = Wire.read();
  read_hour = Wire.read();
  read_day = Wire.read();
  read_date = Wire.read();
  read_month = Wire.read();
  read_year = Wire.read();
 
  read_second = (((read_second & B11110000)>>4)*10 + (read_second & B00001111)); // convert BCD to decimal
  read_minute = (((read_minute & B11110000)>>4)*10 + (read_minute & B00001111)); // convert BCD to decimal
 
  if (read_hour & B01000000)  // This checks to see if the RTC is in 12-hour mode
    {
      read_hour = (((read_hour & B00010000)>>4)*10 + (read_hour & B00001111)); // convert BCD to decimal
      if (read_hour & B00100000)  // This checks to see if it is PM
          {read_hour = (((read_hour & B00010000)>>4)*10 + (read_hour & B00001111)); // convert BCD to decimal
          AMPM = 0;
          }
      else
          AMPM = 1;
    }
     else
    {  // 24-hour mode
          read_hour = (((read_hour & B00110000)>>4)*10 + (read_hour & B00001111)); // convert BCD to decimal
    } 
 
  tft.setTextSize(5);
 
  if (new_menu == 0){
  tft.fillRoundRect(20, 80, 272, 46, 5, 0xF800);
  tft.fillRoundRect(20, 200, 60, 30, 5, 0xF800);
  tft.fillRoundRect(90, 200, 60, 30, 5, 0xF800);
  tft.fillRoundRect(200, 200, 106, 30, 5, 0xF800);
  tft.setTextSize(3);
  tft.setTextColor(0x0000, 0xF800);
  tft.setCursor(33,204);
  tft.print("ON");
  tft.setCursor(95,204);
  tft.print("OFF");
  tft.setTextSize(2);
  tft.setCursor(205,207);
  tft.print("SETTINGS");
  tft.setTextSize(5);
  new_menu = 1;
  }
  if (read_hour < 10)
    {
      tft.setTextColor(0x0000, 0xF800);
      tft.setCursor(25,85);
      tft.print("0");
      if (read_hour != read_hour_old)
      {
        tft.setTextColor(0x0000, 0xF800);
        tft.setCursor(55,85);
        tft.print(read_hour);
        read_hour_old = read_hour;
      }
    }
    else
    {
      if (read_hour != read_hour_old)
      {
        tft.setTextColor(0x0000, 0xF800);
        tft.setCursor(25,85);
        tft.print(read_hour);
        read_hour_old = read_hour;
      }
     
    }
  tft.setTextColor(0x0000);
  tft.setCursor(75,85); 
  tft.print(":");
  if (read_minute < 10)
    {
      tft.setTextColor(0x0000, 0xF800);
      tft.setCursor(95,85);
      tft.print("0");
      if (read_minute != read_minute_old)
      {
        tft.setTextColor(0x0000, 0xF800);
        tft.setCursor(125,85);
        tft.print(read_minute);
        read_minute_old = read_minute;
      }
     
    }
    else
    {
      if (read_minute != read_minute_old)
      {
        tft.setTextColor(0x0000, 0xF800);
        tft.setCursor(95,85);
        tft.print(read_minute);
        read_minute_old = read_minute;
      }
     
    }
  tft.setTextColor(0x0000);
  tft.setCursor(145,85); 
  tft.print(":");
  if (read_second < 10)
    {
      tft.setTextColor(0x0000, 0xF800);
      tft.setCursor(165,85);
      tft.print("0");
      if (read_second != read_second_old)
      {
        tft.setCursor(195,85);
        tft.setTextColor(0x0000, 0xF800);
        tft.print(read_second);
        read_second_old = read_second;
      }
    }
    else
    {

      if (read_second != read_second_old)
      {
        tft.setTextColor(0x0000, 0xF800);
        tft.setCursor(165,85);
        tft.print(read_second);
        read_second_old = read_second;
    }
 
  if (AMPM = 0)
    {
      tft.setCursor(230,85);
      tft.print("AM");
    }
    else
    {
      tft.setCursor(230,85);
      tft.print("PM");
    }
  read_second_old = read_second;
  read_minute_old = read_minute;
  read_hour_old = read_hour;
 

    // a point object holds x y and z coordinates
  Point p = ts.getPoint();
 
  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!
  if (p.z > ts.pressureThreshhold) {
     Serial.print("X = "); Serial.print(p.x);
     Serial.print("\tY = "); Serial.print(p.y);
     Serial.print("\tPressure = "); Serial.println(p.z);
  }

  //delay(100);

}
}
scoopthepoop
 
Posts: 26
Joined: Sat Mar 10, 2012 8:54 am

Re: 2.8 TFT Breakout board

Postby adafruit » Fri May 04, 2012 10:02 pm

does the paint example work?
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: 2.8 TFT Breakout board

Postby scoopthepoop » Sat May 05, 2012 9:15 am

Yes, the paint example works just fine.
scoopthepoop
 
Posts: 26
Joined: Sat Mar 10, 2012 8:54 am

Re: 2.8 TFT Breakout board

Postby adafruit » Sat May 05, 2012 12:01 pm

the paint example draws circles and handles touch at the same time, essentially. just duplicate how that works
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: 2.8 TFT Breakout board

Postby scoopthepoop » Sat May 05, 2012 12:17 pm

Struggling with this, but I am trying.

Question on the code with a nano though, why is it when I try to use analog pins 6 and 7 instead of 2 and 3 does the sketch not work?

#define YP A7 // must be an analog pin, use "An" notation!
#define XM A6 // must be an analog pin, use "An" notation!
#define YM 9 // can be a digital pin
#define XP 8 // can be a digital pin
scoopthepoop
 
Posts: 26
Joined: Sat Mar 10, 2012 8:54 am

Re: 2.8 TFT Breakout board

Postby adafruit » Sat May 05, 2012 3:33 pm

we dont know what is different with the nano, we've never used it
best idea: do not change the pin setup from the paint example, as you have seen, it works!
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: 2.8 TFT Breakout board

Postby scoopthepoop » Sat May 05, 2012 4:22 pm

The example code just isn't working with the time output from the chronodot (it just doesn't change time).

So I have switched to the Mega 2560.

In the tutorial for the LCD and touchscreen you state...

You can wire up the 4 remaining pins as follows. the one on the very left (Y- orange) can connect to digital 9, the next one over (X- green) connects to Analog 2, The next one over (Y+ blue) connects to Analog 3 and the last one (X+ gray) connects to digital 8. The X- and Y+ pins pretty much have to connect to those analog pins (or to analog 4/5) but Y-/X+ can connect to any digital or analog pins.


Is there a reason you say that you have to connect to analog 2, 3, 4, or 5? Can I use one of the other analog pins on the mega??

Thank you.
scoopthepoop
 
Posts: 26
Joined: Sat Mar 10, 2012 8:54 am

Re: 2.8 TFT Breakout board

Postby adafruit » Sat May 05, 2012 4:50 pm

you could try it, but we can't really provide software writing tech support beyond getting the example code working. try spending a few days with the code, and reading through the library if you want to change the pinouts.
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: 2.8 TFT Breakout board

Postby scoopthepoop » Sat May 05, 2012 5:33 pm

I got it with help from johnwasser over at arduino.cc/forum.
scoopthepoop
 
Posts: 26
Joined: Sat Mar 10, 2012 8:54 am


Return to Glowy things (LCD, LED, TFT, EL) purchased at Adafruit

Who is online

Users browsing this forum: mibignistinly, swissarmy and 6 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]