Dynamic display size?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Dynamic display size?

    Hello,
    I am woking on a project where the UI is going to be displayed on a regular PC LCD screen. Although my UI will not take up the entire screen, I would like to be able to scale it depending on the current screen resoultion selected. So, when the user change the screen resolution, my UI windows will be scaled accordingly. I understand that emWin does not support scaling of windows so I have do it manually. My question is concerning the inital settings in LCDConf.c. Is there a way the XSIZE_PHYS and YSIZE_PHYS can be run time configurable? If not, do I set the physical display size to the lagest (or smallest) possible resolution or window size I am going to support? Any pointer of how I should go about doing this will be greatly appreciated.
    Thank you.
  • Hi Nosreme,

    Changing the display size at runtime works as follows:

    Change the symbols XSIZE_PHYS and YSIZE_PHYS to static variables:

    Source Code

    1. static int _LCD_xSize = 320;
    2. static int _LCD_ySize = 240;


    Comment the following lines if existing:

    Source Code

    1. #ifndef XSIZE_PHYS
    2. #error Physical X size of display is not defined!
    3. #endif
    4. #ifndef YSIZE_PHYS
    5. #error Physical Y size of display is not defined!
    6. #endif


    Implement a function to change the x- and y-size:

    Source Code

    1. /*********************************************************************
    2. *
    3. * LCD_SetxSize
    4. *
    5. * Function description
    6. * Sets the display size in x.
    7. *
    8. * Return value
    9. * Returns the old value.
    10. */
    11. int LCD_SetxSize(int xSize) {
    12. int OldxSize;
    13. OldxSize = _LCD_xSize;
    14. _LCD_xSize = xSize;
    15. return OldxSize;
    16. }
    Display All


    Change the size setting functions to use the static variables:

    Source Code

    1. if (LCD_GetSwapXY()) {
    2. LCD_SetSizeEx (0, _LCD_ySize, _LCD_xSize);
    3. LCD_SetVSizeEx(0, _LCD_ySize * NUM_VSCREENS, _LCD_xSize);
    4. } else {
    5. LCD_SetSizeEx (0, _LCD_xSize, _LCD_ySize);
    6. LCD_SetVSizeEx(0, _LCD_xSize, _LCD_ySize * NUM_VSCREENS);
    7. }


    Create a header file which contains the prototypes of the new functions and include them in your application.

    Please note that the display size may be changed ONLY at a time emWin is not initialized. Your application should work as follows:

    Source Code

    1. //
    2. // Set display size.
    3. //
    4. LCD_SetxSize(100);
    5. LCD_SetySize(50);
    6. //
    7. // Initialize emWin.
    8. //
    9. GUI_Init();
    10. /* Do drawing operations */
    11. //
    12. // De-initialize emWin.
    13. //
    14. GUI_Exit();
    15. //
    16. // Change the display size again.
    17. //
    18. LCD_SetxSize(100);
    19. LCD_SetySize(50);
    20. //
    21. // Re-Init emWin.
    22. //
    23. GUI_Init();
    24. /* Do drawing operations */
    25. //
    26. // ...
    27. //
    Display All


    Best regards,
    Adrian