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,16 +1,5 @@
|
|||||||
#pragma once
|
#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
|
* @brief Function used to read state of a normally open(LOW) button
|
||||||
*
|
*
|
||||||
@@ -28,4 +17,3 @@ public:
|
|||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool debounceReadNC(int buttonPin);
|
bool debounceReadNC(int buttonPin);
|
||||||
};
|
|
||||||
@@ -13,6 +13,13 @@
|
|||||||
#include <commonFunctions.h>
|
#include <commonFunctions.h>
|
||||||
#include <constants.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
|
* @brief Function used to read state of a normally open(LOW) button
|
||||||
*
|
*
|
||||||
@@ -20,7 +27,7 @@
|
|||||||
* @return true
|
* @return true
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool Reader::debounceReadNO(int buttonPin)
|
bool debounceReadNO(int buttonPin)
|
||||||
{
|
{
|
||||||
bool reading = digitalRead(buttonPin);
|
bool reading = digitalRead(buttonPin);
|
||||||
|
|
||||||
@@ -60,7 +67,7 @@ bool Reader::debounceReadNO(int buttonPin)
|
|||||||
* @return true
|
* @return true
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool Reader::debounceReadNC(int buttonPin)
|
bool debounceReadNC(int buttonPin)
|
||||||
{
|
{
|
||||||
bool reading = digitalRead(buttonPin);
|
bool reading = digitalRead(buttonPin);
|
||||||
|
|
||||||
|
|||||||
14
src/main.cpp
14
src/main.cpp
@@ -10,8 +10,6 @@ int maxVolume = 64;
|
|||||||
int userVolume = 64;
|
int userVolume = 64;
|
||||||
int oldUserVolume = userVolume;
|
int oldUserVolume = userVolume;
|
||||||
|
|
||||||
Reader reader;
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
pinMode(LED_HIGH, OUTPUT); // Green
|
pinMode(LED_HIGH, OUTPUT); // Green
|
||||||
@@ -45,39 +43,39 @@ void loop()
|
|||||||
updateLeds(maxVolume);
|
updateLeds(maxVolume);
|
||||||
|
|
||||||
// SW1 - Staff Volume Up
|
// SW1 - Staff Volume Up
|
||||||
if (reader.debounceReadNC(BTN_STAFF_UP))
|
if (debounceReadNC(BTN_STAFF_UP))
|
||||||
{
|
{
|
||||||
staffVolumeUp(&maxVolume);
|
staffVolumeUp(&maxVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SW2 - Staff Volume Down
|
// SW2 - Staff Volume Down
|
||||||
if (reader.debounceReadNC(BTN_STAFF_DWN))
|
if (debounceReadNC(BTN_STAFF_DWN))
|
||||||
{
|
{
|
||||||
staffVolumeDown(&maxVolume, &userVolume, &oldUserVolume);
|
staffVolumeDown(&maxVolume, &userVolume, &oldUserVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remote D - Mute
|
// Remote D - Mute
|
||||||
if (reader.debounceReadNO(REMOTE_D))
|
if (debounceReadNO(REMOTE_D))
|
||||||
{
|
{
|
||||||
mute(&userVolume, &oldUserVolume, maxVolume);
|
mute(&userVolume, &oldUserVolume, maxVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remote A - Significantly Lower Volume
|
// Remote A - Significantly Lower Volume
|
||||||
if (reader.debounceReadNO(REMOTE_A))
|
if (debounceReadNO(REMOTE_A))
|
||||||
{
|
{
|
||||||
lowerVolume(&userVolume, &oldUserVolume, maxVolume);
|
lowerVolume(&userVolume, &oldUserVolume, maxVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remote B - Volume Up
|
// Remote B - Volume Up
|
||||||
// Make sure we are not is a state of mute or lowered
|
// 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);
|
volumeUp(&userVolume, &oldUserVolume, maxVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remote C - Volume Down
|
// Remote C - Volume Down
|
||||||
// Make sure we are not is a state of mute or lowered
|
// 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);
|
volumeDown(&userVolume, &oldUserVolume);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user