diff --git a/libs/RobotKit/include/RobotController.h b/libs/RobotKit/include/RobotController.h index 3a33188066..96bdf1ec03 100644 --- a/libs/RobotKit/include/RobotController.h +++ b/libs/RobotKit/include/RobotController.h @@ -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({&_motor_left, &_motor_right, &_lcd, &_rfidkit}); + + for (auto &hardware: hardwares_to_suspend) { + hardware->enableDeepSleep(); + } + } void resetEmergencyStopCounter() final { _emergency_stop_counter = 0; } diff --git a/libs/RobotKit/tests/RobotController_test_hardware.cpp b/libs/RobotKit/tests/RobotController_test_hardware.cpp index 69b1ab7819..22312a58e1 100644 --- a/libs/RobotKit/tests/RobotController_test_hardware.cpp +++ b/libs/RobotKit/tests/RobotController_test_hardware.cpp @@ -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(); }