Skip to content

Commit

Permalink
♻️ (LedKitAnimations) Move animations in LedKitAnimations
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Dec 14, 2022
1 parent 370f4b1 commit d641c2a
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 71 deletions.
2 changes: 1 addition & 1 deletion libs/BehaviorKit/source/BehaviorKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "rtos/ThisThread.h"

#include "LedKit.h"
#include "LedKitAnimations.h"

namespace leka {

Expand Down
3 changes: 1 addition & 2 deletions libs/BehaviorKit/tests/BehaviorKit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

#include "BehaviorKit.h"

#include "LedKit.h"
#include "LedKitAnimations.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "mocks/leka/CoreMotor.h"
#include "mocks/leka/LEDAnimation.h"
#include "mocks/leka/LedKit.h"
#include "mocks/leka/VideoKit.h"

Expand Down
66 changes: 6 additions & 60 deletions libs/LedKit/include/LedKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,21 @@
#include "drivers/HighResClock.h"

#include "ColorKit.h"
#include "animations/AfraidBlue.h"
#include "animations/AfraidRed.h"
#include "animations/AfraidRedBlue.h"
#include "animations/Amazed.h"
#include "animations/Angry.h"
#include "animations/AngryShort.h"
#include "animations/BleConnection.h"
#include "animations/BlinkGreen.h"
#include "animations/Bubbles.h"
#include "animations/Disgusted.h"
#include "animations/Fire.h"
#include "animations/Fly.h"
#include "animations/Happy.h"
#include "animations/Rainbow.h"
#include "animations/Sad.h"
#include "animations/SadCry.h"
#include "animations/Sick.h"
#include "animations/Singing.h"
#include "animations/Sleeping.h"
#include "animations/Sneeze.h"
#include "animations/SpinBlink.h"
#include "animations/Sprinkles.h"
#include "animations/Underwater.h"
#include "animations/WakeUp.h"
#include "animations/Wink.h"
#include "animations/Yawn.h"
#include "LEDAnimation.h"
#include "interface/libs/EventLoop.h"
#include "interface/libs/LedKit.h"
namespace leka {

namespace led::animation {
static inline auto afraid_blue = led::animation::AfraidBlue {};
static inline auto afraid_red = led::animation::AfraidRed {};
static inline auto afraid_red_blue = led::animation::AfraidRedBlue {};
static inline auto amazed = led::animation::Amazed {};
static inline auto angry = led::animation::Angry {};
static inline auto angry_short = led::animation::AngryShort {};
static inline auto blink_green = led::animation::BlinkGreen {};
static inline auto bubbles = led::animation::Bubbles {};
static inline auto ble_connection = led::animation::BleConnection {};
static inline auto disgusted = led::animation::Disgusted {};
static inline auto fire = led::animation::Fire {};
static inline auto fly = led::animation::Fly {};
static inline auto happy = led::animation::Happy {};
static inline auto rainbow = led::animation::Rainbow {};
static inline auto sad = led::animation::Sad {};
static inline auto sad_cry = led::animation::SadCry {};
static inline auto sick = led::animation::Sick {};
static inline auto singing = led::animation::Singing {};
static inline auto sleeping = led::animation::Sleeping {};
static inline auto sneeze = led::animation::Sneeze {};
static inline auto spin_blink = led::animation::SpinBlink {};
static inline auto sprinkles = led::animation::Sprinkles {};
static inline auto underwater = led::animation::Underwater {};
static inline auto wake_up = led::animation::WakeUp {};
static inline auto wink = led::animation::Wink {};
static inline auto yawn = led::animation::Yawn {};
}; // namespace led::animation

namespace leka {
class LedKit : public interface::LedKit
{
public:
static constexpr auto kNumberOfLedsEars = 2;
static constexpr auto kNumberOfLedsBelt = 20;

struct flags {
static constexpr uint32_t START_LED_ANIMATION_FLAG = (1UL << 1);
};

LedKit(interface::EventLoop &event_loop, interface::LED &ears, interface::LED &belt)
: _event_loop(event_loop), _ears(ears), _belt(belt) {};

Expand All @@ -80,10 +30,6 @@ class LedKit : public interface::LedKit
void run() final;
void stop() final;

struct flags {
static constexpr uint32_t START_LED_ANIMATION_FLAG = (1UL << 1);
};

private:
interface::EventLoop &_event_loop;

Expand Down
63 changes: 63 additions & 0 deletions libs/LedKit/include/LedKitAnimations.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Leka - LekaOS
// Copyright 2022 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "animations/AfraidBlue.h"
#include "animations/AfraidRed.h"
#include "animations/AfraidRedBlue.h"
#include "animations/Amazed.h"
#include "animations/Angry.h"
#include "animations/AngryShort.h"
#include "animations/BleConnection.h"
#include "animations/BlinkGreen.h"
#include "animations/Bubbles.h"
#include "animations/Disgusted.h"
#include "animations/Fire.h"
#include "animations/Fly.h"
#include "animations/Happy.h"
#include "animations/Rainbow.h"
#include "animations/Sad.h"
#include "animations/SadCry.h"
#include "animations/Sick.h"
#include "animations/Singing.h"
#include "animations/Sleeping.h"
#include "animations/Sneeze.h"
#include "animations/SpinBlink.h"
#include "animations/Sprinkles.h"
#include "animations/Underwater.h"
#include "animations/WakeUp.h"
#include "animations/Wink.h"
#include "animations/Yawn.h"

namespace leka::led::animation {

static inline auto afraid_blue = led::animation::AfraidBlue {};
static inline auto afraid_red = led::animation::AfraidRed {};
static inline auto afraid_red_blue = led::animation::AfraidRedBlue {};
static inline auto amazed = led::animation::Amazed {};
static inline auto angry = led::animation::Angry {};
static inline auto angry_short = led::animation::AngryShort {};
static inline auto blink_green = led::animation::BlinkGreen {};
static inline auto bubbles = led::animation::Bubbles {};
static inline auto ble_connection = led::animation::BleConnection {};
static inline auto disgusted = led::animation::Disgusted {};
static inline auto fire = led::animation::Fire {};
static inline auto fly = led::animation::Fly {};
static inline auto happy = led::animation::Happy {};
static inline auto rainbow = led::animation::Rainbow {};
static inline auto sad = led::animation::Sad {};
static inline auto sad_cry = led::animation::SadCry {};
static inline auto sick = led::animation::Sick {};
static inline auto singing = led::animation::Singing {};
static inline auto sleeping = led::animation::Sleeping {};
static inline auto sneeze = led::animation::Sneeze {};
static inline auto spin_blink = led::animation::SpinBlink {};
static inline auto sprinkles = led::animation::Sprinkles {};
static inline auto underwater = led::animation::Underwater {};
static inline auto wake_up = led::animation::WakeUp {};
static inline auto wink = led::animation::Wink {};
static inline auto yawn = led::animation::Yawn {};

}; // namespace leka::led::animation
2 changes: 1 addition & 1 deletion libs/ReinforcerKit/source/ReinforcerKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "ReinforcerKit.h"

#include "LedKit.h"
#include "LedKitAnimations.h"

using namespace leka;
using namespace std::chrono;
Expand Down
4 changes: 1 addition & 3 deletions libs/ReinforcerKit/tests/ReinforcerKit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

#include "ReinforcerKit.h"

#include "LedKit.h"
#include "LedKitAnimations.h"
#include "MotionKit.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "mocks/leka/Accelerometer.h"
#include "mocks/leka/CoreLED.h"
#include "mocks/leka/CoreMotor.h"
#include "mocks/leka/Gyroscope.h"
#include "mocks/leka/LEDAnimation.h"
#include "mocks/leka/LedKit.h"
#include "mocks/leka/VideoKit.h"
#include "stubs/leka/EventLoopKit.h"
Expand Down
8 changes: 4 additions & 4 deletions libs/RobotKit/tests/RobotController_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "CorePwm.h"
#include "CoreRFIDReaderCR95HF.h"
#include "DisplayTags.h"
#include "LedKit.h"
#include "LedKitAnimations.h"
#include "RFIDKit.h"
#include "SerialNumberKit.h"
#include "gmock/gmock.h"
Expand Down Expand Up @@ -130,9 +130,9 @@ class RobotControllerTest : public testing::Test
void expectedCallsStopActuators()
{
EXPECT_CALL(mock_ledkit, stop).Times(AtLeast(1));
EXPECT_CALL(mock_videokit, stopVideo).Times(AtLeast(2));
EXPECT_CALL(mock_motor_left, stop()).Times(AtLeast(2));
EXPECT_CALL(mock_motor_right, stop()).Times(AtLeast(2));
EXPECT_CALL(mock_videokit, stopVideo).Times(AtLeast(1));
EXPECT_CALL(mock_motor_left, stop()).Times(AtLeast(1));
EXPECT_CALL(mock_motor_right, stop()).Times(AtLeast(1));
EXPECT_CALL(mock_belt, hide).Times(AtLeast(1));
EXPECT_CALL(mock_ears, hide).Times(AtLeast(1));
}
Expand Down
1 change: 1 addition & 0 deletions spikes/lk_led_kit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "EventLoopKit.h"
#include "HelloWorld.h"
#include "LedKit.h"
#include "LedKitAnimations.h"
#include "LogKit.h"

using namespace leka;
Expand Down

0 comments on commit d641c2a

Please sign in to comment.