Skip to content

Commit

Permalink
♻️ (behaviorkit): Separate bleConnection into bleConnectionWithoutVid…
Browse files Browse the repository at this point in the history
…eo and bleConnectionWithVideo
  • Loading branch information
YannLocatelli committed Jan 13, 2023
1 parent e6c3a8f commit 50d98bc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion libs/BehaviorKit/include/BehaviorKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class BehaviorKit
void chargingHigh();
void chargingFull();

void bleConnection(bool with_video);
void bleConnectionWithoutVideo();
void bleConnectionWithVideo();
void working();

void fileExchange();
Expand Down
11 changes: 7 additions & 4 deletions libs/BehaviorKit/source/BehaviorKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ void BehaviorKit::chargingFull()
_videokit.displayImage("/fs/home/img/system/robot-battery-charging-quarter_4-green.jpg");
}

void BehaviorKit::bleConnection(bool with_video)
void BehaviorKit::bleConnectionWithoutVideo()
{
_ledkit.start(&led::animation::ble_connection);
if (with_video) {
_videokit.playVideoOnce("/fs/home/vid/system/robot-system-ble_connection-wink-no_eyebrows.avi");
}
}

void BehaviorKit::bleConnectionWithVideo()
{
_ledkit.start(&led::animation::ble_connection);
_videokit.playVideoOnce("/fs/home/vid/system/robot-system-ble_connection-wink-no_eyebrows.avi");
}

void BehaviorKit::working()
Expand Down
4 changes: 2 additions & 2 deletions libs/BehaviorKit/tests/BehaviorKit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ TEST_F(BehaviorKitTest, bleConnectionWithoutVideo)
EXPECT_CALL(mock_videokit, playVideoOnce).Times(0);
EXPECT_CALL(mock_ledkit, start(isSameAnimation(&led::animation::ble_connection))).Times(1);

behaviorkit.bleConnection(false);
behaviorkit.bleConnectionWithoutVideo();
}

TEST_F(BehaviorKitTest, bleConnectionWithVideo)
{
EXPECT_CALL(mock_videokit, playVideoOnce);
EXPECT_CALL(mock_ledkit, start(isSameAnimation(&led::animation::ble_connection))).Times(1);

behaviorkit.bleConnection(true);
behaviorkit.bleConnectionWithVideo();
}

TEST_F(BehaviorKitTest, working)
Expand Down
4 changes: 2 additions & 2 deletions libs/RobotKit/include/RobotController.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ class RobotController : public interface::RobotController
using namespace std::chrono_literals;
stopActuators();
if (_battery.isCharging()) {
_behaviorkit.bleConnection(false);
_behaviorkit.bleConnectionWithoutVideo();
rtos::ThisThread::sleep_for(5s);
_behaviorkit.blinkOnCharge();
} else {
_behaviorkit.bleConnection(true);
_behaviorkit.bleConnectionWithVideo();
_lcd.turnOn();
}
}
Expand Down

0 comments on commit 50d98bc

Please sign in to comment.