diff --git a/src/shared/actuators/Buzzer.h b/src/shared/actuators/Buzzer.h index 50c6b33409f87870da9f18dbeb04d4050f4216dc..ad3539d87de3675587a1c5593b7776f64951583f 100644 --- a/src/shared/actuators/Buzzer.h +++ b/src/shared/actuators/Buzzer.h @@ -83,15 +83,6 @@ private: inline Buzzer::Buzzer(TIM_TypeDef *timer, TimerUtils::Channel channel) : timer(timer), channel(channel) { - // this->timer.setPrescaler( - // TimerUtils::computePrescalerValue(timer, frequency * 2)); - // this->timer.setAutoReloadRegister(1); - // this->timer.setOutputCompareMode(channel, - // TimerUtils::OutputCompareMode::TOGGLE); - // this->timer.setCaptureCompareRegister(channel, 1); - // this->timer.generateUpdate(); - // this->timer.enableCaptureCompareOutput(channel); - // this->timer.enableCaptureCompareComplementaryOutput(channel); } inline void Buzzer::on() diff --git a/src/shared/actuators/Servo/ServoData.h b/src/shared/actuators/Servo/ServoData.h index b4ff14d357a09257f6d9882ed6921c640fad430e..5676c0c4be9ea6c9ace7acd855c45480582d2f6c 100644 --- a/src/shared/actuators/Servo/ServoData.h +++ b/src/shared/actuators/Servo/ServoData.h @@ -38,8 +38,8 @@ struct ServoData void print(std::ostream& os) const { - os << timestamp << "," << timer << "," << channel << "," << position - << "\n"; + os << timestamp << "," << static_cast<int>(timer) << "," + << static_cast<int>(channel) << "," << position << "\n"; } }; diff --git a/src/shared/drivers/timer/PWM.cpp b/src/shared/drivers/timer/PWM.cpp index f8e2faa107ec05978202ac4d8725ef2ae8d2313c..e8b156b9643529f44a937898958b425e37649b45 100644 --- a/src/shared/drivers/timer/PWM.cpp +++ b/src/shared/drivers/timer/PWM.cpp @@ -78,8 +78,8 @@ void PWM::setDutyCycle(TimerUtils::Channel channel, float dutyCycle) { if (dutyCycle >= 0 && dutyCycle <= 1) timer.setCaptureCompareRegister( - channel, - static_cast<uint16_t>(dutyCycle * timer.readAutoReloadRegister())); + channel, static_cast<uint16_t>( + dutyCycle * timer.readAutoReloadRegister() + 0.5)); } float PWM::getDutyCycle(TimerUtils::Channel channel) @@ -88,7 +88,7 @@ float PWM::getDutyCycle(TimerUtils::Channel channel) static_cast<float>(timer.readAutoReloadRegister()); } -GP16bitTimer PWM::getTimer() { return timer; } +GP16bitTimer& PWM::getTimer() { return timer; } void PWM::setTimerConfiguration() { diff --git a/src/shared/drivers/timer/PWM.h b/src/shared/drivers/timer/PWM.h index d30e5d45ca031a536acf963a4b50739d99d79b49..085be48f6bc55ad0f589f31bc6ed25bc788fe713 100644 --- a/src/shared/drivers/timer/PWM.h +++ b/src/shared/drivers/timer/PWM.h @@ -65,7 +65,7 @@ public: * @param dutyCycleResolution Duty cycle levels. */ explicit PWM(TIM_TypeDef* const timer, unsigned int pwmFrequency = 50, - unsigned int dutyCycleResolution = 1000); + unsigned int dutyCycleResolution = 20000); ~PWM(); @@ -98,7 +98,7 @@ public: /** * @brief Returns the timer used to generate the pwm signal. */ - GP16bitTimer getTimer(); + GP16bitTimer& getTimer(); private: // This class is not copyable!