#include "avr/pgmspace.h" #include "OneButton.h" #include "DigiKeyboard.h" // Setup a new OneButton on pin D0. OneButton button1(0, false); byte c = 0; // credencial pointer const char S0[] PROGMEM = "preambulo"; //parte comum a todas as senhas const char S1[] PROGMEM = "otorrinolaringologista="; const char S2[] PROGMEM = "mamae+sou+forte="; const char S3[] PROGMEM = "+inconstitucionalissimamente="; const char S4[] PROGMEM = "vai+danada+vai+danada!"; const char* const table[] PROGMEM = { S0, S1, S2, S3, S4 }; char buffer[56]; // make sure this is large enough for the largest string it must hold void setup() { // link the button 1 functions. button1.attachClick(click1); button1.attachDuringLongPress(longPress1); button1.attachDoubleClick(doubleclick1); } void loop() { // keep watching the push buttons: button1.tick(); DigiKeyboard.delay(10); } // when button1 is single pressed this happens void click1() { c=c+1; DigiKeyboard.sendKeyStroke(c+3); // (a is 4) DigiKeyboard.sendKeyStroke(KEY_A,MOD_CONTROL_LEFT); // select the word writen if(c==7) { c=1; } } // ----- button 1 callback functions // This function will be called often, while the button1 is pressed for a long time. void longPress1() { DigiKeyboard.print(strcpy_P(buffer, (char *)pgm_read_word(&table[0]))); DigiKeyboard.print(strcpy_P(buffer, (char *)pgm_read_word(&table[c]))); DigiKeyboard.delay(500); DigiKeyboard.sendKeyStroke(KEY_A,MOD_CONTROL_LEFT); // select the word writen DigiKeyboard.sendKeyStroke(KEY_X,MOD_CONTROL_LEFT); // copy the codified pass DigiKeyboard.sendKeyStroke(KEY_2,MOD_CONTROL_LEFT | MOD_SHIFT_LEFT ); // print the decodified pass } //when button1 is double pressed: void doubleclick1() { c=c-1; DigiKeyboard.sendKeyStroke(c); DigiKeyboard.sendKeyStroke(KEY_A,MOD_CONTROL_LEFT); // select the word writen if(c<0) { c=0; } }