Removed reader class
All checks were successful
Generate Documentation / build (push) Successful in 15s

This commit is contained in:
2025-11-02 14:10:50 +01:00
parent 4a4a66f0d4
commit 02a9c782c2
3 changed files with 31 additions and 38 deletions

View File

@@ -1,16 +1,5 @@
#pragma once
class Reader
{
private:
unsigned long lastDebounceTime = 0;
bool lastButtonStateNO = LOW;
bool buttonStateNO = HIGH;
bool lastButtonStateNC = HIGH;
bool buttonStateNC = LOW;
int lastPin;
public:
/**
* @brief Function used to read state of a normally open(LOW) button
*
@@ -28,4 +17,3 @@ public:
* @return false
*/
bool debounceReadNC(int buttonPin);
};

View File

@@ -13,6 +13,13 @@
#include <commonFunctions.h>
#include <constants.h>
unsigned long lastDebounceTime = 0;
bool lastButtonStateNO = LOW;
bool buttonStateNO = HIGH;
bool lastButtonStateNC = HIGH;
bool buttonStateNC = LOW;
int lastPin;
/**
* @brief Function used to read state of a normally open(LOW) button
*
@@ -20,7 +27,7 @@
* @return true
* @return false
*/
bool Reader::debounceReadNO(int buttonPin)
bool debounceReadNO(int buttonPin)
{
bool reading = digitalRead(buttonPin);
@@ -60,7 +67,7 @@ bool Reader::debounceReadNO(int buttonPin)
* @return true
* @return false
*/
bool Reader::debounceReadNC(int buttonPin)
bool debounceReadNC(int buttonPin)
{
bool reading = digitalRead(buttonPin);

View File

@@ -10,8 +10,6 @@ int maxVolume = 64;
int userVolume = 64;
int oldUserVolume = userVolume;
Reader reader;
void setup()
{
pinMode(LED_HIGH, OUTPUT); // Green
@@ -45,39 +43,39 @@ void loop()
updateLeds(maxVolume);
// SW1 - Staff Volume Up
if (reader.debounceReadNC(BTN_STAFF_UP))
if (debounceReadNC(BTN_STAFF_UP))
{
staffVolumeUp(&maxVolume);
}
// SW2 - Staff Volume Down
if (reader.debounceReadNC(BTN_STAFF_DWN))
if (debounceReadNC(BTN_STAFF_DWN))
{
staffVolumeDown(&maxVolume, &userVolume, &oldUserVolume);
}
// Remote D - Mute
if (reader.debounceReadNO(REMOTE_D))
if (debounceReadNO(REMOTE_D))
{
mute(&userVolume, &oldUserVolume, maxVolume);
}
// Remote A - Significantly Lower Volume
if (reader.debounceReadNO(REMOTE_A))
if (debounceReadNO(REMOTE_A))
{
lowerVolume(&userVolume, &oldUserVolume, maxVolume);
}
// Remote B - Volume Up
// Make sure we are not is a state of mute or lowered
if (reader.debounceReadNO(REMOTE_B) && !(oldUserVolume > userVolume))
if (debounceReadNO(REMOTE_B) && !(oldUserVolume > userVolume))
{
volumeUp(&userVolume, &oldUserVolume, maxVolume);
}
// Remote C - Volume Down
// Make sure we are not is a state of mute or lowered
if (reader.debounceReadNO(REMOTE_C) && !(oldUserVolume > userVolume))
if (debounceReadNO(REMOTE_C) && !(oldUserVolume > userVolume))
{
volumeDown(&userVolume, &oldUserVolume);
}