#include #include #include "sdkconfig.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_chip_info.h" #include "esp_flash.h" #include "esp_system.h" #include "blk_box.h" #include "blk_box_drivers/i2c.h" #include "blk_box_drivers/inputs.hpp" #include "blk_box_drivers/leds.hpp" extern "C" void app_main(void) { BlkBoxInitConfig blk_box_cfg = {}; init_blk_box(blk_box_cfg); printf("Hello, Blk Box!\n"); uint32_t i = 0; while (1) { if (InputsController::has_button_press()) { Button b = InputsController::wait_button_press(); printf("Button pressed: %d\n", raw_value(b)); if (b == Button::GREEN) { LEDController::set_indicator(static_cast(i + LED_SHAPE_COUNT), LEDColor::GREEN); LEDController::flush(); } else if (b == Button::YELLOW) { LEDController::set_indicator(static_cast(i + LED_SHAPE_COUNT), LEDColor::YELLOW); LEDController::flush(); } else if (b == Button::RED) { i = (i + 1) % LED_INDICATOR_COUNT; } else if (b == Button::BLUE) { i = (i + LED_INDICATOR_COUNT - 1) % LED_INDICATOR_COUNT; } } if (InputsController::has_switch_flip()) { SwitchFlip flip = InputsController::wait_switch_flip(); printf("Switch flipped: %d, new state: %d\n", raw_value(flip.get_switch()), flip.is_up()); } if (InputsController::has_keypad_press()) { KeypadKey k = InputsController::wait_keypad_press(); printf("Keypad key pressed: %c\n", keypad_key_to_char(k)); LEDController::flush(); } vTaskDelay(10 / portTICK_PERIOD_MS); } }