move touch_position into apply_touch

This commit is contained in:
TT 2017-01-01 15:03:41 +09:00
parent ed6aeb873c
commit 1c3f2df97a

30
ui.c
View file

@ -218,7 +218,7 @@ int8_t last_touch_status = FALSE;
int16_t last_touch_x; int16_t last_touch_x;
int16_t last_touch_y; int16_t last_touch_y;
//int16_t touch_cal[4] = { 1000, 1000, 10*16, 12*16 }; //int16_t touch_cal[4] = { 1000, 1000, 10*16, 12*16 };
int16_t touch_cal[4] = { 630, 600, 130, 180 }; int16_t touch_cal[4] = { 620, 600, 130, 180 };
#define EVT_TOUCH_NONE 0 #define EVT_TOUCH_NONE 0
#define EVT_TOUCH_DOWN 1 #define EVT_TOUCH_DOWN 1
#define EVT_TOUCH_PRESSED 2 #define EVT_TOUCH_PRESSED 2
@ -780,10 +780,13 @@ menu_select_touch(int i)
} }
void void
menu_apply_touch(int touch_x, int touch_y) menu_apply_touch(void)
{ {
int touch_x, touch_y;
const menuitem_t *menu = menu_stack[menu_current_level]; const menuitem_t *menu = menu_stack[menu_current_level];
int i = 0; int i;
touch_position(&touch_x, &touch_y);
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (menu[i].type == MT_NONE) if (menu[i].type == MT_NONE)
break; break;
@ -971,9 +974,13 @@ keypad_click(int selection)
} }
int int
keypad_apply_touch(int touch_x, int touch_y) keypad_apply_touch(void)
{ {
int touch_x, touch_y;
int i = 0; int i = 0;
touch_position(&touch_x, &touch_y);
while (keypads[i].x) { while (keypads[i].x) {
if (keypads[i].x < touch_x && touch_x < keypads[i].x+44 if (keypads[i].x < touch_x && touch_x < keypads[i].x+44
&& keypads[i].y < touch_y && touch_y < keypads[i].y+44) { && keypads[i].y < touch_y && touch_y < keypads[i].y+44) {
@ -1021,9 +1028,7 @@ ui_process_keypad(void)
status = touch_check(); status = touch_check();
if (status == EVT_TOUCH_PRESSED) { if (status == EVT_TOUCH_PRESSED) {
int x, y; if (keypad_apply_touch()
touch_position(&x, &y);
if (keypad_apply_touch(x, y)
&& keypad_click(selection)) && keypad_click(selection))
/* exit loop on done or cancel */ /* exit loop on done or cancel */
break; break;
@ -1055,7 +1060,6 @@ ui_process_lever(void)
void ui_process_touch(void) void ui_process_touch(void)
{ {
extern int awd_count; extern int awd_count;
int x, y;
awd_count++; awd_count++;
adc_stop(ADC1); adc_stop(ADC1);
@ -1068,15 +1072,7 @@ void ui_process_touch(void)
break; break;
case UI_MENU: case UI_MENU:
touch_position(&x, &y); menu_apply_touch();
menu_apply_touch(x, y);
break;
case UI_KEYPAD:
#if 0
touch_position(&x, &y);
keypad_apply_touch(x, y);
#endif
break; break;
} }
} }