I'm using a teensy 3.6, on an adafruit feather adapter board, which is then mounted on the adafruit featherwing 3.5" tft display. This hardware combination works and is currently functional when used with the adafruit HX8357 library.
I bought the teensy for improved screen refresh rate of the 3.5" display, and there is much improvement over the feather m0, but there is still visible "flashing".
(And yes I am only doing "intelligent" redraws of the screen-only drawing parts that have changed)
So far I have been using the adafruit HX8357 library, and I'm hoping I can get one of the optimized teensy 3.x libraries to work. I spent all day yesterday and today trying to get the HX8357_t3 library to work: https://github.com/Asaurus1/HX8357_t3 . Also the screen buffer library looks like it would be awesome if it could be made to work: https://github.com/FrankBoesing/ILI9341_t3DMA/blob/master/ILI9341_t3DMA.cpp
So far no cigar on either library and I'm hoping someone with better software skills than I can help.
The SPI library optimized for teensy has been installed. To make sure It is being used, I put a debug print statement in the begin() function of the teensy optimized spi library:
The adafruit library works. Here is the start of the sketch:
Here's output from serial monitor with adafruit library:
The HX8357_t3 library doesnt get the same serial diagnostic info, and it seems the SPI library doesnt like the pins chosen for CS and DC. This is evident by the some print statements put in the HX8357_t3 begin function. Here's the print statements added:
Here's the sketch used with the HX8357_t3 library:
And here's the output:
Supposing the SPI.pinIsChipSelect(_cs, _dc) check is bypassed, it still doesnt fix things. I'm starting to get to the limit of my coding skills, can anyone offer some pointers? Thanks so much
I bought the teensy for improved screen refresh rate of the 3.5" display, and there is much improvement over the feather m0, but there is still visible "flashing".
(And yes I am only doing "intelligent" redraws of the screen-only drawing parts that have changed)
So far I have been using the adafruit HX8357 library, and I'm hoping I can get one of the optimized teensy 3.x libraries to work. I spent all day yesterday and today trying to get the HX8357_t3 library to work: https://github.com/Asaurus1/HX8357_t3 . Also the screen buffer library looks like it would be awesome if it could be made to work: https://github.com/FrankBoesing/ILI9341_t3DMA/blob/master/ILI9341_t3DMA.cpp
So far no cigar on either library and I'm hoping someone with better software skills than I can help.
The SPI library optimized for teensy has been installed. To make sure It is being used, I put a debug print statement in the begin() function of the teensy optimized spi library:
Code:
void SPIClass::begin()
{
volatile uint32_t *reg;
Serial.println("TEENSY SPI BEING USED");
hardware().clock_gate_register |= hardware().clock_gate_mask;
port().MCR = SPI_MCR_MDIS | SPI_MCR_HALT | SPI_MCR_PCSIS(0x1F);
port().CTAR0 = SPI_CTAR_FMSZ(7) | SPI_CTAR_PBR(0) | SPI_CTAR_BR(1) | SPI_CTAR_CSSCK(1);
port().CTAR1 = SPI_CTAR_FMSZ(15) | SPI_CTAR_PBR(0) | SPI_CTAR_BR(1) | SPI_CTAR_CSSCK(1);
port().MCR = SPI_MCR_MSTR | SPI_MCR_PCSIS(0x1F);
reg = portConfigRegister(hardware().mosi_pin[mosi_pin_index]);
*reg = hardware().mosi_mux[mosi_pin_index];
reg = portConfigRegister(hardware().miso_pin[miso_pin_index]);
*reg= hardware().miso_mux[miso_pin_index];
reg = portConfigRegister(hardware().sck_pin[sck_pin_index]);
*reg = hardware().sck_mux[sck_pin_index];
}
The adafruit library works. Here is the start of the sketch:
Code:
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_HX8357.h"
#ifdef ESP8266
#define STMPE_CS 16
#define TFT_CS 0
#define TFT_DC 15
#define SD_CS 2
#endif
#ifdef ESP32
#define STMPE_CS 32
#define TFT_CS 15
#define TFT_DC 33
#define SD_CS 14
#endif
#ifdef __AVR_ATmega32U4__
#define STMPE_CS 6
#define TFT_CS 9
#define TFT_DC 10
#define SD_CS 5
#endif
#ifdef ARDUINO_SAMD_FEATHER_M0
#define STMPE_CS 6
#define TFT_CS 9
#define TFT_DC 10
#define SD_CS 5
#endif
#ifdef TEENSYDUINO
#define TFT_DC 10
#define TFT_CS 4
#define STMPE_CS 3
#define SD_CS 8
#endif
#ifdef ARDUINO_STM32_FEATHER
#define TFT_DC PB4
#define TFT_CS PA15
#define STMPE_CS PC7
#define SD_CS PC5
#endif
#ifdef ARDUINO_FEATHER52
#define STMPE_CS 30
#define TFT_CS 13
#define TFT_DC 11
#define SD_CS 27
#endif
#define TFT_RST -1
Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
while (!Serial) ;
tft.begin(HX8357D);
Serial.print("CS: ");
Serial.println(TFT_CS);
Serial.print("DC: ");
Serial.println(TFT_DC);
uint8_t x = tft.readcommand8(HX8357_RDPOWMODE);
Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDMADCTL);
Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDCOLMOD);
Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDDIM);
Serial.print("Image Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDDSDR);
Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
}
Here's output from serial monitor with adafruit library:
Code:
TEENSY SPI BEING USED
CS: 4
DC: 10
Display Power Mode: 0x9C
MADCTL Mode: 0x60
Pixel Format: 0x5
Image Format: 0x0
Self Diagnostic: 0xC0
The HX8357_t3 library doesnt get the same serial diagnostic info, and it seems the SPI library doesnt like the pins chosen for CS and DC. This is evident by the some print statements put in the HX8357_t3 begin function. Here's the print statements added:
Code:
void HX8357_t3::begin(uint8_t type)
{
// verify SPI pins are valid;
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
if ((_mosi == 11 || _mosi == 7 || _mosi == 28) && (_miso == 12 || _miso == 8 || _miso == 39)
&& (_sclk == 13 || _sclk == 14 || _sclk == 27)) {
#else
if ((_mosi == 11 || _mosi == 7) && (_miso == 12 || _miso == 8) && (_sclk == 13 || _sclk == 14)) {
#endif
SPI.setMOSI(_mosi);
SPI.setMISO(_miso);
SPI.setSCK(_sclk);
Serial.println("The SPI pins were setup in begin");
Serial.print("CS: ");
Serial.println(_cs);
Serial.print("DC: ");
Serial.println(_dc);
Serial.print("mosi: ");
Serial.println(_mosi);
Serial.print("miso: ");
Serial.println(_miso);
Serial.print("sclk: ");
Serial.println(_sclk);
} else
return; // not valid pins...
SPI.begin();
if (SPI.pinIsChipSelect(_cs, _dc)) {
pcs_data = SPI.setCS(_cs);
pcs_command = pcs_data | SPI.setCS(_dc);
Serial.println("Chip select is valid");
} else {
pcs_data = 0;
pcs_command = 0;
Serial.println("Pins Not Valid");
//return;
}
Serial.print("pcs_data: ");
Serial.println(pcs_data);
Serial.print("pcs_command: ");
Serial.println(pcs_command);
Here's the sketch used with the HX8357_t3 library:
Code:
#include "SPI.h"
#include "HX8357_t3.h"
// For the Adafruit shield, these are the default.
#define TFT_DC 10
#define TFT_CS 4
void setup() {
Serial.begin(115200);
while (!Serial) ; // wait for Arduino Serial Monitor
HX8357_t3 tft = HX8357_t3(TFT_CS, TFT_DC); // put inside setup to see debug info when instantiating
tft.begin(HX8357D);
// read diagnostics (optional but can help debug problems)
uint8_t x = tft.readcommand8(HX8357_RDMODE);
Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDMADCTL);
Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDPIXFMT);
Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDIMGFMT);
Serial.print("Image Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(HX8357_RDSELFDIAG);
Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
}
And here's the output:
Code:
The SPI pins were setup in begin
CS: 4
DC: 10
mosi: 11
miso: 12
sclk: 13
TEENSY SPI BEING USED
Pins Not Valid
pcs_data: 0
pcs_command: 0
type == HX8357D
Display Power Mode: 0xFF
MADCTL Mode: 0xFF
Pixel Format: 0xFF
Image Format: 0xFF
Self Diagnostic: 0xFF
Supposing the SPI.pinIsChipSelect(_cs, _dc) check is bypassed, it still doesnt fix things. I'm starting to get to the limit of my coding skills, can anyone offer some pointers? Thanks so much