Non-Arduino keyMatrix library with Arduino support.

keymatrix.ino 1006B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
  3. * Date: 04/2016
  4. * License: GPLv3
  5. */
  6. extern "C" {
  7. #include "keymatrix.h"
  8. }
  9. // arduino style
  10. void setup()
  11. {
  12. Serial.begin(115200);
  13. km_init();
  14. }
  15. void loop()
  16. {
  17. //Serial.println("Hallo Welt!");
  18. /**/
  19. // call this set of functionality every xxxx ms
  20. //km_updateKeyStates();
  21. //uint8_t key = km_getLastChangedKey();
  22. /*
  23. Serial.print("key=");
  24. Serial.print(key);
  25. Serial.println(" ");
  26. */
  27. //km_activateCol(3);
  28. //km_updateKeyState(0,3);
  29. km_updateKeyStates();
  30. Serial.println("=================================================");
  31. // get key status
  32. for (uint8_t k = 0; k < KEYMATRIX_COLUMNS*KEYMATRIX_ROWS; k++)
  33. {
  34. uint8_t state = km_getKeyState(k);
  35. if (k < 10)
  36. Serial.print(" ");
  37. Serial.print(k);
  38. Serial.print("=");
  39. Serial.print(state);
  40. Serial.print(" ");
  41. if (((k+1) % KEYMATRIX_COLUMNS) == 0)
  42. Serial.println("");
  43. }
  44. Serial.println("");
  45. /**/
  46. delay(500);
  47. }