Git Product home page Git Product logo

switch-hal's Introduction

switch-hal

Rust crates.io crates.io docs.rs

Switch-HAL is a no_std embedded Rust library for working with buttons, switches, LEDs, and transistors. Basically, anything that acts like a switch, whether an input or output.

It is both a driver that uses the embedded-hal::digital traits and is an abstraction in it's own right. It provides a simple, zero-cost, abstraction to clarify the intent of your application code.

Why Switch-HAL? Why not just use raw GPIO?

Did you mean to drive that line high?
Or did you mean to turn that LED off?
Wait a second... is that LED active high?
Where's the schematic?
Okay... cathode is wired to the input line... that means it's active low.

Now repeat this every place in your code where you need to turn that LED on or off.
What happens when the hardware changes?
Using the raw GPIO to set pins high and low will have you making changes all over your code base.

Wouldn't it be nicer if you only had to think about that once, when you initialize your application,
and from then on out, simply called led.on() or led.off().
Having an abstraction at the proper level reduces cognitive load.
Specifying whether a simple peripheral is active high or low in a single place in your application reduces the maintenace burden.

Documentation

https://docs.rs/crate/switch-hal

or build a local copy

cargo docs

and open target/doc/switch_hal/index.html in your browser.

License

Licensed under either of

at your option.

Architectural Decision Records

Major design decisions are tracked in the adr directory.

switch-hal's People

Contributors

rubberduck203 avatar dzarda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.