diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputCard.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputCard.cpp index 0cf87f0..9ae678d 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputCard.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputCard.cpp @@ -310,4 +310,16 @@ void DigitalInputCard::loadPinMap(uint8_t pinMap[16]) uint8_t DigitalInputCard::getType() { return CARD_TYPE_DIGITAL_INPUT; +} + +/** + * @brief Preload the previous input buffer and the input buffer + * + * @note This function is useful if you want to preload the input buffers with a run-time value + */ +void DigitalInputCard::preloadInputBuffer() { + refreshInputBankA(); + refreshInputBankB(); + previousInputBufferA = inputBufferA; + previousInputBufferB = inputBufferB; } \ No newline at end of file diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputCard.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputCard.hpp index 3ba7805..f5587ba 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputCard.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputCard.hpp @@ -41,6 +41,8 @@ class DigitalInputCard : public ExpansionCard { void unregisterCallback(uint8_t handler); // Load a new pin map void loadPinMap(uint8_t pinMap[16]); + // Preload previousInputBuffer and inputBuffer + void preloadInputBuffer(); // Get type of card uint8_t getType(); private: diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.cpp index cefa8e8..d760dc1 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.cpp @@ -306,4 +306,13 @@ void DigitalOutputCard::saveStateToFRAM() { if(!framBinded) return; uint16_t packed = packStates(); this->fram->write16(framAddress, packed); +} + +/** + * @brief Toggle the state of the specified pin + * + * @param pin The pin to toggle + */ +void DigitalOutputCard::toggleState(uint8_t pin) { + this->setState(pin, !this->state_buffer[pin]); } \ No newline at end of file diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.hpp index a3ed97c..88ebbaa 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.hpp @@ -58,6 +58,8 @@ public: void setValue(uint8_t pin, uint16_t value); // Get the state of the specified pin bool getState(uint8_t pin); + // Toggle the state of the specified pin + void toggleState(uint8_t pin); // Get the pwm value of the specified pin uint16_t getValue(uint8_t pin); // Register a callback function that will be called when the state of a pin changes diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaCommon.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaCommon.hpp index 3c1fa1d..655573d 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaCommon.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaCommon.hpp @@ -1,3 +1,3 @@ #pragma once -#define SDK_VESRION "2.9.1" \ No newline at end of file +#define SDK_VESRION "2.9.2" \ No newline at end of file