const char NO_KEY = 0;
class AbstractKeypad {
public:
AbstractKeypad() {
};
void Trigger(char key) {
nextKey = key;
return true;
};
void Update() {
lastKey = currentKey;
currentKey = nextKey;
nextKey = NO_KEY;
};
char getKey() {
return currentKey;
};
private:
char currentKey;
char lastKey;
char nextKey;
};
AbstractKeypad keypad();
char cc;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println(F("Start"));
}
/*
void kSerial(){
if(Serial.available()>0){
char c = Serial.read();
if(c!='\n'){
if(Serial.read()=='\n'){
keypad.triggerKeyPress(c);
Serial.print(F("Trigger Key '"));
Serial.print(c);
Serial.println(F("'"));
}
}
while(Serial.available()) Serial.read();
}
}
*/
void readSerial() {
if (Serial.available() > 0) {
char c = Serial.read();
if (c != '\n') {
if (Serial.read() == '\n') {
cc = c;
// keypad.triggerKeyPress(c);
}
}
while (Serial.available() > 0) Serial.read();
}
//
}
void onInput(char c) {
if (c != 0) {
Serial.print(F("Trigger Key '"));
Serial.print(c);
Serial.println(F("'"));
// keypad.triggerKeyPress(c);
}
cc = 0;
}
//
void loop() {
// put your main code here, to run repeatedly:
readSerial();
onInput(cc);
delay(100);
}