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.

63 lines
1.7 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  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. #define INPUT_74HC4051_TOLERANCE 0 /**< I/O DIRECTION REGISTER PORT A - Controls the direction of the data I/O. */
  16. #if !defined(CallbackFunction)
  17. /**
  18. * callback function
  19. *
  20. * @param address
  21. * @param pin
  22. * @param value
  23. */
  24. typedef void (*CallbackFunction)(int,int,int);
  25. #endif
  26. class INPUT_74HC4051
  27. {
  28. public:
  29. /**
  30. * initalize the class, should be called in setup() function
  31. *
  32. * @param analog input pin on arduino, connected Z pin here
  33. * @param digital output pin for S0
  34. * @param digital output pin for S0
  35. * @param digital output pin for S0
  36. * @param callback function
  37. */
  38. void begin(uint8_t analog, uint8_t s0, uint8_t s1, uint8_t s2,CallbackFunction cbF);
  39. /**
  40. * read values and call callback function on change, should be called in loop()
  41. */
  42. void loop(void);
  43. /**
  44. * get value of specific pin (0-7)
  45. *
  46. * @param pin
  47. * @return value of pin
  48. */
  49. int getSpecificValue(uint8_t pin);
  50. private:
  51. uint8_t _analog; /**< analog input pin on arduino, connected Z pin here */
  52. uint8_t _s0; /**< digital output pin for S0 */
  53. uint8_t _s1; /**< digital output pin for S0 */
  54. uint8_t _s2; /**< digital output pin for S0 */
  55. int _value[8]; /**< read values */
  56. CallbackFunction _callbackFunction; /**< callback function */
  57. };
  58. #endif