allow input preload and state toggling

This commit is contained in:
Siwat Sirichai 2024-06-21 21:34:51 +07:00
parent b778fb6a02
commit 4ea2122f6e
5 changed files with 26 additions and 1 deletions

View File

@ -311,3 +311,15 @@ 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;
}

View File

@ -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:

View File

@ -307,3 +307,12 @@ void DigitalOutputCard::saveStateToFRAM() {
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]);
}

View File

@ -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

View File

@ -1,3 +1,3 @@
#pragma once
#define SDK_VESRION "2.9.1"
#define SDK_VESRION "2.9.2"