Skip to content

Commit e67ce06

Browse files
committed
Merge branch 'master' of github.com:dxinteractive/ResponsiveAnalogRead
2 parents 7835403 + df96742 commit e67ce06

2 files changed

Lines changed: 40 additions & 14 deletions

File tree

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
MIT License
3+
4+
Copyright (c) 2016 Damien Clarke
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
#ResponsiveAnalogRead
2-
[http://damienclarke.me/code/responsive-analog-read](http://damienclarke.me/code/responsive-analog-read)
32

43
ResponsiveAnalogRead is an Arduino library for eliminating noise in analogRead inputs without decreasing responsiveness. It sets out to achieve the following:
54

65
1. Be able to reduce large amounts of noise when reading a signal. So if a voltage is unchanging aside from noise, the values returned should never change due to noise alone.
76
2. Be extremely responsive (i.e. not sluggish) when the voltage changes quickly.
8-
3. Have the option to be responsive when a voltage *stops* changing - when enabled the values returned must stop changing almost immediately after.
7+
3. Have the option to be responsive when a voltage *stops* changing - when enabled the values returned must stop changing almost immediately after. When this option is enabled, a very small sacrifice in accuracy is permitted.
98
4. The returned values must avoid 'jumping' up several numbers at once, especially when the input signal changes very slowly. It's better to transition smoothly as long as that smooth transition is short.
109

11-
You can preview the way the algorithm works with [sleep enabled](http://codepen.io/dxinteractive/pen/KzGegy) (minimising the time spend transitioning between values) and with [sleep disabled](http://codepen.io/dxinteractive/pen/ezdJxL) (transitioning responsively but smooth).
10+
You can preview the way the algorithm works with [sleep enabled](http://codepen.io/dxinteractive/pen/zBEbpP) (minimising the time spend transitioning between values) and with [sleep disabled](http://codepen.io/dxinteractive/pen/ezdJxL) (transitioning responsively and accurately but smooth).
1211

1312
An article discussing the design of the algorithm can be found [here](http://damienclarke.me/code/posts/writing-a-better-noise-reducing-analogread).
1413

15-
###Impending version bump
16-
Written 14/07/2016
17-
18-
Improvements to the sleep algorithm will be pushed as a minor version upgrade soon. Special thanks to /u/brontide for the assistance.
19-
2014
##How to install
2115

2216
In the Arduino IDE, go to Sketch > Include libraries > Manage libraries, and search for ResponsiveAnalogInput.
@@ -38,7 +32,7 @@ const int ANALOG_PIN = A0;
3832
3933
// make a ResponsiveAnalogRead object, pass in the pin, and either true or false depending on if you want sleep enabled
4034
// enabling sleep will cause values to take less time to stop changing and potentially stop changing more abruptly,
41-
// where as disabling sleep will cause values to ease into their correct position smoothly
35+
// where as disabling sleep will cause values to ease into their correct position smoothly and with slightly greater accuracy
4236
ResponsiveAnalogRead analog(ANALOG_PIN, true);
4337
4438
// the next optional argument is snapMultiplier, which is set to 0.01 by default
@@ -81,6 +75,8 @@ void loop() {
8175
- `int getRawValue() // get the raw analogRead() value from last update`
8276
- `bool hasChanged() // returns true if the responsive value has changed during the last update`
8377
- `void update(); // updates the value by performing an analogRead() and calculating a responsive value based off it`
78+
- `void update(int rawValue); // updates the value by accepting a raw value and calculating a responsive value based off it (version 1.1.0+)`
79+
- `bool isSleeping() // returns true if the algorithm is in sleep mode (version 1.1.0+)`
8480

8581
##Other methods (settings)
8682

@@ -98,9 +94,7 @@ Sleep allows you to minimise the amount of responsive value changes over time. I
9894

9995
It's behaviour can be modified with the following methods:
10096
- `void enableEdgeSnap() // edge snap ensures that values at the edges of the spectrum (0 and 1023) can be easily reached when sleep is enabled`
101-
- `void setSleepDelay(unsigned int ms) // sets the amount of time before sleeping`
102-
- `void setSleepActivityThreshold(unsigned int newThreshold) // the amount of movement that must take place while asleep for it to register as activity and start moving the output value. Defaults to 20.`
103-
- `void setAwakeActivityThreshold(unsigned int newThreshold) // the amount of movement that must take place while awake for it to register as activity, and reset the timer before sleep occurs. Defaults to 5.`
97+
- `void setActivityThreshold(float newThreshold) // the amount of movement that must take place for it to register as activity and start moving the output value. Defaults to 4.0. (version 1.1+)`
10498

10599
###Snap multiplier
106100

@@ -109,8 +103,18 @@ It's behaviour can be modified with the following methods:
109103
SnapMultiplier is a value from 0 to 1 that controls the amount of easing. Increase this to lessen the amount of easing (such as 0.1) and make the responsive values more responsive, but doing so may cause more noise to seep through when sleep is not enabled.
110104

111105
###Analog resolution
112-
- `void setAnalogResolution(unsigned int resolution)`
106+
- `void setAnalogResolution(int resolution)`
113107

114108
If your ADC is something other than 10bit (1024), set that using this.
115109

116-
Damien Clarke, 2016
110+
## License
111+
112+
Licensed under the MIT License (MIT)
113+
114+
Copyright (c) 2016, Damien Clarke
115+
116+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
117+
118+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
119+
120+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)