{"id":28999972,"url":"https://github.com/ripred/smooth","last_synced_at":"2025-09-11T05:14:33.541Z","repository":{"id":176277155,"uuid":"655254576","full_name":"ripred/Smooth","owner":"ripred","description":"Keep smooth running averages without using arrays! Uses exponential moving averages and only 8-bytes no matter how many samples! No looping! No Arrays! Constant Compute Time! The sample size is adjustable at runtime. The average is available and accurate even before N samples have been received. Now with Callbacks!","archived":false,"fork":false,"pushed_at":"2025-02-14T16:41:32.000Z","size":63,"stargazers_count":59,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-14T17:36:12.416Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/ripred/Smooth","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ripred.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-18T11:04:55.000Z","updated_at":"2025-02-14T16:41:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"a7f46b25-e3db-4bb9-90b9-ed886d58a4c3","html_url":"https://github.com/ripred/Smooth","commit_stats":null,"previous_names":["ripred/smooth"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ripred/Smooth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FSmooth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FSmooth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FSmooth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FSmooth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ripred","download_url":"https://codeload.github.com/ripred/Smooth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FSmooth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261838335,"owners_count":23217616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-25T08:41:12.180Z","updated_at":"2025-06-25T08:41:14.166Z","avatar_url":"https://github.com/ripred.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Arduino CI](https://github.com/ripred/Smooth/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)\n[![Arduino-lint](https://github.com/ripred/Smooth/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/ripred/Smooth/actions/workflows/arduino-lint.yml)\n[![JSON check](https://github.com/ripred/Smooth/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/ripred/Smooth/actions/workflows/jsoncheck.yml)\n[![GitHub release](https://img.shields.io/github/release/ripred/Smooth.svg?maxAge=3600)](https://github.com/ripred/Smooth/releases)\n[![PlatformIO Registry](https://badges.registry.platformio.org/packages/ripred/library/Smooth.svg)](https://registry.platformio.org/libraries/ripred/Smooth)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ripred/Smooth/blob/master/LICENSE)\n\n![code size:](https://img.shields.io/github/languages/code-size/ripred/Smooth)\n[![Stars](https://img.shields.io/github/stars/ripred/Smooth.svg?style=flat-square\u0026colorB=4183c4)](https://github.com/ripred/Smooth)\n[![Forks](https://img.shields.io/github/forks/ripred/Smooth.svg?style=flat-square\u0026colorB=4183c4)](https://github.com/ripred/Smooth)\n\n\n# Smooth Arduino Library\n\nKeep smooth running averages without using arrays! No arrays. No Looping. Fast and Constant Time regardless of the sample window size!\n\nThe sample size is adjustable at runtime. The average is available and accurate even before N samples have been received. \nThe `Smooth` object uses 8 bytes of memory. That's it. No matter how large the window size. Perfect for smoothing and filtering \nsignals from noisy devices **like accelerometers** and **stable potentiometer readings**!\n\nupdate: added support for change, upper and lower bounds callbacks!\n\n### Example sketch:\n\n```cpp\n#include \u003cArduino.h\u003e\n#include \u003cSmooth.h\u003e\n\n#define  SMOOTHED_SAMPLE_SIZE  10\n\n// Smoothing average object\nSmooth  average(SMOOTHED_SAMPLE_SIZE);\n\n// Simulated wandering sample value\nint sample = 0;\n\nvoid setup() {\n    Serial.begin(115200);\n    randomSeed(analogRead(A0));\n}\n\nvoid loop() {\n    // get a random -1, 0, or +1 value\n    int const updown = random(0, 3) - 1;\n\n    // move our simulated wandering sample up or down\n    sample += updown;\n\n    // add it to the running average\n    average += sample;                      // or call average.add(sample)\n\n    // display the results:\n    char scratch[64] = \"\";\n    snprintf(scratch, sizeof(scratch), \"count: %4d, sample: %3d, average: %3d\\n\",\n        average.get_count(),\n        updown,\n        (int) average());                   // or call average.get_avg()\n\n    Serial.print(scratch);\n}\n```\n\nexample output:\n```\ncount:    1, sample:   0, average:   0\ncount:    2, sample:   0, average:   0\ncount:    3, sample:   1, average:   0\ncount:    4, sample:   2, average:   0\ncount:    5, sample:   2, average:   1\ncount:    6, sample:   3, average:   1\ncount:    7, sample:   2, average:   1\ncount:    8, sample:   3, average:   1\ncount:    9, sample:   4, average:   1\ncount:   10, sample:   4, average:   2\ncount:   11, sample:   3, average:   2\ncount:   12, sample:   4, average:   2\ncount:   13, sample:   3, average:   2\ncount:   14, sample:   4, average:   2\ncount:   15, sample:   3, average:   2\ncount:   16, sample:   4, average:   2\ncount:   17, sample:   4, average:   2\ncount:   18, sample:   4, average:   3\ncount:   19, sample:   4, average:   3\ncount:   20, sample:   4, average:   3\ncount:   21, sample:   3, average:   3\ncount:   22, sample:   3, average:   3\ncount:   23, sample:   2, average:   3\ncount:   24, sample:   3, average:   3\ncount:   25, sample:   3, average:   3\ncount:   26, sample:   2, average:   2\ncount:   27, sample:   1, average:   2\ncount:   28, sample:   0, average:   2\ncount:   29, sample:   1, average:   2\ncount:   30, sample:   1, average:   2\ncount:   31, sample:   1, average:   2\ncount:   32, sample:   2, average:   2\ncount:   33, sample:   3, average:   2\ncount:   34, sample:   3, average:   2\ncount:   35, sample:   4, average:   2\ncount:   36, sample:   3, average:   2\ncount:   37, sample:   3, average:   2\ncount:   38, sample:   3, average:   2\ncount:   39, sample:   2, average:   2\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripred%2Fsmooth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fripred%2Fsmooth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripred%2Fsmooth/lists"}