From 2623b7508abd67f8c42572e9a9fc404509d6d977 Mon Sep 17 00:00:00 2001 From: Alan Boulton Date: Mon, 16 Dec 2024 11:11:45 +0000 Subject: [PATCH 1/2] Bug fix: output volume control fails, because feature detection logic is wrong Explanation: since '==' is higher priority than '&' then both feature detections (lines 776 and 778) always fail. Parentheses enforce correct evaluation (and match correct feature detection logic elsewhere in this file - like lines 565 and 571). --- mtb_wm8960.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mtb_wm8960.cpp b/mtb_wm8960.cpp index 1db686e..32b4436 100644 --- a/mtb_wm8960.cpp +++ b/mtb_wm8960.cpp @@ -773,10 +773,10 @@ bool mtb_wm8960_adjust_speaker_output_volume(uint8_t volume) bool mtb_wm8960_set_output_volume(uint8_t volume){ bool result = true; - if (enabled_features & WM8960_FEATURE_SPEAKER == WM8960_FEATURE_SPEAKER ) - result = result && mtb_wm8960_adjust_speaker_output_volume(volume); - if (enabled_features & WM8960_FEATURE_HEADPHONE == WM8960_FEATURE_HEADPHONE) - result = result && mtb_wm8960_adjust_heaphone_output_volume(volume); + if ((enabled_features & WM8960_FEATURE_SPEAKER) == WM8960_FEATURE_SPEAKER ) + result = result && mtb_wm8960_adjust_speaker_output_volume(volume); + if ((enabled_features & WM8960_FEATURE_HEADPHONE) == WM8960_FEATURE_HEADPHONE) + result = result && mtb_wm8960_adjust_heaphone_output_volume(volume); return result; } From 278bd401232619374698d6bb7610f6bea7640cd2 Mon Sep 17 00:00:00 2001 From: Alan Boulton Date: Mon, 16 Dec 2024 11:14:28 +0000 Subject: [PATCH 2/2] Cosmetic: corrected LOG message to indicate speaker rather than headphone. --- mtb_wm8960.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mtb_wm8960.cpp b/mtb_wm8960.cpp index 32b4436..f321b6b 100644 --- a/mtb_wm8960.cpp +++ b/mtb_wm8960.cpp @@ -756,7 +756,7 @@ bool mtb_wm8960_adjust_heaphone_output_volume(uint8_t volume) //-------------------------------------------------------------------------------------------------- bool mtb_wm8960_adjust_speaker_output_volume(uint8_t volume) { - WM8960_LOG("mtb_wm8960_adjust_heaphone_output_volume"); + WM8960_LOG("mtb_wm8960_adjust_speaker_output_volume"); if (volume > WM8960_LOUT1_ROUT1_VOL_OUT1VOL_6dB) { return false;