GUIDEMO_VScreen.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*********************************************************************
  2. * SEGGER Microcontroller GmbH & Co. KG *
  3. * Solutions for real time microcontroller applications *
  4. **********************************************************************
  5. * *
  6. * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG *
  7. * *
  8. * Internet: www.segger.com Support: support@segger.com *
  9. * *
  10. **********************************************************************
  11. ** emWin V5.32 - Graphical user interface for embedded applications **
  12. All Intellectual Property rights in the Software belongs to SEGGER.
  13. emWin is protected by international copyright laws. Knowledge of the
  14. source code may not be used to write a similar product. This file may
  15. only be used in accordance with the following terms:
  16. The software has been licensed to STMicroelectronics International
  17. N.V. a Dutch company with a Swiss branch and its headquarters in Plan-
  18. les-Ouates, Geneva, 39 Chemin du Champ des Filles, Switzerland for the
  19. purposes of creating libraries for ARM Cortex-M-based 32-bit microcon_
  20. troller products commercialized by Licensee only, sublicensed and dis_
  21. tributed under the terms and conditions of the End User License Agree_
  22. ment supplied by STMicroelectronics International N.V.
  23. Full source code is available at: www.segger.com
  24. We appreciate your understanding and fairness.
  25. ----------------------------------------------------------------------
  26. Licensing information
  27. Licensor: SEGGER Software GmbH
  28. Licensed to: STMicroelectronics International NV
  29. Licensed SEGGER software: emWin
  30. License number: GUI-00429
  31. License model: Buyout SRC [Buyout Source Code License, signed November 29th 2012]
  32. Licensed product: -
  33. Licensed platform: STMs ARM Cortex-M based 32 BIT CPUs
  34. Licensed number of seats: -
  35. ----------------------------------------------------------------------
  36. File : GUIDEMO_VScreen.c
  37. Purpose : Virtual screen demo
  38. ----------------------------------------------------------------------
  39. */
  40. #include "GUIDEMO.h"
  41. #if (SHOW_GUIDEMO_VSCREEN)
  42. /*********************************************************************
  43. *
  44. * Static code
  45. *
  46. **********************************************************************
  47. */
  48. /*********************************************************************
  49. *
  50. * _Loop
  51. */
  52. static int _Loop(int y, int d, int n, int Delay) {
  53. do {
  54. y += d;
  55. GUI_SetOrg(0, y);
  56. GUI_Delay(Delay);
  57. if (GUIDEMO_CheckCancel()) {
  58. return 1;
  59. }
  60. } while (--n);
  61. return 0;
  62. }
  63. /*********************************************************************
  64. *
  65. * _DemoVScreen
  66. */
  67. static void _DemoVScreen(void) {
  68. GUI_RECT Rect;
  69. unsigned j;
  70. int xSize;
  71. int ySize;
  72. int n;
  73. int aDelay[] = { 20, 5 };
  74. xSize = LCD_GetXSize();
  75. ySize = LCD_GetYSize();
  76. GUI_SetFont(&GUI_FontComic24B_ASCII);
  77. GUI_SetTextMode(GUI_TM_TRANS);
  78. Rect.x0 = 0;
  79. Rect.y0 = 0;
  80. Rect.x1 = xSize - 1;
  81. Rect.y1 = ySize - 1;
  82. GUI_SetColor(GUI_WHITE);
  83. GUI_DispStringInRect("Default screen", &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER);
  84. GUI_Delay(250);
  85. Rect.y0 += ySize;
  86. Rect.y1 += ySize;
  87. GUI_DrawGradientV(Rect.x0, Rect.y0, Rect.x1, Rect.y1, 0xFFFFFF, 0x000000);
  88. Rect.y1 -= ySize / 3;
  89. GUI_SetColor(GUI_DARKGREEN);
  90. GUI_DispStringInRect("Here is the virtual screen", &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER);
  91. n = ySize / 5;
  92. for (j = 0; j < GUI_COUNTOF(aDelay); j++) {
  93. if (_Loop(0, 5, n, aDelay[j]) == 1) {
  94. return;
  95. }
  96. GUI_SetOrg(0, ySize);
  97. GUI_Delay(250);
  98. if (_Loop(ySize, -5, n, aDelay[j]) == 1) {
  99. return;
  100. }
  101. GUI_SetOrg(0, 0);
  102. GUI_Delay(250);
  103. if (GUIDEMO_CheckCancel()) {
  104. return;
  105. }
  106. }
  107. for (j = 0; j < 5; j++) {
  108. GUI_SetOrg(0, ySize);
  109. GUI_Delay(200);
  110. GUI_SetOrg(0, 0);
  111. GUI_Delay(200);
  112. if (GUIDEMO_CheckCancel()) {
  113. return;
  114. }
  115. }
  116. GUIDEMO_Delay(1000);
  117. }
  118. /*********************************************************************
  119. *
  120. * Public code
  121. *
  122. **********************************************************************
  123. */
  124. /*********************************************************************
  125. *
  126. * GUIDEMO_VScreen
  127. */
  128. void GUIDEMO_VScreen(void) {
  129. int vySize;
  130. int ySize;
  131. ySize = LCD_GetYSize();
  132. vySize = LCD_GetVYSize();
  133. if (vySize < (ySize * 2)) {
  134. GUIDEMO_ConfigureDemo("Virtual Screen", "Works only with a virtual screen with at least twice the ySize of the display.\nDemo will be skipped...", GUIDEMO_SHOW_CURSOR | GUIDEMO_SHOW_INFO | GUIDEMO_SHOW_CONTROL);
  135. return;
  136. }
  137. GUIDEMO_ConfigureDemo("Virtual Screen", "Demonstrates how to use\nvirtual screens", GUIDEMO_SHOW_CURSOR | GUIDEMO_SHOW_INFO | GUIDEMO_SHOW_CONTROL);
  138. GUIDEMO_DrawBk();
  139. _DemoVScreen();
  140. GUI_SetOrg(0, 0);
  141. }
  142. #else
  143. void GUIDEMO_VScreen_C(void);
  144. void GUIDEMO_VScreen_C(void) {}
  145. #endif // SHOW_GUIDEMO_VSCREEN
  146. /*************************** End of file ****************************/