From 5da8036627847148d0334aaf043e7b386ee489ca Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Tue, 20 Feb 2024 12:21:51 +0100 Subject: [PATCH] :sparkles: (spike): Add leds on imu wakeup --- .../CMakeLists.txt | 1 + .../main.cpp | 50 ++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/spikes/lk_sensors_imu_wakeup_calibration/CMakeLists.txt b/spikes/lk_sensors_imu_wakeup_calibration/CMakeLists.txt index 785ac7296a..b9bd0e4438 100644 --- a/spikes/lk_sensors_imu_wakeup_calibration/CMakeLists.txt +++ b/spikes/lk_sensors_imu_wakeup_calibration/CMakeLists.txt @@ -17,6 +17,7 @@ target_sources(spike_lk_sensors_imu_wakeup_calibration target_link_libraries(spike_lk_sensors_imu_wakeup_calibration CoreIMU CoreI2C + CoreLED ) target_link_custom_leka_targets(spike_lk_sensors_imu_wakeup_calibration) diff --git a/spikes/lk_sensors_imu_wakeup_calibration/main.cpp b/spikes/lk_sensors_imu_wakeup_calibration/main.cpp index 9965fd33de..5e70971929 100644 --- a/spikes/lk_sensors_imu_wakeup_calibration/main.cpp +++ b/spikes/lk_sensors_imu_wakeup_calibration/main.cpp @@ -8,6 +8,8 @@ #include "CoreI2C.h" #include "CoreIMU.hpp" +#include "CoreLED.h" +#include "CoreSPI.h" #include "HelloWorld.h" #include "LogKit.h" @@ -29,8 +31,54 @@ namespace imu { } // namespace imu +namespace leds { + + namespace internal { + + namespace ears { + + auto spi = CoreSPI {LED_EARS_SPI_MOSI, NC, LED_EARS_SPI_SCK}; + constexpr auto size = 2; + + } // namespace ears + + namespace belt { + + auto spi = CoreSPI {LED_BELT_SPI_MOSI, NC, LED_BELT_SPI_SCK}; + constexpr auto size = 20; + + } // namespace belt + + } // namespace internal + + auto ears = CoreLED {internal::ears::spi}; + auto belt = CoreLED {internal::belt::spi}; + +} // namespace leds + } // namespace +void setColor(RGB color) +{ + leds::ears.setColor(color); + leds::belt.setColor(color); + + leds::ears.show(); + leds::belt.show(); +} + +void turnOff() +{ + setColor(RGB::black); +} + +void wakeUpReaction() +{ + setColor(RGB::pure_blue); + rtos::ThisThread::sleep_for(2s); + turnOff(); +} + auto main() -> int { logger::init(); @@ -43,7 +91,7 @@ auto main() -> int imu::coreimu.init(); imu::coreimu.setPowerMode(CoreIMU::PowerMode::Normal); - auto callback = [] { log_info("waking up!"); }; + auto callback = [] { wakeUpReaction(); }; imu::coreimu.registerOnWakeUpCallback(callback); imu::coreimu.enableOnWakeUpInterrupt();