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.
WIDGET_Progbar.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 : WIDGET_Progbar.c 00041 Purpose : Simple demo shows the use of the PROGBAR widget 00042 Requirements: WindowManager - (x) 00043 MemoryDevices - ( ) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 00051 #include "GUI.h" 00052 #include "PROGBAR.h" 00053 #include <stddef.h> 00054 00055 /********************************************************************* 00056 * 00057 * Defines 00058 * 00059 ********************************************************************** 00060 */ 00061 // 00062 // Recommended memory to run the sample with adequate performance 00063 // 00064 #define RECOMMENDED_MEMORY (1024L * 5) 00065 00066 /******************************************************************* 00067 * 00068 * static code 00069 * 00070 ******************************************************************** 00071 */ 00072 /******************************************************************* 00073 * 00074 * _DemoProgBar 00075 */ 00076 static void _DemoProgBar(void) { 00077 int i; 00078 PROGBAR_Handle ahProgBar[2]; 00079 00080 GUI_SetBkColor(GUI_BLACK); 00081 GUI_Clear(); 00082 GUI_SetColor(GUI_WHITE); 00083 GUI_SetFont(&GUI_Font24_ASCII); 00084 GUI_DispStringHCenterAt("WIDGET_Progbar - Sample", 160, 5); 00085 GUI_SetFont(&GUI_Font8x16); 00086 GUI_DispStringAt("Progress bar", 100,80); 00087 // 00088 // Create the progbars 00089 // 00090 ahProgBar[0] = PROGBAR_Create(100,100,100,20, WM_CF_SHOW); 00091 ahProgBar[1] = PROGBAR_Create( 80,150,140,10, WM_CF_SHOW); 00092 // 00093 // Use memory device (optional, for better looks) 00094 // 00095 WM_EnableMemdev(ahProgBar[0]); 00096 WM_EnableMemdev(ahProgBar[1]); 00097 PROGBAR_SetMinMax(ahProgBar[1], 0, 500); 00098 PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16); 00099 GUI_Delay(500); 00100 while(1) { 00101 PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16); 00102 if (LCD_GetDevCap(LCD_DEVCAP_BITSPERPIXEL) <= 4) { 00103 PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY); 00104 PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY); 00105 } else { 00106 PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN); 00107 PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED); 00108 } 00109 PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_HCENTER); 00110 PROGBAR_SetText(ahProgBar[0], NULL); 00111 for (i=0; i<=100; i++) { 00112 PROGBAR_SetValue(ahProgBar[0], i); 00113 PROGBAR_SetValue(ahProgBar[1], i); 00114 GUI_Delay(5); 00115 } 00116 PROGBAR_SetText(ahProgBar[0], "Tank empty"); 00117 for (; i>=0; i--) { 00118 PROGBAR_SetValue(ahProgBar[0], i); 00119 PROGBAR_SetValue(ahProgBar[1], 200-i); 00120 GUI_Delay(5); 00121 } 00122 PROGBAR_SetText(ahProgBar[0], "Any text..."); 00123 PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_LEFT); 00124 for (; i<=100; i++) { 00125 PROGBAR_SetValue(ahProgBar[0], i); 00126 PROGBAR_SetValue(ahProgBar[1], 200+i); 00127 GUI_Delay(5); 00128 } 00129 PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_RIGHT); 00130 for (; i>=0; i--) { 00131 PROGBAR_SetValue(ahProgBar[0], i); 00132 PROGBAR_SetValue(ahProgBar[1], 400-i); 00133 GUI_Delay(5); 00134 } 00135 PROGBAR_SetFont(ahProgBar[0], &GUI_FontComic18B_1); 00136 PROGBAR_SetText(ahProgBar[0], "Any font..."); 00137 for (; i<=100; i++) { 00138 PROGBAR_SetValue(ahProgBar[0], i); 00139 PROGBAR_SetValue(ahProgBar[1], 400+i); 00140 GUI_Delay(5); 00141 } 00142 GUI_Delay(500); 00143 } 00144 } 00145 00146 /********************************************************************* 00147 * 00148 * Public code 00149 * 00150 ********************************************************************** 00151 */ 00152 /********************************************************************* 00153 * 00154 * MainTask 00155 */ 00156 void MainTask(void) { 00157 GUI_Init(); 00158 // 00159 // Check if recommended memory for the sample is available 00160 // 00161 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00162 GUI_ErrorOut("Not enough memory available."); 00163 return; 00164 } 00165 while (1) { 00166 _DemoProgBar(); 00167 } 00168 } 00169 00170 /*************************** End of file ****************************/ 00171
Generated on Thu Jul 14 2022 12:58:43 by
