diff --git a/inc/drivers/DynamicPwm.h b/inc/drivers/DynamicPwm.h index 3290eec..441f048 100644 --- a/inc/drivers/DynamicPwm.h +++ b/inc/drivers/DynamicPwm.h @@ -40,7 +40,7 @@ DEALINGS IN THE SOFTWARE. class DynamicPwm : public PwmOut { private: - uint32_t period; + static uint32_t period; float lastValue; public: diff --git a/source/drivers/DynamicPwm.cpp b/source/drivers/DynamicPwm.cpp index 9e67aba..ac9d981 100644 --- a/source/drivers/DynamicPwm.cpp +++ b/source/drivers/DynamicPwm.cpp @@ -35,6 +35,8 @@ DEALINGS IN THE SOFTWARE. #include "MicroBitPin.h" #include "ErrorNo.h" +uint32_t DynamicPwm::period = MICROBIT_DEFAULT_PWM_PERIOD; + /** * An internal constructor used when allocating a new DynamicPwm instance. * @@ -45,7 +47,6 @@ DEALINGS IN THE SOFTWARE. */ DynamicPwm::DynamicPwm(PinName pin) : PwmOut(pin) { - this->period = 0; } /** @@ -131,7 +132,7 @@ int DynamicPwm::getValue() */ uint32_t DynamicPwm::getPeriodUs() { - return period; + return this->period; } /**