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_GraphXY.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_GraphXY.c 00041 Purpose : Demonstrates the use of the GRAPH widget 00042 Requirements: WindowManager - (x) 00043 MemoryDevices - (x) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 #include <stdlib.h> 00051 #include <string.h> 00052 #include <math.h> 00053 00054 #include "DIALOG.h" 00055 #include "GRAPH.h" 00056 00057 /********************************************************************* 00058 * 00059 * Defines 00060 * 00061 ********************************************************************** 00062 */ 00063 #define PI 3.1415926f 00064 #define DEG2RAD (PI / 180) 00065 00066 // 00067 // Recommended memory to run the sample with adequate performance 00068 // 00069 #define RECOMMENDED_MEMORY (1024L * 20) 00070 00071 /********************************************************************* 00072 * 00073 * Static data 00074 * 00075 ********************************************************************** 00076 */ 00077 static GUI_CONST_STORAGE GUI_COLOR Colors[] = { 00078 GUI_MAKE_COLOR(0xFFFFFF), GUI_MAKE_COLOR(0x0000AA) 00079 }; 00080 00081 static GUI_CONST_STORAGE GUI_LOGPALETTE Pal = { 00082 2, // number of entries 00083 1, // Has transparency 00084 &Colors[0] 00085 }; 00086 00087 static GUI_CONST_STORAGE unsigned char acEnlarge[] = { 00088 _______X, X_______, 00089 ______XX, XX______, 00090 _____XXX, XXX_____, 00091 _______X, X_______, 00092 __X____X, X____X__, 00093 _XX_____, _____XX_, 00094 XXXXX___, ___XXXXX, 00095 XXXXX___, ___XXXXX, 00096 _XX_____, _____XX_, 00097 __X____X, X____X__, 00098 _______X, X_______, 00099 _____XXX, XXX_____, 00100 ______XX, XX______, 00101 _______X, X_______ 00102 }; 00103 00104 static GUI_CONST_STORAGE unsigned char acShrink[] = { 00105 _______X, X_______, 00106 _______X, X_______, 00107 _____XXX, XXX_____, 00108 ______XX, XX______, 00109 __X____X, X____X__, 00110 __XX____, ____XX__, 00111 XXXXX___, ___XXXXX, 00112 XXXXX___, ___XXXXX, 00113 __XX____, ____XX__, 00114 __X____X, X____X__, 00115 ______XX, XX______, 00116 _____XXX, XXX_____, 00117 _______X, X_______, 00118 _______X, X_______ 00119 }; 00120 00121 static GUI_CONST_STORAGE GUI_BITMAP _bmEnlarge = { 00122 16, // XSize 00123 14, // YSize 00124 2, // BytesPerLine 00125 1, // BitsPerPixel 00126 acEnlarge, // Pointer to picture data (indices) 00127 &Pal // Pointer to palette 00128 }; 00129 00130 static GUI_CONST_STORAGE GUI_BITMAP _bmShrink = { 00131 16, // XSize 00132 14, // YSize 00133 2, // BytesPerLine 00134 1, // BitsPerPixel 00135 acShrink, // Pointer to picture data (indices) 00136 &Pal // Pointer to palette 00137 }; 00138 00139 static GRAPH_SCALE_Handle _hScaleV; // Handle of vertical scale 00140 static GRAPH_SCALE_Handle _hScaleH; // Handle of horizontal scale 00141 00142 static const GUI_COLOR _aColor[3] = {GUI_RED, GUI_DARKGREEN, GUI_MAGENTA}; 00143 static const U8 _aLStyle[3] = {GUI_LS_SOLID, GUI_LS_DOT, GUI_LS_DASH}; 00144 00145 // 00146 // Dialog ressource 00147 // 00148 static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { 00149 { FRAMEWIN_CreateIndirect, "GRAPH_DATA_XY demo", 0 , 0, 0, 320, 240, FRAMEWIN_CF_MOVEABLE }, 00150 { GRAPH_CreateIndirect, 0, GUI_ID_GRAPH0 , 5, 5, 265, 170 }, 00151 { TEXT_CreateIndirect, "Spacing X:", 0 , 5, 180, 50, 20 }, 00152 { TEXT_CreateIndirect, "Spacing Y:", 0 , 5, 200, 50, 20 }, 00153 { SLIDER_CreateIndirect, 0, GUI_ID_SLIDER0 , 55, 180, 60, 16 }, 00154 { SLIDER_CreateIndirect, 0, GUI_ID_SLIDER1 , 55, 200, 60, 16 }, 00155 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK8 , 120, 180, 50, 0 }, 00156 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK9 , 120, 200, 50, 0 }, 00157 { RADIO_CreateIndirect, 0, GUI_ID_RADIO1 , 170, 175, 40, 0, 0, (13 << 8) | 3 }, 00158 { TEXT_CreateIndirect, "Border", 0 , 275, 5, 35, 15 }, 00159 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK2 , 275, 20, 35, 0 }, 00160 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK3 , 275, 40, 35, 0 }, 00161 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK4 , 275, 60, 35, 0 }, 00162 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK5 , 275, 80, 35, 0 }, 00163 { TEXT_CreateIndirect, "Effect", 0 , 275, 100, 35, 15 }, 00164 { RADIO_CreateIndirect, 0, GUI_ID_RADIO0 , 270, 115, 35, 0, 0, (20 << 8) | 3 }, 00165 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK6 , 215, 180, 50, 0 }, 00166 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK7 , 215, 200, 50, 0 }, 00167 { BUTTON_CreateIndirect, "", GUI_ID_BUTTON0 , 270, 180, 36, 18 }, 00168 { CHECKBOX_CreateIndirect, 0, GUI_ID_CHECK1 , 270, 200, 40, 0 }, 00169 }; 00170 00171 // 00172 // Misc. 00173 // 00174 static int _NumPoints; 00175 static const int _aNumPoints[] = { 46, 25, 13 }; 00176 static GUI_POINT _aPoint[3][46]; 00177 GRAPH_DATA_Handle _ahDataXY[3]; 00178 00179 /********************************************************************* 00180 * 00181 * Static code 00182 * 00183 ********************************************************************** 00184 */ 00185 /********************************************************************* 00186 * 00187 * _InitPoints 00188 */ 00189 static void _InitPoints(int NumPoints) { 00190 int i; 00191 int r; 00192 int m; 00193 00194 _NumPoints = NumPoints; 00195 m = 360 / (_NumPoints - 1); 00196 r = 95; 00197 for (i = 0; i <= _NumPoints - 1; i++) { 00198 double Rad; 00199 int Deg; 00200 Deg = i * m; 00201 Rad = Deg * DEG2RAD; 00202 _aPoint[0][i].x = (int)(100 - r * cos(Rad)); 00203 _aPoint[0][i].y = (int)(100 + r * sin(Rad) * Deg / 360); 00204 _aPoint[1][i].x = (int)(100 - r * cos(Rad)); 00205 _aPoint[1][i].y = (int)(100 + r * sin(Rad) * Deg / 300); 00206 _aPoint[2][i].x = (int)(((100 - r * cos(Rad) * 0.9) * 10) / 10); 00207 _aPoint[2][i].y = (int)(100 + r * sin(Rad) * Deg / 320); 00208 } 00209 } 00210 00211 /********************************************************************* 00212 * 00213 * _OwnerDraw 00214 */ 00215 static int _OwnerDraw(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) { 00216 switch (pDrawItemInfo->Cmd) { 00217 case WIDGET_ITEM_DRAW: 00218 GUI_DrawRect(pDrawItemInfo->x0 - 3, pDrawItemInfo->y0 - 3, pDrawItemInfo->x0 + 3, pDrawItemInfo->y0 + 3); 00219 break; 00220 } 00221 return 0; 00222 } 00223 00224 /********************************************************************* 00225 * 00226 * _UserDraw 00227 * 00228 * Function description 00229 * This routine is called by the GRAPH object before anything is drawn 00230 * and after the last drawing operation. 00231 */ 00232 static void _UserDraw(WM_HWIN hWin, int Stage) { 00233 if (Stage == GRAPH_DRAW_LAST) { 00234 char acText[] = "Flow Rate L/s"; 00235 GUI_RECT Rect; 00236 GUI_RECT RectInvalid; 00237 int FontSizeY; 00238 00239 GUI_SetFont(&GUI_Font13_ASCII); 00240 FontSizeY = GUI_GetFontSizeY(); 00241 WM_GetInsideRect(&Rect); 00242 WM_GetInvalidRect(hWin, &RectInvalid); 00243 Rect.x1 = Rect.x0 + FontSizeY; 00244 GUI_SetColor(GUI_RED); 00245 GUI_DispStringInRectEx(acText, &Rect, GUI_TA_HCENTER, strlen(acText), GUI_ROTATE_CCW); 00246 } 00247 } 00248 00249 /********************************************************************* 00250 * 00251 * _ForEach 00252 * 00253 * Function description 00254 * This routine hides/shows all windows except the button, graph and scroll bar widgets 00255 */ 00256 static void _ForEach(WM_HWIN hWin, void * pData) { 00257 int Id; 00258 int FullScreenMode; 00259 00260 FullScreenMode = *(int *)pData; 00261 Id = WM_GetId(hWin); 00262 if ((Id == GUI_ID_GRAPH0) || (Id == GUI_ID_BUTTON0) || (Id == GUI_ID_VSCROLL) || (Id == GUI_ID_HSCROLL)) { 00263 return; 00264 } 00265 if (FullScreenMode) { 00266 WM_HideWindow(hWin); 00267 } else { 00268 WM_ShowWindow(hWin); 00269 } 00270 } 00271 00272 /********************************************************************* 00273 * 00274 * _ToggleFullScreenMode 00275 * 00276 * Function description 00277 * This routine switches between full screen mode and normal mode by hiding or showing the 00278 * widgets of the dialog, enlarging/shrinking the graph widget and modifying some other 00279 * attributes of the dialog widgets. 00280 */ 00281 static void _ToggleFullScreenMode(WM_HWIN hDlg) { 00282 static int FullScreenMode; 00283 static GUI_RECT Rect; 00284 static unsigned ScalePos; 00285 WM_HWIN hGraph; 00286 WM_HWIN hButton; 00287 00288 hGraph = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); 00289 hButton = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0); 00290 FullScreenMode ^= 1; 00291 if (FullScreenMode) { 00292 // 00293 // Enter the full screen mode 00294 // 00295 WM_HWIN hClient; 00296 GUI_RECT RectInside; 00297 00298 hClient = WM_GetClientWindow(hDlg); 00299 BUTTON_SetBitmapEx(hButton, BUTTON_BI_PRESSED, &_bmShrink, 10, 2); 00300 BUTTON_SetBitmapEx(hButton, BUTTON_BI_UNPRESSED, &_bmShrink, 10, 2); 00301 WM_MoveWindow(hButton, 0, 11); 00302 FRAMEWIN_SetTitleVis(hDlg, 0); 00303 WM_GetInsideRectEx(hClient, &RectInside); 00304 WM_GetWindowRectEx(hGraph, &Rect); 00305 WM_ForEachDesc(hClient, _ForEach, &FullScreenMode); // Hide all descendants 00306 WM_SetWindowPos(hGraph, WM_GetWindowOrgX(hClient), WM_GetWindowOrgX(hClient), RectInside.x1, RectInside.y1); 00307 ScalePos = GRAPH_SCALE_SetPos(_hScaleH, RectInside.y1 - 105); 00308 } else { 00309 // 00310 // Return to normal mode 00311 // 00312 BUTTON_SetBitmapEx(hButton, BUTTON_BI_PRESSED, &_bmEnlarge, 10, 2); 00313 BUTTON_SetBitmapEx(hButton, BUTTON_BI_UNPRESSED, &_bmEnlarge, 10, 2); 00314 WM_MoveWindow(hButton, 0, -11); 00315 WM_ForEachDesc(WM_GetClientWindow(hDlg), _ForEach, &FullScreenMode); // Show all descendants 00316 WM_SetWindowPos(hGraph, Rect.x0, Rect.y0, Rect.x1 - Rect.x0 + 1, Rect.y1 - Rect.y0 + 1); 00317 FRAMEWIN_SetTitleVis(hDlg, 1); 00318 GRAPH_SCALE_SetPos(_hScaleH, ScalePos); 00319 } 00320 } 00321 00322 /********************************************************************* 00323 * 00324 * _cbCallback 00325 * 00326 * Function description 00327 * Callback function of the dialog 00328 */ 00329 static void _cbCallback(WM_MESSAGE * pMsg) { 00330 int NCode; 00331 int Id; 00332 int Value; 00333 int i; 00334 int j; 00335 WM_HWIN hDlg; 00336 WM_HWIN hItem; 00337 00338 hDlg = pMsg->hWin; 00339 switch (pMsg->MsgId) { 00340 case WM_INIT_DIALOG: 00341 hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); 00342 _InitPoints(_aNumPoints[0]); 00343 // 00344 // Add graphs 00345 // 00346 for (i = 0; i < 3; i++) { 00347 _ahDataXY[i] = GRAPH_DATA_XY_Create(_aColor[i], _NumPoints, _aPoint[i], _NumPoints); 00348 GRAPH_DATA_XY_SetLineStyle(_ahDataXY[i], _aLStyle[i]); 00349 GRAPH_AttachData(hItem, _ahDataXY[i]); 00350 GRAPH_DATA_XY_SetOwnerDraw(_ahDataXY[i], _OwnerDraw); 00351 } 00352 // 00353 // Set graph attributes 00354 // 00355 GRAPH_SetGridDistY(hItem, 25); 00356 GRAPH_SetGridVis(hItem, 1); 00357 GRAPH_SetUserDraw(hItem, _UserDraw); 00358 // 00359 // Create and add vertical scale 00360 // 00361 _hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25); 00362 GRAPH_SCALE_SetOff(_hScaleV, 100); 00363 GRAPH_SCALE_SetFactor(_hScaleV, 0.04f); 00364 GRAPH_SCALE_SetTextColor(_hScaleV, GUI_RED); 00365 GRAPH_AttachScale(hItem, _hScaleV); 00366 // 00367 // Create and add horizontal scale 00368 // 00369 _hScaleH = GRAPH_SCALE_Create(70, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50); 00370 GRAPH_SCALE_SetFactor(_hScaleH, 0.02f); 00371 GRAPH_SCALE_SetTextColor(_hScaleH, GUI_DARKGREEN); 00372 GRAPH_AttachScale(hItem, _hScaleH); 00373 // 00374 // Init check boxes 00375 // 00376 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK2); 00377 CHECKBOX_SetText(hItem, "L"); 00378 CHECKBOX_SetState(hItem, 1); 00379 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK3); 00380 CHECKBOX_SetText(hItem, "T"); 00381 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK4); 00382 CHECKBOX_SetText(hItem, "R"); 00383 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK5); 00384 CHECKBOX_SetText(hItem, "B"); 00385 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK1); 00386 CHECKBOX_SetText(hItem, "Grid"); 00387 CHECKBOX_SetState(hItem, 1); 00388 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK6); 00389 CHECKBOX_SetText(hItem, "HScroll"); 00390 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK7); 00391 CHECKBOX_SetText(hItem, "VScroll"); 00392 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK8); 00393 CHECKBOX_SetText(hItem, "Lines"); 00394 CHECKBOX_SetState(hItem, 1); 00395 hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK9); 00396 CHECKBOX_SetText(hItem, "Points"); 00397 CHECKBOX_SetState(hItem, 1); 00398 // 00399 // Init slider widgets 00400 // 00401 hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0); 00402 SLIDER_SetRange(hItem, 0, 10); 00403 SLIDER_SetValue(hItem, 5); 00404 SLIDER_SetNumTicks(hItem, 6); 00405 hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER1); 00406 SLIDER_SetRange(hItem, 0, 20); 00407 SLIDER_SetValue(hItem, 5); 00408 SLIDER_SetNumTicks(hItem, 6); 00409 // 00410 // Init radio widget 00411 // 00412 hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0); 00413 RADIO_SetText(hItem, "3D", 0); 00414 RADIO_SetText(hItem, "flat", 1); 00415 RADIO_SetText(hItem, "-", 2); 00416 hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO1); 00417 RADIO_SetFont(hItem, &GUI_Font10_ASCII); 00418 RADIO_SetText(hItem, "fine", 0); 00419 RADIO_SetText(hItem, "med.", 1); 00420 RADIO_SetText(hItem, "raw", 2); 00421 RADIO_SetValue(hItem, 2); 00422 // 00423 // Init button widget 00424 // 00425 hItem = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0); 00426 BUTTON_SetBitmapEx(hItem, BUTTON_BI_PRESSED, &_bmEnlarge, 10, 2); 00427 BUTTON_SetBitmapEx(hItem, BUTTON_BI_UNPRESSED, &_bmEnlarge, 10, 2); 00428 WM_SetStayOnTop(hItem, 1); 00429 break; 00430 case WM_NOTIFY_PARENT: 00431 Id = WM_GetId(pMsg->hWinSrc); // Id of widget 00432 NCode = pMsg->Data.v; // Notification code 00433 switch (NCode) { 00434 case WM_NOTIFICATION_CLICKED: 00435 switch (Id) { 00436 case GUI_ID_BUTTON0: 00437 _ToggleFullScreenMode(hDlg); 00438 break; 00439 } 00440 break; 00441 case WM_NOTIFICATION_VALUE_CHANGED: 00442 switch (Id) { 00443 case GUI_ID_CHECK1: 00444 // 00445 // Toggle grid 00446 // 00447 hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); 00448 GRAPH_SetGridVis(hItem, CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK1))); 00449 break; 00450 case GUI_ID_CHECK2: 00451 case GUI_ID_CHECK3: 00452 case GUI_ID_CHECK4: 00453 case GUI_ID_CHECK5: 00454 // 00455 // Toggle border 00456 // 00457 hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); 00458 GRAPH_SetBorder(hItem, 00459 CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK2)) * 40, 00460 CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK3)) * 5, 00461 CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK4)) * 5, 00462 CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK5)) * 5); 00463 break; 00464 case GUI_ID_CHECK6: 00465 // 00466 // Toggle horizontal scroll bar 00467 // 00468 hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); 00469 if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK6))) { 00470 GRAPH_SetVSizeX(hItem, 500); 00471 } else { 00472 GRAPH_SetVSizeX(hItem, 0); 00473 } 00474 break; 00475 case GUI_ID_CHECK7: 00476 // 00477 // Toggle vertical scroll bar 00478 // 00479 hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); 00480 if (CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, GUI_ID_CHECK7))) { 00481 GRAPH_SetVSizeY(hItem, 300); 00482 } else { 00483 GRAPH_SetVSizeY(hItem, 0); 00484 } 00485 break; 00486 case GUI_ID_CHECK8: 00487 Value = CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, Id)); 00488 for (i = 0; i < 3; i++) { 00489 GRAPH_DATA_XY_SetLineVis(_ahDataXY[i], Value); 00490 } 00491 break; 00492 case GUI_ID_CHECK9: 00493 Value = CHECKBOX_IsChecked(WM_GetDialogItem(hDlg, Id)); 00494 for (i = 0; i < 3; i++) { 00495 GRAPH_DATA_XY_SetPointVis(_ahDataXY[i], Value); 00496 } 00497 break; 00498 case GUI_ID_SLIDER0: 00499 // 00500 // Set horizontal grid spacing 00501 // 00502 hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); 00503 Value = SLIDER_GetValue(pMsg->hWinSrc) * 10; 00504 GRAPH_SetGridDistX(hItem, Value); 00505 GRAPH_SCALE_SetTickDist(_hScaleH, Value); 00506 if (Value != 50) { 00507 GRAPH_SCALE_SetNumDecs(_hScaleH, 1); 00508 } else { 00509 GRAPH_SCALE_SetNumDecs(_hScaleH, 0); 00510 } 00511 break; 00512 case GUI_ID_SLIDER1: 00513 // 00514 // Set vertical grid spacing 00515 // 00516 hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); 00517 Value = SLIDER_GetValue(pMsg->hWinSrc) * 5; 00518 GRAPH_SetGridDistY(hItem, Value); 00519 GRAPH_SCALE_SetTickDist(_hScaleV, Value); 00520 if (Value != 25) { 00521 GRAPH_SCALE_SetNumDecs(_hScaleV, 1); 00522 } else { 00523 GRAPH_SCALE_SetNumDecs(_hScaleV, 0); 00524 } 00525 break; 00526 case GUI_ID_RADIO0: 00527 // 00528 // Set the widget effect 00529 // 00530 hItem = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); 00531 switch (RADIO_GetValue(pMsg->hWinSrc)) { 00532 case 0: 00533 WIDGET_SetEffect(hItem, &WIDGET_Effect_3D); 00534 break; 00535 case 1: 00536 WIDGET_SetEffect(hItem, &WIDGET_Effect_Simple); 00537 break; 00538 case 2: 00539 WIDGET_SetEffect(hItem, &WIDGET_Effect_None); 00540 break; 00541 } 00542 break; 00543 case GUI_ID_RADIO1: 00544 // 00545 // Set number of points 00546 // 00547 Value = _aNumPoints[RADIO_GetValue(pMsg->hWinSrc)]; 00548 _InitPoints(Value); 00549 for (i = 0; i < 3; i++) { 00550 GRAPH_DATA_XY_Clear(_ahDataXY[i]); 00551 for (j = 0; j < _NumPoints; j++) { 00552 GRAPH_DATA_XY_AddPoint(_ahDataXY[i], &_aPoint[i][j]); 00553 } 00554 } 00555 break; 00556 } 00557 break; 00558 } 00559 break; 00560 default: 00561 WM_DefaultProc(pMsg); 00562 } 00563 } 00564 00565 /********************************************************************* 00566 * 00567 * Public code 00568 * 00569 ********************************************************************** 00570 */ 00571 /********************************************************************* 00572 * 00573 * MainTask 00574 */ 00575 void MainTask(void) { 00576 00577 GUI_Init(); 00578 // 00579 // Check if recommended memory for the sample is available 00580 // 00581 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00582 GUI_ErrorOut("Not enough memory available."); 00583 return; 00584 } 00585 GUI_CURSOR_Show(); 00586 WM_SetDesktopColor(GUI_BLACK); 00587 #if GUI_SUPPORT_MEMDEV 00588 WM_SetCreateFlags(WM_CF_MEMDEV); 00589 #endif 00590 GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbCallback, 0, 0, 0); 00591 while (1) { 00592 GUI_Delay(10); 00593 } 00594 } 00595 00596 /*************************** End of file ****************************/
Generated on Thu Jul 14 2022 12:58:43 by
