expander test code

This commit is contained in:
Mitchell Marino 2026-04-01 15:55:37 -05:00
parent 85fcb23a87
commit c3075141fb
2 changed files with 18 additions and 30 deletions

@ -1 +1 @@
Subproject commit 8c0b6823fd8743cb829973811bed5f96226bb53d Subproject commit c82c9adf321b6e653c8069758f226d931fc39d9f

View File

@ -8,6 +8,7 @@
#include "esp_system.h" #include "esp_system.h"
#include "blk_box.h" #include "blk_box.h"
#include "blk_box_drivers/i2c.h" #include "blk_box_drivers/i2c.h"
#include "blk_box_drivers/expander.hpp"
extern "C" void app_main(void) { extern "C" void app_main(void) {
BlkBoxInitConfig blk_box_cfg = {}; BlkBoxInitConfig blk_box_cfg = {};
@ -15,36 +16,23 @@ extern "C" void app_main(void) {
printf("Hello, Blk Box!\n"); printf("Hello, Blk Box!\n");
/* Print chip information */ while (1) {
esp_chip_info_t chip_info; if (InputsController::has_button_press()) {
uint32_t flash_size; Button b = InputsController::wait_button_press();
esp_chip_info(&chip_info); printf("Button pressed: %d\n", raw_value(b));
printf("This is %s chip with %d CPU core(s), %s%s%s%s, ", }
CONFIG_IDF_TARGET,
chip_info.cores,
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
(chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "");
unsigned major_rev = chip_info.revision / 100; if (InputsController::has_switch_flip()) {
unsigned minor_rev = chip_info.revision % 100; SwitchFlip flip = InputsController::wait_switch_flip();
printf("silicon revision v%d.%d, ", major_rev, minor_rev); printf("Switch flipped: %d, new state: %d\n", raw_value(flip.get_switch()), flip.is_up());
if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) { }
printf("Get flash size failed");
return; if (InputsController::has_keypad_press()) {
KeypadKey k = InputsController::wait_keypad_press();
printf("Keypad key pressed: %c\n", keypad_key_to_char(k));
}
vTaskDelay(10 / portTICK_PERIOD_MS);
} }
printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
for (int i = 10; i >= 0; i--) {
printf("Doing nothing in %d seconds...\n", i);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
// printf("Restarting now.\n");
// fflush(stdout);
// esp_restart();
} }