Coder Social home page Coder Social logo

rotarydial's Introduction

Rotary Dial Arduino Library

This library was written for use with the dial pictured above (Dial from Czech telephone Tesla AS-10, green and yellow wire). But it should work with anything capable of producing bursts of pulses.

This implementation is for the North American system, where [1, 9] pulses correspond to the numbers [1, 9], and 0 is represented by 10 pulses.

Connection & Circuit

This library uses interrupts, so you have to connect the dial to pin which supports interrupts (this is different for different arduinos, but most common boards can do interrupts on pins 2 and 3).

Unfortunataly this library is static, so currently you can use it only once at a time (= with one dial).

Internal pullup is used, so all you need is to connect NC terminals of rotary dial to GND and Pin 2 (or whatever pin you choose in the code).

TODO

  • Possibility to register callback for processing received numbers
  • Make timing constants user configurable
  • Allow inverting of logic to use NO instead of NC dials (not sure if there are such)
  • Allow more than one dial at the same time
  • Provide method to detach interrupt if needed
  • Handle dial timeout directly in library? (= send ENTER when user is done typing numbers, currently we handle this in example sketch)

See also

rotarydial's People

Contributors

harvie avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

rotarydial's Issues

Incorrect digit can be read from a partial pulse train

Nice library! Very succinct and efficient. Truly a pleasure to read and use.

I suspect there is one failure mode though. If a client delays read()ing out the latest dialed digit, and if the next digit is being dialed when client read()s, then the next digit may have some but not all of its pulses skipped. This will result in a digit that is lower than what's been actually dialed returned next. And the user would have no way to detect this and reject corrupted input.

One potential solution is to track when a new pulse train begins -- even if the previous digit is still available(). If that happens, discard either the previous (complete) digit or the entire new pulse train(s) until the last available digit is read. Lossy! But at least no false/partial digits. Another possibility is to queue digits as they are dialed, and read them, first-in-first-out, form the queue. Still lossy, but not until the queue overflows. Finally, adding/taking into account the third (dial/ready) wire could help, too.

Either solution is probably too much trouble, and -- realistically -- of little value in real life. But I thought I'd mention this to warn users of this failure mode, so that they make sure to read() timely, or else risk getting false digits.

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.