Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST7789V in portrait results in ultrawide resolution #230

Open
SgtSiff opened this issue Sep 21, 2021 · 2 comments
Open

ST7789V in portrait results in ultrawide resolution #230

SgtSiff opened this issue Sep 21, 2021 · 2 comments

Comments

@SgtSiff
Copy link

SgtSiff commented Sep 21, 2021

I've managed to get my ST7789V based display working almost correctly, however, I noticed the cursor was disappearing off of the right hand side of the screen. I used the command:

xdpyinfo  | grep -oP 'dimensions:\s+\K\S+'

Which reports that my resolution is 960x320. 960 is a multiple of both 320 and 240 so I must have messed up a setting somewhere.

The display I am using is the Phoenix Contact 1226370.

Below are the changes I made to the files. This is on a fresh install of Raspbian on a CM4 plugged into the IO board. Ignore the [!], these aren't in the code, I just used them for syntax highlighting.

  1. config.h:
// If defined, rotates the display 180 degrees. This might not rotate the panel scan order though,
// so adding this can cause up to one vsync worth of extra display latency. It is best to avoid this and
// install the display in its natural rotation order, if possible.
!  #define DISPLAY_ROTATE_180_DEGREES

// If defined, displays in landscape. Undefine to display in portrait.
!  //#define DISPLAY_OUTPUT_LANDSCAPE
  1. st7735r.h:
#if defined(ST7789) || defined(ST7789VW)
#define DISPLAY_NATIVE_WIDTH 240
!#define DISPLAY_NATIVE_HEIGHT 320
  1. st7735r.cpp:
#endif
!   madctl ^= MADCTL_COLUMN_ADDRESS_ORDER_SWAP;
    SPI_TRANSFER(0x36/*MADCTL: Memory Access Control*/, madctl);
    usleep(10*1000);
  1. st7735r.cpp:
#ifdef ST7789
    // The ST7789 controller is actually a unit with 320x240 graphics memory area, but only 240x240 portion
    // of it is displayed. Therefore if we wanted to swap row address mode above, writes to Y=0...239 range will actually land in
    // memory in row addresses Y = 319-(0...239) = 319...80 range. To view this range, we must scroll the view by +80 units in Y
    // direction so that contents of Y=80...319 is displayed instead of Y=0...239.
    if ((madctl & MADCTL_ROW_ADDRESS_ORDER_SWAP))
!      SPI_TRANSFER(0x37/*VSCSAD: Vertical Scroll Start Address of RAM*/, 0, 0);
#endif
  1. /boot/config.txt:
!hdmi_group=2
!hdmi_mode=87
!hdmi_cvt=240 320 60 1 0 0 0
!hdmi_force_hotplug=1
  1. /etc/rc.local
sudo /home/pi/fbcp-ili9341/build/fbcp-ili9341 &

The cmake command I used was:

cmake -DST7789VW=ON -DGPIO_TFT_DATA_CONTROL=25 -DGPIO_TFT_RESET_PIN=27 -DSPI_BUS_CLOCK_DIVISOR=8 -DSTATISTICS=0 ..

Thank you in advance.

@juj
Copy link
Owner

juj commented Sep 25, 2021

Which reports that my resolution is 960x320.

If the system is reporting the display size to be 960x320, but you have hdmi_cvt at boot config set to 240x320, it is possible that some application/utility has changed the display size after the Pi has booted. You can run tvservice -s to check what the Pi thinks of the HDMI mode. See https://www.raspberrypi.org/documentation/computers/configuration.html#what-modes-does-my-device-support.

What does fbcp-ili9341 print at startup for the screen dimensions?

@Gadgetoid
Copy link

Is this an ST7789V2 based display? Does this work for you: #242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants