I have a Teensy 3.2 and the 2046 touchscreen with the _t3 library. I've successfully gotten the blink program to run so I'm working on the touchscreen next. I'm not using the Arduino IDE but simply compiling and uploading from Cygwin on Win 7 Pro and that works well (later I'll do an IDE but not now). I'm using a CPP style main from the Teensy core files. I'm also looking at Defragster's XPT2046_Touchscreen github work as an example and have some questions.
1. I'm compiling with SPI so I assume that's what actually talks to the touchscreen unit?
2. I'm seeing some confusing documentation.
A. https://www.pjrc.com/store/display_ili9341_touch.html lists a ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO); as initializiation but Defragster only has two parameters to his call. The ILI9341_t3 source file does not default any of the parameters. This call takes care of the Display portion (the ILI9341) so if I want to use touch I need to add some defines for the T_pins then - correct? The page is for touch but only talks about the display portion of the unit and not the touch setupo.
B. https://www.pjrc.com/store/display_ili9341_touch.html also lists a standard Teensy and Audio. I have, as far as I know a plain Teensy 3.2 that does not have any Audio. Yet according to the section on the optimized library I need to use the pins for the Teensy 3.x with Audio board. I assume that's because the optimized library requires that. Basically I can use any alternates I want as long as I keep to the SPI guidelines.
C. If I'm using the SPI library shouldn't I be using calls like SPI.begin() instead of Serial.begin() or does the Touchscreen library handle that. In the ILI9341_t3.cpp library source there are some Serial.Prints that are commented out so I assuem they are debugging. Or is this Serial for communicating with the console? I seem to remember one of Defragster's posts discussing it worked with the console but not without.
D. The SPI lists four pins that it uses and the XPT2046 has 14. CC, GND, LED are obvious. I assume a non touch would not have the T_ pins which are for touch screen communication.
3. The Welcome to Teensy 3.2 card (very nice including that. It has been very helpful) has pins like CS in bold and also non-bold. I assume Bold is default with non-bold being alternates. Kudos to whoever thought up the card.
I'm assuming once I hook up the pins and download a simply program such as this I should get a red screen. Is that correct?
Thanks.
#include "WProgram.h"
#include "XPT2046_Touchscreen.h"
#include "ILI9341_t3.h"
#include "font_Arial.h"
#include "SPI.H"
/*
Defines for pins.
*/
#define DC_PIN 20
#define CS_PIN 21
#define RST_PIN 255
#define MOSI_PIN 7
#define SCLK_PIN 14
#define MISO_PIN 12
/*
Interrupt pin
*/
#define TIRQ_PIN 2
#define LEDON true
ILI9341_t3 tft = ILI9341_t3(CS_PIN, DC_PIN,RST_PIN, MOSI_PIN, SCLK_PIN, MISO_PIN);
XPT2046_Touchscreen ts = XPT2046_Touchscreen(CS_PIN,TIRQ_PIN);
extern "C" int main(void)
{
#ifdef USING_MAKEFILE
/*
Variables
*/
/*
Initial setup.
*/
Serial.begin(38400);
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_RED);
ts.begin();
while (!SERIAL && (millis() <= 10000)); /* Give it time to initalize. */
} /* End main
1. I'm compiling with SPI so I assume that's what actually talks to the touchscreen unit?
2. I'm seeing some confusing documentation.
A. https://www.pjrc.com/store/display_ili9341_touch.html lists a ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO); as initializiation but Defragster only has two parameters to his call. The ILI9341_t3 source file does not default any of the parameters. This call takes care of the Display portion (the ILI9341) so if I want to use touch I need to add some defines for the T_pins then - correct? The page is for touch but only talks about the display portion of the unit and not the touch setupo.
B. https://www.pjrc.com/store/display_ili9341_touch.html also lists a standard Teensy and Audio. I have, as far as I know a plain Teensy 3.2 that does not have any Audio. Yet according to the section on the optimized library I need to use the pins for the Teensy 3.x with Audio board. I assume that's because the optimized library requires that. Basically I can use any alternates I want as long as I keep to the SPI guidelines.
C. If I'm using the SPI library shouldn't I be using calls like SPI.begin() instead of Serial.begin() or does the Touchscreen library handle that. In the ILI9341_t3.cpp library source there are some Serial.Prints that are commented out so I assuem they are debugging. Or is this Serial for communicating with the console? I seem to remember one of Defragster's posts discussing it worked with the console but not without.
D. The SPI lists four pins that it uses and the XPT2046 has 14. CC, GND, LED are obvious. I assume a non touch would not have the T_ pins which are for touch screen communication.
3. The Welcome to Teensy 3.2 card (very nice including that. It has been very helpful) has pins like CS in bold and also non-bold. I assume Bold is default with non-bold being alternates. Kudos to whoever thought up the card.
I'm assuming once I hook up the pins and download a simply program such as this I should get a red screen. Is that correct?
Thanks.
#include "WProgram.h"
#include "XPT2046_Touchscreen.h"
#include "ILI9341_t3.h"
#include "font_Arial.h"
#include "SPI.H"
/*
Defines for pins.
*/
#define DC_PIN 20
#define CS_PIN 21
#define RST_PIN 255
#define MOSI_PIN 7
#define SCLK_PIN 14
#define MISO_PIN 12
/*
Interrupt pin
*/
#define TIRQ_PIN 2
#define LEDON true
ILI9341_t3 tft = ILI9341_t3(CS_PIN, DC_PIN,RST_PIN, MOSI_PIN, SCLK_PIN, MISO_PIN);
XPT2046_Touchscreen ts = XPT2046_Touchscreen(CS_PIN,TIRQ_PIN);
extern "C" int main(void)
{
#ifdef USING_MAKEFILE
/*
Variables
*/
/*
Initial setup.
*/
Serial.begin(38400);
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_RED);
ts.begin();
while (!SERIAL && (millis() <= 10000)); /* Give it time to initalize. */
} /* End main