Advertisement
Guest User

Untitled

a guest
May 1st, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #include "avr/pgmspace.h"
  2. #include "OneButton.h"
  3. #include "DigiKeyboard.h"
  4. // Setup a new OneButton on pin D0.
  5. OneButton button1(0, false);
  6.  
  7. byte c = 0; // credencial pointer
  8.  
  9. const char S0[] PROGMEM = "preambulo"; //parte comum a todas as senhas
  10. const char S1[] PROGMEM = "otorrinolaringologista=";
  11. const char S2[] PROGMEM = "mamae+sou+forte=";
  12. const char S3[] PROGMEM = "+inconstitucionalissimamente=";
  13. const char S4[] PROGMEM = "vai+danada+vai+danada!";
  14.  
  15.  
  16. const char* const table[] PROGMEM = {
  17. S0, S1, S2, S3, S4
  18. };
  19.  
  20. char buffer[56]; // make sure this is large enough for the largest string it must hold
  21.  
  22. void setup() {
  23. // link the button 1 functions.
  24. button1.attachClick(click1);
  25. button1.attachDuringLongPress(longPress1);
  26. button1.attachDoubleClick(doubleclick1);
  27.  
  28.  
  29. }
  30.  
  31. void loop() {
  32. // keep watching the push buttons:
  33. button1.tick();
  34. DigiKeyboard.delay(10);
  35.  
  36.  
  37. }
  38.  
  39. // when button1 is single pressed this happens
  40. void click1() {
  41. c=c+1;
  42. DigiKeyboard.sendKeyStroke(c+3); // (a is 4)
  43. DigiKeyboard.sendKeyStroke(KEY_A,MOD_CONTROL_LEFT); // select the word writen
  44. if(c==7) {
  45. c=1;
  46. }
  47. }
  48.  
  49. // ----- button 1 callback functions
  50. // This function will be called often, while the button1 is pressed for a long time.
  51. void longPress1() {
  52. DigiKeyboard.print(strcpy_P(buffer, (char *)pgm_read_word(&table[0])));
  53. DigiKeyboard.print(strcpy_P(buffer, (char *)pgm_read_word(&table[c])));
  54. DigiKeyboard.delay(500);
  55. DigiKeyboard.sendKeyStroke(KEY_A,MOD_CONTROL_LEFT); // select the word writen
  56. DigiKeyboard.sendKeyStroke(KEY_X,MOD_CONTROL_LEFT); // copy the codified pass
  57. DigiKeyboard.sendKeyStroke(KEY_2,MOD_CONTROL_LEFT | MOD_SHIFT_LEFT ); // print the decodified pass
  58. }
  59.  
  60. //when button1 is double pressed:
  61. void doubleclick1() {
  62. c=c-1;
  63. DigiKeyboard.sendKeyStroke(c);
  64. DigiKeyboard.sendKeyStroke(KEY_A,MOD_CONTROL_LEFT); // select the word writen
  65. if(c<0) {
  66. c=0;
  67. }
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement