diff --git a/src/main.cpp b/src/main.cpp index 07aaeea..624d2b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -146,21 +146,44 @@ void loop() // Remote A - Significantly Lower Volume if (digitalRead(A3)) { + + // Check if we volume is already lowered if (oldUserVolume > userVolume) { + + // If it is lowered - restore it + // Check if max volume has changed since lowering if (oldUserVolume > maxVolume) { + // If the max volume has been lowered since lowering, then set the user volume to the new max volume userVolume = maxVolume; + + for (int i = 0; i < maxVolume; i++) + { + volumeUp(); + } } else { + // If the max volume hasn't changed then, or the old user volume is lower than the new max - restore it to where it was userVolume = oldUserVolume; + + for (int i = 0; i < oldUserVolume; i++) + { + volumeUp(); + } } } else { + // This is if the user is not lowered and is aksing to be lowered + for (int i = 0; i < userVolume - 10; i++) + { + volumeDown(); + } + oldUserVolume = userVolume; - userVolume = 15; + userVolume -= 10; } delay(300);