Teensy 4.0 First Beta Test

Status
Not open for further replies.
@KurtE - running that \SpeedTest\SpeedTest.ino I changed :: disp.setRotation(0); - and I didn't see a change?

Also - when it finished the table of number sprinted don't seem to start at 0,0? It there a #160 hard coded somewhere that is offsetting wierd on my 128x128 display?
The final table print seems to work right if I do this:: disp.setCursor(0, 32);
Except the final numbers after 'Total' are clipped when it prints 1-15.


In loop the clear screen had to change to :: disp.fillRect(disp.width(), 0, 8, disp.height(), RGB(r,g,b));
 
Also on my long list of stuff to eventually do is a library to implement USB device on Teensy 3.6's 2nd USB port. If running both ports on T4 in device mode works, would make sense for that library to do both.

If I wanted to try USB device on T3.6's 2nd USB port, what do you recommend, to work on usb.c (from T4) or usb_dev.c (T3)?
for the time being, I only need Seremu and MTP, so that should be achievable, even if not implemented yet in usb.c
But there is no usb_mem in T4, so T4 approach may be easier?
 
Last edited:
@defragster @mjs513 ...

st7735_t3: Originally I did not plan to buy some of these displays... I was working on different driver (a year or two ago) and purchased one that was supposed to be the other one on Amazon, and it turned out be one of these... I purchased a couple more direct from EBay seller (that Amazon sold through) and again same one...

Currently I am doing a little more hacking on the library to also support ST7789 display like now the Adafruit library does. I purchased one of these a couple of months ago and never tried it...
https://smile.amazon.com/gp/product/B07MH93747

Will see if it works.

@defragster - Set rototation - never tried it... Actually never used these displays for anything except getting libraries to build... But will try it out.

Offsets - Again I am no expert on these displays but as I understand it the ST7735 display is setup to handle something like 128x160 displays. So if you have a 128x128, some of the displays start their actual output at something like (0,0) and others start at (32,0)... That is why there is things mentioned like black_tape versus Green_tape... or the like...

Now back to playing
 
Thoughts?
Want to try it out? https://github.com/KurtE/ST7735_t3/tree/T4_beta (needs my update Adafruit_gfx as well)

I'm planning to work on Adafruit GFX next week. Also going to revert (or mostly revert) the SD lib contribution that broke too much stuff.



If I wanted to try USB device on T3.6's 2nd USB port, what do you recommend, to work on usb.c (from T4) or usb_dev.c (T3)?

Definitely start from T4's usb.c, since the 2nd USB port on T3.6 is basically the same USB hardware as both ports in T4.

Or if you're not in a hurry, that T4 code is going to get another big round of improvements before the 1st release.
 
I'm planning to work on Adafruit GFX next week. Also going to revert (or mostly revert) the SD lib contribution that broke too much stuff.
Hi @PaulStoffregen - As I mentioned back in the thread posting #3349

I have a working version of the Adafruit_GFX library in my fork/branch: https://github.com/KurtE/Adafruit-GFX-Library/tree/T4_Beta

The one issue left is there is a compiler warning about redefining PROGMEM which @defragster mentioned in #3355.
Code:
In file included from T:\tCode\libraries\Adafruit_GFX\Adafruit_GFX.cpp:3 5:0:

T:\tCode\libraries\Adafruit_GFX\glcdfont.c:13:0: warning: "PROGMEM" redefined
#define PROGMEM
^

In file included from T:\Ard186t4b2\hardware\teensy\avr\cores\teensy4/WProgram.h:41:0,
from T:\TEMP\arduino_build_882294/pch/Arduino.h:6,
from T:\tCode\libraries\Adafruit_GFX\Adafruit_GFX.h:5,
from T:\tCode\libraries\Adafruit_GFX\Adafruit_GFX.cpp:3 4:

T:\Ard186t4b2\hardware\teensy\avr\cores\teensy4/avr/pgmspace.h:28:0: note: this is the location of the previous definition
#define PROGMEM __attribute__((section(".progmem")))

If I update the file glcdfont.c that on T4 not define: #define PROGMEM

It gives an error as I mentioned in #3358
Code:
C:\Users\kurte\Documents\Arduino\libraries\Adafruit_GFX_Library\glcdfont.c:20:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PROGMEM'

 static const unsigned char font[] PROGMEM = {

I can easily get away with doing something like:
#undef PROGMEM
#define PROGMEM

But that probably defeats the purpose...

Note: If I put their structure directly into a sketch it compiles just fine...
The file is #included in Adafruit_GFX.cpp file... So will still try to localize what is dfferent...

Maybe it is defined in an extern "C" block?
 
Definitely start from T4's usb.c, since the 2nd USB port on T3.6 is basically the same USB hardware as both ports in T4.

Or if you're not in a hurry, that T4 code is going to get another big round of improvements before the 1st release.

I will at least try, but without desperation.
 
@defragster @mjs513 ...

st7735_t3: Originally I did not plan to buy some of these displays... I was working on different driver (a year or two ago) and purchased one that was supposed to be the other one on Amazon, and it turned out be one of these... I purchased a couple more direct from EBay seller (that Amazon sold through) and again same one...

Currently I am doing a little more hacking on the library to also support ST7789 display like now the Adafruit library does. I purchased one of these a couple of months ago and never tried it...
https://smile.amazon.com/gp/product/B07MH93747

Will see if it works.

@defragster - Set rototation - never tried it... Actually never used these displays for anything except getting libraries to build... But will try it out.

Offsets - Again I am no expert on these displays but as I understand it the ST7735 display is setup to handle something like 128x160 displays. So if you have a 128x128, some of the displays start their actual output at something like (0,0) and others start at (32,0)... That is why there is things mentioned like black_tape versus Green_tape... or the like...

Now back to playing

Wow - amazon lists this as "HD" - 1.3" ST7789 240x240 - High pixel Density! Nice and clear to read - under magnification!

opps - thought you were already in the code when I mentioned rotation. If porting 7789 into 7735 I suppose you will be. Rotation of 0 and 1 do work - but my display shows 2 and 3 the same as those two.

With the fixed 'n=0' array index fix my hack to re-run the initial 7735 128x128 screen fill tests has been running just fine. Bad miss of the "n++" on my part as I was rushing out the door.

Anyhow that shows you did well on the GFX and the T4 happy on the SPI - only 10.17 FPS measured but if reading the 'normalize[]' code right that is 4.5 times faster than measured on Adafruit base unit.
That is at ST7735_SPICLOCK 12000000 - minor change to ST7735_SPICLOCK 32000000 takes that to 18.7 FPS and 9.5 times faster than the normalized Adafruit. Still runs at 48 MHZ SPI and bumps to 23.2 FPS and 12.9 of normalized. And still runs at 64 & 72 MHZ SPI - but no faster as that must scale down to same clock.

Makes sense the generic code just shifts over the missing 32 pixels in some fashion.

Here is the edited version of Speedtest that pushes the results down and compacts them to fit on my 128x128 ST7735 {other extents unchanged for missing 32 pixels}, and for fun periodically re-reruns the intro graphics tests:
Code:
// SpeedTest written by Peter Loveday
//
// http://forum.pjrc.com/threads/15576-Teensy3-ST7735-Library?p=21355&viewfull=1#post21355

// This Teensy3 native optimized version requires specific pins
//
#define TFT_SCLK 13  // SCLK can also use pin 14
#define TFT_MOSI 11  // MOSI can also use pin 7
#define TFT_CS   10  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define TFT_DC    9  //  but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define TFT_RST   8  // RST can use any pin
#define SD_CS     4  // CS for SD card, can use any pin

#include <Adafruit_GFX.h>
#include <ST7735_t3.h>
#include <SPI.h>

ST7735_t3 disp = ST7735_t3(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

#define RGB(r,g,b) (b<<11|g<<6|r)

float pi = 3.1415926f;

void testlines(uint16_t color)
{
  disp.fillScreen(ST7735_BLACK);

  for (int16_t x = 0; x < disp.width(); x += 6)
    disp.drawLine(0, 0, x, disp.height() - 1, color);

  for (int16_t y = 0; y < disp.height(); y += 6)
    disp.drawLine(0, 0, disp.width() - 1, y, color);

  for (int16_t x = 0; x < disp.width(); x += 6)
    disp.drawLine(disp.width() - 1, 0, x, disp.height() - 1, color);

  for (int16_t y = 0; y < disp.height(); y += 6)
    disp.drawLine(disp.width() - 1, 0, 0, y, color);

  for (int16_t x = 0; x < disp.width(); x += 6)
    disp.drawLine(0, disp.height() - 1, x, 0, color);

  for (int16_t y = 0; y < disp.height(); y += 6)
    disp.drawLine(0, disp.height() - 1, disp.width() - 1, y, color);

  for (int16_t x = 0; x < disp.width(); x += 6)
    disp.drawLine(disp.width() - 1, disp.height() - 1, x, 0, color);

  for (int16_t y = 0; y < disp.height(); y += 6)
    disp.drawLine(disp.width() - 1, disp.height() - 1, 0, y, color);
}

void testdrawtext(const char *text, uint16_t color, uint16_t bgcolor)
{
  disp.setCursor(0, 0);
  disp.setTextColor(color, bgcolor);
  disp.setTextWrap(true);
  disp.print(text);
}

void testfastlines(uint16_t color1, uint16_t color2)
{
  disp.fillScreen(ST7735_BLACK);

  for (int16_t y = 0; y < disp.height(); y += 5)
    disp.drawFastHLine(0, y, disp.width(), color1);

  for (int16_t x = 0; x < disp.width(); x += 5)
    disp.drawFastVLine(x, 0, disp.height(), color2);
}

void testdrawrects(uint16_t color)
{
  disp.fillScreen(ST7735_BLACK);

  for (int16_t x = 0; x < disp.width(); x += 6)
    disp.drawRect(disp.width() / 2 - x / 2, disp.height() / 2 - x / 2 , x, x, color);
}

void testfillrects(uint16_t color1, uint16_t color2)
{
  disp.fillScreen(ST7735_BLACK);

  for (int16_t x = disp.width() - 1; x > 6; x -= 6) {
    disp.fillRect(disp.width() / 2 - x / 2, disp.height() / 2 - x / 2 , x, x, color1);
    disp.drawRect(disp.width() / 2 - x / 2, disp.height() / 2 - x / 2 , x, x, color2);
  }
}

void testfillcircles(uint8_t radius, uint16_t color)
{
  for (int16_t x = radius; x < disp.width(); x += radius * 2)
    for (int16_t y = radius; y < disp.height(); y += radius * 2)
      disp.fillCircle(x, y, radius, color);
}

void testdrawcircles(uint8_t radius, uint16_t color)
{
  for (int16_t x = 0; x < disp.width() + radius; x += radius * 2)
    for (int16_t y = 0; y < disp.height() + radius; y += radius * 2)
      disp.drawCircle(x, y, radius, color);
}

void testtriangles()
{
  disp.fillScreen(ST7735_BLACK);

  int color = 0xF800;
  int t;
  int w = 63;
  int x = 159;
  int y = 0;
  int z = 127;

  for (t = 0 ; t <= 15; t += 1) {
    disp.drawTriangle(w, y, y, x, z, x, color);
    x -= 4;
    y += 4;
    z -= 4;
    color += 100;
  }
}

void testroundrects()
{
  disp.fillScreen(ST7735_BLACK);

  int color = 100;
  int i;
  int t;

  for (t = 0 ; t <= 4; t += 1) {
    int x = 0;
    int y = 0;
    int w = 127;
    int h = 159;
    for (i = 0 ; i <= 24; i += 1) {
      disp.drawRoundRect(x, y, w, h, 5, color);
      x += 2;
      y += 3;
      w -= 4;
      h -= 6;
      color += 1100;
    }
    color += 100;
  }
}

#define SETCOLOR(c) disp.setTextColor(c, bg ? ST7735_BLACK : c);

void tftPrintTest(bool bg)
{
  disp.setTextWrap(false);
  disp.fillScreen(ST7735_BLACK);
  disp.setCursor(0, 30);
  SETCOLOR(ST7735_RED);
  disp.setTextSize(1);
  disp.println("Hello World!");
  SETCOLOR(ST7735_YELLOW);
  disp.setTextSize(2);
  disp.println("Hello World!");
  SETCOLOR(ST7735_GREEN);
  disp.setTextSize(3);
  disp.println("Hello World!");
  SETCOLOR(ST7735_BLUE);
  disp.setTextSize(4);
  disp.print(1234.567);

  disp.setCursor(0, 0);
  disp.fillScreen(ST7735_BLACK);
  SETCOLOR(ST7735_WHITE);
  disp.setTextSize(0);
  disp.println("Hello World!");
  disp.setTextSize(1);
  SETCOLOR(ST7735_GREEN);
  disp.print(pi, 6);
  disp.println(" Want pi?");
  disp.println(" ");
  disp.print(8675309, HEX);
  disp.println(" Print HEX!");
  disp.println(" ");
  SETCOLOR(ST7735_WHITE);
  disp.println("Sketch has been");
  disp.println("running for: ");
  SETCOLOR(ST7735_MAGENTA);
  disp.print(millis() / 1000);
  SETCOLOR(ST7735_WHITE);
  disp.print(" seconds.");
}

void mediabuttons()
{
  // play
  disp.fillScreen(ST7735_BLACK);
  disp.fillRoundRect(25, 10, 78, 60, 8, ST7735_WHITE);
  disp.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_RED);

  // pause
  disp.fillRoundRect(25, 90, 78, 60, 8, ST7735_WHITE);
  disp.fillRoundRect(39, 98, 20, 45, 5, ST7735_GREEN);
  disp.fillRoundRect(69, 98, 20, 45, 5, ST7735_GREEN);

  // play color
  disp.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_BLUE);

  // pause color
  disp.fillRoundRect(39, 98, 20, 45, 5, ST7735_RED);
  disp.fillRoundRect(69, 98, 20, 45, 5, ST7735_RED);
  // play color
  disp.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_GREEN);
}

int t[20];
int n = 0;

void setup()
{
  pinMode(SD_CS, INPUT_PULLUP);  // keep SD CS high when not using SD card

  // Use this initializer if you're using a 1.8" TFT
  disp.initR(INITR_BLACKTAB);
  // Use this initializer (uncomment) if you're using a 1.44" TFT
  //disp.initR(INITR_144GREENTAB);
  firstset();
}
void firstset()
{
  n = 0;
  disp.setRotation(0);
  disp.setTextWrap(true);
  disp.setTextColor(RGB(31, 31, 31), RGB(0, 0, 0));
  disp.setCursor(0, 0);

  disp.fillScreen(RGB(0, 0, 0));
  t[n++] = millis();
  disp.fillScreen(ST7735_BLACK);
  t[n++] = millis();
  testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST7735_WHITE, ST7735_WHITE);
  t[n++] = millis();
  tftPrintTest(false);
  t[n++] = millis();
  testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST7735_WHITE, ST7735_BLACK);
  t[n++] = millis();
  tftPrintTest(true);
  t[n++] = millis();
  testlines(ST7735_YELLOW);
  t[n++] = millis();
  testfastlines(ST7735_RED, ST7735_BLUE);
  t[n++] = millis();
  testdrawrects(ST7735_GREEN);
  t[n++] = millis();
  testfillrects(ST7735_YELLOW, ST7735_MAGENTA);
  t[n++] = millis();
  disp.fillScreen(ST7735_BLACK);
  t[n++] = millis();
  testfillcircles(10, ST7735_BLUE);
  t[n++] = millis();
  testdrawcircles(10, ST7735_WHITE);
  t[n++] = millis();
  testroundrects();
  t[n++] = millis();
  testtriangles();
  t[n++] = millis();
  mediabuttons();
  t[n++] = millis();
  disp.fillScreen(RGB(0, 0, 0));
}

// These are the results for the adafruit library, so we can report results as Nx

uint16_t normalize[] =
{
  129,
  216,
  348,
  955,
  630,
  1658,
  185,
  168,
  955,
  129,
  195,
  163,
  604,
  362,
  253,
  6950
};

void loop()
{
  static float fps = 0.0;
  static int h = 0;
  if ( !(h % 129) ) {
    firstset();
    delay(500);
  }

  uint8_t r, g, b;
  if (h < 32) {
    r = 31; g = h; b = 0;
  } else if (h < 64) {
    r = 63 - h; g = 31; b = 0;
  } else if (h < 96) {
    r = 0; g = 31; b = h - 64;
  } else if (h < 128) {
    r = 0; g = 127 - h; b = 31;
  } else if (h < 160) {
    r = h - 128; g = 0; b = 31;
  } else if (h < 192) {
    r = 31; g = 0; b = 191 - h;
  } else {
    r = 31; g = 0; b = 0;
    h = 0;
  }
  h++;
  int start = micros();
  disp.fillRect(120, 0, 8, 160, RGB(r, g, b));

  disp.setTextWrap(false);
  disp.setTextColor(RGB(31, 31, 31), RGB(0, 0, 0));
  disp.setCursor(0, 38);

  for (int i = 1; i < n; i++) {
    disp.print(i < 10 ? "T#" : "Test ");
    disp.print(i, DEC);
    disp.print(i < 10 ? ":" : ": ");
    disp.print(float(normalize[i - 1]) / float(t[i] - t[i - 1]), 2);
    if ( i > 8 || !(i % 2) )
      disp.println();
    else
      disp.print(' ');
  }

  disp.println("");
  disp.print("Total  : ");
  disp.println(float(normalize[n - 1]) / float(t[n - 1] - t[0]), 2);

  disp.println("");
  disp.print("FPS    : ");
  disp.println(fps, 2);

  int end = micros();

  fps = 1000000.0f / float(end - start);
}
 
Wow - amazon lists this as "HD" - 1.3" ST7789 240x240 - High pixel Density! Nice and clear to read - under magnification!

I have the code compiling now, but need to figure out how to hook up the display. It appears to require +5v on it's VIN to work... Not sure how to get +5v with current breakout boards.

I could probably unplug and solder in pin o VUSB and get it from there. Or could breadboard it.

Soon I will solder up at least part of my own breakouts, but having an itchy day, so probably not today...

Actually any things you see wrong are great! May take me a bit to understand enough of the code to fix!
 
I have the code compiling now, but need to figure out how to hook up the display. It appears to require +5v on it's VIN to work... Not sure how to get +5v with current breakout boards.

I could probably unplug and solder in pin o VUSB and get it from there. Or could breadboard it.

Soon I will solder up at least part of my own breakouts, but having an itchy day, so probably not today...

Actually any things you see wrong are great! May take me a bit to understand enough of the code to fix!

I actually have mine fed 5V - I never properly populated an OSH Purple PJRC Test board - just the 100 OHM on the end - center pullups - three headers on top - and on this board pull a wire from VIN ( where some part was supposed to be ) to the display VCC.
 
I have the code compiling now, but need to figure out how to hook up the display. It appears to require +5v on it's VIN to work... Not sure how to get +5v with current breakout boards.
One of my GPS requries 5v, i'd just use a 2nd USB to T3.2 and use its Vin to power the GPS, and jumper the PPS pin to one of the Serialx male pins on the T4 breakout.
 
I have the code compiling now, but need to figure out how to hook up the display. It appears to require +5v on it's VIN to work... Not sure how to get +5v with current breakout boards.

I could probably unplug and solder in pin o VUSB and get it from there. Or could breadboard it.

Soon I will solder up at least part of my own breakouts, but having an itchy day, so probably not today...

Actually any things you see wrong are great! May take me a bit to understand enough of the code to fix!

Ok - I gave up - just ordered a 7735 and a 7789 from Amazon. Will be here Monday. Started playing with touch again on the ILI9341 and 9488 boards. Interesting on the 9341 boards I have. I plug them into the Teensy64 and touch/Graphics works fine. If I use that shield I have that just brings the pins to the right location on the breakout graphics will work as long as I cut connections to the touch. Looking at Paul's purple board noticed he has 2 10k resistors to the CS pins. Think I will give that a try tomorrow. As for the 9488 have to figure out how to hook up the tristate buffer = do I hook it up to just the graphics CS pin or to the touch CS pin, or do I need both.

EDIT: I just brought out the 5v line to an unused pin between gnd and rx/tx lines. Used a wirewrap wire (yep - still have that hanging around).
 
@mjs513
I just put two pieces of wire wrap wire under the final Ribbon Beta T4 - pulled out #26/27 to end pins on Serial 6/7 rows when I opened that for the rest of the POGO pins. Handy stuff.

I almost ordered a 7735 then looked and found one oddly in the Displays bin :) No 7789 yet. 7735 running SpeedTest posted code with 48 MHz SPI clock.

I had the 9341 on the display board before swapping to the 7735. When I did that the GFX worked and so did the TouchPaint. There was some time back when touch seemed 'skippy'? Sometimes the SPI LED stayed on too even with IRQ code, I didn't see that this time. It was working at least mostly on 9488 - but have not hooked that up lately.

It seems the TriState buffer should go active when CS takes display offline and reconnect the pin when Display CS indicates transfer - but that only helps when reading the display since it was MISO that needed the fix and MOSI was good as tested here. Of course any Touch I/O during that will ruin things, so have to use IRQ to not read touch during display time - that would only come up with DMA xfer though?

Depending on hardware the CS pullups are just proper - but with bad hardware combo they are critical to prevent crosstalk.
 
@defragster and @mjs513 - (Sorry - As I mentioned I purchased some of them by mistake and some of them as there was another issue recently for the 89...)...

I just updated my Fork/Branch with header/source file for ST7789, that sublasses the ST7735 code. I could (maybe should) make it slightly cleaner and do like Adafruit and have base class like ST77xx_t3, and have the ST7735 sub-class as well. That way if you are using the ST7789, it won't necessarily include the two init functions and rotate function for 7735...

Also found issue with rotation... That was the command/data were output, but did not properly wait for the writeData() to complete before the endTranaction/ (clear CS)...

Now looks like the ST7789 works OK on 3.3v...

Did quick test of setRotation using @defragsters example and it does go to all three directions now. Still issues on what to do about Width and Height changes...
 
Good work @KurtE - I'll give the rotate a view on my short unit and see what shows up.

I suppose I should start feeding my displays 3.3V instead of 5V.
 
ili9163 - those are the last little display I was working with @Sumotoy on 3-4 years back ... : https://github.com/sumotoy/TFT_ILI9163C

SPI 128x128 and 1.44"
Version 1.0 it's one the corner!
New version doesn't use the adafruit_GFX and have all the drawing incorporated, this because I've speedup a lot with all processors and uses less resources.

Plugged ili9163 in on T4 running the ST7735 code and it is working!

Will try the @sumotoy code shortly with T4 … unless @KurtE is reading and he beats me to it.

BOARD and display look identical to the package opened labelled ST7735 - same size, PCB, V1.1 - but open one I found was helpfully hand marked ili9163 as it was used with @sumotoy code.
 
Last edited:
The Sumotoy code was last seen on T_3.2 - not even #ifdef's for K66 or K64, and it embeds SPI code like this the T4 doesn't appreciate with #ifdef IMXRT1062 added:
Code:
				KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;

Compiler says this code is installed with TeensyDuino: ...\hardware\teensy\avr\libraries\TFT_ILI9163C

On T4 - the TFT_ILI9163C.h code CAN run his samples with proper settings - but it is using worst case non T_LC and non T_3.x code choices without Teensy optimizations.

Odd thing is I have 'red board' - and used that before AFAIK - but now that is shifted 32 pixel lines so I set for _BLACK_ and it is better in : ...\libraries\TFT_ILI9163C\_settings\TFT_ILI9163C_settings.h

Still puzzled how two I have out are 'hand' marked ILI9163 - but the bagged one factory label was ST7735 - and it works well with Kurt's changes. So if KurtE cleans this up the ili9163C code may be due for removal?
 
I just received my T4b2 from Robin on Tuesday.
Amazing form factor!
Will the ribbon be provided in the final product too?

The card was just on time to understand properly the pinout. So, no I don't have any remark. Everything I needed was there clearly.
It really helped me to find out all the pins I needed for the joystick and the buttons on the serial pins of the break out board.

I have the emulator framework that I had for the T4b1 working with the ILI9341 in DMA mode and SPI mode, reading from the SDIO connected build in SD card and the joystick +buttons.
For some reason I have a memory issue with some of the small emulators that were working fine on the T4b1. I was expecting that using malloc (mapped to the 512k OCRAM by default?) would work but I had to move back some buffers to static arrays. The 128k DMA video buffer is static default so I don't expect any other malloc using OCRAM than the one of the emulator (64k emulated RAM)
I could compile the Atari ST emulator (now running to slowly on the ESP32) by annotating the big piece of code and constant arrays with PROGMEM to free up some RAM.
Compiling but not running yet.
I need to debug...

Is there a way to allocate the full 512k of OCRAM to my sketch?
If create an empty sketch that does a 512k malloc but it always fails.
Do I do something wrong?
 
@defragster -

ILI9163 - Is probably the one I ordered from Amazon/Ebay and ended up with the ST7735 boards instead. I think it was a case where the manufacturer might do several runs with several chips and it is pot luck which one you get. It was sort of like when I was trying to order an ILI9488 display and some of the listings said the board might have X, Y or Z on it...

Sumotoy code - I sort of remember that from the T3.5/6 beta time frame, that some of the drivers we were trying to get updated, but it was difficult (if even possible) to get changes incorporated back into the libraries.

ST7789 - I remember buying it for another thread: https://forum.pjrc.com/threads/5531...4-x-libs-doesn-t-work-for-me?highlight=ST7789
So I purchased one, but never got back to it...

@PaullStoffregen - What is interesting, is that up on your github is: https://github.com/PaulStoffregen/ST7789_t3
Which I have not pulled down... looks like probably copy of ST7735_t3 library, which I am sure does not have stuff in it for T4.

My current PR for ST7735_t3 is hopefully working for both ST7735 and ST7789, I probably should update at least one of the examples, like Adafruit did with theirs: to include both header files and have constructors for both (one commented out) and likewise all three forms of init, with two commented out... Update: graphictest now can do either display

Other features of changes:
a) Should work on all SPI buss objects. It asks if the MOSI/SCLK/DC pins are valid for SPI, if not Try SPI1 (LC, T3.5, T3.6), and SPI2 (3.5/6)
b) Uses SPI transactions
c) CS can be on NON hardware CS pin and not have to fall back to bitbang...

Questions remaining
1) I removed Arduino DUE and AVR support. Could probably add AVR support back, but not sure if it is needed or not?
2) Still is hooked to Adafruit_GFX, wonder if we should do like ILI9341_T3 and put all of the features directly into library?
3) Currently ST7789_T3 object is sub-class of ST7735_t3 object. Could(should?) do like Adafruit and put most of this code into new files/class like: ST77XX_T3 and make ST7735_T3 be subclass of this one as well. The only specific parts for ST7735 are the two init functions, including the const static Init tables plus setRotation. Not much work, will do it if you would like? The ST77XX_T3.h file would then probably contain a second copy of some of the defines, probably mainly the COLORS, like:
Code:
#define ST77XX_BLACK   0x0000
#define ST77XX_BLUE    0x001F
#define ST77XX_RED     0xF800
#define ST77XX_GREEN   0x07E0
#define ST77XX_CYAN    0x07FF
#define ST77XX_MAGENTA 0xF81F
#define ST77XX_YELLOW  0xFFE0
#define ST77XX_WHITE   0xFFFF

So Example apps that use ST7789 Won't need to use ST7735 constants...
4) I have not yet put in code for T4, that if the DC is on hardware CS it will use that feature of hardware stack (I have for ili9341_t3n and _t3 in PR). Code is mostly there will try it out this morning. Update: (Done - not much speed up)

Then soon back to USB Host - Bluetooth - multiple objects. Debugging multiple PS3s...
 
Last edited:
Hi Kurt
Just gave your changes a try with the T4. Ran graphicstest as you did and worked no problem. Ran a version, for just drawpixels using my budhabrot example and it ran as well no problems.

@KurtE - @defragster

Still playing with breakout boards for the ILI9341 and trying to get touch working. No luck on touch but must have had pins messed up last night for graphics. Did try the adding 10K resistors didn't help with the touch on either the T3.6 or the T4. Going to solder up a purple board and give it a try.

Anyway in retesting your adafruit gfx changes noticed that this construct works:
Code:
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
but this one does not - sketch runs but nothing is displayed - don't know if its me or the something else:
Code:
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

EDIT: Dumb question DOUT=MOSI, DIN=MISO? Have to ask only thing that I may have messed up.
 
Last edited:
@mjs513 and @defragster (and others )
Code:
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

Wonder if it is trying to do BITBANG to do all of the outputs? I know in my code bases I will see if MOSI, CLK, MISO,

But I don't think that is the case with the SPITFT code in Adafruit_GFX... looks like a bit more work to get that go right...

Edit: Confirmed it does not work with the bitbang output...

Will take a pass through to see if I can get it to work. Looks like most of the stuff is setup to allow Set/Clear registers to be used. But not sure if it has the masks set up...
 
Last edited:
Is there a way to allocate the full 512k of OCRAM to my sketch?
If create an empty sketch that does a 512k malloc but it always fails.

You can't get all 512K with malloc, because malloc uses some of the memory to manage a list of allocations.

Any static or global variables with DMAMEM also go into OCRAM, reducing the amount of memory malloc can give you. Currently the USB code is using DTCM for buffers, but the plan is to change it to use DMAMEM.

While not as issue right now, in a future version I'm considering reserving the last 8K of OCRAM for a special feature. If this is done in the linker script, the maximum allocation will be 8192 bytes less.
 
@PaulStoffregen @mjs513 and @defragster ...

Adafruit_GFX - Put in fixes for BITBANG version for T4...

Code is up in my github fork/branch: https://github.com/KurtE/Adafruit-GFX-Library/tree/T4_Beta

There is already code in place to use the Set and Clear registers for the different signals. With Kinetisk boards these registers were assumed to be used for only one IO pin... For other platforms that support this, there is a mask value... Which was not setup for T4... That is for example:
Code:
inline void Adafruit_SPITFT::SPI_SCK_HIGH(void) {
#if defined(USE_FAST_PINIO)
 #if defined(HAS_PORT_SET_CLR)
  #if defined(KINETISK)
    *swspi.sckPortSet = 1;
  #else  // !KINETISK
    *swspi.sckPortSet = swspi.sckPinMask;
    #if defined(__IMXRT1052__) || defined(__IMXRT1062__)  // Teensy 4.x
    for(volatile uint8_t i=0; i<1; i++);
    #endif  
  #endif
 #else  // !HAS_PORT_SET_CLR
    *swspi.sckPort   |= swspi.sckPinMaskSet;
 #endif // end !HAS_PORT_SET_CLR
#else  // !USE_FAST_PINIO
    digitalWrite(swspi._sck, HIGH);
 #if defined(ESP32)
    for(volatile uint8_t i=0; i<1; i++);
 #endif // end ESP32
#endif // end !USE_FAST_PINIO
}

So I put in the code to init swspi.sckPinMask (and the others)...

When I first tried it, it ran too fast for the ILI9341 display, so I put in delay like what was in for ESP32... Appears to now run at about 12.5mhz clk... If necessary someone can probably tweak to get higher (but not too high)...

But was able to run the Adafruit_ili9341 graphic test
Code:
// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 23
#define TFT_MOSI 11
#define TFT_MISO 12
#define TFT_CLK  13
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, 23);
// If using the breakout, change pins as desired
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

Edit: Note: I have not issued a PR to Adafruit on this yet, as I currently have the Font setup to not use PROGMEM...
I did get rid of the warning, by first adding #undef PROGMEM before the #define PROGMEM.
 
KurtE said:
But was able to run the Adafruit_ili9341 graphic test
Code:
// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 23
#define TFT_MOSI 11
#define TFT_MISO 12
#define TFT_CLK  13
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, 23);
// If using the breakout, change pins as desired
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
Edit: Note: I have not issued a PR to Adafruit on this yet, as I currently have the Font setup to not use PROGMEM...
I did get rid of the warning, by first adding #undef PROGMEM before the #define PROGMEM.

@KurtE @PaulStoffregen @mjs513 and @defragster
Just gave downloaded the updated library and graphicstest worked right away with the both constructs. Whereas before it was giving me some problems with loading and running. Would have to do it twice sometimes. Also, did not see the progmem error this time around.

Side note. Sorted my issue out with Touch - had MISO and MOSI crossed going to Touch pins: DIN <=> MISO, DO<=>MOSI. Check the purple board and the T64. Duh...

With that said using T_CS=7 and T_IRQ=6 works great on a T3.6. When I tested on the T4 touch would not work. Have to debug a bit more I guess.

UPDATE: Works - was a loose wire. So all is good in the world now that I got the connections correct :)
 
Last edited:
@KurtE - got the latest - will run some sketches. I suppose you read and followed AdaFruit 'github Roadmap' and Prime Directive …

Starting with red board 1.44" V1.1 SPI '??[ 9163, 7735 ] 128x128' - I have 3 that look the same - for all I know they came together - newest opened shows 7735

Compiling and Running these things on T4 that #include <Adafruit_GFX.h>:
> sumotoy 9163: Bigtest.ino okay on either of my ??[ 9163, 7735 ] 128x128
> sumotoy 9163: Benchmark.ino okay on either of my ??[ 9163, 7735 ] 128x128 - has the 32 pixel shift on (2) rotations - a settings issue
>> Just for ref as it says it included the _GFX - going to close these sketches/lib here as 'not broken'

> ST7735_t3: post #3382 edited SpeedTest.ino : good and faster with OC'd SPI on either of my ??[ 9163, 7735 ] 128x128
>> ODD setRotation? - only (0) works right with text shift. With 1,3 graphics shift but text still text same orientation - This is what @sumotoy was doing in settings AFAIK - accounting for board specific shifts.
>> Back to SPI 12 Mhz - Displays run fine and faster at 24 and 48 Mhz
> ST7735_t3\examples\graphicstest: Good.

Gotta run - but no obvious issues
 
@defragster - Adafruit... I have done some PR's in the past some end up in limbo for a long time. My guess with PR's associated with PJRC products, it probably catch their attention faster when the PR's are from Paul... Which is why I have not made one on the Adafruit_GFX code changes for T4 yet.

Probably also need to do a PR on the Adafruit_ST7735 stuff. At least I believe there are issues compiling the current stuff up on github. I have it building and running, need to double check it.


Right now playing with Bluetooth
 
Status
Not open for further replies.
Back
Top