User guide

SFSU - Embedded Systems Tutorial Nano- Electronics & Computing Research Lab
82
For touch display, different cases are referred for each option selected, which is discussed in
the next section.
alt_touchscreen_get_pen(screen, (&pen_data.pen_down), (&pen_data.x), (&pen_data.y));
if (PtInRect(&rcPlus, pen_data.x, pen_data.y)){
select = 0;
}
if (PtInRect(&rcMinus, pen_data.x, pen_data.y)){
select = 1;
}
if (PtInRect(&rcAnd, pen_data.x, pen_data.y)){
select = 2;
}
if (PtInRect(&rcOr, pen_data.x, pen_data.y)){
select = 3;
}
For different ALU options, case statements are used.
switch (select)
{
case 0:
result = number1 + number2;
sprintf (szText,"%d (+) %d = %d ",number1,number2,result);
printf ("%d + %d = %d ",number1,number2,result);
vid_print_string_alpha(400, 300, COLOR_WHITE, COLOR_BLACK, tahomabold_20, display,
szText);
break;
case 1:
result = number1 - number2;
sprintf (szText,"%d (-) %d = %d ",number1,number2,result);
printf ("%d - %d = %d ",number1,number2,result);
vid_print_string_alpha(400, 300, COLOR_WHITE, COLOR_BLACK, tahomabold_20, display,
szText);
break;
case 2:
result = number1 & number2;
sprintf (szText,"%d (&) %d = %d ",number1,number2,result);
printf ("%d & %d = %d ",number1,number2,result);
vid_print_string_alpha(400, 300, COLOR_WHITE, COLOR_BLACK, tahomabold_20, display,