From 706ccc91ee2a776aabe93dac66b45c2875818b1e Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Sat, 9 Jan 2016 11:10:56 +0100 Subject: [PATCH 01/10] include read_n method Adds a relative noise cancelling reading method to the library which is more stable if used with lower quality potentiometers --- Potentiometer.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Potentiometer.cpp b/Potentiometer.cpp index 202cf61..14de1f5 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(){ + + 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-8) || tempRead_n>=(lastValue_n+8)) { //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 +} From 0523211efc0c7ea1eedb8b226acd416da04966ff Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Sat, 9 Jan 2016 15:24:55 +0100 Subject: [PATCH 02/10] Updated read_n user is now able to provide an custom deviation --- Potentiometer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Potentiometer.cpp b/Potentiometer.cpp index 14de1f5..55205a0 100644 --- a/Potentiometer.cpp +++ b/Potentiometer.cpp @@ -51,7 +51,7 @@ void Potentiometer::read(){ } // read with relative noise canceling -void Potentiometer::read_n(){ +void Potentiometer::read_n(int deviation = 8){ if(mapped){ tempRead=constrain(analogRead(pin),inMin,inMax); @@ -61,7 +61,7 @@ void Potentiometer::read_n(){ tempRead=map(analogRead(pin), 0, 1023, 0, 127); tempRead_n=analogRead(pin); - if (tempRead_n<=(lastValue_n-8) || tempRead_n>=(lastValue_n+8)) { //value changed + 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; } From 4736f49189eb430077012d2e3218707ad7101e05 Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Mon, 25 Jan 2016 00:13:06 +0100 Subject: [PATCH 03/10] Forgot to add the new function in the header file --- Potentiometer.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 From ce9f7412bfbd154705cb5f0ead43d37778c31f91 Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Sun, 31 Jan 2016 11:06:50 +0100 Subject: [PATCH 04/10] Added compatibility for systems that use Arduino.h --- Button.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 From da627470dc3a54ebe87b96659e2958cd8fcb7592 Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Sun, 31 Jan 2016 11:07:39 +0100 Subject: [PATCH 05/10] Added compatibility for systems that use Arduino.h --- Led.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 From ba2d73f4b2458dea4ff54d2511f64f0fda278caa Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Sun, 31 Jan 2016 11:08:49 +0100 Subject: [PATCH 06/10] Added compatibility for systems that use Arduino.h --- MIDIBounce.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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" From 23e67267b60eef464571d59e6c10d3b16d5526db Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Sun, 31 Jan 2016 11:11:09 +0100 Subject: [PATCH 07/10] Update Potentiometer.cpp From ecb4423ca13aa286005ad1a4f5a5856c1c7f08da Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Sun, 31 Jan 2016 11:11:40 +0100 Subject: [PATCH 08/10] Added compatibility for systems that use Arduino.h From 334ed02187d4645be3d28b3031210804ebe31d36 Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Sun, 31 Jan 2016 11:12:17 +0100 Subject: [PATCH 09/10] Added compatibility for systems that use Arduino.h --- RGBLed.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 From 8a437cce550ac36df5fdff5fa6848ae7d3304d97 Mon Sep 17 00:00:00 2001 From: NickolasBoyer Date: Sun, 31 Jan 2016 11:12:53 +0100 Subject: [PATCH 10/10] Added compatibility for systems that use Arduino.h --- RGLed.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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