begin update of PushButton to make it more generic

Eliminated constructor that had no pin parameter.  Pin parameter is now always required.  Since PushButton was not part of HomeSpan API, these changes should not impact any users.
This commit is contained in:
Gregg 2022-08-11 06:12:41 -05:00
parent 57d791178c
commit 54b8374573
4 changed files with 4 additions and 44 deletions

View File

@ -191,7 +191,6 @@ class Span{
const char *defaultSetupCode=DEFAULT_SETUP_CODE; // Setup Code used for pairing
int statusPin=DEFAULT_STATUS_PIN; // pin for Status LED
uint16_t autoOffLED=0; // automatic turn-off duration (in seconds) for Status LED
// int controlPin=DEFAULT_CONTROL_PIN; // pin for Control Pushbutton
uint8_t logLevel=DEFAULT_LOG_LEVEL; // level for writing out log messages to serial monitor
uint8_t maxConnections=CONFIG_LWIP_MAX_SOCKETS-2; // maximum number of allowed simultaneous HAP connections
uint8_t requestedMaxCon=CONFIG_LWIP_MAX_SOCKETS-2; // requested maximum number of simultaneous HAP connections

View File

@ -71,7 +71,6 @@
#define DEFAULT_QR_ID "HSPN" // change with homeSpan.setQRID(qrID);
//#define DEFAULT_CONTROL_PIN -1 // change with homeSpan.setControlPin(pin)
#define DEFAULT_STATUS_PIN -1 // change with homeSpan.setStatusPin(pin)
#define DEFAULT_AP_SSID "HomeSpan-Setup" // change with homeSpan.setApSSID(ssid)

View File

@ -85,22 +85,9 @@ String Utils::mask(char *c, int n){
// PushButton //
////////////////////////////////
PushButton::PushButton(){}
//////////////////////////////////////
PushButton::PushButton(int pin){
init(pin);
}
//////////////////////////////////////
void PushButton::init(int pin){
this->pin=pin;
if(pin<0)
return;
status=0;
doubleCheck=false;
pinMode(pin, INPUT_PULLUP);
@ -110,9 +97,6 @@ void PushButton::init(int pin){
boolean PushButton::triggered(uint16_t singleTime, uint16_t longTime, uint16_t doubleTime){
if(pin<0)
return(false);
unsigned long cTime=millis();
switch(status){
@ -190,9 +174,6 @@ boolean PushButton::triggered(uint16_t singleTime, uint16_t longTime, uint16_t d
boolean PushButton::primed(){
if(pin<0)
return(false);
if(millis()>singleAlarm && status==1){
status=2;
return(true);
@ -210,10 +191,6 @@ int PushButton::type(){
//////////////////////////////////////
void PushButton::wait(){
if(pin<0)
return;
while(!digitalRead(pin));
}

View File

@ -89,24 +89,9 @@ class PushButton{
LONG=2
};
PushButton();
PushButton(int pin);
// Creates generic pushbutton functionality on specified pin
// that is wired to connect to ground when the button is pressed.
//
// In the first form, a PushButton is instantiated without specifying
// the pin. In this case the pin must be specified in a subsequent call
// to init() before the PushButton can be used.
//
// In the second form, a PushButton is instantiated and initialized with
// the specified pin, obviating the need for a separate call to init().
//
// pin: Pin mumber to which pushbutton connects to ground when pressed
void init(int pin);
// Initializes PushButton, if not configured during instantiation.
// Creates generic pushbutton functionality on specified pin.
//
// pin: Pin mumber to which pushbutton connects to ground when pressed