allow input preload and state toggling
This commit is contained in:
parent
b778fb6a02
commit
4ea2122f6e
|
@ -310,4 +310,16 @@ void DigitalInputCard::loadPinMap(uint8_t pinMap[16])
|
||||||
uint8_t DigitalInputCard::getType()
|
uint8_t DigitalInputCard::getType()
|
||||||
{
|
{
|
||||||
return CARD_TYPE_DIGITAL_INPUT;
|
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;
|
||||||
}
|
}
|
|
@ -41,6 +41,8 @@ class DigitalInputCard : public ExpansionCard {
|
||||||
void unregisterCallback(uint8_t handler);
|
void unregisterCallback(uint8_t handler);
|
||||||
// Load a new pin map
|
// Load a new pin map
|
||||||
void loadPinMap(uint8_t pinMap[16]);
|
void loadPinMap(uint8_t pinMap[16]);
|
||||||
|
// Preload previousInputBuffer and inputBuffer
|
||||||
|
void preloadInputBuffer();
|
||||||
// Get type of card
|
// Get type of card
|
||||||
uint8_t getType();
|
uint8_t getType();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -306,4 +306,13 @@ void DigitalOutputCard::saveStateToFRAM() {
|
||||||
if(!framBinded) return;
|
if(!framBinded) return;
|
||||||
uint16_t packed = packStates();
|
uint16_t packed = packStates();
|
||||||
this->fram->write16(framAddress, packed);
|
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]);
|
||||||
}
|
}
|
|
@ -58,6 +58,8 @@ public:
|
||||||
void setValue(uint8_t pin, uint16_t value);
|
void setValue(uint8_t pin, uint16_t value);
|
||||||
// Get the state of the specified pin
|
// Get the state of the specified pin
|
||||||
bool getState(uint8_t 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
|
// Get the pwm value of the specified pin
|
||||||
uint16_t getValue(uint8_t pin);
|
uint16_t getValue(uint8_t pin);
|
||||||
// Register a callback function that will be called when the state of a pin changes
|
// Register a callback function that will be called when the state of a pin changes
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define SDK_VESRION "2.9.1"
|
#define SDK_VESRION "2.9.2"
|
Loading…
Reference in New Issue