Use CoreMotion in Landscape mode

Hello friends

I’m currently developing an iOS application that uses the attitude from CoreMotion. For this I need to evaluate the specific values of Pitch, Roll and Yaw. As long as the app is in landscape mode and the device upright (X-axis up), I only need some small adjustments of the values to get the right attitude data.

New: Pitch -> Y-axis, Yaw -> X-axis and Roll = Z-axis.

func startDeviceMotion() {
    if motionManager.isAccelerometerAvailable {
        self.motionManager.deviceMotionUpdateInterval = self.interval
            self.motionManager.showsDeviceMovementDisplay = true
                    
            self.motionManager.startDeviceMotionUpdates(using: .xTrueNorthZVertical)

                    // Configure a timer to fetch the motion data
            self.timer = Timer(fire: Date(), interval: self.interval, repeats: true,
                    block: { (timer) in
                        if let motion = self.motionManager.deviceMotion {
                
                            
               // write the values my own orientation data structure
              self.orientation.azimuthAngle = Measurement(value: -motion.attitude.yaw, unit: UnitAngle.radians)
              self.orientation.inclinationAngle = Measurement(value: -motion.attitude.roll-(Double.pi/2.0), unit: UnitAngle.radians)
               self.orientation.bankAngle = Measurement(value: motion.attitude.pitch, unit: UnitAngle.radians)
            }
        })
        // Add the timer to the current run loop.
        RunLoop.current.add(self.timer!, forMode: RunLoop.Mode.default)
    }
}

However, when I use it in portrait mode (Y-axis up), I can't find a suitable conversion that provides me good values. Most of the time I get mixed values. The goal is that the following axes define Pitch, Roll and Yaw.

Pitch -> X-axis, Yaw -> Y-axis, Roll -> Z-axis

Has anyone ever had this problem and could explain how to get meaningful pitch, roll and yaw values with an iPad in portrait mode?

Kind regards