rc-switch icon indicating copy to clipboard operation
rc-switch copied to clipboard

Add protocol with 12 bits preamble

Open ilyamordasov opened this issue 1 year ago • 0 comments

Seems it doesn't work with some remotes, i.e. I have a remote for garage gate ANMotors, that has 12 bits of preamble and 65 bits of code, usually I thend it like this:

int Pe = 413;
int Pe2 = Pe*2;
void SendANMotors(long c1, long c2) // c1 = 0x20247878, c2 = 0x150bce89
{
  noInterrupts();
  for (int j = 0; j < 4; j++)
  {
    for (int i = 0; i < 12; i++) {
      delayMicroseconds(Pe);
      digitalWrite(txPin, HIGH);
      delayMicroseconds(Pe);
      digitalWrite(txPin, LOW);
    }
    delayMicroseconds(Pe * 10);
    for (int i = 4 * 8; i > 0; i--) {
      SendBit(bitRead(c1, i - 1));
    }
    for (int i = 4 * 8; i > 0; i--) {
      SendBit(bitRead(c2, i - 1));
    }
    SendBit(1);
    SendBit(1);
    delayMicroseconds(Pe * 39);
  }
  interrupts();
}
 
void SendBit(byte b) {
  if (b == 0) {
    digitalWrite(txPin, HIGH); // 0
    delayMicroseconds(Pe2);
    digitalWrite(txPin, LOW);
    delayMicroseconds(Pe);
  }
  else {
    digitalWrite(txPin, HIGH); // 1
    delayMicroseconds(Pe);
    digitalWrite(txPin, LOW);
    delayMicroseconds(Pe2);
  }
}

could you please add this protocol?

ilyamordasov avatar Dec 21 '22 08:12 ilyamordasov