Giter VIP home page Giter VIP logo

blinq's Introduction

Blinq - a blinking queue

Documentation

A queue for toggling a GPIO or blinking an LED, with binary patterns encoded as a u32.

Example

use blinq::{Pattern, Blinq, patterns, consts};

// Create a blink queue with room for 8 patterns (note: the capacity must be 1 higher
// then the amount of patterns you wish to store), that is active-low
let mut blinq: Blinq<FakeGpio, 9> = Blinq::new(gpio, true);

// Insert "HELLO." in morse code

blinq.enqueue(patterns::morse::H); // 8 steps
blinq.enqueue(patterns::morse::E); // 2 steps
blinq.enqueue(patterns::morse::L); // 10 steps
blinq.enqueue(patterns::morse::L); // 10 steps
blinq.enqueue(patterns::morse::O); // 12 steps
blinq.enqueue(patterns::morse::FULL_STOP); // 18 steps

// This is 60 steps
for _ in 0..60 {
   blinq.step();
}

// The queue is now exhausted, and the GPIO will be driven to the
// inactive state
blinq.step();

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

blinq's People

Contributors

chrysn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

blinq's Issues

Use switch_hal rather than manually working with active-low

Issue status: Mostly a note-to-self; if you like the proposed resolution I can put it into a PR at some later point.

The way the active-low and active-high semantics are packed into the blinq constructor is convenient for typical cases, but falls short when a board already provides the active-high/active-low abstraction through switch-hal. (In particular, for RIOT I currently provide fake pins with fake active-high logic, but I'd rather deprecate that in favor of exposing things at the right semantic level).

Concrete suggestion for blinq:

  • Add switch_hal as a dependency
  • Implement blinq in terms of switches, moving the constructor to build a switch from the arguments.
    • This is a bit harder than it seems, because in a switch the level logic is in type state whereas here it's in runtime state. (This could need an own implementation of OutputSwitch that uses runtime polarity, but that's just a few lines).
    • This would be a breaking change as Blinq's G type changes (from pin to switch) -- one of these "yes it's a breaking release, but unless you fixed that type somewhere you're good to upgrade" changes.
  • Provide a new_from_switch constructor that takes an OutputSwitch (with its on/off semantics), rather than an OutputPin (with its high-low semantics) and a boolean

Alternative: HALs keep providing switches with extra GPIO versions, "It's not really a GPIO, but if some API needs it, use it as OutputPin where it simulates active-high logic". (Which may well be viable).

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.