dougkpowers/pc1550-interface

Question on sendKey

ccullin opened this issue · 2 comments

hi Doug - Great code - works like a champion. I am connecting an arduino to a raspberry pi and adding SMS notifications to the alarm.

The Output side of things works great but I have one challenge on sendKey. I need to call processTransmissionCycle() twice between each sendKey, otherwise sendKey is false.

The following code works but there is either something I don't understand or something not quite right. Any thoughts or suggestions?

thanks
Chris

My code is:

void loop() {
//process a full transmisison cycle with the PC1550 controller
alarm.processTransmissionCycle();

//process serial port key press
if (Serial.available() > 0){
    alarm.processTransmissionCycle();  //without this call every other sendKey is false
    inChar = Serial.read();
    Serial.print (inChar);
    if (!alarm.sendKey(inChar)) {
        Serial.println("send not successful");
    }
    else {
        Serial.println("send OK");
    }
} 

//print the state of the keypad and and PGM output to the Serial console
if (alarm.keypadStateChanged()){
    printState();
}

}

Seems like this is expected if you look at the example in #4

@ccullin sendKey simply sets the key that should be sent on the next transmission cycle. If you call it 4 times in a row, then the first 3 calls would be ignored.

sendKey(..) means "Make this the next key you send"
processTransmissionCycle() ...amongst many things, this will send the last key set via sendKey (if it hasn't already been set)