Skip to content
12 changes: 10 additions & 2 deletions Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
#define Button_H

//-----------------------------------------------------------------------------------
#include "WProgram.h" //It is very important to remember this! note that if you are using Arduino 1.0 IDE, change "WProgram.h" to "Arduino.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#elif defined(WIRING)
#include "Wiring.h"
#else
#include "WProgram.h"
#include "pins_arduino.h"
#endif

#include <MIDIBounce.h>

/*! \brief Class for handling push button switches.
Expand Down Expand Up @@ -40,4 +48,4 @@ class Button {
};
//-----------------------------------------------------------------------------------

#endif
#endif
11 changes: 9 additions & 2 deletions Led.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
#define Led_H

//-----------------------------------------------------------------------------------
#include "WProgram.h" //It is very important to remember this! note that if you are using Arduino 1.0 IDE, change "WProgram.h" to "Arduino.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#elif defined(WIRING)
#include "Wiring.h"
#else
#include "WProgram.h"
#include "pins_arduino.h"
#endif

/*! \brief Class for handling single color LEDs.

Expand All @@ -35,4 +42,4 @@ class Led {
};
//-----------------------------------------------------------------------------------

#endif
#endif
8 changes: 8 additions & 0 deletions MIDIBounce.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@

// Please read MIDIBounce.h for information about the liscence and authors

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#elif defined(WIRING)
#include "Wiring.h"
#else
#include "WProgram.h"
#include "pins_arduino.h"
#endif

#include "MIDIBounce.h"


Expand Down
20 changes: 19 additions & 1 deletion Potentiometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ void Potentiometer::read(){
lastValue=tempRead;
}

// read with relative noise canceling
void Potentiometer::read_n(int deviation = 8){

if(mapped){
tempRead=constrain(analogRead(pin),inMin,inMax);
tempRead=map(tempRead,inMin,inMax,0,127);
}
else
tempRead=map(analogRead(pin), 0, 1023, 0, 127);
tempRead_n=analogRead(pin);

if (tempRead_n<=(lastValue_n-deviation) || tempRead_n>=(lastValue_n+deviation)) { //value changed
midiCC(map(tempRead_n, 0, 1023, 0, 127), map(lastValue_n, 0, 1023, 0, 127));
lastValue_n=tempRead_n;
}

}

// read
void Potentiometer::readAvr(){
tempRead=0;
Expand Down Expand Up @@ -149,4 +167,4 @@ void Potentiometer::midiCC(int v, int oldv) {

void Potentiometer::changeSecondary( bool s){
secondary=s;
}
}
14 changes: 12 additions & 2 deletions Potentiometer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
#define Potentiometer_H

//-----------------------------------------------------------------------------------
#include "WProgram.h" //It is very important to remember this! note that if you are using Arduino 1.0 IDE, change "WProgram.h" to "Arduino.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#elif defined(WIRING)
#include "Wiring.h"
#else
#include "WProgram.h"
#include "pins_arduino.h"
#endif

/*! \brief Class for handling faders, knobs or other analog input.

Expand All @@ -23,7 +30,9 @@ class Potentiometer {
bool mapped;
int inMin, inMax;
int lastValue;
int lastValue_n;
int tempRead;
int tempRead_n;
int readValues[3];
byte pin; // pin on teensy
byte channel; // midi channel
Expand All @@ -37,11 +46,12 @@ class Potentiometer {
~Potentiometer(); // destructor
void read(); //!< read the values and send a midi message if the fader or knob state changed. use in main loop
void readAvr(); //!< read the values for couple of iterations for a smoother value and send a midi message if the fader or knob state changed. use in main loop
void read_n(int); // !< Read with noise reduction
int readValue(bool &changed); //!< read and return the analog value, pass state change @param changed will beset to true if the state of the value changed from last time
int readValueAvr(bool &changed); //!< read and return a smooth analog value, pass state change @param changed will beset to true if the state of the value changed from last time
void changeSecondary(bool s); //!< enable or disable the secondary super knob cc messages @param s enable super knob
void bound(int iMin, int iMax); //!< map and bound the analog readings to minimum and maximum values, useful for normalizing light or force sensors. @param iMin the value below everything will be set as 0 @param iMax the value above everything will be set as 127
};
//-----------------------------------------------------------------------------------

#endif
#endif
11 changes: 9 additions & 2 deletions RGBLed.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
#define RGBLed_H

//-----------------------------------------------------------------------------------
#include "WProgram.h" //It is very important to remember this! note that if you are using Arduino 1.0 IDE, change "WProgram.h" to "Arduino.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#elif defined(WIRING)
#include "Wiring.h"
#else
#include "WProgram.h"
#include "pins_arduino.h"
#endif

/*! \brief Class for handling tri color LEDs.

Expand Down Expand Up @@ -44,4 +51,4 @@ class RGBLed {
};
//-----------------------------------------------------------------------------------

#endif
#endif
11 changes: 9 additions & 2 deletions RGLed.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
#define RGLed_H

//-----------------------------------------------------------------------------------
#include "WProgram.h" //It is very important to remember this! note that if you are using Arduino 1.0 IDE, change "WProgram.h" to "Arduino.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#elif defined(WIRING)
#include "Wiring.h"
#else
#include "WProgram.h"
#include "pins_arduino.h"
#endif

/*! \brief Class for handling bi color LEDs.

Expand Down Expand Up @@ -43,4 +50,4 @@ class RGLed {
};
//-----------------------------------------------------------------------------------

#endif
#endif