RA8876LiteTeensy For Teensy T36 and T40

@MorganS
Code:
You would think that the memory-copy functions would be useful to have a mouse cursor or game character move over a background without erasing it. Save the piece of background you are going to damage and replace it after the character moves away. But what if your industrial computer display wants to update the numbers under the cursor? You end up just repainting the whole display and drawing the mouse cursor last.

As far as a non-destructive mouse cursor, the RA8876 has that. It has 4 programmable mouse cursor memories that can be programed with a 16X16 (256) byte cursor shape. It also as 256 cursor colors that work out to cursor color and cursor border color. I have this working with my file manager. It uses my USB mouse driver. Also the one thing I have not had time to mess with is pattern ram, If I am correct this is an overlay as well (not tested). These are RA8876 internal functions that don't need to repaint the screen. I think the same principals apply to user defined fonts which is working. In the RA8876 user manual page 143... REG [03] - REG[04} and elsewhere these are explained (kinda). The only roadblock I have run into is saving portions of the screen for menus, dialog boxes and pop up screens. Using SPI in linear addressing mode is just to slow to be practical. So what I have to do is a bte memory copy back and forth from one screen page to another to restore a screen after a dialog box is finished. I am sure there are other ways to do this.
Hopefully I understood what you were asking:)
 
@wwatson
Was going through the code today and noticed that you had the following constructs:
Code:
putPicture_16bpp
putPicture_16bppData8
putPicture_16bppData16
Was there a specific reason you changed it from the way Ra8876_Lite was originally setup, i.e.,
Code:
putPicture_16bpp(ru16 x,ru16 y,ru16 width, ru16 height)
putPicture_16bpp(ru16 x,ru16 y,ru16 width, ru16 height, const unsigned char *data)
putPicture_16bpp(ru16 x,ru16 y,ru16 width, ru16 height, const unsigned short *data)

If no particular reason could we put it back. Lib should automatically pick the appropriate construct?
 
@wwatson
Was going through the code today and noticed that you had the following constructs:
Code:
putPicture_16bpp
putPicture_16bppData8
putPicture_16bppData16
Was there a specific reason you changed it from the way Ra8876_Lite was originally setup, i.e.,
Code:
putPicture_16bpp(ru16 x,ru16 y,ru16 width, ru16 height)
putPicture_16bpp(ru16 x,ru16 y,ru16 width, ru16 height, const unsigned char *data)
putPicture_16bpp(ru16 x,ru16 y,ru16 width, ru16 height, const unsigned short *data)

If no particular reason could we put it back. Lib should automatically pick the appropriate construct?

If I remember right putPicture_16bpp() was not working for one reason or another. I probably forgot about . But this weekend I will play with it and see what the problem was. Maybe something to do with lcdDataWrite() and lcdDataWrite16bbp(). If I remember right even the original demos from RAIO would not work with lcdDataWrite16bbp().
 
I've just finished a lot of work on the BTE functions. I got it loading images more than twice as fast. I've opened a pull request on GitHub.

It turns out the fundamental difference between the "data8" and "data16" versions of these functions is the byte order. If you open up the example I just pushed, you will see I have a .h file with two versions of the same image with the bytes swapped. 8 and 16 both work at the same speed.

I did not touch the putPicture_xxx functions yet. The same speedup can be applied to them too.

I also worked out how the "window alpha" function worked. This wasn't implemented in the original code. It makes a nice fade effect.
 
@MorganS - @wwatson
Merge complete!

The issue with putPicture_xxx functions is the lcdDataWrite16bbp() doesn't seem to work. Have to look at it more
 
@MorganS - @wwatson
Merge complete!

The issue with putPicture_xxx functions is the lcdDataWrite16bbp() doesn't seem to work. Have to look at it more

@mjs513 - @MorganS
Thanks guys. I have it working on my setup at 47MHZ. Very awesome.

I have spent today working up a graphics cursor sketch that demonstrates the use of a graphics cursor. I used Ra8876-redo for testing.
Find the zipped file is below. I have commented most of what it does and hopefully I have been accurate.

Edit: I added functions for using double clicks of the left mouse button but mouse.cpp will have to be changed for it to work.
Explained in the sketch.
 

Attachments

  • graphicCursor.zip
    2.7 KB · Views: 66
Last edited:
@KurtE
What do you think if we make the changes to mouse.cpp in USBHost_t36, as explained in the sketch:
Code:
* I have included a few experimental routines of my own for detecting
* single and double clicks of the left mouse button.
*
* For double and single click testing mouse.cpp in USBHost_t36 library
* has to have line 102 "//	buttons = 0;" commented out.
* The button presses automatically cleared on release.
* I don't think they need to be part of "mouseDataClear();". Also
* wheel and wheelH are cleared when there is a button press or there is
* movement of the mouse.
Not sure what will break if we do this with other sketches out there?
 
@KurtE
What do you think if we make the changes to mouse.cpp in USBHost_t36, as explained in the sketch:
Not sure what will break if we do this with other sketches out there?
Me neither. I look like those lines went in probably in the original code by Paul about 3 years ago.
 
Me neither. I look like those lines went in probably in the original code by Paul about 3 years ago.
Have to check the mouse spec wonder if they have a double click field? Only really looked at Joystick in detail but probably not.
 
I have spent today working up a graphics cursor sketch that demonstrates the use of a graphics cursor. I used Ra8876-redo for testing.
Find the zipped file is below. I have commented most of what it does and hopefully I have been accurate.

Thanks for that sketch! I don't have a mouse hooked up but I do have a touchscreen, so I've been experimenting with making an animated graphics cursor in my touchscreen example. The RA8876 lets you upload an image to the cursor that's currently displayed and it's only a little bit glitchy.

I've ordered a Teensy 4.1 and started on updating my PCB to use the 16-bit parallel interface. For an extra $2 worth of board area, I've added USB, Ethernet and CAN BUS. With the 14 pins I want to use for my buttons and knobs, every single pin on the Teensy 4.1 is in use, except for pgm/vbatt/gnd across the middle. The routing just barely works on a 2-layer board.

V4.2PCB.png
 
Thanks for that sketch! I don't have a mouse hooked up but I do have a touchscreen, so I've been experimenting with making an animated graphics cursor in my touchscreen example. The RA8876 lets you upload an image to the cursor that's currently displayed and it's only a little bit glitchy.

I've ordered a Teensy 4.1 and started on updating my PCB to use the 16-bit parallel interface. For an extra $2 worth of board area, I've added USB, Ethernet and CAN BUS. With the 14 pins I want to use for my buttons and knobs, every single pin on the Teensy 4.1 is in use, except for pgm/vbatt/gnd across the middle. The routing just barely works on a 2-layer board.

Nice and compact :)
 
I've managed to make image-loading even faster now. (Pull request coming soon.)

My basic problem was that SPI.transfer(data, length) locked up hard and required the program button to be pressed to recover the board. After a lot of digging in the SPI library code, I realized that this will attempt to put received data into the same buffer. If that buffer was PROGMEM then it couldn't write and couldn't recover.

Changing to SPI.transfer(data, NULL, length) doesn't attempt to save received data and works just fine.

So now my 172x172 test image can load in 10ms at 75MHz when it was taking 15ms before. At slower SPI speeds, you don't get such a big improvement: more like 4ms less and that's a much smaller fraction of the total time taken.

Next I want to make a DMA version so I don't need to wait for the transfer. That might take some major surgery on the library to make the rest of it aware of DMA transfers.
 
I don't think I will be helping out here anytime soon... It has been about 30 days since my display shipped and still not here.. Still shows waiting in China. Emailed with Buy display today and their response:

To be rfank,some packages on the way have been over 80 days.But the goods has leaving overseas in deed.

I can't give you a certain date,but I believe you'll receive it one day.We're also distressed for this problem.

Could you pls place a new order on our website with DHL shipping way if you need the displays urgently?

I'm terribly sorry for this inconvenient!!
 
I don't think I will be helping out here anytime soon... It has been about 30 days since my display shipped and still not here.. Still shows waiting in China. Emailed with Buy display today and their response:

I was getting ready to order another 10.1"' display with a capacative touch from BuyDisplay but knowing you have been waiting a month now for it to arrive kinda spooks me. Mine have always arrived in a week or two through DHL. Hopefully yours will arrive soon

Edit:
Could you pls place a new order on our website with DHL shipping way if you need the displays urgently?
Seems suspicious.
 
I was getting ready to order another 10.1"' display with a capacative touch from BuyDisplay but knowing you have been waiting a month now for it to arrive kinda spooks me. Mine have always arrived in a week or two through DHL. Hopefully yours will arrive soon

Edit:
Seems suspicious.

I ordered same display as @KurtE's but used DHL and still comes in about a week. @KurtE ordered his but used ePacket type shipping. So if you use DHL don't think you will have a problem.
 
I ordered same display as @KurtE's but used DHL and still comes in about a week. @KurtE ordered his but used ePacket type shipping. So if you use DHL don't think you will have a problem.

Yep - I think you ordered your probably within 8 hours after mine. And during that time, BuyDisplay discontinued using ePacket... So I was one of the lucky few (or probably many) who are now stuck. So IF it arrives it will probably be long after my interest for using it will have subsided and it will end up in the box of other displays... :( You win some and you lose some. :D
 
Kurt, which one did you want? I have almost all the different ones and I don't need them all right now. I can send one to you for free if there is some expectation to get it back. Are you located in the USA?

And thanks to some of your example code you posted years ago on the forum, I've got DMA SPI transfers working for bulk data. (Pull request now open on Mike's repository.) It turned out that it was not difficult at all to make all the legacy code aware of DMA and any user code which doesn't care about DMA will "just work" sequentially like it used to.

Mike, I'm thinking your OpenGL could benefit from DMA by sending a big buffer while it's working on the next frame.
 
Kurt, which one did you want? I have almost all the different ones and I don't need them all right now. I can send one to you for free if there is some expectation to get it back. Are you located in the USA?

And thanks to some of your example code you posted years ago on the forum, I've got DMA SPI transfers working for bulk data. (Pull request now open on Mike's repository.) It turned out that it was not difficult at all to make all the legacy code aware of DMA and any user code which doesn't care about DMA will "just work" sequentially like it used to.

Mike, I'm thinking your OpenGL could benefit from DMA by sending a big buffer while it's working on the next frame.

Nice work. Just updated to TD1.52 and updated RA8876-redo. It works well. For some reason I had to use
Code:
digitalWrite(BACKLITE, HIGH);
to get it to work.
My display does not seem to work with
Code:
//  analogWrite(BACKLITE, 256);
and I am not sure why. it's not a big deal for me.

@mjs513 - I tried to get 'open_3DModels.ino' to work but I am getting this error.
Code:
/home/wwatson/arduino-1.8.12/arduino-builder -dump-prefs -logger=machine -hardware /home/wwatson/arduino-1.8.12/hardware -hardware /home/wwatson/.arduino15/packages -tools /home/wwatson/arduino-1.8.12/tools-builder -tools /home/wwatson/arduino-1.8.12/hardware/tools/avr -tools /home/wwatson/.arduino15/packages -built-in-libraries /home/wwatson/arduino-1.8.12/libraries -libraries /home/wwatson/Arduino/libraries -fqbn=teensy:avr:teensy41:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10812 -build-path /tmp/arduino_build_314827 -warnings=none -build-cache /tmp/arduino_cache_405041 -verbose /home/wwatson/Arduino/libraries/TeensyOpenGL_t4/examples/opengl_3DModels/opengl_3DModels.ino
/home/wwatson/arduino-1.8.12/arduino-builder -compile -logger=machine -hardware /home/wwatson/arduino-1.8.12/hardware -hardware /home/wwatson/.arduino15/packages -tools /home/wwatson/arduino-1.8.12/tools-builder -tools /home/wwatson/arduino-1.8.12/hardware/tools/avr -tools /home/wwatson/.arduino15/packages -built-in-libraries /home/wwatson/arduino-1.8.12/libraries -libraries /home/wwatson/Arduino/libraries -fqbn=teensy:avr:teensy41:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10812 -build-path /tmp/arduino_build_314827 -warnings=none -build-cache /tmp/arduino_cache_405041 -verbose /home/wwatson/Arduino/libraries/TeensyOpenGL_t4/examples/opengl_3DModels/opengl_3DModels.ino
Using board 'teensy41' from platform in folder: /home/wwatson/arduino-1.8.12/hardware/teensy/avr
Using core 'teensy4' from platform in folder: /home/wwatson/arduino-1.8.12/hardware/teensy/avr
Detecting libraries used...
/home/wwatson/arduino-1.8.12/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=152 -DARDUINO=10812 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/home/wwatson/arduino-1.8.12/hardware/teensy/avr/cores/teensy4 /tmp/arduino_build_314827/sketch/opengl_3DModels.ino.cpp -o /dev/null
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
  -> candidates: [SPI@1.0]
/home/wwatson/arduino-1.8.12/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=152 -DARDUINO=10812 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/home/wwatson/arduino-1.8.12/hardware/teensy/avr/cores/teensy4 -I/home/wwatson/arduino-1.8.12/hardware/teensy/avr/libraries/SPI /tmp/arduino_build_314827/sketch/opengl_3DModels.ino.cpp -o /dev/null
Alternatives for ILI9341_t3n.h: []
ResolveLibrary(ILI9341_t3n.h)
/home/wwatson/Arduino/libraries/TeensyOpenGL_t4/examples/opengl_3DModels/opengl_3DModels.ino:3:25: fatal error: ILI9341_t3n.h: No such file or directory
  -> candidates: []
compilation terminated.
Using library SPI at version 1.0 in folder: /home/wwatson/arduino-1.8.12/hardware/teensy/avr/libraries/SPI 
Error compiling for board Teensy 4.1.

It's probably something I am missing:)
 
@wwatson
Sorry I didn't answer sooner. Not sure why you are getting those errors. A couple of things. Make sure you have the latest lib and 2 I am attaching this sketch that I just ran without errors: View attachment opengl_3DModels-200516a.zip.

Let me know if it works for you. In all truth haven't pulled down the latest changes.
 
@wwatson
Sorry I didn't answer sooner. Not sure why you are getting those errors. A couple of things. Make sure you have the latest lib and 2 I am attaching this sketch that I just ran without errors: View attachment 20154.

Let me know if it works for you. In all truth haven't pulled down the latest changes.

Don't be sorry. I know you have been very busy with the T4.1 psram and flash drivers. I have been lurking and watching:) In fact, I just ordered my first two production T4.1's and a few psram chips from PRJC. I will try it out.

Thanks
 
I use AnalogWrite with the 7" 8876 display from Buydisplay, no problems.
But I think my ALS code give full value at at 255, not 256.
 
IF it arrives it will probably be long after my interest for using it will have subsided and it will end up in the box of other displays... :( You win some and you lose some. :D

Eheh, how many times did this happen to me? Don't ask! :D
 
Kurt, which one did you want? I have almost all the different ones and I don't need them all right now. I can send one to you for free if there is some expectation to get it back. Are you located in the USA?

Thanks for the offer. Yes I am in US in same time zone as Paul... I ordered their 7".... But for now I will hold off, who knows someday it will arrive. Plus it looks like you are already making good progress and I do have a few other projects to keep me busy. Things like a new Lynxmotion Hexapod to get working, garden, maybe build root cellar... Lots of stuff to do now that we are into Spring
 
That's great. The RA8876 chip has some good possibilities but can be tricky to use. Understanding the RA8876 manual is the other thing that took me some time. The terminology can be tough to decipher. This last weekend I played with display rotation. It is a little disappointing in the fact that you are limited to a 180 text screen flip or a left rotation of 90 degrees of a character font. Full rotation of the graphic screen should be possible but I did not have time to mess with it. You can rotate 270 degrees and I think with the mirror function you might be able to get full rotation.

Greetings all! I've been following this thread for awhile and finally got my display in to start playing with it for an upcoming controller project. I have ben able to get examples to compile for T40 (needed to change "setTextAt" to "setTextCursor" in both examples I tried) and have started to build some graphics for the controller. I was wondering if you had had any more success with screen and/or text rotation. I read up in the manual on initializing the screen and reorienting it in graphics mode, but even with changing the initialization in the library, I wasn't able to get it to rotate. I also discovered that as soon as you write text, it switches to text mode (makes sense), so the flip may not work for what I need anyways (a mixture of graphics and incoming data strings).

Also, I think I will be relying on the putString command, so I rewrote that in the library, as it was not using the inputted coordinates for the function.

Thanks everyone for their work on this, I look forward to helping in any way I can/sharing this project as it progresses.

Code:
//**************************************************************//
/* Print a string using internal font or external font code     */
//**************************************************************//
void  Ra8876_Lite::putString(ru16 x0,ru16 y0, const char *str)
{
  textMode(true);
  setTextCursor(x0, y0);//added 16 May 2020 to place strings in the correct location
  while(*str != '\0')
  {
    write(*str);
    ++str; 
  }
}
 
Back
Top