mirror of
https://github.com/badgeteam/mch2022-template-app.git
synced 2024-12-22 23:26:36 +00:00
commit
19c6a589e2
6 changed files with 41 additions and 38 deletions
|
@ -142,13 +142,10 @@ void file_browser(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9
|
|||
closedir(dir);
|
||||
|
||||
bool render = true;
|
||||
bool renderbg = true;
|
||||
bool exit = false;
|
||||
file_browser_menu_args_t* menuArgs = NULL;
|
||||
|
||||
pax_background(pax_buffer, 0xFFFFFF);
|
||||
pax_noclip(pax_buffer);
|
||||
pax_draw_text(pax_buffer, 0xFF000000, NULL, 18, 5, 240 - 19, "[A] install [B] back");
|
||||
|
||||
while (1) {
|
||||
rp2040_input_message_t buttonMessage = {0};
|
||||
if (xQueueReceive(buttonQueue, &buttonMessage, 16 / portTICK_PERIOD_MS) == pdTRUE) {
|
||||
|
@ -171,6 +168,7 @@ void file_browser(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9
|
|||
if (value) {
|
||||
menuArgs = pd_args;
|
||||
}
|
||||
break;
|
||||
case RP2040_INPUT_BUTTON_ACCEPT:
|
||||
case RP2040_INPUT_JOYSTICK_PRESS:
|
||||
if (value) {
|
||||
|
@ -185,8 +183,15 @@ void file_browser(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9
|
|||
}
|
||||
}
|
||||
|
||||
if (renderbg) {
|
||||
pax_background(pax_buffer, 0xFFFFFF);
|
||||
pax_noclip(pax_buffer);
|
||||
pax_draw_text(pax_buffer, 0xFF000000, NULL, 18, 5, 240 - 19, "[A] install [B] back");
|
||||
renderbg = false;
|
||||
}
|
||||
|
||||
if (render) {
|
||||
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF72008a);
|
||||
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF000000);
|
||||
ili9341_write(ili9341, pax_buffer->buf);
|
||||
render = false;
|
||||
}
|
||||
|
@ -201,6 +206,7 @@ void file_browser(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9
|
|||
}
|
||||
menuArgs = NULL;
|
||||
render = true;
|
||||
renderbg = true;
|
||||
}
|
||||
|
||||
if (exit) {
|
||||
|
|
|
@ -480,9 +480,7 @@ static bool run_test(ICE40* ice40, pax_buf_t* pax_buffer, const pax_font_t *font
|
|||
} while (0)
|
||||
|
||||
|
||||
static void
|
||||
run_all_tests(xQueueHandle buttonQueue, ICE40* ice40, pax_buf_t* pax_buffer, ILI9341* ili9341)
|
||||
{
|
||||
bool run_fpga_tests(xQueueHandle buttonQueue, ICE40* ice40, pax_buf_t* pax_buffer, ILI9341* ili9341) {
|
||||
const pax_font_t *font;
|
||||
int line = 0;
|
||||
bool ok = true;
|
||||
|
@ -510,23 +508,23 @@ run_all_tests(xQueueHandle buttonQueue, ICE40* ice40, pax_buf_t* pax_buffer, ILI
|
|||
RUN_TEST("PMOD open", test_pmod_open);
|
||||
|
||||
/* Show instructions for interactive test */
|
||||
pax_draw_text(pax_buffer, 0xffc0c0c0, font, 9, 25, 20*line+ 0, "Insert PMOD plug");
|
||||
/*pax_draw_text(pax_buffer, 0xffc0c0c0, font, 9, 25, 20*line+ 0, "Insert PMOD plug");
|
||||
pax_draw_text(pax_buffer, 0xffc0c0c0, font, 9, 25, 20*line+10, "Then press button for interactive test");
|
||||
pax_draw_text(pax_buffer, 0xffc0c0c0, font, 9, 25, 20*line+20, " - Check LCD color bars");
|
||||
pax_draw_text(pax_buffer, 0xffc0c0c0, font, 9, 25, 20*line+30, " - Then LCD & RGB led color cycling");
|
||||
ili9341_write(ili9341, pax_buffer->buf);
|
||||
ili9341_write(ili9341, pax_buffer->buf);*/
|
||||
|
||||
/* Wait for button */
|
||||
wait_button(buttonQueue);
|
||||
//wait_button(buttonQueue);
|
||||
|
||||
/* Clear the instructions from buffer */
|
||||
pax_draw_rect(pax_buffer, 0xff8060f0, 0, 20*line, 320, 240-20*line);
|
||||
//pax_draw_rect(pax_buffer, 0xff8060f0, 0, 20*line, 320, 240-20*line);
|
||||
|
||||
/* Handover LCD to FPGA */
|
||||
ili9341_deinit(ili9341);
|
||||
|
||||
/* Run interactive tests */
|
||||
RUN_TEST("PMOD plug", test_pmod_plug);
|
||||
//RUN_TEST("PMOD plug", test_pmod_plug);
|
||||
RUN_TEST("LCD init", test_lcd_init);
|
||||
|
||||
/* Wait a second (for user to see color bars) */
|
||||
|
@ -536,7 +534,9 @@ run_all_tests(xQueueHandle buttonQueue, ICE40* ice40, pax_buf_t* pax_buffer, ILI
|
|||
soc_message(ice40, SOC_CMD_LCD_RGB_CYCLE_SET, 1, NULL, 0);
|
||||
|
||||
/* Wait for button */
|
||||
wait_button(buttonQueue);
|
||||
if (!wait_button(buttonQueue)) {
|
||||
ok = false;
|
||||
}
|
||||
|
||||
/* Stop LCD / RGB cycling */
|
||||
soc_message(ice40, SOC_CMD_LCD_RGB_CYCLE_SET, 0, NULL, 0);
|
||||
|
@ -550,21 +550,19 @@ error:
|
|||
|
||||
/* Pass / Fail result on screen */
|
||||
if (ok)
|
||||
pax_draw_text(pax_buffer, 0xff00ff00, font, 36, 100, 20*line, "PASS");
|
||||
pax_draw_text(pax_buffer, 0xff00ff00, font, 36, 0, 20*line, "FPGA PASS");
|
||||
else
|
||||
pax_draw_text(pax_buffer, 0xffff0000, font, 36, 100, 20*line, "FAIL");
|
||||
pax_draw_text(pax_buffer, 0xffff0000, font, 36, 0, 20*line, "FPGA FAIL");
|
||||
|
||||
ili9341_write(ili9341, pax_buffer->buf);
|
||||
|
||||
/* Done, just wait for button */
|
||||
wait_button(buttonQueue);
|
||||
|
||||
/* Cleanup */
|
||||
ice40_disable(ice40);
|
||||
|
||||
return;
|
||||
return ok;
|
||||
}
|
||||
|
||||
void fpga_test(xQueueHandle buttonQueue, ICE40* ice40, pax_buf_t* pax_buffer, ILI9341* ili9341) {
|
||||
run_all_tests(buttonQueue, ice40, pax_buffer, ili9341);
|
||||
run_fpga_tests(buttonQueue, ice40, pax_buffer, ili9341);
|
||||
wait_button(buttonQueue);
|
||||
}
|
||||
|
|
29
main/main.c
29
main/main.c
|
@ -102,9 +102,9 @@ void app_main(void) {
|
|||
esp_restart();
|
||||
}
|
||||
|
||||
audio_init();
|
||||
display_boot_screen(pax_buffer, ili9341, "Starting...");
|
||||
|
||||
display_boot_screen(pax_buffer, ili9341, "Initializing RP2040...");
|
||||
audio_init();
|
||||
|
||||
if (bsp_rp2040_init() != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize the RP2040 co-processor");
|
||||
|
@ -120,16 +120,14 @@ void app_main(void) {
|
|||
|
||||
rp2040_updater(rp2040, pax_buffer, ili9341); // Handle RP2040 firmware update & bootloader mode
|
||||
|
||||
uint8_t rp2040_uid[8];
|
||||
/*uint8_t rp2040_uid[8];
|
||||
if (rp2040_get_uid(rp2040, rp2040_uid) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to get RP2040 UID");
|
||||
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "Failed to read UID", NULL, NULL);
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
printf("RP2040 UID: %02X%02X%02X%02X%02X%02X%02X%02X\n", rp2040_uid[0], rp2040_uid[1], rp2040_uid[2], rp2040_uid[3], rp2040_uid[4], rp2040_uid[5], rp2040_uid[6], rp2040_uid[7]);
|
||||
|
||||
display_boot_screen(pax_buffer, ili9341, "Initializing ICE40...");
|
||||
printf("RP2040 UID: %02X%02X%02X%02X%02X%02X%02X%02X\n", rp2040_uid[0], rp2040_uid[1], rp2040_uid[2], rp2040_uid[3], rp2040_uid[4], rp2040_uid[5], rp2040_uid[6], rp2040_uid[7]);*/
|
||||
|
||||
if (bsp_ice40_init() != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize the ICE40 FPGA");
|
||||
|
@ -143,7 +141,7 @@ void app_main(void) {
|
|||
esp_restart();
|
||||
}
|
||||
|
||||
display_boot_screen(pax_buffer, ili9341, "Initializing BNO055...");
|
||||
/*display_boot_screen(pax_buffer, ili9341, "Initializing BNO055...");
|
||||
|
||||
if (bsp_bno055_init() != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize the BNO055 position sensor");
|
||||
|
@ -155,9 +153,9 @@ void app_main(void) {
|
|||
if (bno055 == NULL) {
|
||||
ESP_LOGE(TAG, "bno055 is NULL");
|
||||
esp_restart();
|
||||
}
|
||||
}*/
|
||||
|
||||
display_boot_screen(pax_buffer, ili9341, "Initializing BME680...");
|
||||
/*display_boot_screen(pax_buffer, ili9341, "Initializing BME680...");
|
||||
|
||||
if (bsp_bme680_init() != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize the BME680 position sensor");
|
||||
|
@ -169,9 +167,9 @@ void app_main(void) {
|
|||
if (bme680 == NULL) {
|
||||
ESP_LOGE(TAG, "bme680 is NULL");
|
||||
esp_restart();
|
||||
}
|
||||
}*/
|
||||
|
||||
display_boot_screen(pax_buffer, ili9341, "Initializing AppFS...");
|
||||
//display_boot_screen(pax_buffer, ili9341, "Initializing AppFS...");
|
||||
|
||||
/* Start AppFS */
|
||||
res = appfs_init();
|
||||
|
@ -181,7 +179,7 @@ void app_main(void) {
|
|||
esp_restart();
|
||||
}
|
||||
|
||||
display_boot_screen(pax_buffer, ili9341, "Initializing NVS...");
|
||||
//display_boot_screen(pax_buffer, ili9341, "Initializing NVS...");
|
||||
|
||||
/* Start NVS */
|
||||
res = nvs_init();
|
||||
|
@ -191,7 +189,7 @@ void app_main(void) {
|
|||
esp_restart();
|
||||
}
|
||||
|
||||
display_boot_screen(pax_buffer, ili9341, "Initializing filesystem...");
|
||||
//display_boot_screen(pax_buffer, ili9341, "Initializing filesystem...");
|
||||
|
||||
/* Start internal filesystem */
|
||||
const esp_partition_t* fs_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_FAT, "locfd");
|
||||
|
@ -221,8 +219,6 @@ void app_main(void) {
|
|||
ESP_LOGI(TAG, "SD card filesystem mounted");
|
||||
}
|
||||
|
||||
play_bootsound();
|
||||
|
||||
/* Start LEDs */
|
||||
ws2812_init(GPIO_LED_DATA);
|
||||
uint8_t ledBuffer[15] = {50, 0, 0, 50, 0, 0, 50, 0, 0, 50, 0, 0, 50, 0, 0};
|
||||
|
@ -231,6 +227,9 @@ void app_main(void) {
|
|||
/* Start WiFi */
|
||||
wifi_init();
|
||||
|
||||
/* Rick that roll */
|
||||
play_bootsound();
|
||||
|
||||
/* Launcher menu */
|
||||
while (true) {
|
||||
menu_start(rp2040->queue, pax_buffer, ili9341);
|
||||
|
|
|
@ -87,7 +87,7 @@ void menu_launcher(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili
|
|||
}
|
||||
|
||||
if (render) {
|
||||
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF72008a);
|
||||
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF000000);
|
||||
ili9341_write(ili9341, pax_buffer->buf);
|
||||
render = false;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ void menu_settings(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili
|
|||
}
|
||||
|
||||
if (render) {
|
||||
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF2f55a8);
|
||||
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF000000);
|
||||
ili9341_write(ili9341, pax_buffer->buf);
|
||||
render = false;
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue