Skip to content

Commit

Permalink
✨ (spike): Add leds on imu wakeup
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Feb 20, 2024
1 parent 890f596 commit 5da8036
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions spikes/lk_sensors_imu_wakeup_calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
50 changes: 49 additions & 1 deletion spikes/lk_sensors_imu_wakeup_calibration/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "CoreI2C.h"
#include "CoreIMU.hpp"
#include "CoreLED.h"
#include "CoreSPI.h"
#include "HelloWorld.h"
#include "LogKit.h"

Expand All @@ -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::size> {internal::ears::spi};
auto belt = CoreLED<internal::belt::size> {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();
Expand All @@ -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();
Expand Down

0 comments on commit 5da8036

Please sign in to comment.