Smooth keyboard update

multi_trace
DiSlord 5 years ago committed by erikkaashoek
parent 394ded7c36
commit 22b2a4e3d3

24
ui.c

@ -961,12 +961,13 @@ void drawMessageBox(char *header, char *text, uint32_t delay){
} }
static void static void
draw_keypad(void) draw_keypad(uint32_t mask)
{ {
int i = 0; int i;
ui_button_t button; ui_button_t button;
button.fg = LCD_MENU_TEXT_COLOR; button.fg = LCD_MENU_TEXT_COLOR;
while (keypads[i].c >= 0) { for(i = 0; keypads[i].c >= 0; i++) {
if ((mask&(1<<i)) == 0) continue;
button.bg = LCD_MENU_COLOR; button.bg = LCD_MENU_COLOR;
if (i == selection){ if (i == selection){
button.bg = LCD_MENU_ACTIVE_COLOR; button.bg = LCD_MENU_ACTIVE_COLOR;
@ -987,7 +988,6 @@ draw_keypad(void)
x + (KP_WIDTH - wFONT_MAX_WIDTH*strlen(t)) / 2, x + (KP_WIDTH - wFONT_MAX_WIDTH*strlen(t)) / 2,
y + (KP_HEIGHT - wFONT_GET_HEIGHT) / 2); y + (KP_HEIGHT - wFONT_GET_HEIGHT) / 2);
} }
i++;
} }
} }
@ -1604,7 +1604,7 @@ ui_mode_keypad(int _keypad_mode)
ui_mode = UI_KEYPAD; ui_mode = UI_KEYPAD;
if (!current_menu_is_form()) if (!current_menu_is_form())
draw_menu(); draw_menu();
draw_keypad(); draw_keypad(-1);
draw_numeric_area_frame(); draw_numeric_area_frame();
ui_process_keypad(); ui_process_keypad();
} }
@ -1800,7 +1800,7 @@ ui_process_menu_lever(void)
//activate: //activate:
ensure_selection(); ensure_selection();
draw_menu_mask(mask|(1<<selection)); draw_menu_mask(mask|(1<<selection));
chThdSleepMilliseconds(50); // Add delay for not move so fast in menu chThdSleepMilliseconds(100); // Add delay for not move so fast in menu
} while ((status = btn_wait_release()) != 0); } while ((status = btn_wait_release()) != 0);
} }
} }
@ -1906,13 +1906,14 @@ keypad_apply_touch(void)
int x = KP_GET_X(keypads[i].x); int x = KP_GET_X(keypads[i].x);
int y = KP_GET_Y(keypads[i].y); int y = KP_GET_Y(keypads[i].y);
if (x < touch_x && touch_x < x+KP_WIDTH && y < touch_y && touch_y < y+KP_HEIGHT) { if (x < touch_x && touch_x < x+KP_WIDTH && y < touch_y && touch_y < y+KP_HEIGHT) {
uint32_t mask = (1<<i)|(1<<selection);
// draw focus // draw focus
selection = i; selection = i;
draw_keypad(); draw_keypad(mask);
touch_wait_release(); touch_wait_release();
// erase focus // erase focus
selection = -1; selection = -1;
draw_keypad(); draw_keypad((1<<i));
return i; return i;
} }
i++; i++;
@ -1933,15 +1934,16 @@ ui_process_keypad(void)
if (status & (EVT_UP|EVT_DOWN)) { if (status & (EVT_UP|EVT_DOWN)) {
int s = status; int s = status;
do { do {
uint32_t mask = (1<<selection);
if (s & EVT_UP) if (s & EVT_UP)
if (--selection < 0) if (--selection < 0)
selection = keypads_last_index; selection = keypads_last_index;
if (s & EVT_DOWN) if (s & EVT_DOWN)
if (++selection > keypads_last_index) if (++selection > keypads_last_index)
selection = 0; selection = 0;
draw_keypad(); draw_keypad(mask|(1<<selection));
s = btn_wait_release(); chThdSleepMilliseconds(100);
} while (s != 0); } while ((s = btn_wait_release()) != 0);
} }
if (status == EVT_BUTTON_SINGLE_CLICK) { if (status == EVT_BUTTON_SINGLE_CLICK) {

Loading…
Cancel
Save

Powered by TurnKey Linux.