Removed reader class
All checks were successful
Generate Documentation / build (push) Successful in 15s
All checks were successful
Generate Documentation / build (push) Successful in 15s
This commit is contained in:
@@ -1,31 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
class Reader
|
||||
{
|
||||
private:
|
||||
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
|
||||
*
|
||||
* @param buttonPin The pin of the button
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool debounceReadNO(int buttonPin);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Function used to read state of a normally open(LOW) button
|
||||
*
|
||||
* @param buttonPin The pin of the button
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool debounceReadNO(int buttonPin);
|
||||
|
||||
/**
|
||||
* @brief Function used to read state of a normally closed(HIGH) button
|
||||
*
|
||||
* @param buttonPin The pin of the button
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool debounceReadNC(int buttonPin);
|
||||
};
|
||||
/**
|
||||
* @brief Function used to read state of a normally closed(HIGH) button
|
||||
*
|
||||
* @param buttonPin The pin of the button
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool debounceReadNC(int buttonPin);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
14
src/main.cpp
14
src/main.cpp
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user