Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "DIALOG.h"
#include "k_module.h"
#include "k_rtc.h"
#include "system_res.c"
Private function prototypes
Private typedef
system_info
settings
Private defines
#define ID_FRAMEWIN_INFO
#define ID_TEXT_BOARD
#define ID_TEXT_CORE
#define ID_TEXT_CPU
#define ID_TEXT_VERSION
#define ID_TEXT_COPYRIGHT
#define ID_MULTIPAGE
#define ID_IMAGE_LOGO
#define ID_CHECKBOX_SPRITES
#define ID_CHECKBOX_BACKGROUND
#define ID_CHECKBOX_CPU180
#define ID_CHECKBOX_FLEXSKIN
#define ID_TEXT_WARNING
#define ID_SPINBOX_HOUR
#define ID_TEXT_0
#define ID_TEXT_1
#define ID_SPINBOX_MINUTE
#define ID_BUTTON_APPLYSETTINGS
#define ID_BUTTON_1
#define ID_TEXT_2
#define ID_CALENDAR
#define ID_SPINBOX_SEC
#define PI
#define AA_FACTOR
#define X0
#define Y0
Private variables
_aDialog
_aDialogSystemInformation
_aDialogGeneralSettings
_aDialogClockSettings
aPoints
aPointsDest
DrawNeedle(uint32_t, uint16_t, uint16_t)
GUI_UpdateClock(uint16_t, uint16_t, uint8_t, uint8_t, uint8_t)
_cbSystemInformation(WM_MESSAGE *)
_cbGeneralSettings(WM_MESSAGE *)
_cbClockSettings(WM_MESSAGE *)
_cbDialog(WM_MESSAGE *)
Startup(GUI_HWIN, uint16_t, uint16_t)
Files
loading...
CodeScopeSTM32 Libraries and SamplesSTemWinModules/system/system_win.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file system_win.c * @author MCD Application Team * @brief System information functions ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "DIALOG.h" #include "k_module.h" #include "k_rtc.h" #include "system_res.c" /** @addtogroup SYSTEM_MODULE * @{ *//* ... */ /** @defgroup SYSTEM * @brief system routines * @{ *//* ... */ Includes /* External variables --------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos); Private function prototypes /* Private typedef -----------------------------------------------------------*/ K_ModuleItem_Typedef system_info = { 4, "System", &bminfo, Startup, NULL, ...} ; SystemSettingsTypeDef settings; Private typedef /* Private defines -----------------------------------------------------------*/ #define ID_FRAMEWIN_INFO (GUI_ID_USER + 0x01) #define ID_TEXT_BOARD (GUI_ID_USER + 0x02) #define ID_TEXT_CORE (GUI_ID_USER + 0x03) #define ID_TEXT_CPU (GUI_ID_USER + 0x04) #define ID_TEXT_VERSION (GUI_ID_USER + 0x05) #define ID_TEXT_COPYRIGHT (GUI_ID_USER + 0x06) #define ID_MULTIPAGE (GUI_ID_USER + 0x07) #define ID_IMAGE_LOGO (GUI_ID_USER + 0x08) #define ID_CHECKBOX_SPRITES (GUI_ID_USER + 0x10) #define ID_CHECKBOX_BACKGROUND (GUI_ID_USER + 0x11) #define ID_CHECKBOX_CPU180 (GUI_ID_USER + 0x12) #define ID_CHECKBOX_FLEXSKIN (GUI_ID_USER + 0x13) #define ID_TEXT_WARNING (GUI_ID_USER + 0x15) #define ID_SPINBOX_HOUR (GUI_ID_USER + 0x16) #define ID_TEXT_0 (GUI_ID_USER + 0x17) #define ID_TEXT_1 (GUI_ID_USER + 0x18) #define ID_SPINBOX_MINUTE (GUI_ID_USER + 0x19) #define ID_BUTTON_APPLYSETTINGS (GUI_ID_USER + 0x1A) #define ID_BUTTON_1 (GUI_ID_USER + 0x1B) #define ID_TEXT_2 (GUI_ID_USER + 0x1C) #define ID_CALENDAR (GUI_ID_USER + 0x1D) #define ID_SPINBOX_SEC (GUI_ID_USER + 0x1E) #define PI 3.14 #define AA_FACTOR 3 #define X0 49 #define Y0 48 26 defines Private defines/* Private macros ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Dialog resource using a WINDOW widget*/ static const GUI_WIDGET_CREATE_INFO _aDialog[] = { { FRAMEWIN_CreateIndirect, "System", ID_FRAMEWIN_INFO, 0, 0, 320, 215, 0, 0x64, 0 }, { MULTIPAGE_CreateIndirect, "Multipage", ID_MULTIPAGE, 10, 10, 300, 180, 0, 0x0, 0 }, ...}; static const GUI_WIDGET_CREATE_INFO _aDialogSystemInformation[] = { { WINDOW_CreateIndirect, "System Information", 0, 0, 0, 300, 180, FRAMEWIN_CF_MOVEABLE }, { TEXT_CreateIndirect, "Board : STM324xG-EVAL", ID_TEXT_BOARD, 15, 15, 200, 20, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Core: STM32F-4 Series", ID_TEXT_CORE, 15, 35, 200, 20, 0, 0x0, 0 }, { TEXT_CreateIndirect, "CPU Speed : 168MHz", ID_TEXT_CPU, 15, 55, 200, 20, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Firmware Version : 1.6.0", ID_TEXT_VERSION, 15, 75, 280, 20, 0, 0x0, 0 }, { IMAGE_CreateIndirect, "Image", ID_IMAGE_LOGO, 90, 95, 40, 20, 0, 0, 0 }, { TEXT_CreateIndirect, "Copyright (c) STMicroelectronics 2017", ID_TEXT_COPYRIGHT, 15, 125, 200, 20, 0, 0x0, 0 }, ...}; static const GUI_WIDGET_CREATE_INFO _aDialogGeneralSettings[] = { { WINDOW_CreateIndirect, "General Settings", 0, 0, 0, 300, 180, FRAMEWIN_CF_MOVEABLE }, { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_SPRITES, 6, 05, 147, 20, 0, 0x0, 0 }, { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_BACKGROUND, 6, 35, 227, 20, 0, 0x0, 0 }, { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_CPU180, 6, 65, 215, 20, 0, 0x0, 0 }, { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_FLEXSKIN, 6, 95, 147, 20, 0, 0x0, 0 }, { TEXT_CreateIndirect, "[!! Restart the demonstration to apply the new settings !!]", ID_TEXT_WARNING, 6, 135, 300, 20, 0, 0x0, 0 }, ...}; static const GUI_WIDGET_CREATE_INFO _aDialogClockSettings[] = { { WINDOW_CreateIndirect, "Clock Settings", 0, 0, 0, 300, 180, FRAMEWIN_CF_MOVEABLE }, { SPINBOX_CreateIndirect, "Spinbox", ID_SPINBOX_HOUR, 160, 87, 37, 30, 0, 0x0, 0 }, { SPINBOX_CreateIndirect, "Spinbox", ID_SPINBOX_MINUTE, 200, 87, 36, 30, 0, 0x0, 0 }, { SPINBOX_CreateIndirect, "Spinbox", ID_SPINBOX_SEC, 239, 87, 37, 30, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Apply settings", ID_BUTTON_APPLYSETTINGS, 160, 122, 116, 37, 0, 0x0, 0 }, ...}; static const GUI_POINT aPoints[3][4] = { /* Hour Needle */ {{ 0 * AA_FACTOR, 2 * AA_FACTOR}, {-1 * AA_FACTOR,-4 * AA_FACTOR}, { 0 * AA_FACTOR,-6 * AA_FACTOR}, { 1 * AA_FACTOR,-4 * AA_FACTOR}...}, /* Min Needle */ {{ 0 * AA_FACTOR, 2 * AA_FACTOR}, {-1 * AA_FACTOR,-2 * AA_FACTOR}, { 0 * AA_FACTOR,-8 * AA_FACTOR}, { 1 * AA_FACTOR,-2 * AA_FACTOR}...}, /* Sec Needle */ {{0 * AA_FACTOR, 1 * AA_FACTOR}, { 1 * AA_FACTOR, 1 * AA_FACTOR}, { 1 * AA_FACTOR,-34 * AA_FACTOR}, {0 * AA_FACTOR,-34 * AA_FACTOR}...}, ...}; GUI_POINT aPointsDest[3][4]; Private variables /* Private functions ---------------------------------------------------------*/ /** * @brief Draw Needle * @param index: Needle index * @param x0: x position * @param y0: y position * @retval None *//* ... */ static void DrawNeedle(uint32_t index, uint16_t x0, uint16_t y0) { /* draw Needles */ if(index == 2) { GUI_SetColor(GUI_RED); GUI_AA_FillPolygon(aPointsDest[index], 4, AA_FACTOR * x0, AA_FACTOR * y0); }if (index == 2) { ... } else { GUI_SetColor(GUI_LIGHTBLUE); GUI_AA_FillPolygon(aPointsDest[index], 4, AA_FACTOR * x0, AA_FACTOR * y0); }else { ... } }{ ... } /** * @brief Update clock * @param x0: x position * @param y0: y position * @param hour: updated hour * @param min: updated minute * @param sec: updated second * @retval None *//* ... */ static void GUI_UpdateClock (uint16_t x0, uint16_t y0, uint8_t hour, uint8_t min, uint8_t sec) { int8_t i = 0; int32_t SinHQ, CosHQ ,a = 0; uint16_t xPos, yPos; GUI_AA_EnableHiRes(); GUI_AA_SetFactor(AA_FACTOR); GUI_SetColor(GUI_LIGHTGRAY); GUI_AA_DrawArc(AA_FACTOR * x0, AA_FACTOR * y0, AA_FACTOR * 39, AA_FACTOR * 39, 0, 360); GUI_SetColor(GUI_GRAY); GUI_AA_DrawArc(AA_FACTOR * x0, AA_FACTOR * y0, AA_FACTOR * 40, AA_FACTOR * 40, 0, 360); GUI_SetColor(GUI_WHITE); GUI_AA_FillCircle(AA_FACTOR * x0, AA_FACTOR * y0, AA_FACTOR * 38); GUI_SetBkColor(GUI_TRANSPARENT); GUI_SetBkColor(GUI_WHITE); GUI_SetColor(GUI_GRAY); GUI_DispStringAt("12", x0 - 5, y0 - 38 + 5); GUI_DispStringAt( "6", x0 - 2, y0 + 38 - 13); GUI_DispStringAt( "9", x0 - 38 + 5, y0 - 5); GUI_DispStringAt( "3", x0 + 38 - 10, y0 - 3); for (i = 0; i <= 12; i++) { a = i * 30000; SinHQ = GUI__SinHQ(a); CosHQ = GUI__CosHQ(a); xPos = x0 + ((36 * CosHQ) >> 16); yPos = y0 - ((36 * SinHQ) >> 16); GUI_AA_FillCircle(AA_FACTOR * xPos, AA_FACTOR * yPos, AA_FACTOR * 1); }for (i = 0; i <= 12; i++) { ... } GUI_MagnifyPolygon(aPointsDest[0], aPoints[0], 4, 4); GUI_RotatePolygon(aPointsDest[0], aPointsDest[0], 4, - 2 * PI * (float)((float)hour + (float)min /60) / 12); DrawNeedle(0, x0, y0); GUI_MagnifyPolygon(aPointsDest[1], aPoints[1], 4, 4); GUI_RotatePolygon(aPointsDest[1], aPointsDest[1], 4, - 2 * PI * (float)((float)min + (float)sec / 60) / 60); DrawNeedle(1, x0, y0); GUI_MagnifyPolygon(aPointsDest[2], aPoints[2], 4, 1); GUI_RotatePolygon(aPointsDest[2], aPointsDest[2], 4, - 2 * PI * sec / 60); DrawNeedle(2, x0, y0); GUI_AA_DisableHiRes(); }{ ... } /** * @brief callback for System Information * @param pMsg: Pointer to Date structure * @retval None *//* ... */ static void _cbSystemInformation(WM_MESSAGE * pMsg) { WM_HWIN hItem; char str[40]; hItem = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Initialization of 'Board : STM324xG' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_BOARD); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, GUI_DARKGRAY); /* Initialization of 'Core: STM32F-4 Series' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CORE); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, GUI_DARKGRAY); /* Initialization of 'CPU Speed : 168MHz' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CPU); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, GUI_DARKGRAY); /* Initialization of 'Firmware Version : 1.0' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_VERSION); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, GUI_DARKGRAY); strcpy(str, "Demo rev: 1.6.0"); TEXT_SetText(hItem, str); /* ST Copyright */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_COPYRIGHT); TEXT_SetFont(hItem, GUI_FONT_10_ASCII); TEXT_SetTextColor(hItem, GUI_DARKGRAY); /* Set ST Logo */ hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LOGO); IMAGE_SetBitmap(hItem, &bmSTLogo40x20); break;case WM_INIT_DIALOG: default: WM_DefaultProc(pMsg);default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief callback for General Settings * @param pMsg: Pointer to Date structure * @retval None *//* ... */ static void _cbGeneralSettings(WM_MESSAGE * pMsg) { WM_HWIN hItem; uint32_t tmp = 0; hItem = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP); /* Initialization of 'Checkbox' (sprite field) */ hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_SPRITES); CHECKBOX_SetFont(hItem, GUI_FONT_8_ASCII); CHECKBOX_SetText(hItem, "Enable Sprites"); WM_DisableWindow(hItem); /* Initialization of 'Checkbox' (Background field) */ hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_BACKGROUND); CHECKBOX_SetFont(hItem, GUI_FONT_8_ASCII); CHECKBOX_SetText(hItem, "Enable background mode"); CHECKBOX_SetState(hItem, settings.b.enable_background); WM_DisableWindow(hItem); /* Initialization of 'Checkbox' (CPU field) */ hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_CPU180); CHECKBOX_SetFont(hItem, GUI_FONT_8_ASCII); CHECKBOX_SetText(hItem, "Run CPU at 180 MHz"); WM_DisableWindow(hItem); /* Initialization of 'Checkbox' Flex skin */ hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_FLEXSKIN); CHECKBOX_SetFont(hItem, GUI_FONT_8_ASCII); CHECKBOX_SetText(hItem, "Disable Flex skin"); CHECKBOX_SetState(hItem, settings.b.disable_flex_skin); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING); TEXT_SetTextColor(hItem, GUI_DARKRED); break; case WM_INIT_DIALOG: case WM_DELETE: /* Save Setting before delete settings frame */ hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_SPRITES); settings.b.enable_sprite = CHECKBOX_IsChecked(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_BACKGROUND); settings.b.enable_background = CHECKBOX_IsChecked(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_CPU180); settings.b.use_180Mhz = CHECKBOX_IsChecked(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_FLEXSKIN); settings.b.disable_flex_skin = CHECKBOX_IsChecked(hItem); tmp = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP); /* check if new settings have to be saved */ if(settings.d32 != tmp) { k_BkupSaveParameter(CALIBRATION_GENERAL_SETTINGS_BKP, settings.d32); }if (settings.d32 != tmp) { ... } break; case WM_DELETE: default: WM_DefaultProc(pMsg);default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief callback for Clock Settings * @param pMsg: Pointer to Date structure * @retval None *//* ... */ static void _cbClockSettings(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; RTC_DateTypeDef Date; RTC_TimeTypeDef Time; static WM_HTIMER hTimerTime; static uint8_t DisableAutoRefresh = 0; static CALENDAR_DATE hDate; hItem = pMsg->hWin; switch (pMsg->MsgId) { case WM_TIMER: WM_InvalidateWindow(pMsg->hWin); WM_RestartTimer(pMsg->Data.v, 1000); break; case WM_TIMER: case WM_DELETE: WM_DeleteTimer(hTimerTime); DisableAutoRefresh = 0; break; case WM_DELETE: case WM_INIT_DIALOG: k_GetDate(&Date); hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 1000, 0); CALENDAR_Create(pMsg->hWin,12, 12, 2015 + Date.Year, Date.Month, Date.Date, 2, ID_CALENDAR, WM_CF_SHOW); CALENDAR_SetDefaultFont(CALENDAR_FI_CONTENT,GUI_FONT_10_1 ); CALENDAR_SetDefaultFont(CALENDAR_FI_HEADER, GUI_FONT_10_1); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_HOUR); SPINBOX_SetRange(hItem, 0, 23); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_MINUTE); SPINBOX_SetRange(hItem, 0, 59); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_SEC); SPINBOX_SetRange(hItem, 0, 59); break; case WM_INIT_DIALOG: case WM_PAINT: if(DisableAutoRefresh == 0) { k_GetTime(&Time); GUI_UpdateClock (220, 42, Time.Hours, Time.Minutes, Time.Seconds); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_HOUR); SPINBOX_SetValue(hItem, Time.Hours); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_MINUTE); SPINBOX_SetValue(hItem, Time.Minutes); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_SEC); SPINBOX_SetValue(hItem, Time.Seconds); }if (DisableAutoRefresh == 0) { ... } else { hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_HOUR); Time.Hours = SPINBOX_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_MINUTE); Time.Minutes = SPINBOX_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_SEC); Time.Seconds = SPINBOX_GetValue(hItem); GUI_UpdateClock (220, 42, Time.Hours, Time.Minutes, Time.Seconds); }else { ... } break; case WM_PAINT: case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_CLICKED: /* React only if released */ switch (Id) { case ID_SPINBOX_HOUR: case ID_SPINBOX_MINUTE: case ID_SPINBOX_SEC: if(DisableAutoRefresh == 0) { DisableAutoRefresh = 1; }if (DisableAutoRefresh == 0) { ... } break; case ID_SPINBOX_SEC: }switch (Id) { ... } break; case WM_NOTIFICATION_CLICKED: case WM_NOTIFICATION_RELEASED: switch (Id) { case ID_BUTTON_APPLYSETTINGS: hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_SEC); Time.Seconds = SPINBOX_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_MINUTE); Time.Minutes = SPINBOX_GetValue(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_HOUR); Time.Hours = SPINBOX_GetValue(hItem); k_SetTime(&Time); hItem = WM_GetDialogItem(pMsg->hWin, ID_CALENDAR); CALENDAR_GetSel (hItem, &hDate); if((hDate.Day > 0) && (hDate.Day <= 31) && (hDate.Month > 0)&& (hDate.Month <= 12) && (hDate.Year >= 1900)) { Date.Date = hDate.Day; Date.Month = hDate.Month; Date.Year = hDate.Year - 2015; Date.WeekDay = 0; k_SetDate(&Date); }if ((hDate.Day > 0) && (hDate.Day <= 31) && (hDate.Month > 0)&& (hDate.Month <= 12) && (hDate.Year >= 1900)) { ... } DisableAutoRefresh = 0; break; case ID_BUTTON_APPLYSETTINGS: }switch (Id) { ... } break;case WM_NOTIFICATION_RELEASED: }switch (NCode) { ... } break; case WM_NOTIFY_PARENT: default: WM_DefaultProc(pMsg);default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem, hDialog; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Initialization of 'System Information' */ hItem = pMsg->hWin; FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE); /* Create and attach the MULTIPAGE dialog windows */ hDialog = GUI_CreateDialogBox(_aDialogSystemInformation, GUI_COUNTOF(_aDialogSystemInformation), &_cbSystemInformation, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hItem, hDialog, "System Information"); hDialog = GUI_CreateDialogBox(_aDialogGeneralSettings, GUI_COUNTOF(_aDialogGeneralSettings), &_cbGeneralSettings, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hItem, hDialog, "General Settings"); hDialog = GUI_CreateDialogBox(_aDialogClockSettings, GUI_COUNTOF(_aDialogClockSettings), &_cbClockSettings, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hItem, hDialog, "Clock Settings"); MULTIPAGE_SelectPage(hItem, 0); break; case WM_INIT_DIALOG: default: WM_DefaultProc(pMsg); break;default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief System info window Startup * @param hWin: pointer to the parent handle. * @param xpos: X position * @param ypos: Y position * @retval None *//* ... */ static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos) { GUI_CreateDialogBox(_aDialog, GUI_COUNTOF(_aDialog), _cbDialog, hWin, xpos, ypos); }{ ... } /** * @} *//* ... */ /** * @} *//* ... */