diff --git a/library.properties b/library.properties index a36aa66..c64ca94 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=DigitalSignalsArduino -version=0.0.4 +version=0.0.5 author=Tolentino Cotesta maintainer=Tolentino Cotesta sentence=Arduino Digital Signal library diff --git a/src/DigitalIn.cpp b/src/DigitalIn.cpp index 62f7165..be56b94 100644 --- a/src/DigitalIn.cpp +++ b/src/DigitalIn.cpp @@ -54,13 +54,13 @@ uint8_t DigitalIn::update() { if (!m_pressEdge && fn_press != nullptr && m_pressedDuration > m_bounceTime) { m_pressEdge = true; - fn_press(); + fn_press(this); } } else { m_pressEdge = false; if (fn_release != nullptr && m_pressedDuration > m_bounceTime) { - fn_release(); + fn_release(this); } if (m_pressedDuration > m_longClickTime) { @@ -99,4 +99,4 @@ bool DigitalIn::longClick(bool waitRelease) { return m_fsmState == LONG_CLICK; else return m_fsmState == PRESSED; -} +} \ No newline at end of file diff --git a/src/DigitalIn.h b/src/DigitalIn.h index 5990676..efcb30c 100644 --- a/src/DigitalIn.h +++ b/src/DigitalIn.h @@ -6,7 +6,7 @@ typedef int IOPinName; typedef int IOPinMode; -typedef void(*function_cb)(); +typedef void(*function_cb)(void*); /** A digital input, used for reading the state of a pin @@ -92,6 +92,11 @@ class DigitalIn { update(); return isActive() && m_pressedDuration > m_bounceTime; } + + /** Get assigned GPIO number */ + int getPin() { + return m_pin; + } }; diff --git a/src/DigitalOut.h b/src/DigitalOut.h index f3f6f4f..61c0ddf 100644 --- a/src/DigitalOut.h +++ b/src/DigitalOut.h @@ -6,7 +6,7 @@ namespace Output { enum class OutType {SR, TOFF, TON, TON_M, BLINK}; } -typedef void(*function_cb)(); +typedef void(*function_out_cb)(); using Output::OutType; @@ -43,8 +43,8 @@ class DigitalOut // Set output state void write(bool val); - function_cb fn_rise = nullptr; - function_cb fn_fall = nullptr; + function_out_cb fn_rise = nullptr; + function_out_cb fn_fall = nullptr; public: DigitalOut(OutType type, uint32_t time = 0); @@ -80,11 +80,11 @@ class DigitalOut write(value); } - inline void onRising(function_cb fn) { + inline void onRising(function_out_cb fn) { fn_rise = fn; } - inline void onFalling(function_cb fn) { + inline void onFalling(function_out_cb fn) { fn_fall = fn; }