diff --git a/main/include/sao_eeprom.h b/main/include/sao_eeprom.h index 562dbd8..6da735e 100644 --- a/main/include/sao_eeprom.h +++ b/main/include/sao_eeprom.h @@ -114,6 +114,7 @@ typedef struct __attribute__((__packed__)) _sao_driver_ntag_data { #define SAO_DRIVER_APP_NAME "app" // data is a string containing the slug name of the app, null terminated +void dump_eeprom_contents(); esp_err_t sao_identify(SAO* sao); esp_err_t sao_write_raw(size_t offset, uint8_t* buffer, size_t buffer_length); esp_err_t sao_format(const char* name, const char* driver, const uint8_t* driver_data, uint8_t driver_data_length, const char* driver2, diff --git a/main/menus/sao.c b/main/menus/sao.c index be3a898..09ad279 100644 --- a/main/menus/sao.c +++ b/main/menus/sao.c @@ -382,7 +382,7 @@ void menu_sao(xQueueHandle button_queue) { display_flush(); - if (xQueueReceive(button_queue, &buttonMessage, 200 / portTICK_PERIOD_MS) == pdTRUE) { + if (xQueueReceive(button_queue, &buttonMessage, 500 / portTICK_PERIOD_MS) == pdTRUE) { uint8_t pin = buttonMessage.input; bool value = buttonMessage.state; if (value) { @@ -394,6 +394,9 @@ void menu_sao(xQueueHandle button_queue) { case RP2040_INPUT_BUTTON_BACK: exit = true; break; + case RP2040_INPUT_BUTTON_SELECT: + dump_eeprom_contents(); + break; case RP2040_INPUT_BUTTON_ACCEPT: if ((sao.type == SAO_BINARY) && (strncmp(sao.driver, "badgeteam_app_link", strlen("badgeteam_app_link")) == 0)) { if (!sao_is_app_installed((char*) sao.driver_data)) { diff --git a/main/sao_eeprom.c b/main/sao_eeprom.c index 9ea0310..a583b48 100644 --- a/main/sao_eeprom.c +++ b/main/sao_eeprom.c @@ -13,6 +13,21 @@ static const char* TAG = "SAO"; EEPROM sao_eeprom = {.i2c_bus = 0, .i2c_address = 0x50}; +void dump_eeprom_contents() { + uint8_t buffer[128] = {0}; + if (eeprom_read(&sao_eeprom, 0, buffer, sizeof(buffer)) != ESP_OK) { + printf("Failed to read EEPROM contents\n"); + } else { + for (int i = 0; i < sizeof(buffer); i++) { + if (i % 16 == 0) { + printf("\n"); + } + printf("%02x ", buffer[i]); + } + } + printf("\n"); +} + esp_err_t sao_identify(SAO* sao) { if (sao == NULL) return ESP_FAIL; memset(sao, 0, sizeof(SAO));