Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "DIALOG.h"
#include "k_module.h"
#include "camera_app.h"
#include "camera_res.c"
#include "k_modules_res.h"
#include "k_storage.h"
#include "k_rtc.h"
#include "k_mem.h"
Private defines
#define ID_WINDOW_0
#define ID_BUTTON_CLOSE
#define ID_BUTTON_CAPTURE
#define ID_BUTTON_SETTINGS
#define ID_RADIO
#define ID_IMAGE
#define ID_TEXT
#define ID_FRAMEWIN_0
#define ID_MULTIPAGE
#define ID_BUTTON_OK
#define ID_BUTTON_CANCEL
#define ID_TEXT_0
#define ID_TEXT_1
#define ID_TEXT_2
#define ID_SLIDER_0
#define ID_SLIDER_1
#define ID_TEXT_3
#define ID_TEXT_4
#define ID_FOLDER
#define ID_BROWSE
#define ID_FOLDER_CAPTION
Private variables
CameraSettings
CAMERA_hWin
hDialogCameraSettings
hDialogFileControl
hSettings
hCameraFrame
FrameAvailable
chooser_select_folder
capture_folder
camera_disabled
pFileInfo
apDrives
acMask_folder
_aDialogCreate
_aSettingsDialogCreate
_aDialogCameraSettings
_aDialogFileControl
frame0
Private function prototypes
camera_capture
_OnPaint_close(BUTTON_Handle)
_OnPaint_capture(BUTTON_Handle)
_OnPaint_settings(BUTTON_Handle)
_cbButton_close(WM_MESSAGE *)
_cbButton_capture(WM_MESSAGE *)
_cbButton_settings(WM_MESSAGE *)
_Check_DefaultPath(uint8_t *)
_cbCameraSettings(WM_MESSAGE *)
_cbFileControl(WM_MESSAGE *)
_cbSettingsDialog(WM_MESSAGE *)
_cbCameraWindow(WM_MESSAGE *)
_cbHint(WM_MESSAGE *)
_cbDialog(WM_MESSAGE *)
Startup(GUI_HWIN, uint16_t, uint16_t)
BSP_CAMERA_FrameEventCallback()
IsFrameAvailable()
Files
loading...
CodeScopeSTM32 Libraries and SamplesSTemWinModules/camera/camera_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
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file camera_win.c * @author MCD Application Team * @brief Camera functions source file ****************************************************************************** * @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 "camera_app.h" #include "camera_res.c" #include "k_modules_res.h" #include "k_storage.h" #include "k_rtc.h" #include "k_mem.h" 8 includes /** @addtogroup CAMERA_MODULE * @{ *//* ... */ /** @defgroup CAMERA * @brief camera routines * @{ *//* ... */ Includes /* External variables --------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/ #define ID_WINDOW_0 (GUI_ID_USER + 0x00) #define ID_BUTTON_CLOSE (GUI_ID_USER + 0x04) #define ID_BUTTON_CAPTURE (GUI_ID_USER + 0x05) #define ID_BUTTON_SETTINGS (GUI_ID_USER + 0x06) #define ID_RADIO (GUI_ID_USER + 0x07) #define ID_IMAGE (GUI_ID_USER + 0x08) #define ID_TEXT (GUI_ID_USER + 0x09) #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x10) #define ID_MULTIPAGE (GUI_ID_USER + 0x11) #define ID_BUTTON_OK (GUI_ID_USER + 0x12) #define ID_BUTTON_CANCEL (GUI_ID_USER + 0x13) #define ID_TEXT_0 (GUI_ID_USER + 0x20) #define ID_TEXT_1 (GUI_ID_USER + 0x21) #define ID_TEXT_2 (GUI_ID_USER + 0x22) #define ID_SLIDER_0 (GUI_ID_USER + 0x23) #define ID_SLIDER_1 (GUI_ID_USER + 0x24) #define ID_TEXT_3 (GUI_ID_USER + 0x25) #define ID_TEXT_4 (GUI_ID_USER + 0x26) #define ID_FOLDER (GUI_ID_USER + 0x30) #define ID_BROWSE (GUI_ID_USER + 0x31) #define ID_FOLDER_CAPTION (GUI_ID_USER + 0x32) 21 defines Private defines/* Private macros ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ CameraSettingsTypeDef CameraSettings; static WM_HWIN CAMERA_hWin, hDialogCameraSettings, hDialogFileControl, hSettings; WM_HWIN hCameraFrame; static __IO uint32_t FrameAvailable = 0; static WM_HWIN chooser_select_folder; static uint8_t capture_folder[FILEMGR_FULL_PATH_SIZE]; static uint8_t camera_disabled = 0; CHOOSEFILE_INFO *pFileInfo; static char const *apDrives[2] = {"0:", "1:"}; const char acMask_folder[] = ".dir"; static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { { WINDOW_CreateIndirect, "Camera", ID_WINDOW_0, 0, 0, 320, 215, 0, 0x0, 0 }, { RADIO_CreateIndirect, "Radio", ID_RADIO, 10, 77, 80, 138, 0, 0x1407, 0 }, { IMAGE_CreateIndirect, "Image", ID_IMAGE, 6, 2, 48, 48, 0, 0, 0 }, { TEXT_CreateIndirect, "Effects", ID_TEXT, 7, 52, 48, 20, 0, 0x0, 0 }, ...}; static const GUI_WIDGET_CREATE_INFO _aSettingsDialogCreate[] = { { FRAMEWIN_CreateIndirect, "Settings", ID_FRAMEWIN_0, 20, 10, 280, 170, 0, 0x0, 0 }, { MULTIPAGE_CreateIndirect, "Multipage", ID_MULTIPAGE, 10, 15, 190, 120, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "OK", ID_BUTTON_OK, 210, 18, 50, 50, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Cancel", ID_BUTTON_CANCEL, 210, 85, 50, 50, 0, 0x0, 0 } ...}; static const GUI_WIDGET_CREATE_INFO _aDialogCameraSettings[] = { { WINDOW_CreateIndirect, "", 0, 0, 0, 260, 140, FRAMEWIN_CF_MOVEABLE }, { TEXT_CreateIndirect, "Brightness", ID_TEXT_0, 20, 20, 63, 20, 0, 0x64, 0 }, { TEXT_CreateIndirect, "Contrast", ID_TEXT_1, 20, 60, 61, 20, 0, 0x0, 0 }, { SLIDER_CreateIndirect, "Slider_Br", ID_SLIDER_0, 100, 20, 80, 20, 0, 0x0, 0 }, { SLIDER_CreateIndirect, "Slider_Co", ID_SLIDER_1, 100, 60, 80, 20, 0, 0x0, 0 }, { TEXT_CreateIndirect, "-2 -1 0 1 2", ID_TEXT_3, 100, 05, 80, 20, 0, 0x0, 0 }, { TEXT_CreateIndirect, "-2 -1 0 1 2", ID_TEXT_4, 100, 45, 80, 20, 0, 0x64, 0 } ...}; static const GUI_WIDGET_CREATE_INFO _aDialogFileControl[] = { { WINDOW_CreateIndirect, "", 0, 0, 0, 260, 140, FRAMEWIN_CF_MOVEABLE }, { TEXT_CreateIndirect, "Capture Folder : ", ID_FOLDER_CAPTION, 15, 30, 120, 20, 0, 0x64, 0 }, { EDIT_CreateIndirect, "Edit", ID_FOLDER, 15, 50, 100, 20, 0, 0x64, 0 }, { BUTTON_CreateIndirect, "Browse", ID_BROWSE, 130, 50, 50, 20, 0, 0x0, 0 }, ...}; GUI_BITMAP frame0 = { 160, /* XSize */ 120, /* YSize */ 320, /* BytesPerLine */ 16, /* BitsPerPixel */ (unsigned char *)(CAMERA_FRAME_BUFFER), /* Pointer to picture data */ NULL, /* Pointer to palette */ GUI_DRAW_BMPM565 ...}; Private variables /* Private function prototypes -----------------------------------------------*/ static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos); static uint8_t IsFrameAvailable(void); K_ModuleItem_Typedef camera_capture = { 12, "Camera", &bmcamera, Startup, NULL, ...} ; Private function prototypes /* Private functions ---------------------------------------------------------*/ /** * @brief Paints Close button * @param hObj: button handle * @retval None *//* ... */ static void _OnPaint_close(BUTTON_Handle hObj) { int Index; GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor()); GUI_Clear(); Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0; if(Index) { GUI_DrawBitmap(&bmclose_pressed, 0, 0); }if (Index) { ... } else { GUI_DrawBitmap(&bmclose_not_pressed, 0, 0); }else { ... } }{ ... } /** * @brief Paints Capture button * @param hObj: button handle * @retval None *//* ... */ static void _OnPaint_capture(BUTTON_Handle hObj) { int Index; GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor()); GUI_Clear(); Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0; if(Index) { GUI_DrawBitmap(&bmcapturebutton_pressed, 0, 0); }if (Index) { ... } else { GUI_DrawBitmap(&bmcapturebutton_not_pressed, 0, 0); }else { ... } }{ ... } /** * @brief Paints Settings button * @param hObj: button handle * @retval None *//* ... */ static void _OnPaint_settings(BUTTON_Handle hObj) { int Index; GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor()); GUI_Clear(); Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0; if(Index) { GUI_DrawBitmap(&bmsettings_button_pressed, 0, 0); }if (Index) { ... } else { GUI_DrawBitmap(&bmsettings_button_not_pressed, 0, 0); }else { ... } }{ ... } /** * @brief callback for close button * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbButton_close(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_PAINT: _OnPaint_close(pMsg->hWin); break;case WM_PAINT: default: /* The original callback */ BUTTON_Callback(pMsg); break;default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief callback for Capture button * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbButton_capture(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_PAINT: _OnPaint_capture(pMsg->hWin); break;case WM_PAINT: default: /* The original callback */ BUTTON_Callback(pMsg); break;default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief callback for Settings button * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbButton_settings(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_PAINT: _OnPaint_settings(pMsg->hWin); break;case WM_PAINT: default: /* The original callback */ BUTTON_Callback(pMsg); break;default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief Set Default folder (saved in backup SRAM) * @param path : pointer to the Default folder * @retval None *//* ... */ static void _Check_DefaultPath (uint8_t *path) { if ((*((char *)(CAMERA_SAVE_PATH )) == '0') || (*((char *)(CAMERA_SAVE_PATH)) == '1')) { strncpy((char *)path, (char *)(CAMERA_SAVE_PATH), FILEMGR_FULL_PATH_SIZE); }if ((*((char *)(CAMERA_SAVE_PATH )) == '0') || (*((char *)(CAMERA_SAVE_PATH)) == '1')) { ... } else { strcpy((char *)path, "0:"); }else { ... } }{ ... } /** * @brief Callback function of the Camera Settings page * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbCameraSettings(WM_MESSAGE * pMsg) { WM_HWIN hItem; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Initialization of 'Brightness' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER); /* Initialization of 'Contrast' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER); /* Initialization of '-2 -1 0 1 2' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetFont(hItem, GUI_FONT_13_1); TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); /* Initialization of '-2 -1 0 1 2' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4); TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_0); SLIDER_SetRange(hItem, 1, 5); SLIDER_SetNumTicks(hItem, 5); if(CameraSettings.b.brightness == 0) { CameraSettings.b.brightness = 3; }if (CameraSettings.b.brightness == 0) { ... } SLIDER_SetValue(hItem, CameraSettings.b.brightness); hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_1); SLIDER_SetRange(hItem, 1, 5); SLIDER_SetNumTicks(hItem, 5); if(CameraSettings.b.contrast == 0) { CameraSettings.b.contrast = 3; }if (CameraSettings.b.contrast == 0) { ... } SLIDER_SetValue(hItem, CameraSettings.b.contrast); break;case WM_INIT_DIALOG: default: WM_DefaultProc(pMsg); break;default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief Callback function of the File Control page * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbFileControl(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; int result; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Initialization of 'Brightness' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_FOLDER_CAPTION); TEXT_SetFont(hItem, GUI_FONT_13B_1); hItem = WM_GetDialogItem(pMsg->hWin, ID_FOLDER); EDIT_SetText(hItem, (char *)capture_folder); break; case WM_INIT_DIALOG: case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BROWSE: /* Notifications sent by 'Radio' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_folder; chooser_select_folder = CHOOSEFILE_Create(CAMERA_hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Select a folder", 0, pFileInfo); WM_MakeModal(chooser_select_folder ); result = GUI_ExecCreatedDialog(chooser_select_folder); if (result == 0) { if(((pFileInfo->pRoot[0] == '0' ) || (pFileInfo->pRoot[0] == '1' ))) { hItem = WM_GetDialogItem(hDialogFileControl, ID_FOLDER); EDIT_SetText(hItem, (char *)pFileInfo->pRoot); chooser_select_folder = 0; WM_InvalidateWindow(hDialogFileControl); WM_Paint(hDialogFileControl); strncpy((char *)(CAMERA_SAVE_PATH),pFileInfo->pRoot , FILEMGR_FULL_PATH_SIZE); strncpy((char *)capture_folder,pFileInfo->pRoot , FILEMGR_FULL_PATH_SIZE); }if (((pFileInfo->pRoot[0] == '0' ) || (pFileInfo->pRoot[0] == '1' ))) { ... } }if (result == 0) { ... } break;case WM_NOTIFICATION_RELEASED: }switch (NCode) { ... } break;case ID_BROWSE: }switch (Id) { ... } break; case WM_NOTIFY_PARENT: default: WM_DefaultProc(pMsg); break;default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief Callback function of the Settings frame * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbSettingsDialog(WM_MESSAGE * pMsg) { int Id, NCode; WM_HWIN hItem; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Settings frame initialization */ hItem = pMsg->hWin; FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0); /* Create and attach the MULTIPAGE dialog windows */ hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE); hDialogCameraSettings = GUI_CreateDialogBox(_aDialogCameraSettings, GUI_COUNTOF(_aDialogCameraSettings), &_cbCameraSettings, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hItem, hDialogCameraSettings, "Camera Settings"); hDialogFileControl = GUI_CreateDialogBox(_aDialogFileControl, GUI_COUNTOF(_aDialogFileControl), &_cbFileControl, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hItem, hDialogFileControl, "File Settings"); MULTIPAGE_SelectPage(hItem, 0); /* 'OK' button initialization */ hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK); BUTTON_SetFont(hItem, GUI_FONT_13B_1); /* 'Cancel' button initialization */ hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL); BUTTON_SetFont(hItem, GUI_FONT_13B_1); break; case WM_INIT_DIALOG: case WM_DELETE: camera_disabled = 0; hSettings = 0; /* Delete choosfile window */ WM_DeleteWindow(chooser_select_folder); break; case WM_DELETE: case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { case ID_BUTTON_OK: /* Notification sent by "OK" button */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* Save camera settings before delete settings frame */ hItem = WM_GetDialogItem(hDialogCameraSettings, ID_SLIDER_0); CameraSettings.b.brightness = SLIDER_GetValue(hItem); hItem = WM_GetDialogItem(hDialogCameraSettings, ID_SLIDER_1); CameraSettings.b.contrast = SLIDER_GetValue(hItem); /* Back to normal mode (no effects) */ hItem = WM_GetDialogItem(CAMERA_hWin, ID_RADIO); RADIO_SetValue(hItem, 0); if(CAMERA_GetState() != CAMERA_ERROR) { /* Apply new settings*/ CAMERA_Set_ContrastBrightness(CameraSettings.b.contrast, CameraSettings.b.brightness); }if (CAMERA_GetState() != CAMERA_ERROR) { ... } GUI_EndDialog(pMsg->hWin, 0); break;case WM_NOTIFICATION_RELEASED: }switch (NCode) { ... } break;case ID_BUTTON_OK: case ID_BUTTON_CANCEL: /* Notification sent by "Cancel" button */ switch (NCode) { case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break;case WM_NOTIFICATION_RELEASED: }switch (NCode) { ... } break;case ID_BUTTON_CANCEL: }switch (Id) { ... } break;case WM_NOTIFY_PARENT: }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief Callback function of the Camera frame * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbCameraWindow(WM_MESSAGE * pMsg) { GUI_RECT r; switch (pMsg->MsgId) { case WM_CREATE: CAMERA_Init(); break; case WM_CREATE: case WM_PAINT: if(IsFrameAvailable() > 0) { GUI_DrawBitmap(&frame0, 0, 0); }if (IsFrameAvailable() > 0) { ... } else { WM_GetInsideRect(&r); GUI_ClearRectEx(&r); if(CAMERA_GetState() == CAMERA_ERROR) { GUI_DispStringAt("Error while Initializing Camera Interface", 45, 120); GUI_DispStringAt("Please, check if the camera module is mounted.", 35, 140); }if (CAMERA_GetState() == CAMERA_ERROR) { ... } }else { ... } break; case WM_PAINT: case WM_POST_PAINT: if(IsFrameAvailable() > 0) { if(camera_disabled == 0) { CAMERA_Resume(); }if (camera_disabled == 0) { ... } }if (IsFrameAvailable() > 0) { ... } break; case WM_POST_PAINT: default: WM_DefaultProc(pMsg);default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief Callback routine of informing user about exploring the disk * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbHint(WM_MESSAGE * pMsg) { GUI_RECT Rect; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_LIGHTBLUE); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font16_1HK); GUI_DispStringHCenterAt("Saving image...", 50 , 10); GUI_SetFont(GUI_DEFAULT_FONT); WM_GetClientRect(&Rect); GUI_SetColor(GUI_DARKGRAY); GUI_DrawRectEx(&Rect); break; case WM_PAINT: default: WM_DefaultProc(pMsg); break; 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, Hint; GUI_RECT r; int NCode, Id; uint32_t tmp_param = 0; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); CameraSettings.d32 = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP); /* Initialization of 'Image' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE); IMAGE_SetBitmap(hItem, &bmwizard); /* Initialization of 'Effects' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT); TEXT_SetFont(hItem, GUI_FONT_16B_1); /* Initialization of 'Radio' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO); RADIO_SetText(hItem, "None", 0); RADIO_SetText(hItem, "B&W", 1); RADIO_SetText(hItem, "Negative", 2); RADIO_SetText(hItem, "Antique", 3); RADIO_SetText(hItem, "Blue", 4); RADIO_SetText(hItem, "Green", 5); RADIO_SetText(hItem, "Red", 6); /* Camera frame initialization */ hItem = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hItem, &r); hCameraFrame = WM_CreateWindowAsChild(r.x0 + 79, r.y0 + 49, r.x1 - 159, r.y1 - 93, hItem, WM_CF_SHOW | WM_CF_LATE_CLIP, _cbCameraWindow, 0); /* Buttons initialization */ hItem = BUTTON_CreateEx(266, 175, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CLOSE); WM_SetCallback(hItem, _cbButton_close); hItem = BUTTON_CreateEx(256, 79, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CAPTURE); WM_SetCallback(hItem, _cbButton_capture); hItem = BUTTON_CreateEx(266, 14, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_SETTINGS); WM_SetCallback(hItem, _cbButton_settings); _Check_DefaultPath (capture_folder); FrameAvailable = 0; break; case WM_INIT_DIALOG: case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; if(hSettings == 0) { switch(Id) { case ID_RADIO: if(NCode == WM_NOTIFICATION_VALUE_CHANGED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO); if(CAMERA_GetState() != CAMERA_ERROR) { CAMERA_SelectEffect(RADIO_GetValue(hItem)); }if (CAMERA_GetState() != CAMERA_ERROR) { ... } }if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { ... } break;case ID_RADIO: case ID_BUTTON_CLOSE: /* Notifications sent by 'Close' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: k_free(pFileInfo); CAMERA_Stop(); GUI_EndDialog(pMsg->hWin, 0); break;case WM_NOTIFICATION_RELEASED: }switch (NCode) { ... } break;case ID_BUTTON_CLOSE: case ID_BUTTON_CAPTURE: /* Notifications sent by 'OK' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: /* Show Hint */ if(CAMERA_GetState() == CAMERA_OK) { Hint = WM_CreateWindowAsChild(100, 90, 120, 32, pMsg->hWin, WM_CF_SHOW , _cbHint, 0); GUI_Exec(); if(CAMERA_GetState() == CAMERA_OK) { CAMERA_SaveToFile(capture_folder); }if (CAMERA_GetState() == CAMERA_OK) { ... } WM_DeleteWindow(Hint); }if (CAMERA_GetState() == CAMERA_OK) { ... } break;case WM_NOTIFICATION_RELEASED: }switch (NCode) { ... } break;case ID_BUTTON_CAPTURE: case ID_BUTTON_SETTINGS: /* Notifications sent by 'Settings' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: camera_disabled = 1; hSettings = GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, CAMERA_hWin, 0, 0); break;case WM_NOTIFICATION_RELEASED: }switch (NCode) { ... } break;case ID_BUTTON_SETTINGS: }switch (Id) { ... } }if (hSettings == 0) { ... } break;case WM_NOTIFY_PARENT: case WM_DELETE: tmp_param = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP); /* check if new settings have to be saved */ if(CameraSettings.d32 != tmp_param) { k_BkupSaveParameter(CALIBRATION_CAMERA_SETTING_BKP, CameraSettings.d32); }if (CameraSettings.d32 != tmp_param) { ... } break; case WM_DELETE: default: WM_DefaultProc(pMsg); break;default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief Camera 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) { camera_disabled = 0; CAMERA_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, hWin, xpos, ypos); }{ ... } /** * @brief Frame Event callback. * @param None * @retval None *//* ... */ void BSP_CAMERA_FrameEventCallback(void) { CAMERA_Suspend(); if(FrameAvailable == 0) { FrameAvailable = 1; }if (FrameAvailable == 0) { ... } WM_InvalidateWindow(hCameraFrame); }{ ... } /** * @brief Check whether the first Frame is Ready * @param None * @retval Init status *//* ... */ static uint8_t IsFrameAvailable(void) { return FrameAvailable; }{ ... } /** * @} *//* ... */ /** * @} *//* ... */