Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MEMDEV_Banding.c
00001 /********************************************************************* 00002 * SEGGER Microcontroller GmbH * 00003 * Solutions for real time microcontroller applications * 00004 ********************************************************************** 00005 * * 00006 * (c) 1996 - 2018 SEGGER Microcontroller GmbH * 00007 * * 00008 * Internet: www.segger.com Support: support@segger.com * 00009 * * 00010 ********************************************************************** 00011 00012 ** emWin V5.48 - Graphical user interface for embedded applications ** 00013 All Intellectual Property rights in the Software belongs to SEGGER. 00014 emWin is protected by international copyright laws. Knowledge of the 00015 source code may not be used to write a similar product. This file may 00016 only be used in accordance with the following terms: 00017 00018 The software has been licensed to Cypress Semiconductor Corporation, 00019 whose registered office is situated at 198 Champion Ct. San Jose, CA 00020 95134 USA solely for the purposes of creating libraries for Cypress 00021 PSoC3 and PSoC5 processor-based devices, sublicensed and distributed 00022 under the terms and conditions of the Cypress End User License 00023 Agreement. 00024 Full source code is available at: www.segger.com 00025 00026 We appreciate your understanding and fairness. 00027 ---------------------------------------------------------------------- 00028 Licensing information 00029 Licensor: SEGGER Microcontroller Systems LLC 00030 Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA 00031 Licensed SEGGER software: emWin 00032 License number: GUI-00319 00033 License model: Services and License Agreement, signed June 10th, 2009 00034 Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) 00035 ---------------------------------------------------------------------- 00036 Support and Update Agreement (SUA) 00037 SUA period: 2009-06-12 - 2022-07-27 00038 Contact to extend SUA: sales@segger.com 00039 ---------------------------------------------------------------------- 00040 File : MEMDEV_Banding.c 00041 Purpose : Example demonstrating the use of banding memory devices 00042 Requirements: WindowManager - ( ) 00043 MemoryDevices - (x) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 00051 #include "GUI.h" 00052 00053 /********************************************************************* 00054 * 00055 * Defines 00056 * 00057 ********************************************************************** 00058 */ 00059 #define USE_BANDING_MEMDEV (1) /* Set to 0 for drawing without banding memory device */ 00060 #define SIZE_OF_ARRAY(Array) (sizeof(Array) / sizeof(Array[0])) 00061 00062 // 00063 // Recommended memory to run the sample with adequate performance 00064 // 00065 #define RECOMMENDED_MEMORY (1024L * 30) 00066 00067 /******************************************************************* 00068 * 00069 * static variables 00070 * 00071 ******************************************************************** 00072 */ 00073 00074 static const GUI_POINT aPoints[] = { 00075 {-50, 0}, 00076 {-10, 10}, 00077 { 0, 50}, 00078 { 10, 10}, 00079 { 50, 0}, 00080 { 10,-10}, 00081 { 0,-50}, 00082 {-10,-10} 00083 }; 00084 00085 typedef struct { 00086 int XPos_Poly; 00087 int YPos_Poly; 00088 int XPos_Text; 00089 int YPos_Text; 00090 GUI_POINT aPointsDest[8]; 00091 } tDrawItContext; 00092 00093 /******************************************************************* 00094 * 00095 * static code 00096 * 00097 ******************************************************************** 00098 */ 00099 00100 /******************************************************************* 00101 * 00102 * _DrawIt 00103 */ 00104 static void _DrawIt(void * pData) { 00105 tDrawItContext * pDrawItContext = (tDrawItContext *)pData; 00106 GUI_Clear(); 00107 GUI_SetFont(&GUI_Font8x8); 00108 GUI_SetTextMode(GUI_TM_TRANS); 00109 // 00110 // draw background 00111 // 00112 GUI_SetColor(GUI_GREEN); 00113 GUI_FillRect(pDrawItContext->XPos_Text, 00114 pDrawItContext->YPos_Text - 25, 00115 pDrawItContext->XPos_Text + 100, 00116 pDrawItContext->YPos_Text - 5); 00117 // 00118 // draw polygon 00119 // 00120 GUI_SetColor(GUI_BLUE); 00121 GUI_FillPolygon(pDrawItContext->aPointsDest, SIZE_OF_ARRAY(aPoints), 160, 120); 00122 // 00123 // draw foreground 00124 // 00125 GUI_SetColor(GUI_RED); 00126 GUI_FillRect(220 - pDrawItContext->XPos_Text, 00127 pDrawItContext->YPos_Text + 5, 00128 220 - pDrawItContext->XPos_Text + 100, 00129 pDrawItContext->YPos_Text + 25); 00130 } 00131 00132 /******************************************************************* 00133 * 00134 * _DemoBandingMemdev 00135 */ 00136 static void _DemoBandingMemdev(void) { 00137 tDrawItContext DrawItContext; 00138 int i, swap=0; 00139 GUI_SetBkColor(GUI_BLACK); 00140 GUI_Clear(); 00141 GUI_SetColor(GUI_WHITE); 00142 GUI_SetFont(&GUI_Font24_ASCII); 00143 GUI_DispStringHCenterAt("MEMDEV_Banding - Sample", 160, 5); 00144 GUI_SetFont(&GUI_Font8x9); 00145 GUI_DispStringHCenterAt("Banding memory device\nwithout flickering", 160, 40); 00146 DrawItContext.XPos_Poly = 160; 00147 DrawItContext.YPos_Poly = 120; 00148 DrawItContext.YPos_Text = 116; 00149 while (1) { 00150 swap = ~swap; 00151 for (i = 0; i < 220; i++) { 00152 float angle = i * 3.1415926 / 55; 00153 DrawItContext.XPos_Text = (swap) ? i : 220 - i; 00154 /* Rotate the polygon */ 00155 GUI_RotatePolygon(DrawItContext.aPointsDest, aPoints, 00156 SIZE_OF_ARRAY(aPoints), angle); 00157 #if USE_BANDING_MEMDEV 00158 { 00159 GUI_RECT Rect = {0, 70, 320,170}; 00160 /* Use banding memory device for drawing */ 00161 GUI_MEMDEV_Draw(&Rect, &_DrawIt, &DrawItContext, 0, 0); 00162 } 00163 #else 00164 /* Simple drawing without using memory devices */ 00165 _DrawIt((void *)&DrawItContext); 00166 #endif 00167 #ifdef WIN32 00168 GUI_Delay(20); /* Use a short delay only in the simulation */ 00169 #endif 00170 } 00171 } 00172 } 00173 00174 /********************************************************************* 00175 * 00176 * Public code 00177 * 00178 ********************************************************************** 00179 */ 00180 /********************************************************************* 00181 * 00182 * MainTask 00183 */ 00184 void MainTask(void) { 00185 GUI_Init(); 00186 // 00187 // Check if recommended memory for the sample is available 00188 // 00189 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00190 GUI_ErrorOut("Not enough memory available."); 00191 return; 00192 } 00193 _DemoBandingMemdev(); 00194 } 00195 00196 /*************************** End of file ****************************/ 00197
Generated on Thu Jul 14 2022 12:58:41 by
