-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d628939
commit 79e8c37
Showing
4 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Include lib: | ||
#include <MovingAveragePlus.h> | ||
|
||
// Create an Arithmetic Moving Average object of unsigned int type, | ||
// 10 in size | ||
MovingAveragePlus<unsigned> integer_mv(10); | ||
|
||
// This variable just generates input for average integer_mv | ||
unsigned delta_x = 0; | ||
|
||
// These variables are the identification of the integer_mv partials | ||
size_t integer_mv_partial_id = 0; | ||
size_t integer_mv_partial_id_2 = 0; | ||
|
||
void setup() { | ||
// Initialize serial interface | ||
Serial.begin(9600); | ||
|
||
integer_mv_partial_id = integer_mv.create_partial(3); | ||
integer_mv_partial_id_2 = integer_mv.create_partial(5); | ||
} | ||
|
||
void loop() { | ||
// Pushes the input in the moving average object | ||
integer_mv.push(delta_x); | ||
|
||
// Generates the next input | ||
delta_x += 5; | ||
if (delta_x > 1000) delta_x = 0; | ||
|
||
// Prints each value stored in the moving average | ||
for (uint8_t i = 0; i < integer_mv.size(); i++) { | ||
Serial.print(integer_mv[i]); | ||
Serial.print(" "); | ||
} | ||
// Prints the result of the average | ||
Serial.print("= "); | ||
Serial.print(integer_mv.get()); | ||
// Prints the value stored in the partials | ||
Serial.print(" | p(3): "); | ||
Serial.print(integer_mv.get_partial(integer_mv_partial_id)); | ||
Serial.print(" p(5): "); | ||
Serial.println(integer_mv.get_partial(integer_mv_partial_id_2)); | ||
|
||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name=MovingAveragePlus | ||
version=4.1.4 | ||
version=4.2.0 | ||
author=Alexandre Hiroyuki Yamauchi <[email protected]> | ||
maintainer=Alexandre Hiroyuki Yamauchi <[email protected]> | ||
sentence=Moving Average library for Arduino | ||
paragraph=Implements a lightweight moving average structure on Arduino. Performance and usability are the two focuses I thought of when creating this library. | ||
sentence=Moving Average library compatible with any number type | ||
paragraph=Fully documented. Implements a lightweight moving average structure on Arduino. Performance and usability are the two focuses I thought of when creating this library. | ||
category=Data Processing | ||
url=https://github.com/AlexandreHiroyuki/MovingAveragePlus | ||
architectures=* |