Update of the bombatuino with a pro micro board with native usb midi support.
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.

70 lines
1.8 KiB

  1. /**
  2. * @file bombatuino_INPUT_74HC4051.h
  3. *
  4. * @author Lukas Haubaum (lukas@haubaum.de)
  5. *
  6. * @date February, 2013
  7. *
  8. * @brief arduino library for reading inputs from 74HC4051 multiplexer
  9. *
  10. * library is for specialiced use: all I/O ports are used as analog inputs, values are stored and a callback function is called, when a value changes
  11. *
  12. * */
  13. #ifndef bombatuino_INPUT_74HC4051_h
  14. #define bombatuino_INPUT_74HC4051_h
  15. #if !defined(CallbackFunction)
  16. /**
  17. * callback function
  18. *
  19. * @param address
  20. * @param pin
  21. * @param value
  22. */
  23. typedef void (*CallbackFunction)(int,int,int);
  24. #endif
  25. class INPUT_74HC4051
  26. {
  27. public:
  28. /**
  29. * initalize the class, should be called in setup() function
  30. *
  31. * @param analog input pin on arduino, connected Z pin here
  32. * @param digital output pin for S0
  33. * @param digital output pin for S0
  34. * @param digital output pin for S0
  35. * @param callback function
  36. */
  37. void begin(uint8_t analog, uint8_t s0, uint8_t s1, uint8_t s2,CallbackFunction cbF);
  38. /**
  39. * Set pins to use as bits (default 0b11111111)
  40. *
  41. * @param pins to use for input
  42. */
  43. void setPins(uint8_t pins);
  44. /**
  45. * read values and call callback function on change, should be called in loop()
  46. */
  47. void loop(void);
  48. /**
  49. * get value of specific pin (0-7)
  50. *
  51. * @param pin
  52. * @return value of pin
  53. */
  54. int getSpecificValue(uint8_t pin);
  55. private:
  56. uint8_t _analog; /**< analog input pin on arduino, connected Z pin here */
  57. uint8_t _s0; /**< digital output pin for S0 */
  58. uint8_t _s1; /**< digital output pin for S0 */
  59. uint8_t _s2; /**< digital output pin for S0 */
  60. int _value[8]; /**< read values */
  61. uint8_t _pins = 0b11111111; /**< which pins to read */
  62. CallbackFunction _callbackFunction; /**< callback function */
  63. };
  64. #endif