Rotation of 5” TFT screen (PID 1596) driven by a RA8875

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
bsengrx2
 
Posts: 4
Joined: Sat Feb 13, 2021 8:53 am

Rotation of 5” TFT screen (PID 1596) driven by a RA8875

Post by bsengrx2 »

I have been working with Arduino hardware for a couple of years and the complexity of my projects led me to need further resources and switched to Pi. I have a 3 b using both spi bus’ to read three MAX31855s and drive a 5” TFT screen (PID 1596) through a RA8875. Reading the Tcs and writing data to a file on the SD works fine, and the display can view the output of ra8875_simpletest.py. The only issue I had was finding the syntax to utilize the screen on the second spi bus:

spi = busio.SPI(clock=board.SCK_1, MOSI=board.MOSI_1, MISO=board.MISO_1)
display = ra8875.RA8875(spi, cs=cs_pin, rst=rst_pin, baudrate=BAUDRATE, width=800, height=480)
display.init()

For the application at hand, the tft screen needs to be in potrait mode. To achieve this I made the changes to /boot/config.txt recommended online in a variety of ways (display_rotate, LCD_rotate, 1, 90, ...). I feel the problem here lies in somehow not defining which screen the rotation is to apply to, similar to defining which hardware is on which spi bus.

Rather than dedicate a display to the Pi, I have been remoting in using SSH or RealVNC. When display_rotate=1 is added to boot/config.txt it results in rotation of the screen displayed through RealVNC but does nothing to the tft display output from ra8875_simpletest.py.

There are several lines in config.txt below I do not understand but think is where the problem lies.

Code: Select all

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d
enable_uart=1
start_x=1
gpu_mem=128

dtoverlay=spi1-1cs, cs0_pin=11
display_rotate=1
i did not post my code, fault messages, or error codes, as there is not a fault to report beyond the fact that the TFT screen does not rotate. This is my first post to this forum, I can provide further information as requested, and thanks in advance.

Tom

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

Re: Rotation of 5” TFT screen (PID 1596) driven by a RA8875

Post by adafruit_support_mike »

Are you using the RA8875 display as a framebuffer device (a display driven by the kernel) or are you controlling it from userland code?

User avatar
bsengrx2
 
Posts: 4
Joined: Sat Feb 13, 2021 8:53 am

Re: Rotation of 5” TFT screen (PID 1596) driven by a RA8875

Post by bsengrx2 »

Userland code is my answer based on the fact that I do not have /dev/fb1 for the tft only /dev/fb0. Is this the correct reasoning for my answer or is there logs or some command output to use to confirm this. I followed the installation instructions here: https://learn.adafruit.com/ra8875-touch ... d/overview. Would this mean that userland code should address the orientation in the Python script and a framebuffer would be addressed in /boot/config.txt? If so I have not been able to find syntax that is accepted in the display definition such as:

Code: Select all

display = ra8875.RA8875(spi, cs=cs_pin, rst=rst_pin, baudrate=BAUDRATE)
Is there a reason for a kernel solution rather than userland code? Does using a framebuffer mean it is permanent and the userland code needs xinput?

Thanks again

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

Re: Rotation of 5” TFT screen (PID 1596) driven by a RA8875

Post by adafruit_support_mike »

bsengrx2 wrote:Would this mean that userland code should address the orientation in the Python script
Yes. I'm pretty sure the options in /boot/config.txt only apply to displays managed by the kernel.

Fortunately, rotation is easy to do in code:

Code: Select all

WIDTH = 800
HEIGHT = 480

def rotateCW (x, y):
	return( HEIGHT-y, x )

def rotateCCW (x, y):
	return( y, WIDTH-x )

User avatar
bsengrx2
 
Posts: 4
Joined: Sat Feb 13, 2021 8:53 am

Re: Rotation of 5” TFT screen (PID 1596) driven by a RA8875

Post by bsengrx2 »

I was not clear in my problem statement. I need to display text in portrait mode or rotated 90 degrees. I can handle the changes from landscape to portrait relative to the (x,y) positions. Can the rotation of text be handled in userland code?

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

Re: Rotation of 5” TFT screen (PID 1596) driven by a RA8875

Post by adafruit_support_mike »

Hmm.. our Arduino GFX library has rotation, but it looks like the CircuitPython version doesn't.

The CircuitPython GFX library does use a function named pixel() that works as a connector between the generic graphics functions and the device-specific libraries. You can insert the rotation code above in the RA8875 library's pixel() function and it will rotate everything:

https://github.com/adafruit/Adafruit_Ci ... #L539-L548

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”