#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST2 21
#define TFT_DC2 20
#define TFT_CS2 15
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST);
ILI9341_t3 tft2 = ILI9341_t3(TFT_CS2, TFT_DC2, TFT_RST2);
tft.begin();
tft.setTextColor(BLACK);
tft.setRotation(3);
tft.fillScreen(ILI9341_GREEN);
tft.setTextSize(1);
tft.setCursor(320-80,0);
tft.print("First TFT");
tft2.begin();
tft2.setTextColor(BLACK);
tft2.setRotation(3);
tft2.fillScreen(ILI9341_RED);
tft2.setTextSize(1);
tft2.setCursor(320-80,0);
tft2.print("Second TFT");
pinMode(TFT_CS2, OUTPUT);
digitalWrite(TFT_CS2, HIGH);
tft.begin();
tft.setTextColor(BLACK);
tft.setRotation(3);
tft.fillScreen(ILI9341_GREEN);
tft.setTextSize(1);
tft.setCursor(320-80,0);
tft.print("First TFT");
tft2.begin();
tft2.setTextColor(BLACK);
tft2.setRotation(3);
tft2.fillScreen(ILI9341_RED);
tft2.setTextSize(1);
tft2.setCursor(320-80,0);
tft2.print("Second TFT");
#include <Arduino.h>
#include <SPI.h>
#include <ILI9341_t3n.h>
#include <SPIN.h>
#include <fonts/font_Raleway-Medium.h>
#include <colours.h>
#define TFT_SCLK 27
#define TFT_DC 40
#define TFT_MOSI 26
#define TFT_MISO 39
#define TFT1_RST 33
#define TFT1_CS 0
#define TFT2_RST 34
#define TFT2_CS 38
ILI9341_t3n tft_Track = ILI9341_t3n(TFT1_CS, TFT_DC, TFT1_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);
ILI9341_t3n tft_Func = ILI9341_t3n(TFT2_CS, TFT_DC, TFT2_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);
void setup()
{
tft_Track.useFrameBuffer(true);
tft_Track.begin();
tft_Track.fillScreen(BACKGROUND);
tft_Func.useFrameBuffer(true);
tft_Func.begin();
tft_Func.fillScreen(BACKGROUND);
}
void DrawIndicator(ILI9341_t3n ScreenRef,uint16_t Y, uint16_t X, uint16_t Width,uint16_t Border, uint16_t IndColour,const char *TEXT,bool Active)
{
int OuterWidth = Width;
int OuterHeight = Width / 2;
int InnerWidth = OuterWidth - (Border*2);
int InnerHeight = (OuterHeight - (Border*2));
int IndHeight = (InnerHeight-6);
int IndWidth = (IndHeight/3);
uint16_t ActColour = BUTTON_ST;
if (Active == true){
ActColour = IndColour;
}
ScreenRef.fillRect(X, Y, OuterWidth, OuterHeight, BUTTON_ST);
ScreenRef.fillRect(X + Border, Y + Border, InnerWidth, InnerHeight, BUTTON_BG);
ScreenRef.fillRect(X + Border, Y + Border, InnerWidth, 2, BUTTON_HL);
ScreenRef.fillRect(X + (OuterWidth-Border-IndWidth-2), Y + Border + 4, IndWidth, IndHeight,ActColour);
ScreenRef.setTextColor(ILI9341_WHITE);
ScreenRef.setFont(RalewayMedium_12);
ScreenRef.setCursor(X+5,Y+(InnerHeight/2)-2.0);
ScreenRef.print(TEXT);
}
void loop()
{
DrawIndicator(tft_Track,30, 30,75,3,ILI9341_GREEN,"SOLO",true);
DrawIndicator(tft_Func,30, 30,75,3,ILI9341_RED,"MUTE",true);
tft_Track.updateScreen();
tft_Func.updateScreen();
}
#include <ILI9341_t3n.h>
#include "ili9341_t3n_font_Arial.h"
//****************************************************************************
// Settings and objects
//****************************************************************************
#define TFT_DC 9
#define TFT_CS 7
#define TFT_RST 8
#define TFT_SCK 13
#define TFT_MISO 12
#define TFT_MOSI 11
#define TOUCH_CS 6
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCK, TFT_MISO);
void drawTextWithBoundingRect(uint16_t x, uint16_t y, const char *str) {
int16_t x1, y1, w, h;
tft.setCursor(x, y);
tft.getTextBounds(str, x, y, &x1, &y1, &w, &h);
tft.print(str);
tft.drawRect(x1, y1, w, h, ILI9341_RED);
}
void drawCenteredText(uint16_t x, uint16_t y, uint16_t w, uint16_t h,
const char *str) {
tft.fillRect(x, y, w, h, ILI9341_YELLOW);
tft.setTextColor(ILI9341_RED, ILI9341_YELLOW);
tft.setCursor(x + w / 2, y + h / 2, true);
// tft.setClipRect(x, y, w, h);
tft.print(str);
// tft.setClipRect();
}
void setup()
{
Serial.begin(9600);
delay(3000);
while (!Serial && millis() < 5000) ;
Serial.println("Teensy 3.2 TFT Clock Program");
#pragma region DISPLAY INITIALIZATION
Serial.println("Initializing TFT display");
tft.begin();
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(2);
tft.setRotation(1);
tft.setFont(Arial_40);
drawTextWithBoundingRect(20, 20, "-");
drawTextWithBoundingRect(60, 20, "+");
drawTextWithBoundingRect(100, 20, "X");
drawTextWithBoundingRect(140, 20, "Next");
drawCenteredText(20, 100, 35, 50, "-");
drawCenteredText(60, 100, 35, 50, "+");
drawCenteredText(100, 100, 35, 50, "X");
drawCenteredText(140, 100, 130, 50, "Next");
}
void loop(void)
{
}
#include <ILI9488_t3.h>
#include "ILI9488_t3_font_Arial.h"
//****************************************************************************
// Settings and objects
//****************************************************************************
#define TFT_DC 9
#define TFT_CS 7
#define TFT_RST 8
#define TFT_SCK 13
#define TFT_MISO 12
#define TFT_MOSI 11
#define TOUCH_CS 6
ILI9488_t3 tft = ILI9488_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCK, TFT_MISO);
void drawTextWithBoundingRect(uint16_t x, uint16_t y, const char *str) {
int16_t x1, y1, w, h;
tft.setCursor(x, y);
tft.getTextBounds(str, x, y, &x1, &y1, &w, &h);
tft.print(str);
tft.drawRect(x1, y1, w, h, ILI9488_RED);
}
void drawCenteredText(uint16_t x, uint16_t y, uint16_t w, uint16_t h,
const char *str) {
tft.fillRect(x, y, w, h, ILI9488_YELLOW);
tft.setTextColor(ILI9488_RED, ILI9488_YELLOW);
tft.setCursor(x + w / 2, y + h / 2, true);
tft.setClipRect(x, y, w, h);
tft.print(str);
tft.setClipRect();
}
void setup()
{
Serial.begin(9600);
delay(3000);
while (!Serial && millis() < 5000) ;
Serial.println("Teensy 3.2 TFT Clock Program");
#pragma region DISPLAY INITIALIZATION
Serial.println("Initializing TFT display");
tft.begin();
tft.fillScreen(ILI9488_BLACK);
tft.setTextColor(ILI9488_YELLOW);
tft.setTextSize(2);
tft.setRotation(1);
tft.setFont(Arial_40);
drawTextWithBoundingRect(20, 20, "-");
drawTextWithBoundingRect(60, 20, "+");
drawTextWithBoundingRect(100, 20, "X");
drawTextWithBoundingRect(140, 20, "Next");
drawCenteredText(20, 100, 35, 50, "-");
drawCenteredText(60, 100, 35, 50, "+");
drawCenteredText(100, 100, 40, 50, "X");
drawCenteredText(150, 100, 130, 50, "Next");
}
void loop(void)
{
}
I have fix for ST7735/89... Pushed a PR
Will let you do the HX8357... Not sure where in my pile of displays I have that one, with a cracked screen
Darn it - forgot about the RA8875 guess we will have to the do the RA8876 - that one is on me.
UPDATE: Just fixed it in @wwatson's RA8876 library and issued a PR.
Darn it - forgot about the RA8875 guess we will have to the do the RA8876 - that one is on me.
UPDATE: Just fixed it in @wwatson's RA8876 library and issued a PR.
#include <Adafruit_GFX.h>
#include <SPI.h>
#include <RA8875.h>
#include "font_Arial.h"
//****************************************************************************
// Settings and objects
//****************************************************************************
#define RA8875_CS 9
#define RA8875_RST 8
RA8875 tft = RA8875(RA8875_CS, RA8875_RST);
void drawTextWithBoundingRect(uint16_t x, uint16_t y, const char *str) {
int16_t x1, y1;
uint16_t w, h;
tft.setCursor(x, y);
tft.getTextBounds(str, x, y, &x1, &y1, &w, &h);
tft.print(str);
tft.drawRect(x1, y1, w, h, RA8875_RED);
}
void drawCenteredText(uint16_t x, uint16_t y, uint16_t w, uint16_t h,
const char *str) {
tft.fillRect(x, y, w, h, RA8875_YELLOW);
tft.setTextColor(RA8875_RED, RA8875_YELLOW);
tft.setCursor(x + w / 2, y + h / 2, true);
tft.setClipRect(x, y, w, h);
tft.print(str);
tft.setClipRect();
}
void setup()
{
Serial.begin(9600);
delay(3000);
while (!Serial && millis() < 5000) ;
Serial.println("Teensy 3.2 TFT Clock Program");
Serial.println("Initializing TFT display");
// begin display: Choose from: RA8875_480x272, RA8875_800x480, RA8875_800x480ALT, Adafruit_480x272, Adafruit_800x480
tft.begin(Adafruit_800x480, 16, 15000000);
tft.fillWindow(RA8875_BLACK);
tft.setTextColor(RA8875_YELLOW);
tft.setTextSize(2);
tft.setRotation(1);
tft.setFont(Arial_40);
drawTextWithBoundingRect(20, 20, "-");
drawTextWithBoundingRect(60, 20, "+");
drawTextWithBoundingRect(100, 20, "X");
drawTextWithBoundingRect(140, 20, "Next");
drawCenteredText(20, 100, 35, 50, "-");
drawCenteredText(60, 100, 35, 50, "+");
drawCenteredText(100, 100, 40, 50, "X");
drawCenteredText(150, 100, 130, 50, "Next");
}
void loop(void)
{
}
#include "SPI.h"
#include "ILI9341_t3n.h"
// *************** Change to your Pin numbers ***************
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 8
#define TFT_SCK 13
#define TFT_MISO 12
#define TFT_MOSI 11
#define TOUCH_CS 6
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCK, TFT_MISO);
#define DEBUG_PIN 0
unsigned int displayWidth = 0u;
unsigned int displayHeight = 0u;
unsigned int middleWidth = 0u;
unsigned int bottomLine = 0u;
unsigned long testMicros = 0ul;
unsigned long millisTimer = 0ul;
void setup()
{
while (!Serial && millis() < 5000) ; // wait for Arduino Serial Monitor
Serial.begin(9600);
delay(500);
Serial.println("ILI9341 Test!");
pinMode(DEBUG_PIN, OUTPUT);
tft.begin();
#ifdef SPI0_DISP2
Serial.println("Reset pin 10 to output");
// pinMode(10, INPUT_PULLUP);
#endif
Serial.println("After TFT Begin");
tft.fillScreen(ILI9341_BLACK);
Serial.println(CORE_PIN10_CONFIG, HEX);
Serial.println(ILI9341_SPICLOCK);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(1);
tft.setRotation(1);
displayWidth = tft.width(),
middleWidth = displayWidth / 2;
displayHeight = tft.height();
bottomLine = displayHeight - 10;
tft.setCursor(middleWidth, bottomLine);
tft.setTextColor(ILI9341_YELLOW);
tft.print("R");
millisTimer = millis();
}
void loop(void)
{
if ( (millis() - millisTimer) >= 33ul)
{
static unsigned int var = 0u;
char objectData[32];
testMicros = micros();
//tft.fillScreen(ILI9341_BLACK);
tft.drawLine(0, bottomLine - 92, middleWidth, bottomLine, ILI9341_YELLOW);
tft.drawLine(middleWidth, bottomLine, displayWidth, bottomLine - 92, ILI9341_YELLOW);
tft.setTextColor(ILI9341_BLACK);
tft.setCursor(var + 5, 200 + 5);
sprintf(objectData, "%d, %d", var + 5, 200 + 5);
tft.print(objectData);
//tft.print(var+5);tft.print(", ");tft.print(120+5);
tft.fillCircle(var, 200, 2, ILI9341_BLACK);
var += 5u;
if (var > 280u)
{
var = 0u;
}
tft.fillCircle(var, 200, 2, ILI9341_CYAN);
tft.setCursor(var + 5, 200 + 5);
tft.setTextColor(ILI9341_CYAN);
sprintf(objectData, "%d, %d", var + 5, 200 + 5);
tft.print(objectData);
//tft.print(var+5);tft.print(", ");tft.print(120+5);
Serial.println(micros() - testMicros);
millisTimer = millis();
//testFastLines(ILI9341_RED, ILI9341_BLUE);
}
}
tft.updateChangedAreasOnly(true);
bool _updateChangedAreasOnly = true; // current default off,
#include "SPI.h"
#include "ILI9341_t3n.h"
#include "constants.h"
#include "variables.h"
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCK, TFT_MISO);
void setup()
{
Serial.begin(57600);
delay(500);
initDisplay();
if ( tft.useFrameBuffer(true) ) Serial.println("Frame buffer is enabled!");
millisTimer = millis();
}
void loop(void)
{
if ( (oneTimeRefresh == true) ||
((runningRefresh == true) &&
((millis() - millisTimer) >= 40ul)) )
{
oneTimeRefresh = false;
testMicros = micros();
/*first clear previously displayed objects*/
clearDisplayedObjects();
/*update values, this is just another for cycle at this point*/
getObjectData();
/*finally draw the FOV lines and update the display with new objects*/
drawFovLines();
updateObjectDisplay();
//tft.updateChangedAreasOnly(true);
tft.updateScreen();
millisTimer = millis();
}
readTerminalInput();
}
void clearDisplayedObjects()
{
char textToDisplay[32];
tft.setTextSize(1);
for (byte i = 0; i < MAX_OBJECT_NUMBER; i++)
{
if (objectData[i].trackStatus == OBJECT_TRACKED)
{
tft.fillCircle(xPos_px[i], yPos_px[i], CIRCLE_SIZE, ILI9341_BLACK);
sprintf(textToDisplay, "%.1f, %.1f", objectData[i].xPos, objectData[i].yPos);
tft.setCursor(xPos_px[i] + OBJECT_TEXT_OFFSET, yPos_px[i] + OBJECT_TEXT_OFFSET);
tft.setTextColor(ILI9341_BLACK, ILI9341_BLACK);
tft.print(textToDisplay);
}
}
}
void getObjectData()
{
for (byte i = 0; i < MAX_OBJECT_NUMBER; i++)
{
objectData[i].trackStatus = (byte)random(OBJECT_NOT_TRACKED, OBJECT_TRACKED + 1);
objectData[i].xPos = (float)((float)random(AREA_LEFT_M * 10, AREA_RIGHT_M * 10) / 10.0f);
objectData[i].yPos = (float)((float)random(AREA_CLOSER_M * 10, AREA_FARTHER_M * 10) / 10.0f);
//objectData[i].objectSpeed = (float)((float)random(20,400)/10.0f)
//objectData[i].trackStatus = OBJECT_TRACKED;
}
}
void drawFovLines()
{
tft.drawLine(0, displayHeight - 94, middleWidth, displayHeight - 2, ILI9341_YELLOW);
tft.drawLine(middleWidth, displayHeight - 2, displayWidth, displayHeight - 94, ILI9341_YELLOW);
tft.drawFastVLine(areaLeftVLine, areaFartherHLine, areaCloserHLine - areaFartherHLine, ILI9341_CYAN);
tft.drawFastVLine(areaRightVLine, areaFartherHLine, areaCloserHLine - areaFartherHLine, ILI9341_CYAN);
tft.drawFastHLine(areaLeftVLine, areaCloserHLine, areaRightVLine - areaLeftVLine, ILI9341_CYAN);
tft.drawFastHLine(areaLeftVLine, areaFartherHLine, areaRightVLine - areaLeftVLine, ILI9341_CYAN);
}
void updateObjectDisplay()
{
byte objectCounter = 0;
char textToDisplay[32];
tft.setTextSize(1);
for (byte i = 0; i < MAX_OBJECT_NUMBER; i++)
{
if (objectData[i].trackStatus == OBJECT_TRACKED)
{
xPos_px[i] = middleWidth + (int16_t)(objectData[i].xPos * (float)METER_TO_PIXEL_FACTOR_X_AXIS);
yPos_px[i] = displayHeight - (int16_t)(objectData[i].yPos * (float)METER_TO_PIXEL_FACTOR_Y_AXIS);
tft.fillCircle(xPos_px[i], yPos_px[i], CIRCLE_SIZE, ILI9341_CYAN);
sprintf(textToDisplay, "%.1f, %.1f", objectData[i].xPos, objectData[i].yPos);
tft.setCursor(xPos_px[i] + OBJECT_TEXT_OFFSET, yPos_px[i] + OBJECT_TEXT_OFFSET);
tft.setTextColor(ILI9341_CYAN, ILI9341_BLACK);
tft.print(textToDisplay);
objectCounter += 1;
}
}
/*print additional information text*/
/*objectCounter*/
sprintf(textToDisplay, "%2d ", objectCounter);
tft.setCursor(xPos_oC_text, yPos_oC_text);
tft.setTextColor(ILI9341_YELLOW, ILI9341_BLACK);
tft.print(textToDisplay);
/*approx. refresh time*/
sprintf(textToDisplay, "%2dms ", ((int)((micros() - testMicros) / 1000u)) );
tft.setTextColor(ILI9341_NAVY, ILI9341_BLACK);
tft.setCursor(displayWidth - 25, bottomLine);
tft.print(textToDisplay);
}
void readTerminalInput()
{
if (Serial.available())
{
char rc = Serial.read();
if (rc == 's')
{
runningRefresh = !runningRefresh;
}
else if (rc == 'o')
{
oneTimeRefresh = true;
}
}
}
void initDisplay()
{
tft.begin();
tft.fillScreen(ILI9341_BLACK);
tft.setRotation(1);
displayWidth = tft.width(),
middleWidth = (int16_t)(displayWidth / 2);
displayHeight = tft.height();
bottomLine = displayHeight - 10;
Serial.println(CORE_PIN10_CONFIG, HEX);
Serial.println(ILI9341_SPICLOCK);
for (byte i = 0; i < MAX_OBJECT_NUMBER; i++)
{
objectData[i].trackStatus = OBJECT_NOT_TRACKED;
objectData[i].xPos = 0.0f;
objectData[i].yPos = 0.0f;
objectData[i].objectSpeed = 0.0f;
xPos_px[i] = 0;
yPos_px[i] = 0;
}
areaLeftVLine = middleWidth + (int16_t)(AREA_LEFT_M * (float)METER_TO_PIXEL_FACTOR_X_AXIS);
areaRightVLine = middleWidth + (int16_t)(AREA_RIGHT_M * (float)METER_TO_PIXEL_FACTOR_X_AXIS);
areaCloserHLine = displayHeight - (int16_t)(AREA_CLOSER_M * (float)METER_TO_PIXEL_FACTOR_Y_AXIS);
areaFartherHLine = displayHeight - (int16_t)(AREA_FARTHER_M * (float)METER_TO_PIXEL_FACTOR_Y_AXIS);
tft.setCursor(5, bottomLine);
tft.setTextColor(ILI9341_YELLOW, ILI9341_BLACK);
tft.print("objectCounter: ");
tft.getCursor(&xPos_oC_text, &yPos_oC_text);
}
#define TFT_DC 9
#define TFT_CS 10
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC);
#include <Arduino.h>
#include <ILI9341_t3n.h>
#define TFT_DC 9
#define TFT_CS 10
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC);
void setup()
{
pinMode(13, OUTPUT); // LED pin
digitalWrite(13, 1);
Serial.begin(115200);
Serial.printf("Started\n");
tft.begin(); // Remove this and it starts fine
}
void loop()
{
Serial.printf("running\n");
}