add pin change

This commit is contained in:
DashyFox 2023-11-30 16:24:43 +03:00
parent 4f6482ec2a
commit 78f8a77f72
2 changed files with 9 additions and 7 deletions

View File

@ -6,7 +6,7 @@
((uint16_t)((dataBuffer[h] << 8) | dataBuffer[l]) >= IR_Broadcast)\
)
IR_Decoder::IR_Decoder(uint16_t addr, IR_Encoder* encPair = nullptr) : addrSelf(addr), encoder(encPair) {
IR_Decoder::IR_Decoder(const uint8_t isrPin, uint16_t addr, IR_Encoder* encPair = nullptr) : isrPin(isrPin), addrSelf(addr), encoder(encPair) {
rawBuffer = new uint8_t[bufferRawSize] { 0 };
prevRise = prevFall = prevPrevFall = prevPrevRise = 0;
start_RX();
@ -191,7 +191,7 @@ void IR_Decoder::isr() { // в прерывании вызываем isr()
}
if (frontCounter > 0) { // в преамбуле
uint32_t risePeriod = micros() - prevRise;
if ((PIND >> 2) & 1 && risePeriod < IR_timeout) { // __/``` ↑ и мы в внутри пакета
if ((PIND >> isrPin) & 1 && risePeriod < IR_timeout) { // __/``` ↑ и мы в внутри пакета
if (risePeriod < riseTimeMin << 1) { // fix рваной единицы
frontCounter += 2;
@ -210,7 +210,7 @@ void IR_Decoder::isr() { // в прерывании вызываем isr()
}
// определить направление фронта
if ((PIND >> 2) & 1) { // Если __/``` ↑
if ((PIND >> isrPin) & 1) { // Если __/``` ↑
uint16_t risePeriod = micros() - prevRise;
uint16_t highTime = micros() - prevFall;

View File

@ -27,7 +27,7 @@ class IR_Decoder : private IR_FOX {
public:
uint16_t addrSelf;
IR_Decoder(uint16_t addr, IR_Encoder* encPair = nullptr);
IR_Decoder(const uint8_t isrPin, uint16_t addr, IR_Encoder* encPair = nullptr);
~IR_Decoder();
// @brief Для прерывания
@ -163,6 +163,8 @@ public:
private:
const uint8_t isrPin;
IR_Encoder* encoder;
bool isPairSending = false;
bool IsPairSendLOW = false;