Are there any RPi4 version of GFX library

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
akhneyzar
 
Posts: 5
Joined: Fri Jul 30, 2021 5:32 am

Are there any RPi4 version of GFX library

Post by akhneyzar »

Hello,

Are there some projects using Adafruit-GFX-Library on rpi4?

If I wanted to create it how could I proceed?

Thanks.

User avatar
akhneyzar
 
Posts: 5
Joined: Fri Jul 30, 2021 5:32 am

Re: Are there any RPi4 version of GFX library

Post by akhneyzar »

Any knowledge out there to understand what needs to be done to adapt the Adafruit-GFX library to a none arduino platform?

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Are there any RPi4 version of GFX library

Post by adafruit_support_mike »

The short version is: it isn’t possible.

The RasPi runs Linux, a time-slicing operating system. The kernel gives each process 10ms of runtime, then suspends it and gives the next process a turn. That’s fine for batch number-crunching and things that move at human speeds, but makes impossible to get fine-grained control of signal tuming.

NeoPixels use self-clocked data signals 1.25us wide. Every bit starts with a rising edge, and the time between the rising edge and falling edge determines whether the bit is a 1 or a 0. The difference is about 400ns, with a tolerance of about 150ns.

A 50us gap in the data stream tells the pixels the current update has ended, and that the next data they see will be a new update.

The RasPi can’t match any of those limits with regular GPIO. The best working option is to use the microprocessor’s Direct Memory Access (DMA) hardware and generate the pulses as streams of 0 and 1 bits.

This tutorial has more information:

https://learn.adafruit.com/neopixels-on ... i/overview

User avatar
akhneyzar
 
Posts: 5
Joined: Fri Jul 30, 2021 5:32 am

Re: Are there any RPi4 version of GFX library

Post by akhneyzar »

I understand that the RPI4 doesn't have that speed capability you describe but I do not understand why this blocks the use of the Adafruit-GFX-Library.

Does all devices using that library enter in the specification range of your example? Cannot they handle slower clock speeds?

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Are there any RPi4 version of GFX library

Post by adafruit_support_mike »

Take a look at the code.

All the graphics primitive functions in the GFX library are essentially wrappers around a function named .drawPixel(). Displays that use the GFX library declare themsleves subclasses of GFX and implement whatever version of .drawPixel() is necessary to interact with the display hardware.

To handle text, the GFX library declares itself a subclass of the Arduino environment’s Stream class. Stream uses the same ‘wrapper around a primitive function’ approach as GFX, with the central function being .drawCharacter(). That lets GFX inherit the same collection of .print() functions and formatting options as any other printable Arduino environment class.

The RasPi is a completely different programming environment. It can’t do pixel-by-pixel display updates with any kind of speed, and doesn’t have a foundation of Arduino environment functions sitting around to inherit.

It does, however, have RAM. The typical approach to RasPi graphical programming is to draw the next image in memory, then write the whole buffer to the display as a single update. It’s also common to use two buffers so you can write to one while updating the display with the contents of the other.

There are also multiple graphics libraries written to take advantage of fast processors with plenty of storage, and don’t have to worry about fitting into a memory footprint of a few kilobytes.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”