Help needed to boost up preformance

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

  • Help needed to boost up preformance

    Hello

    I'm new to Emwin product and Im working on a DASH to my Formula project:
    picasaweb.google.com/100325893…21/Formula02?noredirect=1


    Im usin EA LPC4088 Display unit, mbed base, rtos and emwin library.
    I have made really simple display and got 1 per second frame rate.

    Currently I have created memdev for hole display area 800x480.
    Every time digits areas are first cleared, then written again and last updated to display.

    Mostly I use this type of indicators:

    void Warning_Indcator(unsigned int x_coord, unsigned int y_coord, unsigned char Warning_state, char *warning_text){
    char aa2[40]={0};
    GUI_RECT WarningRect = { x_coord, y_coord, 90+x_coord, 35+y_coord };



    // Gear display
    GUI_ClearRect(x_coord, y_coord, 90+x_coord, 35+y_coord); // Glear digit area...

    GUI_SetColor(GUI_GRAY);
    //GUI_DrawRoundedRect(x_coord, y_coord, 90+x_coord, 35+y_coord ,5);
    GUI_DrawRoundedFrame(x_coord, y_coord, 90+x_coord, 35+y_coord ,3 ,3);

    if(Warning_state){
    GUI_SetColor(GUI_GREEN);
    }
    else {
    GUI_SetColor(GUI_RED);
    }

    //GUI_DrawRoundedFrame(x_coord, y_coord, 90+x_coord, 35+y_coord ,7 ,8);

    GUI_FillRoundedRect(x_coord+2, y_coord+2, 90+x_coord-2, 35+y_coord-2 ,2);
    //GUI_FillRectEx(&WarningRect);

    /*if(Warning_state){

    }
    else {
    GUI_SetColor(GUI_WHITE);
    }*/
    GUI_SetTextMode(GUI_TEXTMODE_TRANS);
    GUI_SetColor(GUI_BLACK);
    GUI_SetFont(GUI_FONT_8X16);

    GUI_DispStringAt(warning_text, 8+x_coord, 12+y_coord);
    }


    This is the way I have done it now, first it clears its own area draw its self then updated.

    This is emwin thread


    void EWMainTask(void const* args) {



    static GUI_MEMDEV_Handle hMem;

    EMWThreadId = Thread::gettid();
    GUI_Init();
    GUI_Delay(1); // kutsuttava ennen mitään piirtoja edes kerran.

    hMem=GUI_MEMDEV_Create(0, 0, 800, 480);
    GUI_MEMDEV_Select(hMem);


    while (1) {

    Draw_main_Window();

    GUI_MEMDEV_CopyToLCD(hMem);
    GUI_Exec();

    Thread::wait(40);

    }
    }




    Any help how get more frame rate than 1/sec would be well come.
    LPC4088 is running its full speed.
    Most likely program is run on external ram and flash.

    The post was edited 2 times, last by jsskangas ().

  • Hi,

    First, nice project :thumbup:

    Second, it's hard to say what causes the slow frame rate. You should check that the external RAM and FLASH is configured properly and doesn't slow down the system.

    Also you should use GUI_Delay(40) instead of GUI_Exec() and Thread::wait(40). In GUI_X.c you can define the GUI_X_Delay() as below:

    C Source Code

    1. void GUI_X_Delay(int Period) {
    2. Thread::wait(Period);
    3. }


    Which RTOS you are using?

    Unfortunately I don't know what happens inside Draw_main_Window(). But I suppose it is not the best idea to draw the whole screen (just guessing) every 40ms. Maybe you should let the window manager handle the redrawing process.

    Just a short sample of how the Window Manager can be used:

    C Source Code

    1. #include "DIALOG.h"
    2. static int _SomethingHappens;
    3. /*********************************************************************
    4. *
    5. * Static code
    6. *
    7. **********************************************************************
    8. */
    9. /*********************************************************************
    10. *
    11. * _cbWin
    12. */
    13. static void _cbWarning(WM_MESSAGE * pMsg) {
    14. switch (pMsg->MsgId) {
    15. case WM_PAINT:
    16. GUI_SetBkColor(GUI_RED);
    17. GUI_Clear();
    18. //
    19. // Handle the drawing of the warning window here
    20. //
    21. break;
    22. default:
    23. //
    24. // Handle all other messages by the default callback
    25. //
    26. WM_DefaultProc(pMsg);
    27. break;
    28. }
    29. }
    30. /*********************************************************************
    31. *
    32. * _cbBk
    33. */
    34. static void _cbBk(WM_MESSAGE * pMsg) {
    35. int xSize;
    36. int ySize;
    37. int Timer;
    38. switch (pMsg->MsgId) {
    39. case WM_PAINT:
    40. xSize = LCD_GetXSize() - 1;
    41. ySize = LCD_GetYSize() - 1;
    42. GUI_DrawGradientH(0, 0, xSize, ySize, GUI_BLACK, GUI_GRAY);
    43. //
    44. // Draw the content of the main window here. If something changes inside this
    45. // area it gets automatically drawn.
    46. //
    47. break;
    48. case WM_TIMER:
    49. _SomethingHappens = (_SomethingHappens == 0) ? 1 : 0;
    50. //
    51. // Restart timer
    52. //
    53. Timer = pMsg->Data.v;
    54. WM_RestartTimer(Timer, 2000);
    55. break;
    56. default:
    57. //
    58. // Handle all other messages by the default callback
    59. //
    60. WM_DefaultProc(pMsg);
    61. break;
    62. }
    63. }
    64. /*********************************************************************
    65. *
    66. * Public code
    67. *
    68. **********************************************************************
    69. */
    70. /*********************************************************************
    71. *
    72. * MainTask
    73. */
    74. void MainTask(void) {
    75. static WM_HWIN hWin;
    76. //
    77. // Automatic use of memory devices, we call it before GUI_Init() so that the background window gets created with
    78. // this flag, too.
    79. //
    80. WM_SetCreateFlags(WM_CF_MEMDEV);
    81. GUI_Init();
    82. //
    83. // Set a callback to the background window and use it as your main window
    84. //
    85. WM_SetCallback(WM_HBKWIN, _cbBk);
    86. WM_CreateTimer(WM_HBKWIN, 0, 2000, 0); // Create a timer and attach it to the main window, this should simulate that something happens
    87. //
    88. // Create the warning window, but don't show it yet. Also it has a callback for handling messages to that window.
    89. //
    90. hWin = WM_CreateWindow(10, 10, 100, 100, 0, _cbWarning, 0);
    91. while (1) {
    92. if (_SomethingHappens == 1) { // Determin if something happens and if then create a warning window
    93. if (WM_IsVisible(hWin) == 0) { // Just show warning window if it is not visible yet
    94. WM_ShowWin(hWin);
    95. }
    96. } else {
    97. if (WM_IsVisible(hWin) == 1) { // If nothing happend but the warning window is visible, hide it
    98. WM_HideWin(hWin);
    99. }
    100. }
    101. GUI_Delay(100);
    102. }
    103. }
    Display All


    For further information just have a look into emWin user manual at chapter 18 The Window Manager (WM).

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello and thanks for answer.

    Im new what comes to UI and graphic libraries.

    Draw_main_Window() function includes:


    Warning_Indcator(10, 150, 1, "Hydraulics");
    Warning_Indcator(10, 190, 0, "Engine");
    Warning_Indcator(10, 230, 1, "Turbo");
    Warning_Indcator(10, 270, 1, "Gearbox");
    Warning_Indcator(10, 310, 1, "Rear Diff");
    Warning_Indcator(10, 350, 1, "Datalogger");
    Warning_Indcator(10, 390, 1, "CCU");
    Warning_Indcator(10, 430, 0, "IO-Unit");


    I attached warning indicator code in earlier message.


    With using window manager would I do it something like this?

    static void _cbmainwin(WM_MESSAGE * pMsg) {
    switch (pMsg->MsgId) {
    case WM_PAINT:
    GUI_SetBkColor(GUI_Black);
    GUI_Clear();



    Warning_Indcator(10, 150, 1, "Hydraulics"); Warning_Indcator(10, 190, 0, "Engine"); Warning_Indcator(10, 230, 1, "Turbo"); Warning_Indcator(10, 270, 1, "Gearbox"); Warning_Indcator(10, 310, 1, "Rear Diff"); Warning_Indcator(10, 350, 1, "Datalogger"); Warning_Indcator(10, 390, 1, "CCU"); Warning_Indcator(10, 430, 0, "IO-Unit");//

    break;
    default:
    //
    // Handle all other messages by the default callback
    //
    WM_DefaultProc(pMsg);
    break;
    }
    }
  • So I did some head scratching and rethink this hole thing from bases of WM.

    So I could create every widget as in own window that is not showing its borders.
    Every widget or widget set would have its own callback function, that call repaint in time based every second.
    Addition to this, there would be event based callback if data is changed.

    Can this data value change callback be handled automatically, if so how?

    This way only those widgets would be redrawn that has data changed.
    This would free a lot of CPU time.

    Thanks for guiding a way, got better results this way.

    The post was edited 1 time, last by jsskangas ().

  • Hi,
    So I could create every widget as in own window that is not showing its borders.
    I'm not sure what you mean, but every widget is its own window. There won't be any visible borders if the window/widget has the same color as the backround or has transparency.
    Every widget or widget set would have its own callback function, that call repaint in time based every second.
    You can set a callback for every widget/window. This can be a dedicated callback for only one window/widget, but it is possible for windows and widget to share one callback (see sample attached).
    The rapaint gets triggered if something changes in the area of a window/widget or if the user calls WM_InvalidateWindow() with handle of a window as parameter.
    Addition to this, there would be event based callback if data is changed.
    The callback reacts on messages, but not if data changes. You can send a message to a window and attach data to this message. When evaluating the message you can react on it as necessary.

    Attached you will find a short sample where I have created a dialog with eight child windows attached. Every two seconds I send a random message to indicate a warning appears and the proper window changes its state.

    You can run this on your hardware or in the emWin simulation which is available as trial version (limitation is a message on start up). The trial can be downloaded under the follwowing link. All what is required is Visual Studio (also the express version works).
    segger.com/downloads/emwin

    Regards,
    Sven
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.