File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ # Arduino Buffer
2+ This is a arduino library that helps to buffer values.
3+
4+ ## Instalation
5+ 1 . Download [ the master branch] ( https://github.com/daviinacio/arduino-buffer/archive/master.zip ) from github.
6+ 2 . Unzip the file on the arduino library folder
7+ 3 . Restart the Arduino IDE
8+
9+ ## Features
10+ - Get buffer averages
11+
12+ ## Getting Started
13+
14+ - ``` length ``` Buffer size
15+ - ``` init ``` Initial value
16+
17+ ### Constructors
18+ ```
19+ Buffer b = Buffer(length, init);
20+
21+ or
22+
23+ Buffer b(length, init);
24+
25+ or
26+
27+ Buffer* b = new Buffer(length, init);
28+ ```
29+
30+ ### Getters
31+ - ``` calcAverage() ``` Calc the buffer average and return the result
32+ - ``` getAverage() ``` Just return the buffer average
33+ - ``` getAt(index) ``` Returns the buffer value by index
34+ - ``` empty() ``` Check if the buffer average is equals the initial value
35+
36+ ### Setters
37+ - ``` fill(value) ``` Fill the buffer with the value
38+ - ``` insert(value) ``` Insert a new value to the buffer and calls ``` calcAverage() ```
39+ - ``` clear() ``` Fill the buffer with the initial value
40+
41+ ## Example
42+ ```
43+ // Create a instance of Buffer
44+ Buffer sensorBuffer(10, 0);
45+
46+ // Your sensor read function
47+ void sensorRead(){
48+ // Get a new sensor value
49+ int read = readSensor();
50+
51+ // Insert the new value on buffer
52+ sensorBuffer.insert(read);
53+
54+ // Print the sensor average on Serial Monitor
55+ Serial.println(sensorBuffer.getAverage());
56+ }
57+
58+ ```
You can’t perform that action at this time.
0 commit comments