void kpdEvent (KeypadEvent Key) { switch (kpd.getState()) { case PRESSED : Serial.println(Key); // mj switch (Key) { // appui sur '*' -> vérification de la saisie en cours case '*' : checkPassword(); break; // appui sur '#' -> réinitialisation de la saisie en cours case '#' : pwd.reset(); clear_lcd_pin(); break; // sinon on ajoute le chiffre à la combinaison default : pwd.append(Key); break; } set_lcd_pin(); default : break; } }
// Process buttons: void procButton(KeypadEvent b) { b -= 48; switch (keypad.getState()) { case RELEASED: // drop right away return; case PRESSED: // momentary if(mode==2) { // Signal Switching 4 ss4Signal(b); break; } else if(mode==3) { pulse(b); // pulse it return; } if(mode==4&&(b<10&&b>=0||b==-13||b==-6||(b>=49&&b<=52))) { // MF tone mf(b); } if(b<10&&b>=0||b==-13||b==-6) { // MF tone mf(b); } else if(b==52) { // D if (stored) playStored(); // don't copy function onto stack if not needed return; } else if(mode==1) { // international kp2/st2 if(b>=49&&b<=51) { mf(b); return; } } else if(mode==0&&(b<=51&&b>=49)) { // A,B,C redbox redBox(b); // pass it to RedBox() return; } break; case HOLD: // HELD (special functions) if(b==50&&mode==3) { // HOLD B for MF2 in PD Mode (mf2)? mf2 = 0 : mf2 = 1; // turn off if on, or on if off freq[0].play(440,70); delay(140); freq[0].play(440,70); delay(140); } if(b<10&&b>=0||b==-13||b==-6) { dial(b); } else if(b==51) { // C takes care of recording now if(rec) { // we are done recording: digitalWrite(13, LOW); // turn off LED rec = 0; stored=1; // we have digits stored recNotify(); } else { // we start recording digitalWrite(13, HIGH); // light up LED rec = 1; for(int i=0; i<=23; i++) { // reset array store[i] = -1; } recNotify(); } // END recording code } else if(b==49) { // ('A' HELD) switching any mode "on" changes to mode, all "off" is domestic if(mode==0) { // mf to international mode=1; } else if(mode==1) { // international to ss4 mode mode=2; } else if(mode==2) { // ss4 mode to pulse mode mode=3; } else if(mode==3) { // pulse mode to DTMF mode=4; } else if(mode==4) { // DTMF to domestic mode=0; } notifyMode(); return; } break; } return; }