fix: improve buzzer volume control on nRF52

- Use inverted PWM polarity (0x8000) with PCT {2,5,12,25,50} giving
  ~6-8 dB perceptual steps (-24/-16/-9/-3/0 dB) vs the original
  uneven steps where levels 4 and 5 were only 1 dB apart
- Guard against cmp=0 truncation in both _nrfStartPwm and applyVolume:
  at level 1 with high notes (freq > ~2.5 kHz) integer math gives
  cmp=0 which with inverted polarity means 100% HIGH → complete silence
- Change volume preview note from C5 (523 Hz) to C6 (1047 Hz) to better
  match the piezo resonant frequency range and actual notification sounds

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-20 09:06:00 +02:00
parent 31e91bda21
commit 6399df1f4a
2 changed files with 6 additions and 2 deletions

View File

@@ -1560,7 +1560,7 @@ void UITask::setBuzzerVolumeLevel(uint8_t level) {
if (level > 4) level = 4;
_node_prefs->buzzer_volume = level;
buzzer.setVolume(level);
if (level > 0) buzzer.playForced("Vol:d=16,o=5,b=120:c");
if (level > 0) buzzer.playForced("Vol:d=16,o=6,b=120:c");
_next_refresh = 0;
#endif
}