{"id":21150799,"url":"https://github.com/cedargrovestudios/circuitpython_rangeslicer","last_synced_at":"2026-05-20T15:07:31.683Z","repository":{"id":139500752,"uuid":"536814011","full_name":"CedarGroveStudios/CircuitPython_RangeSlicer","owner":"CedarGroveStudios","description":"A CircuitPython class for scaling a range of input values into indexed/quantized output values. Adjustable output slice hysteresis for noise reduction.","archived":false,"fork":false,"pushed_at":"2023-12-27T07:15:00.000Z","size":26161,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T08:09:44.339Z","etag":null,"topics":["circuitpython","circuitpython-community-bundle","quantizer"],"latest_commit_sha":null,"homepage":"","language":"Python","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/CedarGroveStudios.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"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}},"created_at":"2022-09-15T01:04:58.000Z","updated_at":"2023-12-15T08:08:12.000Z","dependencies_parsed_at":"2023-12-27T08:26:11.954Z","dependency_job_id":null,"html_url":"https://github.com/CedarGroveStudios/CircuitPython_RangeSlicer","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedarGroveStudios%2FCircuitPython_RangeSlicer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedarGroveStudios%2FCircuitPython_RangeSlicer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedarGroveStudios%2FCircuitPython_RangeSlicer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CedarGroveStudios%2FCircuitPython_RangeSlicer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CedarGroveStudios","download_url":"https://codeload.github.com/CedarGroveStudios/CircuitPython_RangeSlicer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243590545,"owners_count":20315701,"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":["circuitpython","circuitpython-community-bundle","quantizer"],"created_at":"2024-11-20T10:08:23.407Z","updated_at":"2026-05-20T15:07:31.671Z","avatar_url":"https://github.com/CedarGroveStudios.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Introduction\n============\n\n\n\n\n.. image:: https://img.shields.io/discord/327254708534116352.svg\n    :target: https://adafru.it/discord\n    :alt: Discord\n\n\n.. image:: https://github.com/CedarGroveStudios/Cedargrove_CircuitPython_RangeSlicer/workflows/Build%20CI/badge.svg\n    :target: https://github.com/CedarGroveStudios/Cedargrove_CircuitPython_RangeSlicer/actions\n    :alt: Build Status\n\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n    :alt: Code Style: Black\n\nRangeSlicer is a general-purpose CircuitPython analog value converter that linearly scales the input then quantizes it into a collection of precise output slice values. The class detects input value changes and applies selectable hysteresis when slice edge thresholds are reached to eliminate dead-zone noise issues without filtering delays. Applications include converting rotary knob position to discrete ranges of MIDI values, analog signal noise processing, level detection, rotary switch emulation, and signal display.\n\n.. image:: https://github.com/CedarGroveStudios/CircuitPython_RangeSlicer/blob/master/media/range_slicer_models.png\n   :alt: RangeSlicer Signal Models\n\n\nThe effect of using hysteresis to clean up a noisy signal:\n\n.. image:: https://github.com/CedarGroveStudios/CircuitPython_RangeSlicer/blob/master/media/range_slicer_noise_models.png\n   :alt: RangeSlicer Noise Models\n\n\n\nDependencies\n=============\nThis driver depends on:\n\n* `Adafruit CircuitPython \u003chttps://github.com/adafruit/circuitpython\u003e`_\n\nPlease ensure all dependencies are available on the CircuitPython filesystem.\nThis is easily achieved by downloading\n`the Adafruit library and driver bundle \u003chttps://circuitpython.org/libraries\u003e`_\nor individual libraries can be installed using\n`circup \u003chttps://github.com/adafruit/circup\u003e`_.\n\n\nInstalling to a Connected CircuitPython Device with Circup\n==========================================================\n\nMake sure that you have ``circup`` installed in your Python environment.\nInstall it with the following command if necessary:\n\n.. code-block:: shell\n\n    pip3 install circup\n\nWith ``circup`` installed and your CircuitPython device connected use the\nfollowing command to install:\n\n.. code-block:: shell\n\n    circup install cedargrove_rangeslicer\n\nOr the following command to update an existing version:\n\n.. code-block:: shell\n\n    circup update\n\nUsage Example\n=============\n\n.. code-block:: Python\n\n    \"\"\"Reads two potentiometer inputs and produces -1.0 to +1.0 normalized outputs,\n    one with an inverted output range.\"\"\"\n\n    import time\n    import board\n    from analogio import AnalogIn\n    import cedargrove_rangeslicer as rs\n\n    print(\"Two Normalized Outputs: RangeSlicer example 01\")\n\n    \"\"\"Establish range_slicer instances, one for each analog potentiometer\n    input. Input ranges are adjusted for unique potentiometer inaccuracies and\n    noise. Slice size divides the output into 10 slices. Hysteresis factor is\n    25% of a slice.\"\"\"\n\n    ctrl_0 = rs.Slicer(200, 65335, -1.0, +1.0, 0.2, 0.25)\n    ctrl_1 = rs.Slicer(375, 65520, +1.0, -1.0, 0.2, 0.25)\n\n    # establish analog inputs\n    pot_0 = AnalogIn(board.A0)\n    pot_1 = AnalogIn(board.A1)\n\n    while True:  # read potentiometer values\n        control_0 = pot_0.value\n        control_1 = pot_1.value\n\n        # calculate output values and print (or plot in Mu)\n        out_0 = ctrl_0.range_slicer(control_0)[0]\n        out_1 = ctrl_1.range_slicer(control_1)[0]\n        print( (control_0 / 65535, control_1 / 65535, out_0, out_1) )\n\n        time.sleep(0.1)  # pause for 0.1 second\n\n\nDocumentation\n=============\n`RangeSlicer CircuitPython Driver API Class Description \u003chttps://github.com/CedarGroveStudios/CircuitPython_RangeSlicer/blob/master/media/pseudo_readthedocs_rangeslicer.pdf\u003e`_\n\nContributing\n============\n\nContributions are welcome! Please read our `Code of Conduct\n\u003chttps://github.com/CedarGroveStudios/Cedargrove_CircuitPython_RangeSlicer/blob/HEAD/CODE_OF_CONDUCT.md\u003e`_\nbefore contributing to help this project stay welcoming.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedargrovestudios%2Fcircuitpython_rangeslicer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcedargrovestudios%2Fcircuitpython_rangeslicer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedargrovestudios%2Fcircuitpython_rangeslicer/lists"}