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

Portrait Orientation #594

Closed
conrad9900 opened this issue Oct 2, 2024 · 4 comments
Closed

Portrait Orientation #594

conrad9900 opened this issue Oct 2, 2024 · 4 comments

Comments

@conrad9900
Copy link

What were you doing?

Trying to set screen orientation to portrait

What did you expect to happen?

To reboot and see portrait orientation

What happened instead?

No change

Was there an error message displayed? What did it say?

No Change

Version of FullPageOS?

0.14.0

[Can be found in /etc/fullpageos_version ALWAYS INCLUDE.]

Screenshot(s) showing the problem:

[If applicable. Always include if unsure or reporting UI issues.]

If you are building FullPageOS - provide a build.log that is created for the build

@apartmedia
Copy link

You are not explaining in detail what exactly you did already to change the screen orientation, what display you want to rotate and if you also need to rotate the (touch) input.
You can take a look at this issue to get some hints. This comment shows some foundation recommendations regarding screen and touch rotation with the official 7“ RPi DSI Touchscreen. It might be helpful in general when it comes to setting up screen orientation for any display.

@guysoft
Copy link
Owner

guysoft commented Oct 15, 2024

Closing if no answer form OP. Thanks @apartmedia for the reply.

@wlans
Copy link

wlans commented Nov 2, 2024

Step 1: Flash FullPageOS and Configure Wi-Fi

  1. Download FullPageOS:

    • Download the FullPageOS image file, such as 2024-10-28_2024-10-22-fullpageos-bookworm-armhf-lite-0.14.0.zip, to your computer.
  2. Open Raspberry Pi Imager:

  3. Select OS and Storage:

    • Choose OS: Click “CHOOSE OS,” select “Use Custom,” and choose the FullPageOS image file.
    • Choose Storage: Click “CHOOSE STORAGE” and select your microSD card.
  4. Configure Wi-Fi in Advanced Options:

    • Press Ctrl + Shift + X (or Cmd + Shift + X on macOS) to open the Advanced Options.
    • Enable Wi-Fi: Check “Configure wireless LAN.”
    • Enter Network Details: Input your Wi-Fi SSID, password, and Wi-Fi country.
  5. Write the OS to the microSD Card:

    • Click “WRITE” to flash FullPageOS with Wi-Fi settings. Eject the microSD card when complete.
  6. Insert the microSD Card and Boot:

    • Insert the card into the Raspberry Pi, connect it to a monitor and power it on. The Pi should automatically connect to Wi-Fi.

Step 2: Identify the Display Output Name Using xrandr

  1. List Connected Displays:

    • Open a terminal on your Raspberry Pi and run:
      xrandr --listmonitors
  2. Note the Display Name:

    • The output might look like:
      Monitors: 1
       0: +HDMI-2 1920/527x1080/296+0+0  HDMI-2
      
    • Write down the display name (e.g., HDMI-2). If it’s different, such as HDMI-1, use this name in the rotate.sh script.

Step 3: Create and Edit the rotate.sh Script

This script allows flexible rotation by accepting an argument (e.g., left, right, normal, inverted).

  1. Create the rotate.sh Script:

    • In the terminal, create the rotate.sh file in the scripts folder:
      sudo mkdir -p /home/pi/scripts
      sudo nano /home/pi/scripts/rotate.sh
  2. Add the Advanced Rotation Script:

    • Paste the following code into rotate.sh, replacing HDMI-2 with the correct display name if needed:
      #!/bin/bash
      # This script rotates the display. Specify [normal|inverted|left|right] as an argument.
      
      if [ -z "$1" ] ; then
        echo "Usage: $0 [normal|inverted|left|right]"
        echo " "
        exit 1
      fi
      
      function do_rotate {
        xrandr --output HDMI-2 --rotate $1
      
        TRANSFORM='Coordinate Transformation Matrix'
        POINTERS=$(xinput | grep 'slave  pointer')
        POINTERS=$(echo $POINTERS | sed s/↳\ /\$/g)
        POINTERS=$(echo $POINTERS | sed s/\ id=/\@/g)
        POINTERS=$(echo $POINTERS | sed s/\ \\\[slave\ pointer/\#/g)
        
        iIndex=2
        POINTER=$(echo $POINTERS | cut -d "@" -f $iIndex | cut -d "#" -f 1)
        
        while [ "$POINTER" != "" ]; do
          POINTER=$(echo $POINTERS | cut -d "@" -f $iIndex | cut -d "#" -f 1)
          POINTERNAME=$(echo $POINTERS | cut -d "$" -f $iIndex | cut -d "@" -f 1)
      
          if [ "$POINTER" != "" ]; then
            case "$1" in
                normal)
                  [ ! -z "$POINTER" ] && xinput set-prop "$POINTER" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
                  ;;
                inverted)
                  [ ! -z "$POINTER" ] && xinput set-prop "$POINTER" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
                  ;;
                left)
                  [ ! -z "$POINTER" ] && xinput set-prop "$POINTER" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
                  ;;
                right)
                  [ ! -z "$POINTER" ] && xinput set-prop "$POINTER" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
                  ;;
            esac
          fi
          iIndex=$((iIndex + 1))
        done
      }
      
      do_rotate $1
  3. Save and Exit:

    • Press Ctrl + X, then Y, and Enter to save the script.
  4. Make the Script Executable:

    chmod +x /home/pi/scripts/rotate.sh

Step 4: Test the Rotation Script Manually with DISPLAY=:0

  1. Run the Script with DISPLAY=:0:

    • To test the rotation, run the following command, specifying DISPLAY=:0:

      DISPLAY=:0 /home/pi/scripts/rotate.sh left
    • Replace left with your desired rotation direction (left, right, normal, or inverted).

  2. Confirm the Rotation:

    • Verify that the display rotates as expected. If it works correctly, proceed to the next step to set up the script to run automatically on startup.

Step 5: Set Up the Rotation Script to Run on Startup with systemd

  1. Create a systemd Service File:

    • Open a new service file:
      sudo nano /etc/systemd/system/rotate_screen.service
  2. Add Service Configuration with DISPLAY=:0:

    • Add the following configuration to the service file:

      [Unit]
      Description=Screen Rotation Script
      After=network.target
      
      [Service]
      ExecStartPre=/bin/sleep 30           # Optional delay for other services to load
      ExecStart=/home/pi/scripts/rotate.sh left
      Environment="DISPLAY=:0"
      User=pi
      Restart=on-failure
      
      [Install]
      WantedBy=multi-user.target
    • Replace left in ExecStart with your desired orientation (left, right, inverted, or normal).

  3. Save and Exit:

    • Press Ctrl + X, then Y, and Enter.
  4. Enable and Start the Service:

    • Enable the service to start at boot:
      sudo systemctl enable rotate_screen.service
  5. Test the Service:

    • Start the service immediately to verify it works:
      sudo systemctl start rotate_screen.service
  6. Check Status:

    • Confirm that the service is active:
      sudo systemctl status rotate_screen.service

Final Step: Reboot and Verify Everything

  1. Reboot the Raspberry Pi:

    sudo reboot
  2. Confirm Rotation on Startup:

    • After rebooting, verify that the screen rotates automatically as specified by the rotate_screen.service.

@guysoft
Copy link
Owner

guysoft commented Nov 2, 2024

No reply from op, closing for now

@guysoft guysoft closed this as completed Nov 2, 2024
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

4 participants