sources and files for the bombatuino project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.1 KiB

  1. /**
  2. * @file bombatuino_ROTARY_ENCODER.h
  3. *
  4. * @author Lukas Haubaum (lukas@haubaum.de)
  5. *
  6. * @date February, 2013
  7. *
  8. * @brief arduino library for handling a rotary encoder (simplified)
  9. *
  10. * library is for specialiced use: increment- and decrement-functions are called on change of pin A.
  11. *
  12. * */
  13. #ifndef bombatuino_ROTARY_ENCODER_h
  14. #define bombatuino_ROTARY_ENCODER_h
  15. #if !defined(XcrementFunction)
  16. /**
  17. * callback function
  18. *
  19. * @param address
  20. * @param pin
  21. * @param value
  22. */
  23. typedef void (*XcrementFunction)(void);
  24. #endif
  25. class ROTARY_ENCODER
  26. {
  27. public:
  28. /**
  29. * constructor
  30. *
  31. * @param increment function
  32. * @param decrement function
  33. */
  34. ROTARY_ENCODER(XcrementFunction incrementFunction, XcrementFunction decrementFunction);
  35. /**
  36. * set the value of pin B
  37. *
  38. * @param value of B-pin
  39. */
  40. void setPinB(int value);
  41. /**
  42. * set the value of pin A
  43. *
  44. * @param value of A-pin
  45. */
  46. void setPinA(int value);
  47. private:
  48. int _pinA;
  49. int _pinB;
  50. int _oldA;
  51. XcrementFunction _increment; /**< increment function */
  52. XcrementFunction _decrement; /**< decrement function */
  53. void onPinChange();
  54. };
  55. #endif