From 5ea3df10a4351aa99d5dbed5920f9cd153399805 Mon Sep 17 00:00:00 2001 From: Mitchell M Date: Wed, 1 Apr 2026 22:11:54 -0500 Subject: [PATCH] leds --- components/blk_box_lib | 2 +- main/main.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/components/blk_box_lib b/components/blk_box_lib index 8bc5a98..0b79eb8 160000 --- a/components/blk_box_lib +++ b/components/blk_box_lib @@ -1 +1 @@ -Subproject commit 8bc5a982d1d8ff909136af73541df7a05471266d +Subproject commit 0b79eb839961095ddf2b1a1a07479a791871acc6 diff --git a/main/main.cpp b/main/main.cpp index dc0d0db..1c0596e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -9,6 +9,7 @@ #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 = {}; @@ -16,10 +17,23 @@ extern "C" void app_main(void) { 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()) { @@ -30,6 +44,7 @@ extern "C" void app_main(void) { 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);