From 437771fabd4d16318a58dbb85bee8f15c9765f9b Mon Sep 17 00:00:00 2001 From: Gregg Date: Sat, 13 Jan 2024 15:20:20 -0600 Subject: [PATCH] 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 --- src/HomeSpan.h | 9 --------- src/Utils.cpp | 2 +- src/Utils.h | 20 ++++++++++---------- src/src.ino | 5 ++++- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 74ac04a..0608bbf 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -851,15 +851,6 @@ class SpanButton : public PushButton { buttonType_t buttonType=HS_BUTTON; // type of SpanButton 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){}; diff --git a/src/Utils.cpp b/src/Utils.cpp index 7af158e..7244f1f 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -278,4 +278,4 @@ void PushButton::reset(){ ////////////////////////////////////// -touch_value_t PushButton::threshold=0; +PushButton::touch_value_t PushButton::threshold=0; diff --git a/src/Utils.h b/src/Utils.h index 1ce7f6f..705d7d2 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -103,15 +103,7 @@ 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; @@ -119,15 +111,23 @@ class PushButton{ uint32_t singleAlarm; 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; diff --git a/src/src.ino b/src/src.ino index 1ff5792..0a87165 100644 --- a/src/src.ino +++ b/src/src.ino @@ -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");