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.
2DGL_DrawScale.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 : 2DGL_DrawScale.c 00041 Purpose : Drawing a scale using GUI-functions 00042 Requirements: WindowManager - ( ) 00043 MemoryDevices - ( ) 00044 AntiAliasing - (x) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 00051 #include "GUI.h" 00052 #include <math.h> 00053 #include <stddef.h> 00054 00055 /********************************************************************* 00056 * 00057 * Defines 00058 * 00059 ********************************************************************** 00060 */ 00061 #define SPEED 1100 00062 00063 // 00064 // Recommended memory to run the sample with adequate performance 00065 // 00066 #define RECOMMENDED_MEMORY (1024L * 5) 00067 00068 /******************************************************************* 00069 * 00070 * static code 00071 * 00072 ******************************************************************** 00073 */ 00074 /******************************************************************* 00075 * 00076 * _DrawScale 00077 * 00078 * Function description 00079 * Drawing a scale using GUI-functions 00080 */ 00081 static void _DrawScale(void) { 00082 int XSize; 00083 int XMid; 00084 int i; 00085 int r1; 00086 int r2; 00087 int rt; 00088 int y ; 00089 int step; 00090 int r; 00091 00092 XSize = LCD_GetXSize(); 00093 XMid = XSize / 2; 00094 r1 = 110; 00095 r2 = 140; 00096 rt = 100; 00097 y = 240; 00098 step = 15; 00099 r = (r1 + r2) / 2; 00100 GUI_SetBkColor(GUI_BLACK); 00101 GUI_Clear(); 00102 GUI_SetColor(GUI_WHITE); 00103 GUI_SetFont(&GUI_Font24_ASCII); 00104 GUI_SetTextAlign(GUI_TA_HCENTER); 00105 GUI_DispStringAt("DrawScale - Sample", 160, 5); 00106 while (1) { 00107 int c = 0; 00108 GUI_SetColor(GUI_WHITE); 00109 GUI_SetFont(&GUI_Font8x16); 00110 GUI_SetTextAlign(GUI_TA_LEFT); 00111 GUI_Delay(SPEED / 2); 00112 GUI_DispStringAtCEOL("using", 5, 40); 00113 GUI_DispStringAtCEOL("GUI_AA_DrawArc", 5, 55); 00114 GUI_Delay(SPEED * 2); 00115 GUI_SetPenSize(r2 - r1); 00116 GUI_SetColor(GUI_MAKE_COLOR(0x0000AA)); 00117 GUI_AA_DrawArc(XMid, y, r, r, 45, 60); 00118 GUI_Delay(SPEED); 00119 GUI_SetColor(GUI_MAKE_COLOR(0x00AA00)); 00120 GUI_AA_DrawArc(XMid, y, r, r, 60, 90); 00121 GUI_Delay(SPEED); 00122 GUI_SetPenSize(2); 00123 GUI_SetColor(GUI_WHITE); 00124 GUI_AA_DrawArc(XMid, y, r1, r1, 45, 135); 00125 GUI_Delay(SPEED); 00126 GUI_AA_DrawArc(XMid, y, r2, r2, 45, 135); 00127 GUI_Delay(SPEED); 00128 GUI_DispStringAtCEOL("", 5, 55); 00129 GUI_Delay(200); 00130 GUI_DispStringAtCEOL("using", 5, 40); 00131 GUI_DispStringAtCEOL("GUI_AA_DrawLine & GUI_DispCharAt", 5, 55); 00132 GUI_Delay(SPEED * 3); 00133 for (i = 45; i <= 135; i += step) { 00134 float co = cos(i * 3.1415926 / 180); 00135 float si = sin(i * 3.1415926 / 180); 00136 int x1 = XMid - (int)(r1 * co); 00137 int y1 = y - (int)(r1 * si); 00138 int x2 = XMid - (int)((r2 - 1) * co); 00139 int y2 = y - (int)((r2 - 1) * si); 00140 int xt = XMid - (int)(rt * co); 00141 int yt = y - (int)(rt * si); 00142 GUI_SetColor(GUI_WHITE); 00143 GUI_SetPenSize(2); 00144 GUI_AA_DrawLine(x1, y1, x2, y2); 00145 GUI_SetColor(GUI_GREEN); 00146 GUI_SetFont(&GUI_Font8x8); 00147 GUI_DispCharAt('0' + c++, xt - 4, yt - 4); 00148 GUI_Delay(SPEED / 2); 00149 } 00150 GUI_Delay(SPEED * 3); 00151 GUI_ClearRect(0, 30, 320, 240); 00152 } 00153 } 00154 00155 /********************************************************************* 00156 * 00157 * Public code 00158 * 00159 ********************************************************************** 00160 */ 00161 /********************************************************************* 00162 * 00163 * MainTask 00164 */ 00165 void MainTask(void) { 00166 GUI_Init(); 00167 // 00168 // Check if recommended memory for the sample is available 00169 // 00170 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00171 GUI_ErrorOut("Not enough memory available."); 00172 return; 00173 } 00174 _DrawScale(); 00175 while(1); 00176 } 00177 00178 /*************************** End of file ****************************/ 00179
Generated on Thu Jul 14 2022 12:58:38 by
