PickyBiker
Well-known member
This simple sketch works on Arduino UNO but not on Teensy 4.0. On the Teensyit tries to display Hello World but it shows up in the wring place with some of the letters corrupted. I suspect the Teensy's 600 Mhz clock vs UNO's 16 Mhz clock has something to do with it. But what can I do to make it work?
This is the display and it is in SPI mode. https://smile.amazon.com/gp/product/B00TIYUWNY/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1
This is the display and it is in SPI mode. https://smile.amazon.com/gp/product/B00TIYUWNY/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1
Code:
#include "Adafruit_HX8357.h"
#include <Adafruit_GFX.h> // Core graphics library
#include "TouchScreen.h"
// These are the four touchscreen analog pins
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A3 // must be an analog pin, use "An" notation!
#define YM 7 // can be a digital pin
#define XP 8 // can be a digital pin
TouchScreen tscr = TouchScreen(XP, YP, XM, YM, 500);
#define MINPRESSURE 300
#define MAXPRESSURE 1000
// The display uses hardware SPI, plus #9 & #10
#define TFT_RST -1 // dont use a reset pin, tie to arduino RST if you like
#define TFT_DC 9
#define TFT_CS 10
// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 110
#define TS_MINY 80
#define TS_MAXX 900
#define TS_MAXY 940
Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, TFT_RST);
// Colors
#define BACKGROUND 0xB5B6
#define HIGHLIGHT 0x0500
#define TEXTCLR 0x0000
#define BORDER 0x0000
#define BUTTON 0xAD75
#define RED 0xA800
#define GREEN 0x0360
#define WHITE 0xFFFF
void setup()
{
Serial.begin(115200);
tft.begin();
tft.fillScreen(WHITE);
tft.setTextSize(3);
tft.setCursor(130,150);
tft.setTextColor(TEXTCLR);
tft.setRotation(1);
tft.print("Hello World");
}
void loop()
{
}
Last edited: