3.4k views
in Platform Packages by
Hi. I'm using Embedded Wizard 8.30 and Raspberry Pi Platform Package.

I'd like to make an application in a portrait mode but I couldn't find 'ScreenOrientation' attribute at profile.

Could you let me know how to rotate screen on Raspberry Pi?

Thanks in advance for any help.

1 Answer

0 votes
by

Hello,

the attribute 'ScreenOrientation' is only available for dedicated microcontrollers, where the hardware is not able to make a rotation.

In case of Raspberry Pi the underlying graphics API is OpenGL ES 2.0. If you want to define the orientation of the screen (0° - 90° - 180° - 270°), you can just create the UI as it will appear to the user - and let make OpenGL the final rotation on the screen. For doing this, you can rotate the viewport of your application.

Please have a look into your main.c file. There you will find the following initialization of the viewport:

  viewport = EwInitViewport( EwScreenSize, EwNewRect( 0, 0, w, h ), 0, 255,
    &framebuffer, eglDisplay, eglSurface, ViewportProc );

The third parameter is the orientation hint of the viewport - by default this is set to 0. The meaning of this parameter depends on the target system. For example, OpenGL targets are using this parameter to determine the screen rotation in degrees.

Best regards,

Manfred.

by
Hi Manfred,

 

Thanks for your prompt reply.

I've verified that the screen rotation works fine.

 

Best Regards,

Kangmin
by
Hi Manfred,

I successfully changed the screen orientation for 90°, as you decribed. Is there also a similar easy way to manipulate main.c to rotate the touch the same 90°?

Thanks,

Hans-Peter
by

Hello Hans-Peter,

in this case you have to enhance the function EwBspGetTouchPosition() that you will find within the file /TargetSpecific/ew_bsp_touch.c. Here you can adjust the x/y coordinates according your needs, like the following code snippet:

int EwBspGetTouchPosition( XPoint* aPos )
{
  /* receive touch events and provide it to the application */
  if ( aPos && ( TouchState > 0 ))
  {

    #if ( EW_SURFACE_ROTATION == 90 )

      aPos->X = TouchEventYPos;
      aPos->Y = TouchAreaWidth  - TouchEventXPos;

    #elif ( EW_SURFACE_ROTATION == 270 )

      aPos->X = TouchAreaHeight - TouchEventYPos;
      aPos->Y = TouchEventXPos;

    #elif ( EW_SURFACE_ROTATION == 180 )

      aPos->X = TouchAreaWidth  - TouchEventXPos;
      aPos->Y = TouchAreaHeight - TouchEventYPos;

    #else

      aPos->X = TouchEventXPos;
      aPos->Y = TouchEventYPos;

    #endif


    /* begin of touch cycle */
    if ( TouchState == 1 )
    {
      TouchState = 2;
    }

    /* end of touch cycle */
    else if ( TouchState == 3 )
    {
      TouchState = 0;
    }
    return 1;
  }
  return 0;
}

Best regards,

Manfred.

 

by
Hi Manfred,

works like a charm :) Thank you very much!

Embedded Wizard Website | Privacy Policy | Imprint

...