imx233: fix debug screen button handling

The code was very primitive and did not handle release events properly.

Change-Id: I1c56005282a9fb6608f79ff3b483ba614d635fdb
This commit is contained in:
Amaury Pouly 2016-05-02 21:55:26 +01:00
parent 941ac165d8
commit 2dcc9fc39f

View file

@ -55,13 +55,8 @@
#define ACT_RIGHT 6 #define ACT_RIGHT 6
#define ACT_REPEAT 0x1000 #define ACT_REPEAT 0x1000
int my_get_action(int tmo) int xlate_button(int btn)
{ {
int btn = button_get_w_tmo(tmo);
while(btn & BUTTON_REL)
btn = button_get_w_tmo(tmo);
bool repeat = btn & BUTTON_REPEAT;
int act = ACT_NONE;
switch(btn) switch(btn)
{ {
case BUTTON_POWER: case BUTTON_POWER:
@ -72,8 +67,7 @@ int my_get_action(int tmo)
#else #else
#error no key for ACT_CANCEL #error no key for ACT_CANCEL
#endif #endif
act = ACT_CANCEL; return ACT_CANCEL;
break;
#if defined(BUTTON_SELECT) #if defined(BUTTON_SELECT)
case BUTTON_SELECT: case BUTTON_SELECT:
#elif defined(BUTTON_PLAY) #elif defined(BUTTON_PLAY)
@ -83,17 +77,28 @@ int my_get_action(int tmo)
#else #else
#error no key for ACT_OK #error no key for ACT_OK
#endif #endif
act = ACT_OK; return ACT_OK;
break;
case BUTTON_UP: case BUTTON_UP:
act = ACT_PREV; return ACT_PREV;
break;
case BUTTON_DOWN: case BUTTON_DOWN:
act = ACT_NEXT; return ACT_NEXT;
break;
default: default:
yield(); return ACT_NONE;
} }
}
int my_get_status(void)
{
return xlate_button(button_status());
}
int my_get_action(int tmo)
{
int btn = button_get_w_tmo(tmo);
while(btn & BUTTON_REL)
btn = button_get_w_tmo(tmo);
bool repeat = btn & BUTTON_REPEAT;
int act = xlate_button(btn & ~BUTTON_REPEAT);
if(repeat) if(repeat)
act |= ACT_REPEAT; act |= ACT_REPEAT;
return act; return act;
@ -217,7 +222,7 @@ bool dbg_hw_info_power(void)
bool en; bool en;
int linreg; int linreg;
char buf[16]; char buf[16];
lcd_putsf(0, line++, "name value bo linreg"); lcd_putsf(0, line++, "name value bo linreg");
#define DISP_REGULATOR(name) \ #define DISP_REGULATOR(name) \
imx233_power_get_regulator(REGULATOR_##name, &trg, &bo); \ imx233_power_get_regulator(REGULATOR_##name, &trg, &bo); \
@ -254,7 +259,7 @@ bool dbg_hw_info_power(void)
bool dbg_hw_info_lradc(void) bool dbg_hw_info_lradc(void)
{ {
lcd_setfont(FONT_SYSFIXED); lcd_setfont(FONT_SYSFIXED);
while(1) while(1)
{ {
int button = my_get_action(HZ / 25); int button = my_get_action(HZ / 25);
@ -679,7 +684,7 @@ bool dbg_hw_info_ocotp(void)
} }
if(i < top_user) if(i < top_user)
top_user = i - 1; top_user = i - 1;
lcd_update(); lcd_update();
yield(); yield();
} }