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_ButtonPhone.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_PhoneButton.c 00041 Purpose : Example demonstrating the use of a BUTTON widget 00042 Requirements: WindowManager - (x) 00043 MemoryDevices - ( ) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 #include "GUI.h" 00051 #include "BUTTON.h" 00052 00053 /********************************************************************* 00054 * 00055 * Defines 00056 * 00057 ********************************************************************** 00058 */ 00059 // 00060 // Recommended memory to run the sample with adequate performance 00061 // 00062 #define RECOMMENDED_MEMORY (1024L * 5) 00063 00064 /******************************************************************* 00065 * 00066 * static variables 00067 * 00068 ******************************************************************** 00069 */ 00070 /******************************************************************* 00071 * 00072 * Bitmap data, 3 phone logos 00073 */ 00074 static const GUI_COLOR Colors[] = { GUI_MAKE_COLOR(0x000000), GUI_MAKE_COLOR(0xFFFFFF) }; 00075 00076 static const GUI_LOGPALETTE Palette = { 2, 1, Colors }; 00077 00078 static const unsigned char acPhone0[] = { 00079 ________, ________, ________, ________, 00080 ________, ________, ________, ________, 00081 ________, ________, ________, ________, 00082 ________, ________, ________, ________, 00083 ________, ________, ________, ________, 00084 ________, ________, ________, ________, 00085 ________, ________, ________, ________, 00086 ________, ________, ________, ________, 00087 ________, ________, ________, ________, 00088 ________, ________, ________, ________, 00089 ________, ________, ________, ________, 00090 _____XXX, XXXXXXXX, XXXXXXXX, XXX_____, 00091 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00092 __XXXXXX, XXXXXXXX, XXXXXXXX, XXXXXX__, 00093 _XXXXXXX, X_______, _______X, XXXXXXX_, 00094 _XXXXXXX, X__XX___, ___XX__X, XXXXXXX_, 00095 _XXXXXXX, X__XX___, ___XX__X, XXXXXXX_, 00096 _XXXXXXX, X__XX___, ___XX__X, XXXXXXX_, 00097 ________, ___XX___, ___XX___, ________, 00098 _______X, XXXXXXXX, XXXXXXXX, X_______, 00099 ______XX, XXXXXXXX, XXXXXXXX, XX______, 00100 _____XXX, XXXX__X_, _X__XXXX, XXX_____, 00101 ____XXXX, XXXX__X_, _X__XXXX, XXXX____, 00102 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00103 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00104 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00105 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00106 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00107 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00108 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00109 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___ 00110 }; 00111 00112 static const unsigned char acPhone1[] = { 00113 ________, ________, ________, ________, 00114 ______XX, X_______, ________, ________, 00115 ____XXXX, XXXXX___, ________, ________, 00116 ____XXXX, XXXXXXX_, ________, ________, 00117 ___XXXXX, XXXXXXXX, X_______, ________, 00118 ___XXXXX, XXXXXXXX, XXX_____, ________, 00119 _____XXX, XXXX_XXX, XXXXX___, ________, 00120 _______X, XXXX___X, XXXXXXX_, ________, 00121 ________, _XX_____, _XXXXXXX, X_______, 00122 ________, ________, ___XXXXX, XXX_____, 00123 ________, ________, _____XXX, XXXXX___, 00124 ________, ________, _______X, XXXXXX__, 00125 ________, ________, ________, XXXXXXX_, 00126 ________, ________, ________, XXXXXXX_, 00127 ________, ________, _______X, XXXXXXXX, 00128 ________, ___XX___, ___XX__X, XXXXXXXX, 00129 ________, ___XX___, ___XX___, _XXXXXXX, 00130 ________, ___XX___, ___XX___, ___XXXX_, 00131 ________, ___XX___, ___XX___, _____XX_, 00132 _______X, XXXXXXXX, XXXXXXXX, X_______, 00133 ______XX, XXXXXXXX, XXXXXXXX, XX______, 00134 _____XXX, XXXX__X_, _X__XXXX, XXX_____, 00135 ____XXXX, XXXX__X_, _X__XXXX, XXXX____, 00136 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00137 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00138 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00139 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00140 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00141 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00142 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00143 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___ 00144 }; 00145 00146 static const unsigned char acPhone2[] = { 00147 ________, ________, ________, ________, 00148 ________, ________, _______X, XX______, 00149 ________, ________, ___XXXXX, XXXX____, 00150 ________, ________, _XXXXXXX, XXXX____, 00151 ________, _______X, XXXXXXXX, XXXXX___, 00152 ________, _____XXX, XXXXXXXX, XXXXX___, 00153 ________, ___XXXXX, XXX_XXXX, XXX_____, 00154 ________, _XXXXXXX, X___XXXX, X_______, 00155 _______X, XXXXXXX_, _____XX_, ________, 00156 _____XXX, XXXXX___, ________, ________, 00157 ___XXXXX, XXX_____, ________, ________, 00158 __XXXXXX, X_______, ________, ________, 00159 _XXXXXXX, ________, ________, ________, 00160 _XXXXXXX, ________, ________, ________, 00161 XXXXXXXX, X_______, ________, ________, 00162 XXXXXXXX, X__XX___, ___XX___, ________, 00163 XXXXXXX_, ___XX___, ___XX___, ________, 00164 _XXXX___, ___XX___, ___XX___, ________, 00165 _XX_____, ___XX___, ___XX___, ________, 00166 _______X, XXXXXXXX, XXXXXXXX, X_______, 00167 ______XX, XXXXXXXX, XXXXXXXX, XX______, 00168 _____XXX, XXXX__X_, _X__XXXX, XXX_____, 00169 ____XXXX, XXXX__X_, _X__XXXX, XXXX____, 00170 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00171 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00172 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00173 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00174 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00175 ___XXXXX, XXXX__X_, _X__XXXX, XXXXX___, 00176 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___, 00177 ___XXXXX, XXXXXXXX, XXXXXXXX, XXXXX___ 00178 }; 00179 00180 static const GUI_BITMAP bm_1bpp_0 = { 32, 31, 4, 1, acPhone0, &Palette}; 00181 static const GUI_BITMAP bm_1bpp_1 = { 32, 31, 4, 1, acPhone1, &Palette}; 00182 static const GUI_BITMAP bm_1bpp_2 = { 32, 31, 4, 1, acPhone2, &Palette}; 00183 00184 /******************************************************************* 00185 * 00186 * static code 00187 * 00188 ******************************************************************** 00189 */ 00190 /******************************************************************* 00191 * 00192 * _Wait 00193 */ 00194 static int _Wait(int Delay) { 00195 int EndTime; 00196 int r; 00197 00198 r = 1; 00199 EndTime = GUI_GetTime() + Delay; 00200 while (GUI_GetTime() < EndTime) { 00201 GUI_Exec(); 00202 if (GUI_GetKey() == GUI_ID_OK) { 00203 r = 0; 00204 break; 00205 } 00206 } 00207 return r; 00208 } 00209 00210 /******************************************************************* 00211 * 00212 * _DemoButton 00213 */ 00214 static void _DemoButton(void) { 00215 BUTTON_Handle hButton; 00216 00217 GUI_SetFont(&GUI_Font8x16); 00218 GUI_DispStringHCenterAt("Click on phone button...", 160,80); 00219 GUI_Delay(500); 00220 // 00221 // Create the button and modify its attributes 00222 // 00223 hButton = BUTTON_Create(142, 100, 36, 40, GUI_ID_OK, WM_CF_SHOW); 00224 BUTTON_SetBkColor (hButton, 1, GUI_RED); 00225 // 00226 // Loop until button is pressed 00227 // 00228 while (1) { 00229 BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_1, 2, 4); 00230 BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_1, 2, 4); 00231 if (!_Wait(50)) break; 00232 BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_0, 2, 4); 00233 BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_0, 2, 4); 00234 if (!_Wait(45)) break; 00235 BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_2, 2, 4); 00236 BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_2, 2, 4); 00237 if (!_Wait(50)) break; 00238 BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_0, 2, 4); 00239 BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_0, 2, 4); 00240 if (!_Wait(45)) break; 00241 } 00242 BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_1, 2, 4); 00243 BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_1, 2, 4); 00244 GUI_ClearRect(0, 80, 319, 120); 00245 GUI_DispStringHCenterAt("You have answered the telephone", 160, 145); 00246 GUI_Delay(2000); 00247 // 00248 // Delete button object 00249 // 00250 WM_DeleteWindow(hButton); 00251 GUI_ClearRect(0, 50, 319, 239); 00252 GUI_Delay(400); 00253 } 00254 00255 /********************************************************************* 00256 * 00257 * Public code 00258 * 00259 ********************************************************************** 00260 */ 00261 /********************************************************************* 00262 * 00263 * MainTask 00264 */ 00265 void MainTask(void) { 00266 GUI_Init(); 00267 // 00268 // Check if recommended memory for the sample is available 00269 // 00270 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00271 GUI_ErrorOut("Not enough memory available."); 00272 return; 00273 } 00274 GUI_SetBkColor(GUI_BLACK); 00275 GUI_Clear(); 00276 GUI_SetColor(GUI_WHITE); 00277 GUI_SetFont(&GUI_Font24_ASCII); 00278 GUI_DispStringHCenterAt("WIDGET_PhoneButton - Sample", 160, 5); 00279 while (1) { 00280 _DemoButton(); 00281 } 00282 } 00283 00284 /*************************** End of file ****************************/ 00285
Generated on Thu Jul 14 2022 12:58:43 by
