This commit is contained in:
Renze Nicolai 2022-06-04 16:20:10 +02:00
parent fd5398e572
commit 04e6eb8ba3

View file

@ -22,6 +22,19 @@ void test_buttons(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9
bool btn_start = false; bool btn_start = false;
bool btn_accept = false; bool btn_accept = false;
bool btn_back = false; bool btn_back = false;
bool btn_joy_down_green = false;
bool btn_joy_up_green = false;
bool btn_joy_left_green = false;
bool btn_joy_right_green = false;
bool btn_joy_press_green = false;
bool btn_home_green = false;
bool btn_menu_green = false;
bool btn_select_green = false;
bool btn_start_green = false;
bool btn_accept_green = false;
bool btn_back_green = false;
while (!quit) { while (!quit) {
rp2040_input_message_t buttonMessage = {0}; rp2040_input_message_t buttonMessage = {0};
@ -32,36 +45,47 @@ void test_buttons(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9
switch(pin) { switch(pin) {
case RP2040_INPUT_JOYSTICK_DOWN: case RP2040_INPUT_JOYSTICK_DOWN:
btn_joy_down = value; btn_joy_down = value;
if (value) btn_joy_down_green = true;
break; break;
case RP2040_INPUT_JOYSTICK_UP: case RP2040_INPUT_JOYSTICK_UP:
btn_joy_up = value; btn_joy_up = value;
if (value) btn_joy_up_green = true;
break; break;
case RP2040_INPUT_JOYSTICK_LEFT: case RP2040_INPUT_JOYSTICK_LEFT:
btn_joy_left = value; btn_joy_left = value;
if (value) btn_joy_left_green = true;
break; break;
case RP2040_INPUT_JOYSTICK_RIGHT: case RP2040_INPUT_JOYSTICK_RIGHT:
btn_joy_right = value; btn_joy_right = value;
if (value) btn_joy_right_green = true;
break; break;
case RP2040_INPUT_JOYSTICK_PRESS: case RP2040_INPUT_JOYSTICK_PRESS:
btn_joy_press = value; btn_joy_press = value;
if (value) btn_joy_press_green = true;
break; break;
case RP2040_INPUT_BUTTON_HOME: case RP2040_INPUT_BUTTON_HOME:
btn_home = value; btn_home = value;
if (value) btn_home_green = true;
break; break;
case RP2040_INPUT_BUTTON_MENU: case RP2040_INPUT_BUTTON_MENU:
btn_menu = value; btn_menu = value;
if (value) btn_menu_green = true;
break; break;
case RP2040_INPUT_BUTTON_SELECT: case RP2040_INPUT_BUTTON_SELECT:
btn_select = value; btn_select = value;
if (value) btn_select_green = true;
break; break;
case RP2040_INPUT_BUTTON_START: case RP2040_INPUT_BUTTON_START:
btn_start = value; btn_start = value;
if (value) btn_start_green = true;
break; break;
case RP2040_INPUT_BUTTON_ACCEPT: case RP2040_INPUT_BUTTON_ACCEPT:
btn_accept = value; btn_accept = value;
if (value) btn_accept_green = true;
break; break;
case RP2040_INPUT_BUTTON_BACK: case RP2040_INPUT_BUTTON_BACK:
btn_back = value; btn_back = value;
if (value) btn_back_green = true;
default: default:
break; break;
} }
@ -73,27 +97,27 @@ void test_buttons(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*0, "Press HOME + START to exit"); pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*0, "Press HOME + START to exit");
char buffer[64]; char buffer[64];
snprintf(buffer, sizeof(buffer), "JOY DOWN %s", btn_joy_down ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "JOY DOWN %s", btn_joy_down ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*1, buffer); pax_draw_text(pax_buffer, btn_joy_down_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*1, buffer);
snprintf(buffer, sizeof(buffer), "JOY UP %s", btn_joy_up ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "JOY UP %s", btn_joy_up ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*2, buffer); pax_draw_text(pax_buffer, btn_joy_up_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*2, buffer);
snprintf(buffer, sizeof(buffer), "JOY LEFT %s", btn_joy_left ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "JOY LEFT %s", btn_joy_left ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*3, buffer); pax_draw_text(pax_buffer, btn_joy_right_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*3, buffer);
snprintf(buffer, sizeof(buffer), "JOY RIGHT %s", btn_joy_right ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "JOY RIGHT %s", btn_joy_right ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*4, buffer); pax_draw_text(pax_buffer, btn_joy_left_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*4, buffer);
snprintf(buffer, sizeof(buffer), "JOY PRESS %s", btn_joy_press ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "JOY PRESS %s", btn_joy_press ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*5, buffer); pax_draw_text(pax_buffer, btn_joy_press_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*5, buffer);
snprintf(buffer, sizeof(buffer), "BTN HOME %s", btn_home ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "BTN HOME %s", btn_home ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*6, buffer); pax_draw_text(pax_buffer, btn_home_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*6, buffer);
snprintf(buffer, sizeof(buffer), "BTN MENU %s", btn_menu ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "BTN MENU %s", btn_menu ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*7, buffer); pax_draw_text(pax_buffer, btn_menu_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*7, buffer);
snprintf(buffer, sizeof(buffer), "BTN SELECT %s", btn_select ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "BTN SELECT %s", btn_select ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*8, buffer); pax_draw_text(pax_buffer, btn_select_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*8, buffer);
snprintf(buffer, sizeof(buffer), "BTN START %s", btn_start ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "BTN START %s", btn_start ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*9, buffer); pax_draw_text(pax_buffer, btn_start_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*9, buffer);
snprintf(buffer, sizeof(buffer), "BTN A %s", btn_accept ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "BTN A %s", btn_accept ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*10, buffer); pax_draw_text(pax_buffer, btn_accept_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*10, buffer);
snprintf(buffer, sizeof(buffer), "BTN B %s", btn_back ? "PRESSED" : "released"); snprintf(buffer, sizeof(buffer), "BTN B %s", btn_back ? "PRESSED" : "released");
pax_draw_text(pax_buffer, 0xFFFFFFFF, NULL, 18, 0, 20*11, buffer); pax_draw_text(pax_buffer, btn_back_green ? 0xFF00FF00 : 0xFFFFFFFF, NULL, 18, 0, 20*11, buffer);
ili9341_write(ili9341, pax_buffer->buf); ili9341_write(ili9341, pax_buffer->buf);
render = false; render = false;
} }