Skip to content

Commit

Permalink
✨ (RobotController): Implement suspendHardwareForDeepSleep
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Jul 9, 2024
1 parent 9a4dd79 commit 6ed5247
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libs/RobotKit/include/RobotController.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,15 @@ class RobotController : public interface::RobotController
stopActuators();
}

void suspendHardwareForDeepSleep() final { log_info("TO IMPLEMENT - configuring hardware for deep sleep"); }
void suspendHardwareForDeepSleep() final
{
auto hardwares_to_suspend =
std::to_array<interface::DeepSleepEnabled *>({&_motor_left, &_motor_right, &_lcd, &_rfidkit});

for (auto &hardware: hardwares_to_suspend) {
hardware->enableDeepSleep();
}
}

void resetEmergencyStopCounter() final { _emergency_stop_counter = 0; }

Expand Down
5 changes: 5 additions & 0 deletions libs/RobotKit/tests/RobotController_test_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ TEST_F(RobotControllerTest, stopActuatorsAndLcd)

TEST_F(RobotControllerTest, suspendHardwareForDeepSleep)
{
EXPECT_CALL(mock_motor_left, enableDeepSleep);
EXPECT_CALL(mock_motor_right, enableDeepSleep);
EXPECT_CALL(mock_lcd, enableDeepSleep);
// TODO: Expect_call of RFID

rc.suspendHardwareForDeepSleep();
}

Expand Down

0 comments on commit 6ed5247

Please sign in to comment.