Skip to content

Commit

Permalink
✨ (spike): Add lk_imu_kit spike
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Dec 1, 2022
1 parent 60f1a74 commit 4e85f8d
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spikes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_subdirectory(${SPIKES_DIR}/lk_file_reception)
add_subdirectory(${SPIKES_DIR}/lk_file_manager_kit)
add_subdirectory(${SPIKES_DIR}/lk_flash_memory)
add_subdirectory(${SPIKES_DIR}/lk_fs)
add_subdirectory(${SPIKES_DIR}/lk_imu_kit)
add_subdirectory(${SPIKES_DIR}/lk_lcd)
add_subdirectory(${SPIKES_DIR}/lk_led_kit)
add_subdirectory(${SPIKES_DIR}/lk_log_kit)
Expand Down Expand Up @@ -57,6 +58,7 @@ add_dependencies(spikes_leka
spike_lk_file_reception
spike_lk_file_manager_kit
spike_lk_flash_memory
spike_lk_imu_kit
spike_lk_lcd
spike_lk_led_kit
spike_lk_log_kit
Expand Down
23 changes: 23 additions & 0 deletions spikes/lk_imu_kit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Leka - LekaOS
# Copyright 2022 APF France handicap
# SPDX-License-Identifier: Apache-2.0

add_mbed_executable(spike_lk_imu_kit)

target_include_directories(spike_lk_imu_kit
PRIVATE
.
)

target_sources(spike_lk_imu_kit
PRIVATE
main.cpp
)

target_link_libraries(spike_lk_imu_kit
CoreIMU
CoreI2C
IMUKit
)

target_link_custom_leka_targets(spike_lk_imu_kit)
58 changes: 58 additions & 0 deletions spikes/lk_imu_kit/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Leka - LekaOS
// Copyright 2022 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include "rtos/ThisThread.h"

#include "CoreAccelerometer.h"
#include "CoreGyroscope.h"
#include "CoreI2C.h"
#include "CoreLSM6DSOX.h"
#include "EventLoopKit.h"
#include "HelloWorld.h"
#include "IMUKit.h"
#include "LogKit.h"

using namespace std::chrono;
using namespace leka;

namespace {

namespace imu {

namespace internal {

CoreI2C i2c(PinName::SENSOR_IMU_TH_I2C_SDA, PinName::SENSOR_IMU_TH_I2C_SCL);
CoreLSM6DSOX lsm6dsox(internal::i2c);
EventLoopKit event_loop {};

} // namespace internal

CoreAccelerometer accel(internal::lsm6dsox);
CoreGyroscope gyro(internal::lsm6dsox);

IMUKit kit(internal::event_loop, accel, gyro);

} // namespace imu

} // namespace

auto main() -> int
{
logger::init();

HelloWorld hello;
hello.start();

imu::internal::lsm6dsox.init();

imu::kit.init();
imu::kit.start();

while (true) {
auto [pitch, roll, yaw] = imu::kit.getAngles();
log_info("Pitch : %7.2f, Roll : %7.2f Yaw : %7.2f", pitch, roll, yaw);

rtos::ThisThread::sleep_for(140ms);
}
}

0 comments on commit 4e85f8d

Please sign in to comment.