File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed
Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -78,4 +78,4 @@ extern event_action_map_elem_t* event_action_map;
7878inline constexpr const char * board_name = " CATS Vega" ;
7979extern char telemetry_code_version[20 ];
8080
81- // NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
81+ // NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
Original file line number Diff line number Diff line change @@ -22,9 +22,10 @@ namespace driver {
2222
2323void Buzzer::SetVolume (uint16_t volume) {
2424 const uint16_t pwm_depth = m_pwm_channel.GetPwmDepth ();
25+ // Limit volume to 100%
26+ volume = std::min<uint16_t >(100U , volume);
2527 // 100% volume = 50% pwm
26- // NOLINTNEXTLINE(bugprone-implicit-widening-of-multiplication-result)
27- const uint32_t pwm_ticks = (pwm_depth / 200U ) * volume;
28+ const uint32_t pwm_ticks = (static_cast <uint32_t >(pwm_depth) / 200U ) * volume;
2829 m_pwm_channel.SetDutyCycleTicks (pwm_ticks);
2930}
3031
You can’t perform that action at this time.
0 commit comments