ILI9488_t3 - Support for the ILI9488 on T3.x and beyond...

This has been a collaborative project, the actual github master fork is https://github.com/mjs513/ILI9488_t3 (@mjs513)

This sounds like the classic issue with multiple SPI devices on the same buss. You might try setting all of the CS pins HIGH before trying to init either device.

Code:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#include <ILI9488_t3.h>

#define CS_PIN  8
#define TIRQ_PIN  2
XPT2046_Touchscreen ts(CS_PIN, 2);  // Param 2 - Touch IRQ Pin - interrupt enabled polling

#define TFT_DC      20
#define TFT_CS      21
#define TFT_RST    255  // 255 = unused, connect to 3.3V
#define TFT_MOSI     7
#define TFT_SCLK    14
#define TFT_MISO    39

#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000
ILI9488_t3 tft = ILI9488_t3(&SPI, TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);
#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;
void setup() {
  [COLOR="#FF0000"]while (!Serial && millis() < 2000) ;   // Waits for up to 2 seconds for Serial 
  pinMode(TFT_CS, OUTPUT);
  digitalWrite(TFT_CS, HIGH);
  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);[/COLOR]

  Serial.begin(38400);
    tft.begin();

   if (!ts.begin()) {
    Serial.println("Couldn't start touchscreen controller");
    while (1);
  }
  Serial.println("Touchscreen started");
  ts.setRotation(1);
  while (!Serial && (millis() <= 1000));

}
boolean wastouched = true;
void loop() {

  // tirqTouched() is much faster than touched().  For projects where other SPI chips
  // or other time sensitive tasks are added to loop(), using tirqTouched() can greatly
  // reduce the delay added to loop() when the screen has not been touched.
  if (ts.tirqTouched()) {
    if (ts.touched()) {
      TS_Point p = ts.getPoint();
      Serial.print("Pressure = ");
      Serial.print(p.z);
      Serial.print(", x = ");
      Serial.print(p.x);
      Serial.print(", y = ");
      Serial.print(p.y);
      delay(30);
      Serial.println();
    }
  }

}

Sorry, I already change the code as you suggest, but the touch screen still not work. Do i need to change the pin.
 
Sorry, I already change the code as you suggest, but the touch screen still not work. Do i need to change the pin.

It may be that the display in use does not tri-state the LCD MISO pin and that prevents the TOUCH controller reading of the needed data from the shared MISO pin. The common one we got has that issue, either the LCD MISO must not be connected {my solution} - or it must have a tri-state buffer installed and controlled by the use of a CS pin - @mjs513 resolved that - on this thread?
 
For a given SPI bus - unless there is some magic here I missed - common signals go to a common pin. Placing the device wire to another inactive pin would be he same as not having it connected.
 
For a given SPI bus - unless there is some magic here I missed - common signals go to a common pin. Placing the device wire to another inactive pin would be he same as not having it connected.
I remove the TFT MISO as you suggest. the result is change:
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
.....
Could you please to send me your working coding and pinout. I will check it again.
By the way, I also order 74ahc1g125 chip as mjs513 suggest, but it would take 1-2 week to deliver. Hope it work for me.
 
Not sure what sketch I used except an example? Anyone with the right touchscreen XPT2046_Touchscreen driver [ili9341?] if none in that library was right for mine. Even if the display didn't work - that returned valid info with touch on the SPI.
 
@mjs513 and @defragster and ...

For the heck of it I started hacking a copy of the ILI9488_t3 library into another one for this KeDei POS...

It is really a WIP as I only have pieces in place to build for T4, Will probably hack in T3.x soon, may cut out TLC...

Lots of things not done (and/or maybe not doable...). Like I have not tackled rotation yet, nor DMA output Asynch... Not sure how doable that is as you need to change CS and TFT CS for each grouping of 3 or 4 bytes...

But if you look at the example for graphicTest it is running on my machine. Currently have it defined to use Pin 10 CS Pin 6 Touch CS...

Note I edited the zip file to remove bitmaps and most of the examples as to make the file small enough to upload...
 

Attachments

  • KeDeiRPI35_t3.zip
    334.5 KB · Views: 48
@mjs513 and @defragster and ...

For the heck of it I started hacking a copy of the ILI9488_t3 library into another one for this KeDei POS...

It is really a WIP as I only have pieces in place to build for T4, Will probably hack in T3.x soon, may cut out TLC...

Lots of things not done (and/or maybe not doable...). Like I have not tackled rotation yet, nor DMA output Asynch... Not sure how doable that is as you need to change CS and TFT CS for each grouping of 3 or 4 bytes...

But if you look at the example for graphicTest it is running on my machine. Currently have it defined to use Pin 10 CS Pin 6 Touch CS...

Note I edited the zip file to remove bitmaps and most of the examples as to make the file small enough to upload...

Quick test resulted in ::
Code:
T:\tCode\T4\KeDeiRPI35_t3\examples\graphicstestKeDei\graphicstestKeDei.ino:18:27: fatal error: KeDeiRPI35_t3.h: No such file or directory

… gotta run
 
My BAd - it is a LIBRARY - the last download went in sketch book - compiles now - wrong pins ??? gotta check then
 
@KurtE

My Kedei displayed arrived today, same one as yours: https://www.ebay.com/itm/New-3-5-in...e=STRK:MEBIDX:IT&_trksid=p2060353.m2749.l2649, it says version 6.3 on the back - hooked it up to the 3 T4b2s that I have and no dice nothing gets displayed with any of the sketches including your latest library. Have no idea why. Can't have miss connected 3 times but then again you never know.

On a different note - I attached a speaker directly to pin 8 and wanted to test the tone library and came across this updated library for RTTL: https://github.com/end2endzone/NonBlockingRTTTL. Works pretty good, you might want to check it out if you just want sounds, as for clips: https://www.redringtones.com/star-wars-ringtones/page/2/

At least I got something working today.

EDIT: I redownloaded the SPI library and the GFX library as well - just in case. Unless I got something screwy with the core but I don't see how.
 
Using direct wire pins in sketch had to add SPI:: KEDEIRPI35_t3 tft = KEDEIRPI35_t3(&SPI, TFT_CS, TOUCH_CS, 11, 13, 12); //10,6,11,13,12

Also v6.3 of KeDei.

Runs this in setup flashes text in loop() then GOES AWAY - took out :: //tft.setRotation(rotation);
and still wholly goes away …
ILI9488 Test!
Benchmark Time (microseconds)
Screen fill 1188012
Text 36157
Lines 534390
Horiz/Vert Lines 97857
Rectangles (outline) 55514
Rectangles (filled) 2869702
Circles (filled) 440287
Circles (outline) 441493
Triangles (outline) 110346
Triangles (filled) 915483
Rounded rects (outline) 159850
Rounded rects (filled) 3137171
Done!
 
You might try this version? I have rotation working better,

Plus now debugging why not working on T3.6...

I am getting some data going out, now need to verify right order of data bytes...
 

Attachments

  • KeDeiRPI35_t3.zip
    342.7 KB · Views: 50
I guess the next question, is this worthy of saving up to github?

Obviously would need to clean up a few things like library properties. Some comments giving credit to the RPI...

But next may be to try the touch paint program...
 
-- cross post - yeah I saw spare .h above 'folder' I ignored?
Got updated update :) Cool - rotation - much better - cycled loop() maybe 6 times then - POOF … GONE … No T4 on Windows
Repeated and counted 6 loop() draws and poof.

Colors are mixed up - white swapped with black? and others off. I see white fillscreen with black rect_box:
Code:
unsigned long testText() {
  tft.fillScreen(KEDEIRPI35_BLACK);
  tft.fillRect(30, 30, tft.width() / 2, tft.height() / 2, KEDEIRPI35_WHITE);

@mjs513 - did you try direct pin #'s p#335

Is anyone else's over blown white? Washed out
 
@defragster - @KurtE

Tried that as well when I saw it but no luck - nothing displays.

But something looks funny with the LA dump I made:
Capture.JPG

and still nothing on the display - have no idea whats going on - maybe download a new core.
 
Hi Mike No idea what is going on?

I uploaded again the stuff. Moved the updated header file back down to the library.

That change was to get it to work with T3.x... At least it worked on my T3.6 with CS=10, Touch cs=9

I also updated the touchpaint to use the XPT2046 library. It is getting touch stuff, but I have not worked on calibrating the data from touch pad...

Probably it for tonight.

Maybe try lowering the SPI speed?

But got to run
 

Attachments

  • KeDeiRPI35_t3.zip
    334.3 KB · Views: 53
@mjs513 @defragster -
I confirmed that the colors appear to be wrong. RED->BLUE BLUE->RED i.e. instead of RGB it is BGR.

From the code I started from, I thought it was the supposed to be the same order... At least in the example app it had table:
Code:
uint16_t colors[16] = {
  0b0000000000000000,				/* BLACK	000000 */
  0b0000000000010000,				/* NAVY		000080 */
  0b0000000000011111,				/* BLUE		0000ff */
  0b0000010011000000,				/* GREEN	009900 */
  0b0000010011010011,				/* TEAL		009999 */
  0b0000011111100000,				/* LIME		00ff00 */
  0b0000011111111111,				/* AQUA		00ffff */
  0b1000000000000000,				/* MAROON	800000 */
  0b1000000000010000,				/* PURPLE	800080 */
  0b1001110011000000,				/* OLIVE	999900 */
  0b1000010000010000,				/* GRAY		808080 */
  0b1100111001111001,				/* SILVER	cccccc */
  0b1111100000000000,				/* RED		ff0000 */
  0b1111100000011111,				/* FUCHSIA	ff00ff */
  0b1111111111100000,				/* YELLOW	ffff00 */
  0b1111111111111111				/* WHITE	ffffff */
};
So checking to see if somewhere in the code I am screwing it up or some setting I am missing or...

Obviously simple fix would be to just change the constants like:
Code:
#define KEDEIRPI35_BLUE        0x001F      /*   0,   0, 255 */
#define KEDEIRPI35_GREEN       0x07E0      /*   0, 255,   0 */
#define KEDEIRPI35_CYAN        0x07FF      /*   0, 255, 255 */
#define KEDEIRPI35_RED         0xF800      /* 255,   0,   0 */
and the function: color565...

@mjs513 - Your LA dump looks screwy especially on the CS pins. As for wiring, I redid mine again today on T4 (my own breakout) this time with pins 10, 9
So simply have pins 9-13 connected, plus two +5v pins and 2 GNDs - Not sure if both power and GND are needed, but...

Currently playing with it using modified version of my frame buffer/clip test program... Added part at start for trying out colors...
Code:
#include <KeDeiRPI35_t3.h>
#include <KeDeiRPI35_t3_font_Arial.h>
#include <KeDeiRPI35_t3_font_ArialBold.h>
#define TFT_CS 10
#define TOUCH_CS 9
KEDEIRPI35_t3 tft = KEDEIRPI35_t3(&SPI, TFT_CS, TOUCH_CS);

Adafruit_GFX_Button button;
uint8_t use_fb = 0;
uint8_t use_dma = 0;
uint8_t use_clip_rect = 0;
uint8_t use_set_origin = 0;

#define ORIGIN_TEST_X 50
#define ORIGIN_TEST_Y 50

void setup() {
  while (!Serial && (millis() < 4000)) ;
  Serial.begin(115200);
#ifdef TFT_BL
  pinMode(TFT_BL, OUTPUT);
  digitalWrite(TFT_BL, HIGH);
#endif
  tft.begin();
  tft.setRotation(3);
  tft.fillScreen(KEDEIRPI35_BLACK);
  Serial.println("Screen should be black");
  WaitForUserInput();
  tft.fillScreen(KEDEIRPI35_RED);
  Serial.println("Screen should be red");
  WaitForUserInput();
  tft.fillScreen(KEDEIRPI35_GREEN);
  Serial.println("Screen should be green");
  WaitForUserInput();
  tft.fillScreen(KEDEIRPI35_BLUE);
  Serial.println("Screen should be blue");
  WaitForUserInput();
  tft.fillScreen(KEDEIRPI35_WHITE);
  Serial.println("Screen should be white");
  WaitForUserInput();
#ifdef DEBUG_PIN
  pinMode(DEBUG_PIN, OUTPUT);
#endif

  button.initButton(&tft, 200, 125, 100, 40, KEDEIRPI35_GREEN, KEDEIRPI35_YELLOW, KEDEIRPI35_RED, "UP", 1);




  drawTestScreen();
}

void SetupOrClearClipRectAndOffsets() {
  if (use_clip_rect) {
    tft.setClipRect();  // make sure we clear the whole screen
    tft.setOrigin();    // make sure none are set yet

    tft.fillScreen(KEDEIRPI35_LIGHTGREY);

    // Now lets set origin.
    if (use_set_origin)
      tft.setOrigin(ORIGIN_TEST_X, ORIGIN_TEST_Y);
    int x = tft.width() / 4;
    int y = tft.height() / 4;
    int w = tft.width() / 2;
    int h = tft.height() / 2;
    tft.drawRect(x, y, w, h, KEDEIRPI35_ORANGE);
    tft.updateScreen();
    tft.setClipRect(x + 1, y + 1, w - 2, h - 2);
    delay(250);

  } else {
    tft.setClipRect();
    if (use_set_origin)
      tft.setOrigin(ORIGIN_TEST_X, ORIGIN_TEST_Y);
    else
      tft.setOrigin();
  }
}


uint16_t palette[16];  // Should probably be 256, but I don't use many colors...
uint16_t pixel_data[2500];
const uint8_t pict1bpp[] = {0xff, 0xff, 0xc0, 0x03, 0xa0, 0x05, 0x90, 0x9, 0x88, 0x11, 0x84, 0x21, 0x82, 0x41, 0x81, 0x81,
                            0x81, 0x81, 0x82, 0x41, 0x84, 0x21, 0x88, 0x11, 0x90, 0x09, 0xa0, 0x05, 0xc0, 0x03, 0xff, 0xff
                           };
const uint8_t pict2bpp[] = {
  0x00, 0x00, 0x55, 0x55, 0xaa, 0xaa, 0xff, 0xff,
  0x00, 0x00, 0x55, 0x55, 0xaa, 0xaa, 0xff, 0xff,
  0x55, 0x55, 0xaa, 0xaa, 0xff, 0xff, 0x00, 0x00,
  0x55, 0x55, 0xaa, 0xaa, 0xff, 0xff, 0x00, 0x00,
  0xaa, 0xaa, 0xff, 0xff, 0x00, 0x00, 0x55, 0x55,
  0xaa, 0xaa, 0xff, 0xff, 0x00, 0x00, 0x55, 0x55,
  0xff, 0xff, 0x00, 0x00, 0x55, 0x55, 0xaa, 0xaa,
  0xff, 0xff, 0x00, 0x00, 0x55, 0x55, 0xaa, 0xaa,
  0x00, 0x00, 0x55, 0x55, 0xaa, 0xaa, 0xff, 0xff,
  0x00, 0x00, 0x55, 0x55, 0xaa, 0xaa, 0xff, 0xff,
  0x55, 0x55, 0xaa, 0xaa, 0xff, 0xff, 0x00, 0x00,
  0x55, 0x55, 0xaa, 0xaa, 0xff, 0xff, 0x00, 0x00,
  0xaa, 0xaa, 0xff, 0xff, 0x00, 0x00, 0x55, 0x55,
  0xaa, 0xaa, 0xff, 0xff, 0x00, 0x00, 0x55, 0x55,
  0xff, 0xff, 0x00, 0x00, 0x55, 0x55, 0xaa, 0xaa,
  0xff, 0xff, 0x00, 0x00, 0x55, 0x55, 0xaa, 0xaa,
};
const uint8_t pict4bpp[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00,
  0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00,
  0x00, 0x11, 0x22, 0x22, 0x22, 0x22, 0x11, 0x00,
  0x00, 0x11, 0x22, 0x22, 0x22, 0x22, 0x11, 0x00,
  0x00, 0x11, 0x22, 0x33, 0x33, 0x22, 0x11, 0x00,
  0x00, 0x11, 0x22, 0x33, 0x33, 0x22, 0x11, 0x00,
  0x00, 0x11, 0x22, 0x33, 0x33, 0x22, 0x11, 0x00,
  0x00, 0x11, 0x22, 0x33, 0x33, 0x22, 0x11, 0x00,
  0x00, 0x11, 0x22, 0x22, 0x22, 0x22, 0x11, 0x00,
  0x00, 0x11, 0x22, 0x22, 0x22, 0x22, 0x11, 0x00,
  0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00,
  0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};



void drawTestScreen() {
  Serial.printf("Use FB: %d(%d) ", use_fb, use_dma); Serial.flush();
  tft.useFrameBuffer(use_fb);
  SetupOrClearClipRectAndOffsets();
  uint32_t start_time = millis();
  elapsedMillis emAsync;
  tft.fillScreen(use_fb ? KEDEIRPI35_RED : KEDEIRPI35_BLACK);
  //tft.setFont(Inconsolata_60);
  tft.setFont(Arial_24_Bold);
  tft.setTextColor(KEDEIRPI35_WHITE);
  tft.setCursor(0, 0);
  tft.println("Test");
  tft.setTextColor(KEDEIRPI35_WHITE, KEDEIRPI35_RED);
  tft.println("text");
  tft.setCursor(85, 65);
  tft.print("XYZ");
  tft.setFontAdafruit();
  tft.setTextSize(2);
  tft.setTextColor(KEDEIRPI35_WHITE);
  tft.println("01234");
  tft.setTextColor(KEDEIRPI35_WHITE, KEDEIRPI35_GREEN);
  tft.println("56789!@#$%");

  tft.drawRect(0, 150, 100, 50, KEDEIRPI35_WHITE);
  tft.drawLine(0, 150, 100, 50, KEDEIRPI35_GREEN);
  tft.fillRectVGradient(125, 150, 50, 50, KEDEIRPI35_GREEN, KEDEIRPI35_YELLOW);
  tft.fillRectHGradient(200, 150, 50, 50, KEDEIRPI35_YELLOW, KEDEIRPI35_GREEN);
  // Try a read rect and write rect
#ifdef DEBUG_PIN
  digitalWrite(DEBUG_PIN, HIGH);
#endif

  tft.readRect(0, 0, 50, 50, pixel_data);

#ifdef DEBUG_PIN
  digitalWrite(DEBUG_PIN, LOW);
#endif
  tft.writeRect(250, 0, 50, 50, pixel_data);

  // Lets try to pack this rectangle of data into 8 byte
  tft.readRect(85, 65, 50, 50, pixel_data);
  uint16_t *ppd16 = pixel_data;
  uint8_t *ppd8 = (uint8_t*)pixel_data;
  uint8_t palette_cnt = 0;
  int palette_index;
  for (int i = 0; i < 2500; i++) {
    for (palette_index = 0; palette_index < palette_cnt; palette_index++) {
      if (*ppd16 == palette[palette_index])
        break;
    }
    if (palette_index >= palette_cnt) {
      palette[palette_cnt++] = *ppd16;  // save away the color
    }
    *ppd8++ = palette_index;
    ppd16++;
  }
  tft.writeRect8BPP(200, 50, 50, 50, (uint8_t*)pixel_data, palette);
  palette[0] = KEDEIRPI35_CYAN;
  palette[1] = KEDEIRPI35_OLIVE;
  tft.writeRect1BPP(75, 100, 16, 16, pict1bpp, palette);
  tft.writeRect1BPP(320 - 90, 75, 16, 16, pict1bpp, palette);

  palette[2] = KEDEIRPI35_MAROON;
  palette[3] = KEDEIRPI35_PINK;
  tft.writeRect2BPP(75, 125, 32, 16, pict2bpp, palette);

  tft.writeRectNBPP(15, 125, 32, 16, 2, pict2bpp, palette);
  tft.writeRectNBPP(75, 150, 16, 16, 4, pict4bpp, palette);

  // Try drawing button
  tft.setFontAdafruit();
  button.drawButton();

  if (use_dma) {
    emAsync = 0;
    tft.updateScreenAsync();
  } else {
    tft.updateScreen();
  }
  Serial.println(millis() - start_time, DEC);

  if (use_dma && use_fb) {
    while (tft.asyncUpdateActive() && emAsync < 500) ;
    //    delay(500);
    Serial.printf("Async Update Time: %d DMA error status: %x\n",
                  (uint32_t)emAsync, DMA_ES);
  }

  use_fb = !use_fb;

}

void drawTextScreen(bool fOpaque) {
  SetupOrClearClipRectAndOffsets();
  uint32_t start_time = millis();
  tft.useFrameBuffer(use_fb);
  tft.fillScreen(use_fb ? KEDEIRPI35_RED : KEDEIRPI35_BLACK);
  tft.setFont(Arial_40_Bold);
  if (fOpaque)
    tft.setTextColor(KEDEIRPI35_WHITE, use_fb ? KEDEIRPI35_BLACK : KEDEIRPI35_RED);
  else
    tft.setTextColor(KEDEIRPI35_WHITE);
  tft.setCursor(0, 5);
  tft.println("AbCdEfGhIj");
  tft.setFont(Arial_28_Bold);
  tft.println("0123456789!@#$");
#if 1
  tft.setFont(Arial_20_Bold);
  tft.println("abcdefghijklmnopq");
  tft.setFont(Arial_14_Bold);
  tft.println("ABCDEFGHIJKLMNOPQRST");
  tft.setFont(Arial_10_Bold);
  tft.println("0123456789zyxwvutu");
#endif
  tft.updateScreen();

  Serial.printf("Use FB: %d OP: %d, DT: %d OR: %d\n", use_fb, fOpaque, use_set_origin, millis() - start_time);
}
//=============================================================================
// Wait for user input
//=============================================================================
void WaitForUserInput() {
  Serial.println("Hit Enter to continue");
  Serial.flush();
  while (Serial.read() == -1) ;
  while (Serial.read() != -1) ;

}

//=============================================================================
// Try continuous update
//=============================================================================
void WaitForFrame(bool fCont, uint32_t wait_frame_count) {
  if (fCont) {
    while (tft.frameCount() < wait_frame_count) yield();
  } else {
    tft.updateScreenAsync();
    WaitForUserInput();
  }
}

void testDMAContUpdate(bool fCont) {
  // Force frame buffer on

  Serial.printf("continuous DMA udpate test - Frame mode on\n"); Serial.flush();
  if (!fCont) {
    Serial.println("Step Mode");
    Serial.flush();
  }
  use_fb = 1; //

  tft.useFrameBuffer(use_fb);
  tft.fillScreen(KEDEIRPI35_GREEN);

  // check to see if screen memory actually turned green.
  if (use_fb) {
    uint8_t *pw = tft.getFrameBuffer();
    uint16_t *pallet = tft.getPallet();
    int error_count = 0;
    for (int i = 0; i < (KEDEIRPI35_TFTWIDTH * KEDEIRPI35_TFTHEIGHT); i++)
    {
      if (pallet[*pw] != KEDEIRPI35_GREEN) {
        Serial.printf("tft.fillScreen(KEDEIRPI35_GREEN) not green? %d != %x %x\n", i, *pw, pallet[*pw]);
        error_count++;
      }
      pw++;
    }
    Serial.printf("tft.fillScreen(KEDEIRPI35_GREEN(%x)) error count = %d\n", KEDEIRPI35_GREEN, error_count);
  }

  if (fCont)
    tft.updateScreenAsync(fCont);

  // Start the update
  WaitForFrame(fCont, 10);

  tft.fillScreen(KEDEIRPI35_YELLOW);
  tft.drawRect(5, 5, 310, 230, KEDEIRPI35_GREEN);
  tft.fillRect(140, 100, 40, 40, KEDEIRPI35_BLUE);
  WaitForFrame(fCont, 20);

  tft.fillScreen(KEDEIRPI35_RED);
  tft.drawRect(5, 5, 310, 230, KEDEIRPI35_WHITE);

  WaitForFrame(fCont, 30);

  tft.fillScreen(KEDEIRPI35_BLACK);

  tft.drawRect(5, 5, 310, 230, KEDEIRPI35_GREEN);
  tft.drawRect(25, 25, 270, 190, KEDEIRPI35_RED);
  WaitForFrame(fCont, 40);

  digitalWrite(0, HIGH);
  tft.drawRect(5, 5, 310, 230, KEDEIRPI35_GREEN);
  tft.setCursor(10, 100);
  tft.setTextColor(KEDEIRPI35_RED, KEDEIRPI35_BLACK);
  tft.setFont(Arial_20_Bold);
  tft.println("DONE");
  tft.setFontAdafruit();
  tft.setCursor(10, 200);
  tft.setTextColor(KEDEIRPI35_GREEN);
  tft.print("Done");
  tft.setTextSize(2);
  tft.setCursor(10, 50);
  tft.setTextColor(KEDEIRPI35_WHITE, KEDEIRPI35_RED);
  tft.print("Done");
  digitalWrite(0, LOW);
  WaitForFrame(fCont, 45);
  tft.fillRect(0, 0, 2, 2, KEDEIRPI35_PURPLE);

  if (!fCont) {
    Serial.println("Lets now try doing Continue for a few iterations to see if it changes");
    tft.updateScreenAsync(true);
    while (tft.frameCount() < 10) yield();
  }
  tft.endUpdateAsync();
  Serial.println("after endUpdateAsync");
  tft.waitUpdateAsyncComplete();
  Serial.println("after waitUpdateAsyncComplete");
  Serial.println("Finished test");

  delay(2000);
  Serial.println("Do normal update to see if data is there");
  tft.updateScreen();

}

void loop(void) {
  // See if any text entered
  int ich;
  if ((ich = Serial.read()) != -1) {
    while (Serial.read() != -1) ;
    if (ich == 'c') {
      use_clip_rect = !use_clip_rect;
      if (use_clip_rect) Serial.println("Clip Rectangle Turned on");
      else Serial.println("Clip Rectangle turned off");
      return;
    }
    if (ich == 'd') {
      use_dma = !use_dma;
      if (use_dma) Serial.println("DMA Turned on");
      else Serial.println("DMA turned off");
      return;
    }
    if (ich == 's') {
      use_set_origin = !use_set_origin;
      if (use_set_origin) Serial.printf("Set origin to %d, %d\n", ORIGIN_TEST_X, ORIGIN_TEST_Y);
      else Serial.println("Clear origin");
      return;
    }
    if (ich == 'o')
      drawTextScreen(1);
    else if (ich == 't')
      drawTextScreen(0);
    else if (ich == 'r') {
      testDMAContUpdate(true);
      Serial.println("Returned from testDMAContUpdate");
    }
    else if (ich == 'a') {
      testDMAContUpdate(false);
      Serial.println("Returned from testDMAContUpdate");
    }
    else
      drawTestScreen();
  }

}
 
Just verified that our earlier test apps the colors were wrong as well, I updated the simple one to output the color it was going to output to the screen>
Code:
// Original code - KeDei V5.0 code - Conjur
//  https://www.raspberrypi.org/forums/viewtopic.php?p=1019562
//  Mon Aug 22, 2016 2:12 am - Final post on the KeDei v5.0 code.
// References code - Uladzimir Harabtsou l0nley
//  https://github.com/l0nley/kedei35
//
// KeDei 3.5inch LCD V5.0 module for Raspberry Pi
// Modified by FREE WING, Y.Sakamoto
// http://www.neko.ne.jp/~freewing/
//
// WiringPi library version
// gcc -o kedei_lcd_v50_pi_wiringpi kedei_lcd_v50_pi_wiringpi.c -lwiringPi
// sudo ./kedei_lcd_v50_pi_wiringpi
#include "SPI.h"

#define SPICLOCK 60000000

#define LCD_CS 10
#define TOUCH_CS 9

#define LCD_WIDTH  480
#define LCD_HEIGHT 320

static const int DEBUG = 0;		// enable debug outputs

#define uint8_t unsigned char
#define uint16_t unsigned int
#define uint32_t unsigned long

volatile uint8_t color;
volatile uint8_t lcd_rot = 0;
volatile int16_t lcd_h = LCD_HEIGHT;
volatile int16_t lcd_w = LCD_WIDTH;

uint16_t colors[16] = {
  0b0000000000000000,				/* BLACK	000000 */
  0b0000000000010000,				/* NAVY		000080 */
  0b0000000000011111,				/* BLUE		0000ff */
  0b0000010011000000,				/* GREEN	009900 */
  0b0000010011010011,				/* TEAL		009999 */
  0b0000011111100000,				/* LIME		00ff00 */
  0b0000011111111111,				/* AQUA		00ffff */
  0b1000000000000000,				/* MAROON	800000 */
  0b1000000000010000,				/* PURPLE	800080 */
  0b1001110011000000,				/* OLIVE	999900 */
  0b1000010000010000,				/* GRAY		808080 */
  0b1100111001111001,				/* SILVER	cccccc */
  0b1111100000000000,				/* RED		ff0000 */
  0b1111100000011111,				/* FUCHSIA	ff00ff */
  0b1111111111100000,				/* YELLOW	ffff00 */
  0b1111111111111111				/* WHITE	ffffff */
};
const char* colorNames[] = {
  "BLACK: ",
  "NAVY: ",
  "BLUE: ",
  "GREEN: ",
  "TEAL: ",
  "LIME: ",
  "AQUA: ",
  "MAROON: ",
  "PURPLE: ",
  "OLIVE: ",
  "GRAY: ",
  "SILVER: ",
  "RED: ",
  "FUCHSIA: ",
  "YELLOW: ",
  "WHITE: "};


void delayms(int ms) {
  delay(ms);
}


int lcd_open(void) {

  SPI.begin();
  pinMode(LCD_CS, OUTPUT);
  digitalWrite(LCD_CS, HIGH);
  pinMode(TOUCH_CS, OUTPUT);
  digitalWrite(TOUCH_CS, HIGH);
  return 0;
}

int lcd_close(void) {

  return 0;
}

uint32_t g_tcr_save = 0;

void inline beginSPITransaction() {
  g_tcr_save = IMXRT_LPSPI4_S.TCR;
  SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
  IMXRT_LPSPI4_S.TCR = (g_tcr_save & 0xfffff000) | LPSPI_TCR_FRAMESZ(31);  // turn on 32 bit mode
//  digitalWriteFast(LCD_CS, LOW);
}

void inline endSPITransaction() {
//  digitalWriteFast(LCD_CS, HIGH);
  SPI.endTransaction();
}


void spi_transmit32(uint32_t data32)
{
  digitalWriteFast(LCD_CS, LOW);
  if ((IMXRT_LPSPI4_S.TCR & 0xfff) != 31) {
    IMXRT_LPSPI4_S.TCR = (g_tcr_save & 0xfffff000) | LPSPI_TCR_FRAMESZ(31);  // turn on 32 bit mode
  }
  IMXRT_LPSPI4_S.TDR = data32;    // output 32 bit data.
  while ((IMXRT_LPSPI4_S.RSR & LPSPI_RSR_RXEMPTY)) ;  // wait while the RSR fifo is empty...
  data32 = IMXRT_LPSPI4_S.RDR;
  digitalWriteFast(LCD_CS, HIGH);
  digitalWriteFast(TOUCH_CS, LOW);
  delayNanoseconds(1);
  digitalWriteFast(TOUCH_CS, HIGH);
  return;
}

void spi_transmit24(uint32_t data32)
{
  digitalWriteFast(LCD_CS, LOW);
  if ((IMXRT_LPSPI4_S.TCR & 0xfff) != 23) {
    IMXRT_LPSPI4_S.TCR = (g_tcr_save & 0xfffff000) | LPSPI_TCR_FRAMESZ(23);  // turn on 24 bit mode
  }
  IMXRT_LPSPI4_S.TDR = data32;    // output 32 bit data.
  while ((IMXRT_LPSPI4_S.RSR & LPSPI_RSR_RXEMPTY)) ;  // wait while the RSR fifo is empty...
  data32 = IMXRT_LPSPI4_S.RDR;
  digitalWriteFast(LCD_CS, HIGH);
  digitalWriteFast(TOUCH_CS, LOW);
  delayNanoseconds(1);
  digitalWriteFast(TOUCH_CS, HIGH);
  return;
}

void spi_transmit(uint8_t *data_in, int len)
{
  uint32_t data32;
  digitalWriteFast(LCD_CS, LOW);
  if (len == 4) {
    // currently only T4...
    if ((IMXRT_LPSPI4_S.TCR & 0xfff) != 31) {
      IMXRT_LPSPI4_S.TCR = (g_tcr_save & 0xfffff000) | LPSPI_TCR_FRAMESZ(31);  // turn on 32 bit mode
    }
    data32 = ((uint32_t)data_in[0] << 24) | ((uint32_t)data_in[1] << 16) |
             ((uint32_t)data_in[2] << 8) | (uint32_t)data_in[3];
  } else {
    if ((IMXRT_LPSPI4_S.TCR & 0xfff) != 23) {
      IMXRT_LPSPI4_S.TCR = (g_tcr_save & 0xfffff000) | LPSPI_TCR_FRAMESZ(23);  // turn on 32 bit mode
    }
    data32 = ((uint32_t)data_in[0] << 16) | ((uint32_t)data_in[1] << 8) |
             (uint32_t)data_in[2];
  }
  IMXRT_LPSPI4_S.TDR = data32;    // output 32 bit data.
  while ((IMXRT_LPSPI4_S.RSR & LPSPI_RSR_RXEMPTY)) ;  // wait while the RSR fifo is empty...
  data32 = IMXRT_LPSPI4_S.RDR;
  digitalWriteFast(LCD_CS, HIGH);
  digitalWriteFast(TOUCH_CS, LOW);
  delayNanoseconds(1);
  digitalWriteFast(TOUCH_CS, HIGH);
  return;
}

void lcd_rst(void)
{
  beginSPITransaction();
  spi_transmit32(0x00010000L);  //
  endSPITransaction();
  delayms(50);

  beginSPITransaction();
  spi_transmit32(0x00000000L);
  endSPITransaction();
  delayms(120);

  beginSPITransaction();
  spi_transmit32(0x00010000L);
  endSPITransaction();
  delayms(50);
}


inline void lcd_cmd(uint8_t cmd)
{
  spi_transmit32(0x00110000L | cmd);
}


inline void lcd_data(uint8_t dat)
{
  spi_transmit32(0x00150000L | dat);
}

inline void lcd_color(uint16_t col)
{
  spi_transmit32(0x00150000L | col);
}

// 18bit color mode
void lcd_colorRGB(uint8_t r, uint8_t g, uint8_t b) {

  uint16_t col = ((r << 8) & 0xF800) | ((g << 3) & 0x07E0) | ((b >> 3) & 0x001F);

  // 18bit color mode ???
  // 0xF800 R(R5-R1, DB17-DB13)
  // 0x07E0 G(G5-G0, DB11- DB6)
  // 0x001F B(B5-B1, DB5 - DB1)
  // 0x40 = R(R0, DB12), 0x20 = B(B0, DB0)
  spi_transmit24(0x150000L | col);
}

uint8_t lcd_rotations[4] = {
  0x48,	//   0 = 0xEA
  0xE8,	//  90 = 0x4A
  0x88,	// 180 = 0x2A
  0x28	// 270 = 0x8A
};

void lcd_setrotation(uint8_t m)
{
  // command is different in V6.3
  lcd_cmd(0x36);
  lcd_data(lcd_rotations[m]);
  if (m & 1) { // 1=90, 3=270
    lcd_h = LCD_HEIGHT;
    lcd_w = LCD_WIDTH;
  } else {	// 0=0, 2=180
    lcd_h = LCD_WIDTH;
    lcd_w = LCD_HEIGHT;
  }
  lcd_rot = m;
}

void lcd_init(void)
{
  lcd_rst();
  //kedei 6.3 init sequence
  beginSPITransaction();
  lcd_cmd(0x00);
  delayms(20);
  lcd_cmd(0x11);
  endSPITransaction();
  delayms(120);
  beginSPITransaction();
  lcd_cmd(0x13);
  lcd_cmd(0xB4); lcd_data(0x00);
  lcd_cmd(0xC0); lcd_data(0x10); lcd_data(0x3D); lcd_data(0x00); lcd_data(0x02); lcd_data(0x11);
  lcd_cmd(0xC1); lcd_data(0x10);
  lcd_cmd(0xC8); lcd_data(0x00); lcd_data(0x30); lcd_data(0x36); lcd_data(0x45);
  lcd_data(0x04); lcd_data(0x16); lcd_data(0x37); lcd_data(0x75);
  lcd_data(0x77); lcd_data(0x54); lcd_data(0x0F); lcd_data(0x00);
  lcd_cmd(0xD0); lcd_data(0x07); lcd_data(0x40); lcd_data(0x1C);
  lcd_cmd(0xD1); lcd_data(0x00); lcd_data(0x18); lcd_data(0x1D);
  lcd_cmd(0xD2); lcd_data(0x01); lcd_data(0x11);
  lcd_cmd(0xC5); lcd_data(0x08);
  lcd_cmd(0x36); lcd_data(0x28);
  lcd_cmd(0x3A); lcd_data(0x05);
  lcd_cmd(0x2A); lcd_data(0x00); lcd_data(0x00); lcd_data(0x01); lcd_data(0x3F);
  lcd_cmd(0x2B); lcd_data(0x00); lcd_data(0x00); lcd_data(0x01); lcd_data(0xE0);
  endSPITransaction();
  delayms(120);
  beginSPITransaction();
  lcd_cmd(0x29);
  delayms(5);
  lcd_cmd(0x36); lcd_data(0x28);
  lcd_cmd(0x3A); lcd_data(0x55);
  lcd_cmd(0x2A); lcd_data(0x00); lcd_data(0x00); lcd_data(0x01); lcd_data(0x3F);
  lcd_cmd(0x2B); lcd_data(0x00); lcd_data(0x00); lcd_data(0x01); lcd_data(0xE0);
  endSPITransaction();
  delayms(120);
  beginSPITransaction();
  lcd_cmd(0x21);
  lcd_cmd(0x29);
  delayms(50);
  endSPITransaction();
}

void lcd_setframe(int x, int y, int w, int h)
{
  if ( (x + w) > lcd_w)  {
    w = lcd_w - x;
  }
  if ( (y + h) > lcd_h)  {
    h = lcd_h - y;
  }
  uint x1, w1, y1, h1;
  switch (lcd_rot)  {
    default:
    case 0:  // 0-deg.
      x1 = lcd_w - w - x;  y1 = y;
      w1 = w;  h1 = h;
      break;
    case 1:	  // 90-deg.
      x1 = lcd_w - x - w;   w1 = w;
      y1 = lcd_h - y - h;	h1 = h;

      break;
    case 2:	  // 180-deg
      x1 = x;  y1 = lcd_h - y - h;
      w1 = w;  h1 = h;
      break;
    case 3:	  // 270 deg.
      x1 = x;  y1 = y;
      w1 = w;  h1 = h;
      break;
  }
  if (DEBUG) printf("x1=%d, w1=%d, y1=%d, h1=%d\n", x1, w1, y1, h1);
  lcd_cmd(0x2B);  // (y)
  lcd_data(y1 >> 8);
  lcd_data(y1 & 0xFF);
  lcd_data(((h1 + y1) - 1) >> 8);
  lcd_data(((h1 + y1) - 1) & 0xFF);
  lcd_cmd(0x2A);  // (x)
  lcd_data(x1 >> 8);
  lcd_data(x1 & 0xFF);
  lcd_data(((w1 + x1) - 1) >> 8);
  lcd_data(((w1 + x1) - 1) & 0xFF);
  lcd_cmd(0x2C);
  if (DEBUG) printf("LCD 0x2B write: %d %d %d %d\n", y1 >> 8, y1 & 0xFF, ((h1 + y1) - 1) >> 8, ((h1 + y1) - 1) & 0xFF);
  if (DEBUG) printf("LCD 0x2A write: %d %d %d %d\n", x1 >> 8, x1 % 0xFF, ((w1 + x1) - 1) >> 8, ((w1 + x1) - 1) & 0xFF);
}

//lcd_fillframe
//fills an area of the screen with a single color.
void lcd_fillframe(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t col)
{
  int span = h * w;
  int q;
  beginSPITransaction();
  lcd_setframe(x, y, w, h);
  for (q = 0; q < span; q++)
  {
    lcd_color(col);
  }
  endSPITransaction();
}

void lcd_fill(uint16_t col)
{
  lcd_fillframe(0, 0, lcd_w, lcd_h, col);
}

void lcd_fillframeRGB(uint16_t x, uint16_t y,
                      uint16_t w, uint16_t h,
                      uint8_t r, uint8_t g, uint8_t b)
{
  int span = h * w;

  beginSPITransaction();
  lcd_setframe(x, y, w, h);
  int q;
  for (q = 0; q < span; q++)
  {
    lcd_colorRGB(r, g, b);
  }
  endSPITransaction();
}

void lcd_fillRGB(const uint8_t r, const uint8_t g, const uint8_t b)
{
  lcd_fillframeRGB(0, 0, lcd_w, lcd_h, r, g, b);
}

void lcd_img(char const *fname, const int16_t x, const int16_t y) {
  /*
  	uint8_t buf[54];
  	int16_t p, c;
  	int32_t isize, ioffset, iwidth, iheight, ibpp, fpos, rowbytes;

  	FILE *f = fopen(fname, "rb");
  	if (f != NULL) {
  		fseek(f, 0L, SEEK_SET);
  		fread(buf, 30, 1, f);

  		isize =	  buf[2]  + (buf[3]<<8)  + (buf[4]<<16)  + (buf[5]<<24);
  		ioffset = buf[10] + (buf[11]<<8) + (buf[12]<<16) + (buf[13]<<24);
  		iwidth =  buf[18] + (buf[19]<<8) + (buf[20]<<16) + (buf[21]<<24);
  		iheight = buf[22] + (buf[23]<<8) + (buf[24]<<16) + (buf[25]<<24);
  		ibpp =	  buf[28] + (buf[29]<<8);

  		if (DEBUG) printf("\nLCD-Setting: lcd_h=%d, lcd_w=%d\n",lcd_h,lcd_w);
  		if (DEBUG) printf("File Size: %u\nOffset: %u\nWidth: %u\nHeight: %u\nBPP: %u\n\n",isize,ioffset,iwidth,iheight,ibpp);

  		lcd_setframe(x,y,iwidth,iheight); //set the active frame...
  		if (iwidth % 2)  {
  			rowbytes=(iwidth*3) + 4-((iwidth*3)%4);
  		}  else  {
  			rowbytes=(iwidth*3);
  		}

  		for (p=iheight-1;p>=0;p--) {
  			// p = relative page address (y)
  			fpos = ioffset+(p*rowbytes);
  			fseek(f, fpos, SEEK_SET);
  			for (c=0;c<iwidth;c++) {
  				// c = relative column address (x)
  				fread(buf, 3, 1, f);

  				// B buf[0]
  				// G buf[1]
  				// R buf[2]
  				// 24bit color mode
  				if ( (c<(lcd_w-x)) && (p>iheight-(lcd_h-y)) ) {
  					lcd_colorRGB(buf[2], buf[1], buf[0]);
  				}  else  {
  				}
  			}
  		}

  		fclose(f);
  	}
  */
}


void loop() {

  //Update rotation
  lcd_setrotation(lcd_rot);

  //Fill entire screen with new color
  Serial.print(colorNames[color]);
  elapsedMillis em = 0;
  lcd_fillframe(0, 0, lcd_w, lcd_h, colors[color]);
  Serial.println((uint32_t)em, DEC);
  //Make a color+1 box, 5 pixels from the top-left corner, 20 pixels high, 95 (100-5) pixels from right border.
  lcd_fillframe(5, 5, lcd_w - 100, 20, colors[(color + 1) & 0xF]);

  //increment color
  color++;
  //if color is overflowed, reset to 0
  if (color == 16) {
    color = 0;
  }

  //increment rotation
  lcd_rot++;

  //if rotation is overflowed, reset to 0
  if (lcd_rot == 4) lcd_rot = 0;

  delayms(500);
}

void setup()
{
  while (!Serial && millis() < 4000) ;
  Serial.begin(115200);
  Serial.println("Before lcd_open"); Serial.flush();
  delay(5);
  lcd_open();
  Serial.println("After lcd_open"); Serial.flush();
  lcd_init();
  Serial.println("Initialized");
  lcd_fill(0x0); //black out the screen.
  Serial.println("black out the screen");

  /*
      lcd_setrotation(0);  // 0-degree
  	lcd_img("nice.bmp", 0, 0);
      delayms(2000);

      lcd_setrotation(2);	// 180-degree
  	lcd_img("nice.bmp", 0, 0);
      delayms(2000);

      lcd_fill(0x0); //black out the screen.

      lcd_setrotation(0);  // 0-degree
  	lcd_img("nice.bmp", 50, 100);
      delayms(2000);

      lcd_setrotation(1);  // 90-degree
  	lcd_img("nice.bmp", 20, 40);
      delayms(2000);

      lcd_setrotation(2);	// 180-degree
  	lcd_img("nice.bmp", 70, 140);
      delayms(2000);

      lcd_setrotation(3);	// 270-degree
  	lcd_img("nice.bmp", 40, 20);
      delayms(2000);
  */

  lcd_fill(colors[3]);
  delayms(1000);
  lcd_fillRGB(0xFF, 0x00, 0x00);
  lcd_fillRGB(0x00, 0xFF, 0x00);
  lcd_fillRGB(0xFF, 0xFF, 0x00);
  lcd_fillRGB(0x00, 0x00, 0xFF);
  lcd_fillRGB(0xFF, 0x00, 0xFF);
  lcd_fillRGB(0x00, 0xFF, 0xFF);
  lcd_fillRGB(0xFF, 0xFF, 0xFF);
  lcd_fillRGB(0x00, 0x00, 0x00);

  // Demo
  color = 0;
  lcd_rot = 0;

  delay(5000);

  // 24bit Bitmap only
  //lcd_img("kedei_lcd_v50_pi.bmp", 50, 5);

  //lcd_close();
}

My first attempt to fix this was to play with the output of the MADCTL register 0x36, At least for the ili9351 and ili9488 one bit of this is supposed to control if RGB or BGR... At least that is how I read it?
So tried changing commands like: lcd_cmd(0x36); lcd_data(0x28);
to
lcd_cmd(0x36); lcd_data(0x20);

And changed that setting. But no change on the display... Since this is a one off, probably never used display I might simply hack it the other way, And modify the constants for now and the function to generate color from R,G,B...
 
Last edited:
@KurtE

Gave up the RPI display - cant get a damn thing displaying on it. Even tried it on the T3.6. Even tried using pin 9 for CS. I also reinstalled Arduino IDE 1.8.9 and the latest teensyduino from post #3 I think it was. No luck with that either - do you hook up miso to anything? I have no idea why it won't work and my LA trace is so screwy. I did download the latest SPI with writeRect incorporated. Maybe try again later.

ST7735: Still having that same problem with loosing USB with uncanny eyes unless I have debug_tt included. So another problem

SSD1351: No changes to that one either with uncanny.

Issue seems to be with uncanny eyes only. Everything else seems to work. ST7735 uncanny does work on a T3.6 though.
 
@mjs513 - Totally understand giving up on that display! I would post picture of setup, but... Out of curiosity you might try running one of the simple apps like the frame buffer test program posted above, and hook up your LA, but without display, and see if the SPI conversation is still screwed up (that is state of CS pins...)

All of the conversations go through
T4
Code:
	void spi_transmit32(uint32_t data32)
	{
	  DIRECT_WRITE_LOW(_csport, _cspinmask);
	  if ((_pimxrt_spi->TCR & 0xfff) != 31) {
	    _pimxrt_spi->TCR = (_pimxrt_spi->TCR & 0xfffff000) | LPSPI_TCR_FRAMESZ(31);  // turn on 32 bit mode
	  }
	  _pimxrt_spi->TDR = data32;    // output 32 bit data.
	  while ((_pimxrt_spi->RSR & LPSPI_RSR_RXEMPTY)) ;  // wait while the RSR fifo is empty...
	  data32 = _pimxrt_spi->RDR;
	  DIRECT_WRITE_HIGH(_csport, _cspinmask);
	  DIRECT_WRITE_LOW(_touchcsport, _touchcspinmask);
	  delayNanoseconds(5);
	  DIRECT_WRITE_HIGH(_touchcsport, _touchcspinmask);
	  return;
	}

	void spi_transmit24(uint32_t data32)
	{
	  DIRECT_WRITE_LOW(_csport, _cspinmask);
	  if ((_pimxrt_spi->TCR & 0xfff) != 23) {
	    _pimxrt_spi->TCR = (_pimxrt_spi->TCR & 0xfffff000) | LPSPI_TCR_FRAMESZ(23);  // turn on 24 bit mode
	  }
	  _pimxrt_spi->TDR = data32;    // output 32 bit data.
	  while ((_pimxrt_spi->RSR & LPSPI_RSR_RXEMPTY)) ;  // wait while the RSR fifo is empty...
	  data32 = _pimxrt_spi->RDR;
	  DIRECT_WRITE_HIGH(_csport, _cspinmask);
	  DIRECT_WRITE_LOW(_touchcsport, _touchcspinmask);
	  delayNanoseconds(5);
	  DIRECT_WRITE_HIGH(_touchcsport, _touchcspinmask);
	  return;
	}
And T3.x
Code:
	void DIRECT_WRITE_LOW(volatile uint8_t * base, uint8_t mask)  __attribute__((always_inline)) {
		*base = 0;
	}
	void DIRECT_WRITE_HIGH(volatile uint8_t * base, uint8_t mask)  __attribute__((always_inline)) {
		*base = 1;
	}
...
	void delayNanoseconds(uint8_t cnt) {
		while (cnt--) {

		}
	}

	void spi_transmit32(uint32_t data32)
	{
		DIRECT_WRITE_LOW(_csport, _cspinmask);
		uint8_t sr;
		// Push out the two value
 	  	_pkinetisk_spi->PUSHR = (data32 >>16)      |  SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
		do {
			sr = _pkinetisk_spi->SR;
		} while ((uint16_t)(sr & (15 << 12)) > ((uint16_t)(_fifo_size-1) << 12));

		_pkinetisk_spi->PUSHR = (data32 & 0xffff) |  SPI_PUSHR_CTAS(1);
			sr = _pkinetisk_spi->SR;

		uint8_t reads_remaining = 2;
		uint32_t tmp __attribute__((unused));
		while (reads_remaining) {
			sr = _pkinetisk_spi->SR;
			if (sr & 0xF0) {
				tmp = _pkinetisk_spi->POPR;  // drain RX FIFO
				reads_remaining--;
			}
		}
		DIRECT_WRITE_HIGH(_csport, _cspinmask);
		DIRECT_WRITE_LOW(_touchcsport, _touchcspinmask);
		delayNanoseconds(5);
		DIRECT_WRITE_HIGH(_touchcsport, _touchcspinmask);
	}

	void spi_transmit24(uint32_t data32)
	{
		DIRECT_WRITE_LOW(_csport, _cspinmask);
		uint8_t sr;
		// Push out the two value first one 8 bits
 	  	_pkinetisk_spi->PUSHR = (data32 >>16)      |  SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
		do {
			sr = _pkinetisk_spi->SR;
		} while ((uint16_t)(sr & (15 << 12)) > ((uint16_t)(_fifo_size-1) << 12));

		_pkinetisk_spi->PUSHR = (data32 & 0xffff) |  SPI_PUSHR_CTAS(1);
			sr = _pkinetisk_spi->SR;

		uint8_t reads_remaining = 2;
		uint32_t tmp __attribute__((unused));
		while (reads_remaining) {
			sr = _pkinetisk_spi->SR;
			if (sr & 0xF0) {
				tmp = _pkinetisk_spi->POPR;  // drain RX FIFO
				reads_remaining--;
			}
		}
		DIRECT_WRITE_HIGH(_csport, _cspinmask);
		DIRECT_WRITE_LOW(_touchcsport, _touchcspinmask);
		delayNanoseconds(5);
		DIRECT_WRITE_HIGH(_touchcsport, _touchcspinmask);
		return;
	}
So the main CS pin should be low through the whole transfer and then should be a little pulse of touch CS
 
Note: I put in change to color which changed the order of the bits to use BGR order.

I also pushed it up to github as to not have to keep uploading zip files.

I think the Rotation stuff is wrong for X,Y and direction of bits.. Will play later. Included in github is updated touchpaint using the right touch controller. But, X, Y stuff still needs work!
 
@KurtE - nice to know the color swap not just my display.

@mjs513 - bummer on display not displaying. I felt that when I could not get proper connects on breakout. The rPi KeDei here did hook up with a 6" M<>F Dupont cable to bare T4 M_pins into 9488 F_headers:
Code:
[U]T4...CLR..9488[/U]
GND..BLK..GND
6....ORG..T_CS
10...BRN..L_CS
11...BLU..MOSI
12...GRN..MISO
13...YEL..CLK
22...PUR..IRQ
5V...RED..5V

Then in code using :: KEDEIRPI35_t3 tft = KEDEIRPI35_t3(&SPI, TFT_CS, TOUCH_CS, 11, 13, 12); //10,6,11,13,12
If that doesn't work something wrong with display :(
Even working the display doesn't seem worth the effort with observed speed and display quality of output.

Tried power to 3.3V and no go - needs 5V, LED is very bright and as noted seems washed out, not enough contrast from TFT colorizing/blocking with BLACK being light gray.
Pulling 5V from 9488 leaves it partly powered VamPowering from other connections trying to turn off display.

I infected everything with the TempMon HIGH/LOW/PANIC - edited values shutting down for PANIC as it runs hotter driving display … and forgot I put in debug_tt for early tests and … opps … I have placed Temp_isr's in there that were firing about 900K Hz … did the _isr off in _isr and then I started getting FAULT reported on IRQ #79 {'IRQ_GPIO1_INT7'} from that code I found and incorporated ??? Chasing that down shows how ugly and ill formed the debug_tt code is with one long source file and overloaded code ... Needs a ground up re-write.

I changed SublimeText to black on white from default colors - much more readable on larger hi-res screen with tiny font - but I have three copies open to diff folders as I jump from thing to thing ... and each copy has 9 or 18 or 24 random core/lib/sketch files open as I jump from Audio-displays-tempmon-debug_tt-USBHost- {...} - more distractions than focus.
 
Back
Top