RA8876LiteTeensy For Teensy T36 and T40

I have tried both and I now get the display working but as I mentioned USB does not want to talk to PC...

Probably what I should do is to try to power the display separately.

Note: When I tried it using USB, it is off my powered hub, no PC complaints, but maybe internal to HUB shuts off communication.

External power is from wall wart that outputs 5v at 4 amps...

Will try more soon.

I have not had issues powering over USB; however, I am using the 7” screen (on a T4).
 
I have not had issues powering over USB; however, I am using the 7” screen (on a T4).

Thanks, I think maybe it was just that sketch (Memory transfer).

I am now running on USB with Gauges and Graphics, after I edited them to compile... (setTextAt -> setTextCursor)
 
@KurtE
For some reason my usb just isn't enough output for some strange reason. May have to try a couple of other things later.

Working right now on incorporating ILI and GFX fonts. Trying to remember all the moving pieces.
 
Memory Transfer worked for me with 7" screen on a T4. However, the USB port is a 3.0 on a hub hooked to USB-C, which may be the difference (not something I have knowledge of).

Edit: Did a little more investigating with this as the hub has both USB 2.0 and USB 3.0 connections. I discovered I could upload and run memory transfer on both ports; however, if I reseat the USB, the display stops working (on both 2.0 and 3.0), and I cannot re-load the memory transfer sketch. i have to upload another sketch to get the display back up and running again.

Edit #2: In trying to test this, I had reopened the Example from the library and compiled/uploaded it right away. Sadly I had not changed the backlight or reset pins to match my setup. Hence when I reseated it, it had nothing telling it to turn the backlight on - hence why I needed to run another sketch to get it to work again... and I couldn't reset it manually as I had the rest pin defined incorrectly... The moral of the story is it runs fine on USB power for me. Thank you for coming to my TED Talk.

Thanks, I think maybe it was just that sketch (Memory transfer).

I am now running on USB with Gauges and Graphics, after I edited them to compile... (setTextAt -> setTextCursor)
 
Last edited:
@KurtE
For some reason my usb just isn't enough output for some strange reason. May have to try a couple of other things later.

Working right now on incorporating ILI and GFX fonts. Trying to remember all the moving pieces.

You are beating me to it :D

When I say I have mine hooked up to USB 3 HUB - https://smile.amazon.com/gp/product/B07G8CMR18/
I like using this hub as it has individual buttons to turn on or off each socket of the hub.
I believe @defragster has one of these as well.
 
@KurtE

Just ordered the powered hub from Amazon, won't arrive until Monday.

As for the additional fonts. Keep finding have to add more function calls that weren't in the lib over and above the font functions. 2 more things to iron out before I can even try it. Don't worry you can fix it after I get all the moving pieces together. :)
 
@KurtE
Just pushed a new WIP branch for using ILI/GFX fonts: https://github.com/wwatson4506/Ra8876LiteTeensy.

ILI fonts do display - not sure about opaque vs transparent. GFX fonts don't display and if I switch back to default font the whole screen is displayed with the default font. Think I know the issue with later. So just for testing I have that turned off except for the first print.
 
@mjs513 - Good morning,

Sounds great - I synced up and tried building, but getting a link error

Code:
Linking everything together...
"C:\\arduino-1.8.12\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-gcc" -O2 -Wl,--gc-sections,--relax "-TC:\\arduino-1.8.12\\hardware\\teensy\\avr\\cores\\teensy4/imxrt1062_t41.ld" -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793/ILI_GFX_FontTest.ino.elf" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793\\sketch\\ILI_GFX_FontTest.ino.cpp.o" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793\\libraries\\Adafruit_GFX\\glcdfont.c.o" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793\\libraries\\Adafruit_GFX\\Adafruit_GFX.cpp.o" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793\\libraries\\Adafruit_GFX\\Adafruit_SPITFT.cpp.o" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793\\libraries\\SPI\\SPI.cpp.o" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793\\libraries\\ILI9341_t3n\\ILI9341_t3n.a" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793\\libraries\\Ra8876LiteTeensy\\RA8876_t3.cpp.o" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793\\libraries\\Ra8876LiteTeensy\\Ra8876_Lite.cpp.o" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793/core\\core.a" "-LC:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_454793" -larm_cortexM7lfsp_math -lm -lstdc++
C:\Users\kurte\AppData\Local\Temp\arduino_build_454793\libraries\Ra8876LiteTeensy\RA8876_t3.cpp.o: In function `RA8876_t3::drawChar(short, short, unsigned char, unsigned short, unsigned short, unsigned char, unsigned char)':

C:\Users\kurte\Documents\Arduino\libraries\Ra8876LiteTeensy\src/RA8876_t3.cpp:1084: undefined reference to `glcdfont'

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "Adafruit_GFX.h"
 Used: C:\arduino-1.8.12\hardware\teensy\avr\libraries\Adafruit_GFX
 Not used: C:\Users\kurte\Documents\Arduino\libraries\Adafruit_GFX_Library
Multiple libraries were found for "SPI.h"
 Used: C:\Users\kurte\Documents\Arduino\libraries\SPI
 Not used: C:\arduino-1.8.12\hardware\teensy\avr\libraries\SPI
Multiple libraries were found for "ili9341_t3n_font_ComicSansMS.h"
 Used: C:\Users\kurte\Documents\Arduino\libraries\ILI9341_t3n
 Not used: C:\Users\kurte\Documents\Arduino\libraries\HX8357_t3n
Using library Adafruit_GFX at version 1.5.6 in folder: C:\arduino-1.8.12\hardware\teensy\avr\libraries\Adafruit_GFX 
Using library SPI at version 1.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\SPI 
Using library ILI9341_t3n at version 1.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\ILI9341_t3n 
Using library Ra8876LiteTeensy at version 1.0.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\Ra8876LiteTeensy 
Error compiling for board Teensy 4.1.

Now to investigate. Probably something I missed syncing up to.

EDIT - copied file from RA8875... Now runs :D
 
Last edited:
Thanks. Wasn't getting that error so forgot a couple of things - its pulling in the file and comicsans files from my ILI9341_t3n directory. So I just pushed a change to make it standalone with the missing glcdfont.c and comicsans file

EDIT: Think I found the problem with GFX font. Don't think I incorporated the clipping correctly. It keeps returning here:
Code:
// See if anything is within clip rectangle, if not bail
		if((x_start >= _displayclipx2)   || // Clip right
			 (y_start >= _displayclipy2) || // Clip bottom
			 (x_end < _displayclipx1)    || // Clip left
			 (y_end < _displayclipy1))  	// Clip top 
		{
			// But remember to first update the cursor position
			_cursorX += glyph->xAdvance * (int16_t)textsize_x;
			Serial.println("CLIPPED RETURN");
			return;
		}
 
I may go out and play in the dirt for awhile, before it rains,

But right now it does not link as it is finding multiple libraries for _font_ComicSansMS...
 
I may go out and play in the dirt for awhile, before it rains,

But right now it does not link as it is finding multiple libraries for _font_ComicSansMS...

Did you download the latest set of updates with:
#include "_fonts.h"
replacing
#include "ILI9341_t3_fonts.h"
><< Maybe I messed up the push?
 
Thanks that fixed it.

As for the clipping...

I changed your print to:
Code:
			Serial.printf("CLIPPED RETURN XY(%d %d %d %d) CLIP(%d %d %d %d)\n", 
				x_start, x_end, y_start, y_end, 
				_displayclipx1, _displayclipx2, _displayclipy1, _displayclipy2);
			return;
And I am seeing:
Code:
Setup

CLIPPED RETURN XY(0 0 174 174) CLIP(0 0 0 0)
CLIPPED RETURN XY(0 0 174 174) CLIP(0 0 0 0)
CLIPPED RETURN XY(0 0 174 174) CLIP(0 0 0 0)
CLIPPED RETURN XY(0 0 174 174) CLIP(0 0 0 0)
...
So yes the clipping rectangle is not setup...

EDIT:

I think that is solved by adding the calls:
Code:
	setClipRect();
	setOrigin();
To the begin method:
Once I do that the only output to debug terminal is setup...
 
Looks like some more stuff not setup.

like _backTransparent so I changed line to: if (_TXTForeColor == _TXTBackColor)
But still nothing being output:

Turned on some more debug printing:
Code:
    Serial.printf("DGFX_char: %c (%d,%d) : %u %u %u %u %d %d %x %x %d %d\n", c, _cursorX, _cursorY, w, h,  
    			glyph->xAdvance, gfxFont->yAdvance, xo, yo, _TXTForeColor, _TXTBackColor, textsize_x, textsize_y);  Serial.flush();
Which showed:
Code:
Setup

DGFX_char: O (0,174) : 17 18 18 29 2 -3 ffff f800 0 0
DGFX_char: p (0,174) : 14 18 14 29 0 2 ffff f800 0 0
DGFX_char: a (0,174) : 11 13 13 29 2 2 ffff f800 0 0
DGFX_char: q (0,174) : 13 18 13 29 2 2 ffff f800 0 0
DGFX_char: u (0,174) : 12 13 13 29 2 2 ffff f800 0 0
DGFX_char: e (0,174) : 12 13 13 29 2 2 ffff f800 0 0
DGFX_char:   (0,174) : 0 0 7 29 0 15 ffff f800 0 0
DGFX_char: G (0,174) : 16 18 19 29 3 -3 ffff f800 0 0
DGFX_char: F (0,174) : 15 18 14 29 2 -3 ffff f800 0 0
DGFX_char: X (0,174) : 19 18 16 29 0 -3 ffff f800 0 0
DGFX_char:   (0,174) : 0 0 7 29 0 15 ffff f800 0 0
DGFX_char: F (0,174) : 15 18 14 29 2 -3 ffff f800 0 0

First thing I was noticing was that the cursor did not change... So added printing the text size at end...
Which are both 0...

Next to see if default one not set...

EDIT Got farther by having ::begin calling setTextSize(1);

However could not do that directly as you have 3 different versions of setTextSize, which make the calling ambiguous.

So removed the setTextSize version that was a caller for setFontSize(...) and it runs and shows some output.

But not sure if the set colors is working correctly yet... but at least you are getting there!

IMG_0152-(002).jpg
 
Last edited:
@KurtE
Think the whole problem may be related to using two classes for RA8876. Did the same thing as well with setclip and set orgin in the begin function. But notice I also had added it to the RA8876_lite initialization which is called by RA8876_t3 begin.

Also noticed that some of the variable initializations were done in RA8876_lite and declared public and but used in RA8876_t3.

EDIT: If I have to merge the two not a problem but think I need a break for a bit :)
 
Quick update - I now have the opaque versus transparent in both I think...

But a couple of issues, in that we have two different models of what setTextSize and setTextColor do...

Was able to get it to set transparent by doing setTextColor(BLUE, BLUE); ...
Got rid of using the transparent setting. Could reintroduce if we need it.

I pushed up my version as a PR back to you, but it also had debug turned on and my pin numbers...

EDIT: I think I am going to back out some of this and fill in the use of the RA8875 hack, which was if you call with single color, we still fall through and call off to the RA... code, but we internally say, we are transparent for GFX and ILI fonts...
 
Last edited:
@KurtE
At least its some of its working. Cool that you are backing out stuff.

Right now I am in the process of going through everything with the intent of making one RA8876 API with everything in one spot. Too much of what I did was a kludge and surprise ILI fonts even worked.

I will hold off on incorporating the PR until you play some more with the GFX font.
 
I just pushed up changes, that fixes both ILI and GFX fonts with text colors and setup opaque versus transparent.

You might try looking at my branch and see if it works now for you.

Warning, I put in calls to the sketch to step through each logical thing waiting for CR...

Now back to other diversions :D
IMG_0153-(002).jpg
 
Just did the merge :)

EDIT: Just downloaded and loaded up the sketch and seems to be working just as in your picture. And now if I uncomment setFontDef() is draws with the default font without messing up the other fonts :)

PS. Glad you put in the code to step through the code :)
 
Last edited:
Thanks, I stated to try to convert over the RA8875 font test 4... And there are still several issues (opportunities)

Colors - Should we leave it with RED, WHITE, BLACK are specific to this display, or should we have RA8876_RED which sort of matches other libraries.
I could also see an enum part of the class, where then you might do setTextColor(RA8876_t3::RED);

CENTER - Have not migrated all of that in yet.

Fonts: The font library maybe needs more #if __has_include() for this library.
Still wish we could find a way to compile these with some generic include
I have hacked up a version that builds... Will put into new branch to play with...

Lots of work to go!
But up in branch GIFW2...

Also forked your fonts project and created a new branch with hack to see if it would work for defining font format if none of the other __has_include conditions fails.
 
Note with the above, First page displays good.

2nd page starts to royally screw up on the CRYSTAL24 font.
Next page screwy...
Then nothing works...

So have some debug work to do
 
Thanks, I stated to try to convert over the RA8875 font test 4... And there are still several issues (opportunities)
Sorry just woke up :) Now you know why I started with Font_test3 :) Knew there were going to be issues oops opportunities. RA8876 a lot harder to incorporate changes like we did with the RA8875

Colors - Should we leave it with RED, WHITE, BLACK are specific to this display, or should we have RA8876_RED which sort of matches other libraries. I could also see an enum part of the class, where then you might do setTextColor(RA8876_t3::RED);
To be honest - was getting annoyed with have to change the colors with the display type prefix every time I wanted to go from using a ILI9341 to ILI9488 to the RA8875. Was thinking that maybe we should change the other libs as well but that could cause problems as well.

CENTER - Have not migrated all of that in yet.
The rotation on this thing is screwy so I just left it as portrait and then worry about rotation later - that was the reasoning for leaving the _portrait var in. So yeah that's going to be fun as well.

Fonts: The font library maybe needs more #if __has_include() for this library.
Already thought about that but figured I would save it until we were ready, i.e., got the basics working.

Still wish we could find a way to compile these with some generic include
I have hacked up a version that builds... Will put into new branch to play with..
. Ok cool. looking forward to it.

Lots of work to go!
But up in branch GIFW2...

Also forked your fonts project and created a new branch with hack to see if it would work for defining font format if none of the other __has_include conditions fails.
You can say that again!!!!!

Made some progress on combining classes so should be easier than jumping between the 2 to see whats where but still have a bunch to do to get it to work right.
 
@KurtE, @msj513, @MorganS - You guys really are on it. It is fascinating to me to see what you are doing with this display controller. I have been following what you are doing and testing it on my 10.1" display. It is working so well. I see it getting closer to a standardized Arduino library.

Thanks for taking time to modify my original library:) Can't wait to see whats next. Doing arcs are going to be interesting;)
 
@mjs513 (and others) - I pushed up PR for the hacked up fonts library... Not sure how good it is...

Right now looking at the Test4... (hacked up) first issue was on 2nd page, so first page commented out.
On it outputting the title: DroidSans_14, the output of the lower case d leaves me with a vertical line going all of the way down the display...

Crystal24 displays yellow with a horizontal _ all the way to the Right of the last character... Need to step through it Will expand to see if on every character.
On Droid stuff the code looks like:
Code:
  tft.setTextColor(WHITE);
  tft.setFont(DroidSans_14);
  tft.print("D");
  stepThrough();
  tft.print("r");
  stepThrough();
  tft.print("o");
  stepThrough();
  tft.print("i");
  stepThrough();
  tft.print("d");
  stepThrough();
  tft.print("S");
  stepThrough();
  tft.println("ans_14");
  stepThrough();
  displayStuff();
  stepThrough();
And I verified it screwed up on the d...
And also that each character of the Cystal goes to end of line...
IMG_1127.jpg
 
Next Hint: Uncommented a lot of debug print... Here is details for the 'd'
Code:
drawFontChar(d) 100 (36, 0) 10 ffff 1 1
  index =  941
  size =   9,15
  line space = 21
  cap height = 14
  offset = 0,0
  delta =  11
        FG fillrect: 43 -1 2 5 ffff
        FG fillrect: 38 4 4 1 ffff
        FG fillrect: 43 4 2 1 ffff
        FG fillrect: 37 5 3 1 ffff
        FG fillrect: 41 5 4 1 ffff
        FG fillrect: 36 6 2 6 ffff
        FG fillrect: 43 6 2 6 ffff
        FG fillrect: 37 12 3 1 ffff
        FG fillrect: 41 12 4 1 ffff
        FG fillrect: 38 13 4 1 ffff
        FG fillrect: 44 13 1 1 ffff
So calling fillRect(43, -1, 2, 5, WHITE);

fillRect:
Code:
void RA8876_t3::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color) {
	drawSquareFill(x, y, x+w-1, y+h-1, color);
}
And drawSquareFill
Code:
void Ra8876_Lite::drawSquareFill(ru16 x0, ru16 y0, ru16 x1, ru16 y1, ru16 color)
Takes unsigned... So probably not working too well. Will add Quick and dirty clip in your fill rect for now...
And see if that clears up some of it...

EDIT:
This fixed those problems:
Code:
void RA8876_t3::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color) {
	int16_t x_end = x+w-1;
	int16_t y_end = y+h-1;
	if((x >= _displayclipx2)   || // Clip right
		 (y >= _displayclipy2) || // Clip bottom
		 (x_end < _displayclipx1)    || // Clip left
		 (y_end < _displayclipy1))  	// Clip top 
	{
		// outside the clip rectangle
		return;
	}
	if (x < _displayclipx1) x = _displayclipx1;
	if (y < _displayclipy1) y = _displayclipy1;
	if (x_end > _displayclipx2) x_end = _displayclipx2;
	if (y_end > _displayclipy2) y_end = _displayclipy2;
	drawSquareFill(x, y, x_end, y_end, color);
}
Next page is still screwed up... But later.

Looks like Anti-Aliased font issue.
 
Last edited:
@KurtE and @wwatson and @@MorganS

Ok just merged you ILI9341 fonts lib changes.

Also just completed the merge of multiple classes and seems to be working. Also just put in your latest fillrect change. So instead of 4 separate files now down to 3:
Code:
RA8876_t3.h
RA8876_t3.cpp
RA8876Registers.h

Heres a zip of them - what do you all think.

View attachment src.zip
 
Back
Top