Skip to content

Commit

Permalink
⬆️ (IMUKit): IMUKit derive from interface
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Mar 6, 2023
1 parent 13ec4b7 commit d5df351
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/os/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "FlashNumberCounting.h"
#include "FoodRecognition.h"
#include "HelloWorld.h"
#include "IMUKit.hpp"
#include "LedColorRecognition.h"
#include "LedKit.h"
#include "LedNumberCounting.h"
Expand Down
17 changes: 6 additions & 11 deletions libs/IMUKit/include/IMUKit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,21 @@
#pragma once

#include "interface/LSM6DSOX.hpp"
#include "interface/libs/IMUKit.hpp"

namespace leka {

struct EulerAngles {
float pitch;
float roll;
float yaw;
};

class IMUKit
class IMUKit : public interface::IMUKit
{
public:
explicit IMUKit(interface::LSM6DSOX &lsm6dsox) : _lsm6dsox(lsm6dsox) {}

void init();
void start();
void stop();
void start() final;
void stop() final;

void setOrigin();
[[nodiscard]] auto getEulerAngles() const -> EulerAngles;
void setOrigin() final;
[[nodiscard]] auto getEulerAngles() const -> EulerAngles final;

private:
void drdy_callback(interface::LSM6DSOX::SensorData data);
Expand Down
1 change: 1 addition & 0 deletions spikes/lk_command_kit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "EventLoopKit.h"
#include "FATFileSystem.h"
#include "HelloWorld.h"
#include "IMUKit.hpp"
#include "LedKit.h"
#include "LogKit.h"
#include "ReinforcerKit.h"
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/mocks/mocks/leka/IMUKit.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Leka - LekaOS
// Copyright 2023 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "gmock/gmock.h"
#include "interface/libs/IMUKit.hpp"

namespace leka::mock {

class IMUKit : public interface::IMUKit
{
public:
MOCK_METHOD(void, start, (), (override));
MOCK_METHOD(void, stop, (), (override));
MOCK_METHOD(void, setOrigin, (), (override));
MOCK_METHOD(EulerAngles, getEulerAngles, (), (const, override));

void onEulerAnglesReady(angles_ready_callback_t const &cb) override { angles_ready_callback = cb; }

void call_angles_ready_callback(const EulerAngles &data) { angles_ready_callback(data); }

private:
angles_ready_callback_t angles_ready_callback {};
};

} // namespace leka::mock

0 comments on commit d5df351

Please sign in to comment.