11
22[ ![ Arduino CI] ( https://github.com/RobTillaart/AnalogPin/workflows/Arduino%20CI/badge.svg )] ( https://github.com/marketplace/actions/arduino_ci )
3+ [ ![ Arduino-lint] ( https://github.com/RobTillaart/AnalogPin/actions/workflows/arduino-lint.yml/badge.svg )] ( https://github.com/RobTillaart/AnalogPin/actions/workflows/arduino-lint.yml )
4+ [ ![ JSON check] ( https://github.com/RobTillaart/AnalogPin/actions/workflows/jsoncheck.yml/badge.svg )] ( https://github.com/RobTillaart/AnalogPin/actions/workflows/jsoncheck.yml )
35[ ![ License: MIT] ( https://img.shields.io/badge/license-MIT-green.svg )] ( https://github.com/RobTillaart/AnalogPin/blob/master/LICENSE )
46[ ![ GitHub release] ( https://img.shields.io/github/release/RobTillaart/AnalogPin.svg?maxAge=3600 )] ( https://github.com/RobTillaart/AnalogPin/releases )
57
8+
69# AnalogPin
710
811Arduino library to add functionality on top of analogRead()
@@ -12,27 +15,37 @@ Arduino library to add functionality on top of analogRead()
1215
1316AnalogPin is an Arduino class that adds noise filtering and smoothing
1417to analogRead().
15- Furthermore it can speed up the analogRead() function by tuning the prescaler .
18+ Furthermore it can speed up the analogRead() function by tuning the pre-scaler .
1619This latter is AVR only.
1720
1821
19- ## Operation
22+ ## Interface
23+
24+
25+ - ** AnalogPin(uint8_t pin)** constructor with analogue pin as parameter.
26+ - ** void setPrescaler(uint8_t prescale = 7)** AVR only pre-scaler.
27+ - ** uint8_t getPrescaler()** return pre-scaler set.
28+ - ** void setNoiseThreshold(uint8_t noise = 0)** set noise level that should be ignored. Typical 0..2.
29+ - ** uint8_t getNoiseThreshold()** return set value.
30+ - ** void setSmoothWeight(uint8_t alpha = 0)** alpha = 0..31, parameter for low pass filter.
31+ - ** uint8_t getSmoothWeight(void)** returns set alpha.
32+ - ** int read(bool twice = false)** read function, optional read twice to stabilize.
33+ - ** int readSmoothed()** read version that uses low pass filter.
34+ - ** int readPrevious()** returns previous read value.
35+ - ** int readLast()** returns last read value without reading a new one.
2036
21- ** readLast()** returns the last read value without reading a new one.
2237
23- ** get/setPrescaler(prescale) ** can be used to speed up analogRead().
38+ ## Operation
2439
25- The effect is that both the accuracy and precission are affected.
40+ ** get/setPrescaler(prescale)** can be used to speed up analogRead().
41+ The effect is that both the accuracy and precision are affected.
2642You should verify if this is acceptable for your project.
2743*** Works only for AVR based boards***
2844
45+ ** get/setNoiseThreshold(noise)** is used to set the noise threshold to be used by the ** read()** function.
2946
30- ** get/setNoiseThreshold(noise)** is used to set the noise threshold to be used by
31- the ** read()** function.
32-
33- ** read(twice)** implements an ** analogRead()** that supresses small noise fluctuations.
34- The parameter twice is used to force analogRead() to be executed twice to reduce noise
35- from the multiplexing.
47+ ** read(twice)** implements an ** analogRead()** that suppresses small noise fluctuations.
48+ The parameter twice is used to force analogRead() to be executed twice to reduce noise from the multiplexing.
3649
3750Example: if the previous read has the value 300 and you
3851want to interpret all subsequent readings between 290
@@ -56,8 +69,9 @@ This can be used to suppress noise too.
5669
5770** readSmoothed()** implements an analogRead with a running average build in.
5871
59- Two functions that expose information that might sometimes be useful.
60- ** readPrevious()** returns the previous value read.
6172
62- ** readLast()** returns the last value read.
73+ ## Future
74+
75+ - more examples
76+
6377
0 commit comments