Cleaned up some public/private permissioning inside PushButton and SpanButton

Ensure users can access constants like TRIGGER_ON_HIGH, TRIGGER_ON_LOW, etc. using any of these equivalent fully-qualified names:

* PushButton::TRIGGER_ON_HIGH
* SpanButton::TRIGGER_ON_HIGH
* SpanToggle::TRIGGER_ON_HIGH
This commit is contained in:
Gregg 2024-01-13 15:20:20 -06:00
parent 260be21462
commit 437771fabd
4 changed files with 15 additions and 21 deletions

View File

@ -852,15 +852,6 @@ class SpanButton : public PushButton {
public:
static constexpr triggerType_t TRIGGER_ON_LOW=PushButton::TRIGGER_ON_LOW;
static constexpr triggerType_t TRIGGER_ON_HIGH=PushButton::TRIGGER_ON_HIGH;
#if SOC_TOUCH_SENSOR_NUM > 0
static constexpr triggerType_t TRIGGER_ON_TOUCH=PushButton::TRIGGER_ON_TOUCH;
static void setTouchCycles(uint16_t measureTime, uint16_t sleepTime){PushButton::setTouchCycles(measureTime,sleepTime);}
static void setTouchThreshold(touch_value_t thresh){PushButton::setTouchThreshold(thresh);}
#endif
SpanButton(int pin, uint16_t longTime=2000, uint16_t singleTime=5, uint16_t doubleTime=200, triggerType_t triggerType=TRIGGER_ON_LOW);
SpanButton(int pin, triggerType_t triggerType, uint16_t longTime=2000, uint16_t singleTime=5, uint16_t doubleTime=200) : SpanButton(pin,longTime,singleTime,doubleTime,triggerType){};

View File

@ -278,4 +278,4 @@ void PushButton::reset(){
//////////////////////////////////////
touch_value_t PushButton::threshold=0;
PushButton::touch_value_t PushButton::threshold=0;

View File

@ -103,16 +103,8 @@ class TempBuffer {
// PushButton //
////////////////////////////////
#if SOC_TOUCH_VERSION_2
typedef uint32_t touch_value_t;
#else
typedef uint16_t touch_value_t;
#endif
class PushButton{
friend class Span;
int status;
int toggleStatus;
boolean doubleCheck;
@ -120,14 +112,22 @@ class PushButton{
uint32_t doubleAlarm;
uint32_t longAlarm;
#if SOC_TOUCH_VERSION_2
typedef uint32_t touch_value_t;
#else
typedef uint16_t touch_value_t;
#endif
static touch_value_t threshold;
static const int calibCount=20;
public:
typedef boolean (*triggerType_t)(int pin);
protected:
int pressType;
typedef boolean (*triggerType_t)(int pin);
int pin;
triggerType_t triggerType;

View File

@ -33,7 +33,10 @@ void setup() {
Serial.begin(115200);
homeSpan.setLogLevel(1).setControlPin(21,SpanButton::TRIGGER_ON_HIGH).setStatusPin(13);
homeSpan.setLogLevel(1).setStatusPin(13);
pinMode(21,OUTPUT);
homeSpan.setControlPin(21,SpanToggle::TRIGGER_ON_HIGH );
homeSpan.setControlPin(21,PushButton::TRIGGER_ON_HIGH );
homeSpan.enableWebLog(50,"pool.ntp.org","UTC");
homeSpan.begin(Category::Lighting,"HomeSpan Max");