diff --git a/Button.h b/Button.h index 253c4f0..cba6aac 100644 --- a/Button.h +++ b/Button.h @@ -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 /*! \brief Class for handling push button switches. @@ -40,4 +48,4 @@ class Button { }; //----------------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif diff --git a/Led.h b/Led.h index f386612..9c9b39a 100644 --- a/Led.h +++ b/Led.h @@ -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. @@ -35,4 +42,4 @@ class Led { }; //----------------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif diff --git a/MIDIBounce.cpp b/MIDIBounce.cpp index 2c01ab1..4a2035f 100644 --- a/MIDIBounce.cpp +++ b/MIDIBounce.cpp @@ -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" diff --git a/Potentiometer.cpp b/Potentiometer.cpp index 202cf61..55205a0 100644 --- a/Potentiometer.cpp +++ b/Potentiometer.cpp @@ -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; @@ -149,4 +167,4 @@ void Potentiometer::midiCC(int v, int oldv) { void Potentiometer::changeSecondary( bool s){ secondary=s; -} \ No newline at end of file +} diff --git a/Potentiometer.h b/Potentiometer.h index 1f7c163..31cbda5 100644 --- a/Potentiometer.h +++ b/Potentiometer.h @@ -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. @@ -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 @@ -37,6 +46,7 @@ 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 @@ -44,4 +54,4 @@ class Potentiometer { }; //----------------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif diff --git a/RGBLed.h b/RGBLed.h index 5684892..b0e4fcd 100644 --- a/RGBLed.h +++ b/RGBLed.h @@ -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. @@ -44,4 +51,4 @@ class RGBLed { }; //----------------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif diff --git a/RGLed.h b/RGLed.h index 2da2422..71e9da5 100644 --- a/RGLed.h +++ b/RGLed.h @@ -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. @@ -43,4 +50,4 @@ class RGLed { }; //----------------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif