Screen switching

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

  • Screen switching

    Hi All

    Now I am doing a feasibility work ,where I want to switch between different screens that I have created .I don't know how to switch in between using a control.Could you please help me for this.



    Thanks & Regards
    Vichithra UV
  • Hi,

    not sure what you exactly mean with switching between two screens. Do mean two seperate LCDs or two dialogs?

    Here is a quick sample which shows how to switch between two dialogs.

    C Source Code

    1. #include "DIALOG.h"
    2. /*********************************************************************
    3. *
    4. * Defines
    5. *
    6. **********************************************************************
    7. */
    8. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
    9. #define ID_BUTTON_0 (GUI_ID_USER + 0x01)
    10. #define ID_BUTTON_1 (GUI_ID_USER + 0x02)
    11. #define ID_WINDOW_10 (GUI_ID_USER + 0x10)
    12. #define ID_TEXT_10 (GUI_ID_USER + 0x11)
    13. #define ID_WINDOW_20 (GUI_ID_USER + 0x10)
    14. #define ID_TEXT_20 (GUI_ID_USER + 0x11)
    15. /*********************************************************************
    16. *
    17. * Static data
    18. *
    19. **********************************************************************
    20. */
    21. /*********************************************************************
    22. *
    23. * _aDialogCreate
    24. */
    25. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    26. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
    27. { BUTTON_CreateIndirect, "Screen 1", ID_BUTTON_0, 50, 180, 80, 20, 0, 0x0, 0 },
    28. { BUTTON_CreateIndirect, "Screen 2", ID_BUTTON_1, 190, 180, 80, 20, 0, 0x0, 0 },
    29. };
    30. /*********************************************************************
    31. *
    32. * _aScreen1Create
    33. */
    34. static const GUI_WIDGET_CREATE_INFO _aScreen1Create[] = {
    35. { WINDOW_CreateIndirect, "Screen 1", ID_WINDOW_10, 80, 15, 160, 160, 0, 0x0, 0 },
    36. { TEXT_CreateIndirect, "Screen 1", ID_TEXT_10, 30, 70, 100, 20, 0, 0x0, 0 },
    37. };
    38. /*********************************************************************
    39. *
    40. * _aScreen2Create
    41. */
    42. static const GUI_WIDGET_CREATE_INFO _aScreen2Create[] = {
    43. { WINDOW_CreateIndirect, "Screen 2", ID_WINDOW_20, 80, 15, 160, 160, 0, 0x0, 0 },
    44. { TEXT_CreateIndirect, "Screen 2", ID_TEXT_20, 30, 70, 100, 20, 0, 0x0, 0 },
    45. };
    46. /*********************************************************************
    47. *
    48. * Static code
    49. *
    50. **********************************************************************
    51. */
    52. /*********************************************************************
    53. *
    54. * _cbScreen2
    55. */
    56. static void _cbScreen2(WM_MESSAGE * pMsg) {
    57. WM_HWIN hItem;
    58. switch (pMsg->MsgId) {
    59. case WM_INIT_DIALOG:
    60. //
    61. // Initialization of 'Screen 1'
    62. //
    63. hItem = pMsg->hWin;
    64. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00FF0000));
    65. //
    66. // Initialization of 'Screen 1'
    67. //
    68. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_20);
    69. TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    70. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x000000FF));
    71. TEXT_SetFont(hItem, GUI_FONT_24B_1);
    72. break;
    73. default:
    74. WM_DefaultProc(pMsg);
    75. break;
    76. }
    77. }
    78. /*********************************************************************
    79. *
    80. * _cbScreen1
    81. */
    82. static void _cbScreen1(WM_MESSAGE * pMsg) {
    83. WM_HWIN hItem;
    84. switch (pMsg->MsgId) {
    85. case WM_INIT_DIALOG:
    86. //
    87. // Initialization of 'Screen 1'
    88. //
    89. hItem = pMsg->hWin;
    90. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x0000FF00));
    91. //
    92. // Initialization of 'Screen 1'
    93. //
    94. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_10);
    95. TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    96. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x000000FF));
    97. TEXT_SetFont(hItem, GUI_FONT_24B_1);
    98. break;
    99. default:
    100. WM_DefaultProc(pMsg);
    101. break;
    102. }
    103. }
    104. /*********************************************************************
    105. *
    106. * _cbDialog
    107. */
    108. static void _cbDialog(WM_MESSAGE * pMsg) {
    109. WM_HWIN hItem;
    110. int NCode;
    111. int Id;
    112. static WM_HWIN hScreen1, hScreen2;
    113. switch (pMsg->MsgId) {
    114. case WM_INIT_DIALOG:
    115. //
    116. // Initialization of 'Window'
    117. //
    118. hItem = pMsg->hWin;
    119. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00000000));
    120. hScreen1 = GUI_CreateDialogBox(_aScreen1Create, GUI_COUNTOF(_aScreen1Create), _cbScreen1, hItem, 0, 0);
    121. hScreen2 = GUI_CreateDialogBox(_aScreen2Create, GUI_COUNTOF(_aScreen2Create), _cbScreen2, hItem, 0, 0);
    122. WM_HideWindow(hScreen1);
    123. WM_HideWindow(hScreen2);
    124. break;
    125. case WM_NOTIFY_PARENT:
    126. Id = WM_GetId(pMsg->hWinSrc);
    127. NCode = pMsg->Data.v;
    128. switch(Id) {
    129. case ID_BUTTON_0: // Notifications sent by 'Screen 1'
    130. switch(NCode) {
    131. case WM_NOTIFICATION_RELEASED:
    132. WM_HideWindow(hScreen2);
    133. WM_ShowWin(hScreen1);
    134. break;
    135. }
    136. break;
    137. case ID_BUTTON_1: // Notifications sent by 'Screen 2'
    138. switch(NCode) {
    139. case WM_NOTIFICATION_RELEASED:
    140. WM_HideWindow(hScreen1);
    141. WM_ShowWin(hScreen2);
    142. break;
    143. }
    144. break;
    145. }
    146. break;
    147. default:
    148. WM_DefaultProc(pMsg);
    149. break;
    150. }
    151. }
    152. /*********************************************************************
    153. *
    154. * Public code
    155. *
    156. **********************************************************************
    157. */
    158. /*********************************************************************
    159. *
    160. * MainTask
    161. */
    162. void MainTask(void) {
    163. WM_SetCreateFlags(WM_CF_MEMDEV);
    164. GUI_Init();
    165. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
    166. while (1) {
    167. GUI_Delay(100);
    168. }
    169. }
    Display All


    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.