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.
AA_HiResAntialiasing.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 : AA_HiResAntialiasing.c 00041 Purpose : Demonstrates high resolution antialiasing 00042 Requirements: WindowManager - ( ) 00043 MemoryDevices - (x) 00044 AntiAliasing - (x) 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 countof(Obj) (sizeof(Obj)/sizeof(Obj[0])) 00060 00061 // 00062 // Recommended memory to run the sample with adequate performance 00063 // 00064 #define RECOMMENDED_MEMORY (1024L * 20) 00065 00066 /******************************************************************* 00067 * 00068 * static variables 00069 * 00070 ******************************************************************** 00071 */ 00072 00073 static const GUI_POINT _aPointer[] = { 00074 { 0, 3}, 00075 {85, 1}, 00076 {90, 0}, 00077 {85, -1}, 00078 { 0, -3} 00079 }; 00080 00081 static GUI_POINT _aPointerHiRes[countof(_aPointer)]; 00082 00083 typedef struct { 00084 GUI_AUTODEV_INFO AutoInfo; 00085 GUI_POINT aPoints[countof(_aPointer)]; 00086 int Factor; 00087 } PARAM; 00088 00089 /******************************************************************* 00090 * 00091 * Static functions 00092 * 00093 ******************************************************************** 00094 */ 00095 /******************************************************************* 00096 * 00097 * _DrawHiRes 00098 * 00099 * Function description 00100 * This function draws the high resolution pointer 00101 */ 00102 static void _DrawHiRes(void * p) { 00103 PARAM * pParam = (PARAM *)p; 00104 if (pParam->AutoInfo.DrawFixed) { 00105 GUI_ClearRect(60, 60, 159, 159); 00106 } 00107 GUI_AA_FillPolygon(pParam->aPoints, 00108 countof(_aPointer), 00109 65 * pParam->Factor, 00110 155 * pParam->Factor); 00111 } 00112 00113 /******************************************************************* 00114 * 00115 * _Draw 00116 * 00117 * Function description 00118 * This function draws the non high resolution pointer 00119 */ 00120 static void _Draw(void * p) { 00121 PARAM * pParam = (PARAM *)p; 00122 if (pParam->AutoInfo.DrawFixed) { 00123 GUI_ClearRect(160, 60, 259, 159); 00124 } 00125 GUI_AA_FillPolygon(pParam->aPoints, countof(_aPointer), 165, 155); 00126 } 00127 00128 /******************************************************************* 00129 * 00130 * _ShowHiresAntialiasing 00131 * 00132 * Function description 00133 * This function creates the memory auto devices and handle the 00134 * rotation of the pointers 00135 */ 00136 static void _ShowHiresAntialiasing(void) { 00137 GUI_AUTODEV aAuto[2]; 00138 PARAM Param; 00139 unsigned i; 00140 00141 Param.Factor = 3; 00142 GUI_SetBkColor(GUI_BLACK); 00143 GUI_Clear(); 00144 GUI_SetColor(GUI_WHITE); 00145 GUI_SetTextAlign(GUI_TA_HCENTER); 00146 GUI_SetFont(&GUI_Font24_ASCII); 00147 GUI_DispStringAt("AA_HiResAntialiasing - Sample", 160, 5); 00148 GUI_SetFont(&GUI_Font6x8); 00149 GUI_DispStringHCenterAt("Using\nhigh\nresolution\nmode", 110, 180); 00150 GUI_DispStringHCenterAt("Not using\nhigh\nresolution\nmode", 210, 180); 00151 // 00152 // Create GUI_AUTODEV objects 00153 // 00154 for (i = 0; i < countof(aAuto); i++) { 00155 GUI_MEMDEV_CreateAuto(&aAuto[i]); 00156 } 00157 // 00158 // Calculate pointer for high resolution 00159 // 00160 for (i = 0; i < countof(_aPointer); i++) { 00161 _aPointerHiRes[i].x = _aPointer[i].x * Param.Factor; 00162 _aPointerHiRes[i].y = _aPointer[i].y * Param.Factor; 00163 } 00164 GUI_AA_SetFactor(Param.Factor); /* Set antialiasing factor */ 00165 while (1) { 00166 for (i = 0; i < 1800; i++) { 00167 float Angle = (i >= 900) ? 1800 - i : i; 00168 Angle *= 3.1415926f / 1800; 00169 // 00170 // Draw pointer with high resolution 00171 // 00172 GUI_AA_EnableHiRes(); 00173 GUI_RotatePolygon(Param.aPoints, _aPointerHiRes, countof(_aPointer), Angle); 00174 GUI_MEMDEV_DrawAuto(&aAuto[0], &Param.AutoInfo, _DrawHiRes, &Param); 00175 // 00176 // Draw pointer without high resolution 00177 // 00178 GUI_AA_DisableHiRes(); 00179 GUI_RotatePolygon(Param.aPoints, _aPointer, countof(_aPointer), Angle); 00180 GUI_MEMDEV_DrawAuto(&aAuto[1], &Param.AutoInfo, _Draw, &Param); 00181 GUI_Delay(2); 00182 } 00183 } 00184 } 00185 00186 /********************************************************************* 00187 * 00188 * Public code 00189 * 00190 ********************************************************************** 00191 */ 00192 /********************************************************************* 00193 * 00194 * MainTask 00195 */ 00196 void MainTask(void) { 00197 GUI_Init(); 00198 // 00199 // Check if recommended memory for the sample is available 00200 // 00201 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00202 GUI_ErrorOut("Not enough memory available."); 00203 return; 00204 } 00205 _ShowHiresAntialiasing(); 00206 } 00207 00208 /*************************** End of file ****************************/ 00209
Generated on Thu Jul 14 2022 12:58:38 by
