Non-Arduino keyMatrix library with Arduino support.

keymatrix.h 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
  3. * Date: 04/2016
  4. * License: GPLv3
  5. */
  6. /******************************************************************************/
  7. #ifndef __KEYMATRIX_H__
  8. #define __KEYMATRIX_H__
  9. /******************************************************************************/
  10. #include <avr/io.h>
  11. /******************************************************************************/
  12. #define DISABLE_ALL_COLUMNS 255
  13. #define KEY_STATE_UNKNOWN 255 // unknown state
  14. #define KEY_STATE_UP 0 // not pressed
  15. #define KEY_STATE_GO_DOWN 1 // is going to be pressed
  16. #define KEY_STATE_DOWN 2 // is pressed
  17. #define KEY_STATE_GO_UP 3 // is going to be not pressed
  18. #define KEYMATRIX_COLUMNS 4 // columns
  19. #define KEYMATRIX_ROWS 6 // rows
  20. /******************************************************************************/
  21. void km_init(void);
  22. uint8_t km_updateKeyState(uint8_t, uint8_t);
  23. void km_updateKeyStates(void);
  24. void km_activateCol(uint8_t);
  25. uint8_t km_getLastChangedKey(void);
  26. uint8_t km_getKeyState(uint8_t);
  27. void km_getKeyStates(uint8_t*);
  28. /******************************************************************************/
  29. #endif