added fritzing files

This commit is contained in:
Lukas
2013-03-12 14:53:27 +01:00
parent daf4b725fe
commit 0eec581c8a
16 changed files with 345 additions and 35 deletions
@@ -0,0 +1,33 @@
#include "Arduino.h"
#include "bombatuino_ROTARY_ENCODER.h"
ROTARY_ENCODER::ROTARY_ENCODER(XcrementFunction incrementFunction, XcrementFunction decrementFunction) {
_increment = incrementFunction;
_decrement = decrementFunction;
_pinA = LOW;
_pinB = LOW;
_oldA = LOW;
}
void ROTARY_ENCODER::setPinB(int value) {
_pinB = value;
onPinChange();
}
void ROTARY_ENCODER::setPinA(int value) {
_pinA = value;
onPinChange();
}
void ROTARY_ENCODER::onPinChange() {
if ((_oldA == LOW) && (_pinA == HIGH)) {
if (_pinB == LOW) {
(*_increment)();
}
else {
(*_decrement)();
}
}
_oldA = _pinA;
}
@@ -0,0 +1,58 @@
/**
* @file bombatuino_ROTARY_ENCODER.h
*
* @author Lukas Haubaum (lukas@haubaum.de)
*
* @date February, 2013
*
* @brief arduino library for handling a rotary encoder
*
* 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