{"id":19321331,"url":"https://github.com/leshow/rotary-encoder-hal","last_synced_at":"2025-04-22T19:30:51.721Z","repository":{"id":44884188,"uuid":"215411884","full_name":"leshow/rotary-encoder-hal","owner":"leshow","description":"A simple platform agnostic rotary encoder library","archived":false,"fork":false,"pushed_at":"2025-02-11T04:57:59.000Z","size":58,"stargazers_count":29,"open_issues_count":3,"forks_count":15,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-11T11:14:34.404Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/leshow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"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":"2019-10-15T23:03:02.000Z","updated_at":"2025-03-11T09:13:52.000Z","dependencies_parsed_at":"2024-11-10T01:36:51.622Z","dependency_job_id":"ad5c6df5-c9ad-4d70-8665-66c2fc4fb074","html_url":"https://github.com/leshow/rotary-encoder-hal","commit_stats":{"total_commits":41,"total_committers":9,"mean_commits":4.555555555555555,"dds":0.7804878048780488,"last_synced_commit":"098002590722f985b6782b7130e8dfd4bef7e8a2"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Frotary-encoder-hal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Frotary-encoder-hal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Frotary-encoder-hal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Frotary-encoder-hal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leshow","download_url":"https://codeload.github.com/leshow/rotary-encoder-hal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250308216,"owners_count":21409226,"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":"2024-11-10T01:36:45.342Z","updated_at":"2025-04-22T19:30:51.711Z","avatar_url":"https://github.com/leshow.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rotary-encoder-hal\n\n[![Crate](https://img.shields.io/crates/v/rotary-encoder-hal.svg)](https://crates.io/crates/rotary-encoder-hal)\n[![API](https://docs.rs/rotary-encoder-hal/badge.svg)](https://docs.rs/rotary-encoder-hal)\n\nA simple, platform agnostic rotary encoder library.\n\nAn alternate decoder algorithm that is more tolerant of\nnoise is enabled by the Cargo feature `table-decoder`.  It\nfollows the discussion of noisy decoding\n[here](https://www.best-microcontroller-projects.com/rotary-encoder.html).\n\n\nYou can call `update` from an ISR. You may get many spurious\ninterrupts from switch bounce, though the algorithm handles\nthem appropriately. When polling `update`, a poll time of\nabout 1 ms seems to work well.\n\n## Examples\n\n```rust\n#![no_std]\n#![no_main]\n\nextern crate panic_semihosting;\n\nuse cortex_m_rt::entry;\nuse hal::{delay::Delay, prelude::*, stm32};\nuse stm32f3xx_hal as hal;\n\nuse rotary_encoder_hal::{Direction, Rotary};\n\n#[entry]\nfn main() -\u003e ! {\n    let cp = cortex_m::Peripherals::take().unwrap();\n    let peripherals = stm32::Peripherals::take().unwrap();\n\n    let mut flash = peripherals.FLASH.constrain();\n    let mut rcc = peripherals.RCC.constrain();\n\n    let clocks = rcc.cfgr.freeze(\u0026mut flash.acr);\n\n    let mut delay = Delay::new(cp.SYST, clocks);\n\n    let mut gpiob = peripherals.GPIOB.split(\u0026mut rcc.ahb);\n    let pin_a = gpiob\n        .pb10\n        .into_pull_up_input(\u0026mut gpiob.moder, \u0026mut gpiob.pupdr);\n    let pin_b = gpiob\n        .pb11\n        .into_pull_up_input(\u0026mut gpiob.moder, \u0026mut gpiob.pupdr);\n\n    let mut enc = Rotary::new(pin_a, pin_b);\n    let mut pos: isize = 0;\n\n    loop {\n        match enc.update().unwrap() {\n            Direction::Clockwise =\u003e {\n                pos += 1;\n            }\n            Direction::CounterClockwise =\u003e {\n                pos -= 1;\n            }\n            Direction::None =\u003e {}\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleshow%2Frotary-encoder-hal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleshow%2Frotary-encoder-hal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleshow%2Frotary-encoder-hal/lists"}