bombatuino/source/libraries/bombatuino_INPUT_74HC4051/bombatuino_INPUT_74HC4051.h

62 lines
1.6 KiB
C
Raw Normal View History

2013-02-14 12:23:57 +01:00
/**
2013-03-12 14:53:27 +01:00
* @file bombatuino_INPUT_74HC4051.h
2013-02-14 12:23:57 +01:00
*
2021-09-07 14:32:51 +02:00
* @author Lurkars (bombatuino@champonthis.de)
2013-02-14 12:23:57 +01:00
*
* @date February, 2013
*
* @brief arduino library for reading inputs from 74HC4051 multiplexer
*
* 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
*
* */
2013-03-12 14:53:27 +01:00
#ifndef bombatuino_INPUT_74HC4051_h
#define bombatuino_INPUT_74HC4051_h
2013-02-14 12:23:57 +01:00
2013-02-14 02:59:15 +01:00
#if !defined(CallbackFunction)
2013-02-14 12:23:57 +01:00
/**
* callback function
*
* @param address
* @param pin
* @param value
*/
2013-02-14 02:59:15 +01:00
typedef void (*CallbackFunction)(int,int,int);
#endif
class INPUT_74HC4051
{
2013-02-14 12:23:57 +01:00
public:
/**
* initalize the class, should be called in setup() function
*
* @param analog input pin on arduino, connected Z pin here
* @param digital output pin for S0
* @param digital output pin for S0
* @param digital output pin for S0
* @param callback function
*/
void begin(uint8_t analog, uint8_t s0, uint8_t s1, uint8_t s2,CallbackFunction cbF);
/**
* read values and call callback function on change, should be called in loop()
*/
void loop(void);
/**
* get value of specific pin (0-7)
*
* @param pin
* @return value of pin
*/
2013-02-14 02:59:15 +01:00
int getSpecificValue(uint8_t pin);
private:
2013-02-14 12:23:57 +01:00
uint8_t _analog; /**< analog input pin on arduino, connected Z pin here */
uint8_t _s0; /**< digital output pin for S0 */
uint8_t _s1; /**< digital output pin for S0 */
uint8_t _s2; /**< digital output pin for S0 */
int _value[8]; /**< read values */
CallbackFunction _callbackFunction; /**< callback function */
2013-02-14 02:59:15 +01:00
};
#endif