bombatuino/source/libraries/bombatuino_ROTARY_ENCODER/bombatuino_ROTARY_ENCODER.h
2021-09-07 14:32:51 +02:00

59 lines
1.1 KiB
C++

/**
* @file bombatuino_ROTARY_ENCODER.h
*
* @author Lurkars (bombatuino@champonthis.de)
*
* @date February, 2013
*
* @brief arduino library for handling a rotary encoder (simplified)
*
* library is for specialiced use: increment- and decrement-functions are called on change of pin A.
*
* */
#ifndef bombatuino_ROTARY_ENCODER_h
#define bombatuino_ROTARY_ENCODER_h
#if !defined(XcrementFunction)
/**
* callback function
*
* @param address
* @param pin
* @param value
*/
typedef void (*XcrementFunction)(void);
#endif
class ROTARY_ENCODER
{
public:
/**
* constructor
*
* @param increment function
* @param decrement function
*/
ROTARY_ENCODER(XcrementFunction incrementFunction, XcrementFunction decrementFunction);
/**
* set the value of pin B
*
* @param value of B-pin
*/
void setPinB(int value);
/**
* set the value of pin A
*
* @param value of A-pin
*/
void setPinA(int value);
private:
int _pinA;
int _pinB;
int _oldA;
XcrementFunction _increment; /**< increment function */
XcrementFunction _decrement; /**< decrement function */
void onPinChange();
};
#endif