Extracted lowerVolume to seperate file
All checks were successful
Build Code / build (push) Successful in 1m12s
All checks were successful
Build Code / build (push) Successful in 1m12s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
void lowerVolume(int *userVolume, int *oldUserVolume, int maxVolume);
|
||||
void volumeUp(int *userVolume, int *oldUserVolume, int maxVolume);
|
||||
void volumeDown(int *userVolume, int *oldUserVolume);
|
||||
40
src/main.cpp
40
src/main.cpp
@@ -125,45 +125,7 @@ void loop()
|
||||
// Remote A - Significantly Lower Volume
|
||||
if (debounceRead(REMOTE_A))
|
||||
{
|
||||
|
||||
// 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++)
|
||||
{
|
||||
potIncrement();
|
||||
}
|
||||
}
|
||||
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++)
|
||||
{
|
||||
potIncrement();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is if the user is not lowered and is aksing to be lowered
|
||||
for (int i = 0; i < userVolume - 10; i++)
|
||||
{
|
||||
potDecrement();
|
||||
}
|
||||
|
||||
oldUserVolume = userVolume;
|
||||
userVolume -= 10;
|
||||
}
|
||||
lowerVolume(&userVolume, &oldUserVolume, maxVolume);
|
||||
}
|
||||
|
||||
// Remote B - Volume Up
|
||||
|
||||
@@ -2,6 +2,48 @@
|
||||
#include <constants.h>
|
||||
#include <potControlls.h>
|
||||
|
||||
void lowerVolume(int *userVolume, int *oldUserVolume, int maxVolume)
|
||||
{
|
||||
// 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++)
|
||||
{
|
||||
potIncrement();
|
||||
}
|
||||
}
|
||||
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++)
|
||||
{
|
||||
potIncrement();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is if the user is not lowered and is aksing to be lowered
|
||||
for (int i = 0; i < *userVolume - 10; i++)
|
||||
{
|
||||
potDecrement();
|
||||
}
|
||||
|
||||
*oldUserVolume = *userVolume;
|
||||
*userVolume -= 10;
|
||||
}
|
||||
}
|
||||
|
||||
void volumeUp(int *userVolume, int *oldUserVolume, int maxVolume)
|
||||
{
|
||||
if ((*userVolume + USER_STEPS) > maxVolume)
|
||||
|
||||
Reference in New Issue
Block a user