First character written to RA8875 after startup is not printed to the screen

Status
Not open for further replies.

kd5rxt-mark

Well-known member
I'm working on an enhancement to my TeensyMIDIPolySynth which now uses the RA8875 TFT (ER-TFTM070-5) for the all-digital (no more pots / switches / buttons / LEDs !!) user interface. I am having very good luck with the conversion - this is a VERY NICE display !!.

In my program, I have defined a "splash" screen which shows the version of my code & pauses for three seconds before moving on to painting the first operational menu/screen. Just by accident, I happened to notice that the first character of the first line of the printed version information was missing.

This is very easy to reproduce using the included short program below to demonstrate this anomaly. This simple program prints the same string to the display three times . . . only the first print is missing the first character !! Changing which string gets printed (or changing the string's content) does not seem to change that the first character of the first print is always dropped (& not printed);

I'm interested in whether anyone else using an RA8875 display has seen this same behavior and/or can reproduce this same behavior . . .

Code:
//
// small test program to demonstrate the problem where the first character written to the RA8875 after start-up is dropped
//
//
//  Arduino IDE Configuration:
//     Tools/Board:           "Teensy 4.1"
//     Tools/USB Type:        "Serial"
//     Tools/CPU Speed:       "600MHz"
//     Tools/Optimize:        "Faster"
//     Tools/Keyboard Layout: "US English"
//     Tools/Port:            "COMx Serial (Teensy 4.1)"
//

const String VERSION0 = "1-2-3-4-5-6-7-8-9-0";
const String VERSION1 = ">> Testing, Testing, Testing <<";
const String VERSION2 = "version 1.0 dated 03/13/2021 @1500";

#include <SPI.h>    // this must appear in the list of includes *before* RA8875, else compile errors are reported
#include <RA8875.h>

// when used w/ Audio Adapter, must use an alternate CS pin for the display
const int RA8875_CHIP_SELECT     = A14;       // Teensy 38 -to- RA8875 05
const int RA8875_RESET           =   3;       // Teensy 03 -to -RA8875 11
const int RA8875_MISO            = A15;       // Teensy 39 -to- RA8875 06
const int RA8875_MOSI            = A12;       // Teensy 26 -to- RA8875 07
const int RA8875_SCLK            = A13;       // Teensy 27 -to- RA8875 08
const int RA8875_TS_INT          =   2;       // Teensy 02 -to- RA8875 33

const int RA8875_MAX_TOUCH_LIMIT =   1;

RA8875 tft = RA8875(RA8875_CHIP_SELECT, RA8875_RESET, RA8875_MOSI, RA8875_SCLK, RA8875_MISO);

// The following pins are used in this project:
//
// PIN  D2  = RA8875 Capacitive Touchscreen INT
// PIN  D3  = RA8875 Capacitive Touchscreen RESET
// PIN A12  = RA8875 Capacitive Touchscreen MOSI (MOSI1)
// PIN A13  = RA8875 Capacitive Touchscreen SCLK (SCK1)
// PIN A14  = RA8875 Capacitive Touchscreen CS (CS1)
// PIN A15  = RA8875 Capacitive Touchscreen MISO (MISO1)

// onboard LED on pin 13
#define LED_PIN 13



// function headers
         void loop();
FLASHMEM void setup();




// main loop
void loop()
{
}  // loop()


// one-time setup
FLASHMEM void setup()
{
   tft.begin(RA8875_800x480);
   tft.DMA_enable();
   tft.setRotation(2);
   tft.clearScreen();

   delay(100);

   tft.useCapINT(RA8875_TS_INT);   // use the capacitive chip interrupt
   tft.setTouchLimit(RA8875_MAX_TOUCH_LIMIT);
   tft.enableCapISR(true);   // capacitive touch screen interrupt it's armed
   tft.writeTo(L1);//write to layer 1
   tft.layerEffect(OR);//apply AND effect between layer 1 and 2

   Serial.begin(57600);
   while (!Serial && (millis() <= 3000));

   Serial.println("=============================================");
   Serial.print("            ");   Serial.println(VERSION0);
   Serial.print("            ");   Serial.println(VERSION0);
   Serial.print("            ");   Serial.println(VERSION0);
   Serial.println("=============================================");
   Serial.println("");
   Serial.println("");

   delay(500);

   tft.setCursor(tft.width() / 2 - 76, tft.height() / 2 - 150);
   tft.setTextColor(RA8875_GREEN, RA8875_BLACK);
   tft.print(VERSION0);

   tft.setCursor(tft.width() / 2 - 76, tft.height() / 2 - 100);
   tft.setTextColor(RA8875_GREEN, RA8875_BLACK);
   tft.print(VERSION0);

   tft.setCursor(tft.width() / 2 - 76, tft.height() / 2 - 50);
   tft.setTextColor(RA8875_GREEN, RA8875_BLACK);
   tft.print(VERSION0);
}  // setup()


// EOF placeholder

Thanks !!

Mark J Culross
KD5RXT
 
Might help to know things like: Which library are you using? The one one that we have updated or SumoToy's earlier version.

I am assuming the later. I am NO expert on these, although a few of us did some work to make them work on the later teensy boards.

Note: I am VERY rusty on these displays. I did actually start one up this afternoon to test out some text centering issue.

What strikes me first is you are trying to use Layers? I could be completely wrong, and maybe it automatically switches for you, but I don't believe the RA8875 has enough memory for two layers in 16 bit color mode on the 800x480
mode.

I know in my test sketch that I was playing with layers, I had to start up the code like:
Code:
  tft.begin(RA8875_800x480, 8);
Which gets you into 256 color mode...

Also since I don't see anything setting font, I am assuming it must be using the system built in font?

Sorry, I know that is not much help
 
@KurtE:

Thanks for your reply !! I should have noted that I'm running Arduino 1.8.13 + Teensyduino 1.54-b7 under Win10pro 64-bit. The RA8875 library is in "C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\RA8875", which I believe is the version that was installed by Teensyduino. I don't remember specifically loading anything when I started with the RA8875 (just a week ago), plus the Library Manager does not show anything other than the "Adafruit RA8875", which I don't believe is being used here. There does not seem to be any evidence that the earlier Sumotoy library is installed, nor that it is being used.

From just circumstantial evidence (which is only just slightly better than making an assumption !!), I don't think the use of layers is causing any problems. I've drawn lots of sliders, buttons, labels, LEDs, etc. on the screen in Layer1, & I have a pointer indicator which I draw on Layer2 whenever the touchscreen detects a touch (so I can tell exactly where the screen "thinks" it's being touched !!). I have not had any visual anomalies (ghosts, freezes, trails, etc.) with any of my graphics to date. It seems to be working OK with the 16-bit colors.

Yes, the system built-in font is being used (since I started using my TeensyMIDIPolySynth code as a base for this version, I had to cut the previous 16-poly down to 12-poly & I have to compile using "Smallest Code" optimization just to get everything to fit into the available RAM !!) . . . I probably can't afford the extra space required by additional fonts.

I *really* like this display. Before this one, I was using a PJRC 2.8" TFT touchscreen & I was having trouble making even simple screen updates without interfering with the parsing of MIDI messages. With this RA8875, I can repeatedly change screens, make slider & button changes, get LEDs (note & CC) simulated/displayed in real-time on the display, change the backlight brightness (using the pot on the audio adapter, which results in the tft.brightness() function being called, which presumably results in yet another command being sent to the TFT) & parse simultaneous MIDI notes & CCs from standard DIN midi (from a connected sequencer), USB midi (from my PC playing some music), & USBhostMIDI (from a connected USB MIDI keyboard), all simulateneously. All of this all together has been working just fine !! I *really* like this display !!

I'll try this same test program without the use of layers & also with 256-color mode specified to see what difference those changes might make . . .

Thanks again !!

Mark J Culross
KD5RXT
 
Pulled out my RA8875 5in display but does not seem to want to work for some reason. Still debugging will let you know if I can test.
 
Mine is working and does verify the issue.
It also confirmed my memory about layers and color mode. There is code that when you select some layer stuff it will automatically switch you to 8 bit mode...

I added the line:
Code:
tft.setCursor(tft.width() / 2 - 76, tft.height() / 2 - 50);
  tft.setTextColor(RA8875_GREEN, RA8875_BLACK);
  tft.print(VERSION0);

[COLOR="#FF0000"]  Serial.printf("Color BPP: %u\n", tft.getColorBpp());[/COLOR]
}  // setup()

And debug output:
Code:
=============================================
            1-2-3-4-5-6-7-8-9-0
            1-2-3-4-5-6-7-8-9-0
            1-2-3-4-5-6-7-8-9-0
=============================================


Color BPP: 8
Tried to set to 8 bit mode in begin, no difference likewise, tried adding explicit: tft.setFont(INTFONT);

Still no difference
 
Sorry I am probably not much help with the system font issues.
With some things like this I first look up at Sumotoy's wiki on the display: https://github.com/sumotoy/RA8875/wiki

For the heck of it, I tried using an ILI... font:
Code:
//
// small test program to demonstrate the problem where the first character written to the RA8875 after start-up is dropped
//
//
//  Arduino IDE Configuration:
//     Tools/Board:           "Teensy 4.1"
//     Tools/USB Type:        "Serial"
//     Tools/CPU Speed:       "600MHz"
//     Tools/Optimize:        "Faster"
//     Tools/Keyboard Layout: "US English"
//     Tools/Port:            "COMx Serial (Teensy 4.1)"
//

const String VERSION0 = "1-2-3-4-5-6-7-8-9-0";
const String VERSION1 = ">> Testing, Testing, Testing <<";
const String VERSION2 = "version 1.0 dated 03/13/2021 @1500";

#include <SPI.h>    // this must appear in the list of includes *before* RA8875, else compile errors are reported
#include <RA8875.h>
[COLOR="#FF0000"]#include "font_Arial.h"[/COLOR]

// when used w/ Audio Adapter, must use an alternate CS pin for the display
const int RA8875_TS_INT          =   2;       // Teensy 02 -to- RA8875 33

const int RA8875_MAX_TOUCH_LIMIT =   1;

#define RA8875_CS 9
#define RA8875_RST 8
RA8875 tft = RA8875(RA8875_CS, RA8875_RST);

// The following pins are used in this project:
//
// PIN  D2  = RA8875 Capacitive Touchscreen INT
// PIN  D3  = RA8875 Capacitive Touchscreen RESET
// PIN A12  = RA8875 Capacitive Touchscreen MOSI (MOSI1)
// PIN A13  = RA8875 Capacitive Touchscreen SCLK (SCK1)
// PIN A14  = RA8875 Capacitive Touchscreen CS (CS1)
// PIN A15  = RA8875 Capacitive Touchscreen MISO (MISO1)

// onboard LED on pin 13
#define LED_PIN 13



// function headers
void loop();
FLASHMEM void setup();




// main loop
void loop()
{
}  // loop()


// one-time setup
FLASHMEM void setup()
{
  tft.begin(RA8875_800x480);
  tft.DMA_enable();
  tft.setRotation(2);
  tft.clearScreen();

  delay(100);

  //   tft.useCapINT(RA8875_TS_INT);   // use the capacitive chip interrupt
  //   tft.setTouchLimit(RA8875_MAX_TOUCH_LIMIT);
  //   tft.enableCapISR(true);   // capacitive touch screen interrupt it's armed
  //tft.writeTo(L1);//write to layer 1
  //tft.layerEffect(OR);//apply AND effect between layer 1 and 2

  Serial.begin(57600);
  while (!Serial && (millis() <= 3000));

  Serial.println("=============================================");
  Serial.print("            ");   Serial.println(VERSION0);
  Serial.print("            ");   Serial.println(VERSION0);
  Serial.print("            ");   Serial.println(VERSION0);
  Serial.println("=============================================");
  Serial.println("");
  Serial.println("");

  delay(500);
//  tft.setFont(INTFONT);
//  tft.setFontScale(1);
[COLOR="#FF0000"]  tft.setFont(Arial_24);[/COLOR]

  tft.setCursor(tft.width() / 2 - 76, tft.height() / 2 - 150);
  tft.setTextColor(RA8875_GREEN, RA8875_BLACK);
  tft.print(VERSION0);

  tft.setCursor(tft.width() / 2 - 76, tft.height() / 2 - 100);
  tft.setTextColor(RA8875_GREEN, RA8875_BLACK);
  tft.print(VERSION0);

  tft.setCursor(tft.width() / 2 - 76, tft.height() / 2 - 50);
  tft.setTextColor(RA8875_GREEN, RA8875_BLACK);
  tft.print(VERSION0);

  Serial.printf("Color BPP: %u\n", tft.getColorBpp());
}  // setup()


// EOF placeholder

And the first character of the first line shows up correctly...

Maybe someone who uses this display has some better insights.


I know there are other issues in the library, like with some of our added clipping code, but will take that back to a more appropriate thread.
 
May have identified one cause . . .

@KurtE:

Thanks again for your continued testing. I finally found time for my own further testing (by combining my small test program with the simple code in some of the RA8875 Examples), & in doing so, I have stumbled across a very interesting observation: by simply commenting out the "tft.DMA_enable();" line, the problem with the dropped character on the screen does not occur !! Unfortunately, I am not able to take this & turn it into an actual "fix", but hopefully, this observation, combined with what you (KurtE) have already discovered will get us closer to an actual fix. In the meantime, I will be leaving that single line commented out !!

Thanks again for your help,

Mark J Culross
KD5RXT
 
Status
Not open for further replies.
Back
Top