diff --git a/firmware/controllers/actuators/dc_motors.h b/firmware/controllers/actuators/dc_motors.h index fbfd9df40a..d4a9e7894a 100644 --- a/firmware/controllers/actuators/dc_motors.h +++ b/firmware/controllers/actuators/dc_motors.h @@ -68,7 +68,7 @@ public: } const char *msg() { - return dcMotor.msg; + return dcMotor.msg(); } void stop() { diff --git a/firmware/controllers/system/dc_motor.cpp b/firmware/controllers/system/dc_motor.cpp index bcbf3622e7..975b7f63d5 100644 --- a/firmware/controllers/system/dc_motor.cpp +++ b/firmware/controllers/system/dc_motor.cpp @@ -27,14 +27,16 @@ void TwoPinDcMotor::enable() { if (m_disable) { m_disable->setValue(false); } - msg = nullptr; + + m_msg = nullptr; } -void TwoPinDcMotor::disable(const char *p_msg) { - msg = p_msg; +void TwoPinDcMotor::disable(const char *msg) { + m_msg = msg; if (m_disable) { m_disable->setValue(true); } + // Also set the duty to zero set(0); } diff --git a/firmware/controllers/system/dc_motor.h b/firmware/controllers/system/dc_motor.h index 7bc0f0c75b..30c755bcf2 100644 --- a/firmware/controllers/system/dc_motor.h +++ b/firmware/controllers/system/dc_motor.h @@ -37,7 +37,12 @@ public: virtual bool isOpenDirection() const = 0; - const char *msg = nullptr; + const char* msg() const { + return m_msg; + } + +protected: + const char* m_msg = nullptr; }; struct IPwm;