Files
Arduino-Volume-Controller/src/staffFunctions.cpp
Lyubomir Penev 1837e09bc1
All checks were successful
Generate Documentation / build (push) Successful in 12s
Build Code / build (pull_request) Successful in 1m22s
Added fontys email
2025-10-31 15:06:12 +01:00

58 lines
1.5 KiB
C++

/**
* @file staffFunctions.cpp
* @author Lyubomir Penev (me@lpenev.com, 571147@student.fontys.nl)
* @brief Here are all the implementations of the staff functions
* @version 1.0
* @date 2025-10-23
*
* @copyright Copyright (c) 2025
*
*/
#include <staffFunctions.h>
#include <constants.h>
#include <potControlls.h>
/**
* @brief Used to increase the maximum staff volume
*
* @param maxVolume Pointer to the variable used to keep track of staff volume
*/
void staffVolumeUp(int *maxVolume)
{
if (*maxVolume < 64)
{
*maxVolume += STAFF_STEPS;
}
}
/**
* @brief Used to decrease the maximum staff volume. If the max volume is set lower than what the current user volume is, then the user volume will also be lowered.
*
* @param maxVolume Pointer to the variable used to keep track of the max volume
* @param userVolume Pointer to the variable used to keep track of the user volume
* @param oldUserVolume Pointer to the variable used to keep track of the user volume when in mute or lowered
*/
void staffVolumeDown(int *maxVolume, int *userVolume, int *oldUserVolume)
{
if (*maxVolume > STAFF_STEPS)
{
*maxVolume -= STAFF_STEPS;
if (*userVolume > *maxVolume)
{
for (int i = 0; i < (*userVolume - *maxVolume); i++)
{
potDecrement();
}
*userVolume = *maxVolume;
*oldUserVolume = *userVolume;
}
if (*oldUserVolume > *maxVolume)
{
*oldUserVolume = *maxVolume;
}
}
}