1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
30
31
40
44
55
58
63
70
71
72
77
78
79
80
81
82
83
84
85
86
87
88
89
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
134
145
146
157
158
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
204
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
235
236
237
238
239
240
241
242
243
244
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
289
290
291
292
293
294
295
296
297
298
299
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
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
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
403
404
405
406
407
408
409
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
439
444
445
450
451
456
457
468
469
470
471
472
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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
562
569
576
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
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
680
687
694
701
702
703
706
707
/* ... */
#include "main.h"
/* ... */
/* ... */
Includes
#define CIRCLE_RADIUS 45
#define LINE_LENGHT 30
#ifndef TS_MULTI_TOUCH_SUPPORTED
#define TS_MULTI_TOUCH_SUPPORTED
#endif
Private define
#define CIRCLE_XPOS(i) ((i * BSP_LCD_GetXSize()) / 5)
#define CIRCLE_YPOS(i) (BSP_LCD_GetYSize() - CIRCLE_RADIUS - 60)
Private macro
typedef enum
{
TOUCHSCREEN_DEMO_1 = 1,
TOUCHSCREEN_DEMO_2 = 2,
TOUCHSCREEN_DEMO_3 = 3,
TOUCHSCREEN_DEMO_MAX = TOUCHSCREEN_DEMO_3,
...} TouchScreenDemoTypeDef;
Private Structures and Enumerations
TS_StateTypeDef TS_State = {0};
Global variables
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
static uint32_t touchscreen_color_idx = 0;/* ... */
#endif Private variables
static void Touchscreen_SetHint_Demo(TouchScreenDemoTypeDef demoIndex);
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
static uint32_t Touchscreen_Handle_NewTouch(void);
#endif
static void Touchscreen_DrawBackground_Demo1 (uint8_t state);
Private function prototypes
/* ... */
void Touchscreen_demo1(void)
{
uint16_t x1, y1;
uint8_t state = 0;
uint8_t exitTsUseCase = 0;
uint32_t ts_status = TS_OK;
TS_State.touchDetected = 0;
TS_State.touchX[0] = 0;
TS_State.touchY[0] = 0;
if (TouchScreen_IsCalibrationDone() == 0)
{
ts_status = Touchscreen_Calibration();
if(ts_status == TS_OK)
{
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 65, (uint8_t *)"Touchscreen calibration success.", CENTER_MODE);
}if (ts_status == TS_OK) { ... }
}if (TouchScreen_IsCalibrationDone() == 0) { ... }
if(ts_status == TS_OK)
{
Touchscreen_SetHint_Demo(TOUCHSCREEN_DEMO_1);
Touchscreen_DrawBackground_Demo1(state);
while (exitTsUseCase == 0)
{
if (ts_status == TS_OK)
{
ts_status = BSP_TS_GetState(&TS_State);
if(TS_State.touchDetected)
{
x1 = TouchScreen_Get_Calibrated_X(TS_State.touchX[0]);
y1 = TouchScreen_Get_Calibrated_Y(TS_State.touchY[0]);
if ((y1 > (CIRCLE_YPOS(1) - CIRCLE_RADIUS)) &&
(y1 < (CIRCLE_YPOS(1) + CIRCLE_RADIUS)))
{
if ((x1 > (CIRCLE_XPOS(1) - CIRCLE_RADIUS)) &&
(x1 < (CIRCLE_XPOS(1) + CIRCLE_RADIUS)))
{
if ((state & 1) == 0)
{
Touchscreen_DrawBackground_Demo1(state);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS);
state = 1;
}if ((state & 1) == 0) { ... }
}if ((x1 > (CIRCLE_XPOS(1) - CIRCLE_RADIUS)) && (x1 < (CIRCLE_XPOS(1) + CIRCLE_RADIUS))) { ... }
if ((x1 > (CIRCLE_XPOS(2) - CIRCLE_RADIUS)) &&
(x1 < (CIRCLE_XPOS(2) + CIRCLE_RADIUS)))
{
if ((state & 2) == 0)
{
Touchscreen_DrawBackground_Demo1(state);
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS);
state = 2;
}if ((state & 2) == 0) { ... }
}if ((x1 > (CIRCLE_XPOS(2) - CIRCLE_RADIUS)) && (x1 < (CIRCLE_XPOS(2) + CIRCLE_RADIUS))) { ... }
if ((x1 > (CIRCLE_XPOS(3) - CIRCLE_RADIUS)) &&
(x1 < (CIRCLE_XPOS(3) + CIRCLE_RADIUS)))
{
if ((state & 4) == 0)
{
Touchscreen_DrawBackground_Demo1(state);
BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS);
state = 4;
}if ((state & 4) == 0) { ... }
}if ((x1 > (CIRCLE_XPOS(3) - CIRCLE_RADIUS)) && (x1 < (CIRCLE_XPOS(3) + CIRCLE_RADIUS))) { ... }
if ((x1 > (CIRCLE_XPOS(4) - CIRCLE_RADIUS)) &&
(x1 < (CIRCLE_XPOS(4) + CIRCLE_RADIUS)))
{
if ((state & 8) == 0)
{
Touchscreen_DrawBackground_Demo1(state);
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(3), CIRCLE_RADIUS);
state = 8;
}if ((state & 8) == 0) { ... }
}if ((x1 > (CIRCLE_XPOS(4) - CIRCLE_RADIUS)) && (x1 < (CIRCLE_XPOS(4) + CIRCLE_RADIUS))) { ... }
}if ((y1 > (CIRCLE_YPOS(1) - CIRCLE_RADIUS)) && (y1 < (CIRCLE_YPOS(1) + CIRCLE_RADIUS))) { ... }
}if (TS_State.touchDetected) { ... }
}if (ts_status == TS_OK) { ... }
exitTsUseCase = CheckForUserInput();
HAL_Delay(20);
}while (exitTsUseCase == 0) { ... }
}if (ts_status == TS_OK) { ... }
}{ ... }
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
/* ... */
void Touchscreen_demo2(void)
{
uint8_t exitTsUseCase = 0;
uint32_t ts_status = TS_OK;
BSP_TEST_APPLI_ASSERT(BSP_TS_ResetTouchData(&TS_State));
if (TouchScreen_IsCalibrationDone() == 1)
{
}if (TouchScreen_IsCalibrationDone() == 1) { ... }
else
{
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 65, (uint8_t *)"ERROR : touchscreen not yet calibrated.", CENTER_MODE);
ts_status = TS_ERROR;
}else { ... }
if(ts_status == TS_OK)
{
Touchscreen_SetHint_Demo(TOUCHSCREEN_DEMO_2);
while (exitTsUseCase == 0)
{
Touchscreen_Handle_NewTouch();
exitTsUseCase = CheckForUserInput();
HAL_Delay(100);
}while (exitTsUseCase == 0) { ... }
}if (ts_status == TS_OK) { ... }
}{ ... }
/* ... */
void Touchscreen_demo3(void)
{
uint8_t exitTsUseCase = 0;
uint32_t ts_status = TS_OK;
BSP_TEST_APPLI_ASSERT(BSP_TS_ResetTouchData(&TS_State));
if (TouchScreen_IsCalibrationDone() == 0)
{
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 65, (uint8_t *)"ERROR : touchscreen not yet calibrated.", CENTER_MODE);
ts_status = TS_ERROR;
}if (TouchScreen_IsCalibrationDone() == 0) { ... }
if(ts_status == TS_OK)
{
Touchscreen_SetHint_Demo(TOUCHSCREEN_DEMO_3);
ts_status = BSP_TS_ITConfig();
BSP_TEST_APPLI_ASSERT(ts_status != TS_OK);
while (exitTsUseCase == 0)
{
if(exti5_received == 1)
{
exti5_received = 0;
Touchscreen_Handle_NewTouch();
}if (exti5_received == 1) { ... }
exitTsUseCase = CheckForUserInput();
HAL_Delay(10);
}while (exitTsUseCase == 0) { ... }
}if (ts_status == TS_OK) { ... }
}{ ... }
/* ... */
static uint32_t Touchscreen_Handle_NewTouch(void)
{
#define TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS 15
#define TOUCH_INFO_STRING_SIZE 70
uint16_t x1 = 0;
uint16_t y1 = 0;
uint16_t x2 = 0;
uint16_t y2 = 0;
uint32_t drawTouch1 = 0;
uint32_t drawTouch2 = 0;
uint32_t colors[24] = {LCD_COLOR_BLUE, LCD_COLOR_GREEN, LCD_COLOR_RED, LCD_COLOR_CYAN, LCD_COLOR_MAGENTA, LCD_COLOR_YELLOW,
LCD_COLOR_LIGHTBLUE, LCD_COLOR_LIGHTGREEN, LCD_COLOR_LIGHTRED, LCD_COLOR_LIGHTCYAN, LCD_COLOR_LIGHTMAGENTA,
LCD_COLOR_LIGHTYELLOW, LCD_COLOR_DARKBLUE, LCD_COLOR_DARKGREEN, LCD_COLOR_DARKRED, LCD_COLOR_DARKCYAN,
LCD_COLOR_DARKMAGENTA, LCD_COLOR_DARKYELLOW, LCD_COLOR_LIGHTGRAY, LCD_COLOR_GRAY, LCD_COLOR_DARKGRAY,
LCD_COLOR_BLACK, LCD_COLOR_BROWN, LCD_COLOR_ORANGE ...};
uint32_t ts_status = TS_OK;
uint8_t lcd_string[TOUCH_INFO_STRING_SIZE] = "";
ts_status = BSP_TS_GetState(&TS_State);
if(TS_State.touchDetected)
{
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillRect(0, 80, BSP_LCD_GetXSize(), BSP_LCD_GetYSize() - 160);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize() - 180);
BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize() - 182);
BSP_LCD_FillRect(0, BSP_LCD_GetYSize() - 80, BSP_LCD_GetXSize(), 80);
drawTouch1 = drawTouch2 = 0;
x1 = TouchScreen_Get_Calibrated_X(TS_State.touchX[0]);
y1 = TouchScreen_Get_Calibrated_Y(TS_State.touchY[0]);
if((y1 > (90 + TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS)) &&
(y1 < (BSP_LCD_GetYSize() - 90 - TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS)))
{
drawTouch1 = 1;
}if ((y1 > (90 + TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS)) && (y1 < (BSP_LCD_GetYSize() - 90 - TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS))) { ... }
if(drawTouch1 == 1)
{
BSP_LCD_SetTextColor(colors[(touchscreen_color_idx++ % 24)]);
BSP_LCD_FillCircle(x1, y1, TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_SetFont(&Font16);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 70, (uint8_t *)"TOUCH INFO : ", CENTER_MODE);
BSP_LCD_SetFont(&Font12);
sprintf((char*)lcd_string, "x1 = %d, y1 = %d, Event = %s, Weight = %d",
x1,
y1,
ts_event_string_tab[TS_State.touchEventId[0]],
TS_State.touchWeight[0]);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 45, lcd_string, CENTER_MODE);
}if (drawTouch1 == 1) { ... }
if(TS_State.touchDetected > 1)
{
x2 = TouchScreen_Get_Calibrated_X(TS_State.touchX[1]);
y2 = TouchScreen_Get_Calibrated_Y(TS_State.touchY[1]);
if((y2 > (90 + TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS)) &&
(y2 < (BSP_LCD_GetYSize() - 90 - TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS)))
{
drawTouch2 = 1;
}if ((y2 > (90 + TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS)) && (y2 < (BSP_LCD_GetYSize() - 90 - TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS))) { ... }
if(drawTouch2 == 1)
{
sprintf((char*)lcd_string, "x2 = %d, y2 = %d, Event = %s, Weight = %d",
x2,
y2,
ts_event_string_tab[TS_State.touchEventId[1]],
TS_State.touchWeight[1]);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 35, lcd_string, CENTER_MODE);
BSP_LCD_SetTextColor(colors[(touchscreen_color_idx++ % 24)]);
BSP_LCD_FillCircle(x2, y2, TS_MULTITOUCH_FOOTPRINT_CIRCLE_RADIUS);
}if (drawTouch2 == 1) { ... }
}if (TS_State.touchDetected > 1) { ... }
if((drawTouch1 == 1) || (drawTouch2 == 1))
{
ts_status = BSP_TS_Get_GestureId(&TS_State);
sprintf((char*)lcd_string, "Gesture Id = %s", ts_gesture_id_string_tab[TS_State.gestureId]);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 15, lcd_string, CENTER_MODE);
}if ((drawTouch1 == 1) || (drawTouch2 == 1)) { ... }
else
{
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 70, (uint8_t *)"Invalid touch position : use drawn touch area : ", CENTER_MODE);
}else { ... }
}if (TS_State.touchDetected) { ... }
return(ts_status);
}{ ... }
/* ... */#endif
/* ... */
uint8_t TouchScreen_GetTouchPosition(void)
{
uint16_t x1, y1;
uint8_t circleNr = 0;
BSP_TS_GetState(&TS_State);
if(TS_State.touchDetected)
{
x1 = TouchScreen_Get_Calibrated_X(TS_State.touchX[0]);
y1 = TouchScreen_Get_Calibrated_Y(TS_State.touchY[0]);
if ((y1 > (CIRCLE_YPOS(1) - CIRCLE_RADIUS)) &&
(y1 < (CIRCLE_YPOS(1) + CIRCLE_RADIUS)))
{
if ((x1 > (CIRCLE_XPOS(1) - CIRCLE_RADIUS)) &&
(x1 < (CIRCLE_XPOS(1) + CIRCLE_RADIUS)))
{
circleNr = 1;
}if ((x1 > (CIRCLE_XPOS(1) - CIRCLE_RADIUS)) && (x1 < (CIRCLE_XPOS(1) + CIRCLE_RADIUS))) { ... }
if ((x1 > (CIRCLE_XPOS(2) - CIRCLE_RADIUS)) &&
(x1 < (CIRCLE_XPOS(2) + CIRCLE_RADIUS)))
{
circleNr = 2;
}if ((x1 > (CIRCLE_XPOS(2) - CIRCLE_RADIUS)) && (x1 < (CIRCLE_XPOS(2) + CIRCLE_RADIUS))) { ... }
if ((x1 > (CIRCLE_XPOS(3) - CIRCLE_RADIUS)) &&
(x1 < (CIRCLE_XPOS(3) + CIRCLE_RADIUS)))
{
circleNr = 3;
}if ((x1 > (CIRCLE_XPOS(3) - CIRCLE_RADIUS)) && (x1 < (CIRCLE_XPOS(3) + CIRCLE_RADIUS))) { ... }
if ((x1 > (CIRCLE_XPOS(4) - CIRCLE_RADIUS)) &&
(x1 < (CIRCLE_XPOS(4) + CIRCLE_RADIUS)))
{
circleNr = 4;
}if ((x1 > (CIRCLE_XPOS(4) - CIRCLE_RADIUS)) && (x1 < (CIRCLE_XPOS(4) + CIRCLE_RADIUS))) { ... }
}if ((y1 > (CIRCLE_YPOS(1) - CIRCLE_RADIUS)) && (y1 < (CIRCLE_YPOS(1) + CIRCLE_RADIUS))) { ... }
else
{
if (y1 < (CIRCLE_YPOS(1) - 2*CIRCLE_RADIUS))
{
circleNr = 0xFE;
}if (y1 < (CIRCLE_YPOS(1) - 2*CIRCLE_RADIUS)) { ... }
else
{
circleNr = 0xFF;
}else { ... }
}else { ... }
}if (TS_State.touchDetected) { ... }
return circleNr;
}{ ... }
/* ... */
static void Touchscreen_SetHint_Demo(TouchScreenDemoTypeDef demoIndex)
{
if(demoIndex <= TOUCHSCREEN_DEMO_MAX)
{
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
BSP_LCD_SetFont(&Font24);
if(demoIndex == TOUCHSCREEN_DEMO_1)
{
BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Touchscreen basic polling", CENTER_MODE);
BSP_LCD_SetFont(&Font12);
BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)"Please use the Touchscreen to", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"activate the colored circle", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"inside the rectangle", CENTER_MODE);
}if (demoIndex == TOUCHSCREEN_DEMO_1) { ... }
else if (demoIndex == TOUCHSCREEN_DEMO_2)
{
BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Touchscreen dual touch polling", CENTER_MODE);
BSP_LCD_SetFont(&Font12);
BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)"Please press the Touchscreen to", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"activate single and", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"dual touch", CENTER_MODE);
}else if (demoIndex == TOUCHSCREEN_DEMO_2) { ... }
else
{
BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Touchscreen dual touch interrupt", CENTER_MODE);
BSP_LCD_SetFont(&Font12);
BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)"Please press the Touchscreen to", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"activate single and", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"dual touch", CENTER_MODE);
}else { ... }
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize() - 100);
BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize() - 102);
}if (demoIndex <= TOUCHSCREEN_DEMO_MAX) { ... }
}{ ... }
/* ... */
void Touchscreen_DrawBackground_Circle_Buttons (uint8_t state)
{
uint16_t x, y;
switch (state)
{
case 0:
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(3), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(3), CIRCLE_RADIUS - 2);
break;
case 0:
case 1:
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS - 2);
break;
case 1:
case 2:
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS - 2);
break;
case 2:
case 4:
BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS - 2);
break;
case 4:
case 8:
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(4), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(4), CIRCLE_RADIUS - 2);
break;
case 8:
case 16:
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(3), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(3), CIRCLE_RADIUS - 2);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_DrawHLine(CIRCLE_XPOS(1)-LINE_LENGHT, CIRCLE_YPOS(1), 2*LINE_LENGHT);
BSP_LCD_DrawHLine(CIRCLE_XPOS(2)-LINE_LENGHT, CIRCLE_YPOS(2), 2*LINE_LENGHT);
BSP_LCD_DrawVLine(CIRCLE_XPOS(2), CIRCLE_YPOS(2)-LINE_LENGHT, 2*LINE_LENGHT);
BSP_LCD_DrawHLine(CIRCLE_XPOS(3)-LINE_LENGHT, CIRCLE_YPOS(3), 2*LINE_LENGHT);
BSP_LCD_DrawHLine(CIRCLE_XPOS(4)-LINE_LENGHT, CIRCLE_YPOS(4), 2*LINE_LENGHT);
BSP_LCD_DrawVLine(CIRCLE_XPOS(4), CIRCLE_YPOS(4)-LINE_LENGHT, 2*LINE_LENGHT);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetFont(&Font24);
x = CIRCLE_XPOS(1);
y = CIRCLE_YPOS(1) - CIRCLE_RADIUS - BSP_LCD_GetFont()->Height;
BSP_LCD_DisplayStringAt(x, y, (uint8_t *)"Volume", CENTER_MODE);
x = CIRCLE_XPOS(4);
y = CIRCLE_YPOS(4) - CIRCLE_RADIUS - BSP_LCD_GetFont()->Height;
BSP_LCD_DisplayStringAt(x, y, (uint8_t *)"Frequency", CENTER_MODE);
break;
case 16:
case 32:
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS - 2);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetFont(&Font20);
x = CIRCLE_XPOS(1) - 10;
y = CIRCLE_YPOS(1) - (BSP_LCD_GetFont()->Height)/2;
BSP_LCD_DisplayStringAt(x, y, (uint8_t *)"Up", LEFT_MODE);
x = CIRCLE_XPOS(2) - 10;
y = CIRCLE_YPOS(3) - (BSP_LCD_GetFont()->Height)/2;
BSP_LCD_DisplayStringAt(x, y, (uint8_t *)"Dw", LEFT_MODE);
BSP_LCD_SetFont(&Font12);
break;
case 32:
}switch (state) { ... }
}{ ... }
/* ... */
static void Touchscreen_DrawBackground_Demo1 (uint8_t state)
{
switch (state)
{
case 0:
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(3), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS - 2);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(3), CIRCLE_RADIUS - 2);
break;
case 0:
case 1:
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(1), CIRCLE_YPOS(1), CIRCLE_RADIUS - 2);
break;
case 1:
case 2:
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(2), CIRCLE_YPOS(2), CIRCLE_RADIUS - 2);
break;
case 2:
case 4:
BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(3), CIRCLE_YPOS(3), CIRCLE_RADIUS - 2);
break;
case 4:
case 8:
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(4), CIRCLE_RADIUS);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(CIRCLE_XPOS(4), CIRCLE_YPOS(4), CIRCLE_RADIUS - 2);
break;
case 8:
}switch (state) { ... }
}{ ... }
/* ... */
/* ... */