From aa187fa523794eb387192ce97cad3b785bb5b574 Mon Sep 17 00:00:00 2001 From: Gabriel Radzki Date: Wed, 18 Dec 2024 21:16:49 -0300 Subject: [PATCH 1/3] Update RCSwitch.cpp Sync factor before sending signal --- RCSwitch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RCSwitch.cpp b/RCSwitch.cpp index 99d3cc1..727df01 100644 --- a/RCSwitch.cpp +++ b/RCSwitch.cpp @@ -508,13 +508,13 @@ void RCSwitch::send(unsigned long code, unsigned int length) { #endif for (int nRepeat = 0; nRepeat < nRepeatTransmit; nRepeat++) { + this->transmit(protocol.syncFactor); for (int i = length-1; i >= 0; i--) { if (code & (1L << i)) this->transmit(protocol.one); else this->transmit(protocol.zero); } - this->transmit(protocol.syncFactor); } // Disable transmit after sending (i.e., for inverted protocols) From f36945e06e3dfec64d4b62952e9accfd29e9af11 Mon Sep 17 00:00:00 2001 From: Gabriel Radzki Date: Sat, 21 Dec 2024 23:46:42 -0300 Subject: [PATCH 2/3] Setter for sync factor order --- RCSwitch.cpp | 20 +++++++++++++++++++- RCSwitch.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/RCSwitch.cpp b/RCSwitch.cpp index 727df01..4062363 100644 --- a/RCSwitch.cpp +++ b/RCSwitch.cpp @@ -114,6 +114,7 @@ RCSwitch::RCSwitch() { this->nTransmitterPin = -1; this->setRepeatTransmit(10); this->setProtocol(1); + this->setSyncFactorFirst(false); #if not defined( RCSwitchDisableReceiving ) this->nReceiverInterrupt = -1; this->setReceiveTolerance(60); @@ -158,6 +159,14 @@ void RCSwitch::setPulseLength(int nPulseLength) { this->protocol.pulseLength = nPulseLength; } +/** + * Sets sync factor to be sent first, before the code word + */ +void RCSwitch::setSyncFactorFirst(bool syncFactor) { + this->syncFactorFirst = syncFactor; +} + + /** * Sets Repeat Transmits */ @@ -508,13 +517,22 @@ void RCSwitch::send(unsigned long code, unsigned int length) { #endif for (int nRepeat = 0; nRepeat < nRepeatTransmit; nRepeat++) { - this->transmit(protocol.syncFactor); + + if (this->syncFactorFirst) { + this->transmit(protocol.syncFactor); + } + for (int i = length-1; i >= 0; i--) { if (code & (1L << i)) this->transmit(protocol.one); else this->transmit(protocol.zero); } + + if (!this->syncFactorFirst) { + this->transmit(protocol.syncFactor); + } + } // Disable transmit after sending (i.e., for inverted protocols) diff --git a/RCSwitch.h b/RCSwitch.h index b7755e0..c66f1ff 100644 --- a/RCSwitch.h +++ b/RCSwitch.h @@ -162,6 +162,7 @@ class RCSwitch { #endif int nTransmitterPin; int nRepeatTransmit; + bool syncFactorFirst = false; Protocol protocol; From d616ce0fb9b605830da0b321488859d9a7fc41c2 Mon Sep 17 00:00:00 2001 From: Gabriel Radzki Date: Sat, 21 Dec 2024 23:51:33 -0300 Subject: [PATCH 3/3] Add missing declaration --- RCSwitch.h | 1 + 1 file changed, 1 insertion(+) diff --git a/RCSwitch.h b/RCSwitch.h index c66f1ff..1e818e0 100644 --- a/RCSwitch.h +++ b/RCSwitch.h @@ -97,6 +97,7 @@ class RCSwitch { void enableTransmit(int nTransmitterPin); void disableTransmit(); void setPulseLength(int nPulseLength); + void setSyncFactorFirst(bool syncFactorFirst); void setRepeatTransmit(int nRepeatTransmit); #if not defined( RCSwitchDisableReceiving ) void setReceiveTolerance(int nPercent);