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)\ ((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 }; rawBuffer = new uint8_t[bufferRawSize] { 0 };
prevRise = prevFall = prevPrevFall = prevPrevRise = 0; prevRise = prevFall = prevPrevFall = prevPrevRise = 0;
start_RX(); start_RX();
@ -191,7 +191,7 @@ void IR_Decoder::isr() { // в прерывании вызываем isr()
} }
if (frontCounter > 0) { // в преамбуле if (frontCounter > 0) { // в преамбуле
uint32_t risePeriod = micros() - prevRise; uint32_t risePeriod = micros() - prevRise;
if ((PIND >> 2) & 1 && risePeriod < IR_timeout) { // __/``` ↑ и мы в внутри пакета if ((PIND >> isrPin) & 1 && risePeriod < IR_timeout) { // __/``` ↑ и мы в внутри пакета
if (risePeriod < riseTimeMin << 1) { // fix рваной единицы if (risePeriod < riseTimeMin << 1) { // fix рваной единицы
frontCounter += 2; 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 risePeriod = micros() - prevRise;
uint16_t highTime = micros() - prevFall; uint16_t highTime = micros() - prevFall;

View File

@ -27,7 +27,7 @@ class IR_Decoder : private IR_FOX {
public: public:
uint16_t addrSelf; 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(); ~IR_Decoder();
// @brief Для прерывания // @brief Для прерывания
@ -101,7 +101,7 @@ public:
String printData(uint8_t mode = 10) { String printData(uint8_t mode = 10) {
return printBytes(data(), dataSize(), mode); return printBytes(data(), dataSize(), mode);
} }
~Data(){}; ~Data() {};
private: private:
void ini() override { void ini() override {
_addrFrom = (_data[1] << 8) | _data[2]; _addrFrom = (_data[1] << 8) | _data[2];
@ -163,6 +163,8 @@ public:
private: private:
const uint8_t isrPin;
IR_Encoder* encoder; IR_Encoder* encoder;
bool isPairSending = false; bool isPairSending = false;
bool IsPairSendLOW = false; bool IsPairSendLOW = false;