Extracted mute to seperate file
All checks were successful
Build Code / build (push) Successful in 1m17s
All checks were successful
Build Code / build (push) Successful in 1m17s
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
void mute(int *userVolume, int *oldUserVolume, int maxVolume);
|
||||
void lowerVolume(int *userVolume, int *oldUserVolume, int maxVolume);
|
||||
void volumeUp(int *userVolume, int *oldUserVolume, int maxVolume);
|
||||
void volumeDown(int *userVolume, int *oldUserVolume);
|
||||
39
src/main.cpp
39
src/main.cpp
@@ -82,44 +82,7 @@ void loop()
|
||||
// Remote D - Mute
|
||||
if (debounceRead(REMOTE_D))
|
||||
{
|
||||
|
||||
// Check if we are in a muted state
|
||||
if (oldUserVolume > userVolume)
|
||||
{
|
||||
// This is if the user is muted and is asking to be unmuted
|
||||
// Check if max volume has been lowered since mute
|
||||
if (oldUserVolume > maxVolume)
|
||||
{
|
||||
// If the max volume has been lowered since mute, 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 unmuted and is aksing to be muted
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
potDecrement();
|
||||
}
|
||||
|
||||
oldUserVolume = userVolume;
|
||||
userVolume = 0;
|
||||
}
|
||||
mute(&userVolume, &oldUserVolume, maxVolume);
|
||||
}
|
||||
|
||||
// Remote A - Significantly Lower Volume
|
||||
|
||||
@@ -2,6 +2,47 @@
|
||||
#include <constants.h>
|
||||
#include <potControlls.h>
|
||||
|
||||
void mute(int *userVolume, int *oldUserVolume, int maxVolume)
|
||||
{
|
||||
// Check if we are in a muted state
|
||||
if (*oldUserVolume > *userVolume)
|
||||
{
|
||||
// This is if the user is muted and is asking to be unmuted
|
||||
// Check if max volume has been lowered since mute
|
||||
if (*oldUserVolume > maxVolume)
|
||||
{
|
||||
// If the max volume has been lowered since mute, 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 unmuted and is aksing to be muted
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
potDecrement();
|
||||
}
|
||||
|
||||
*oldUserVolume = *userVolume;
|
||||
*userVolume = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void lowerVolume(int *userVolume, int *oldUserVolume, int maxVolume)
|
||||
{
|
||||
// Check if we volume is already lowered
|
||||
|
||||
Reference in New Issue
Block a user