Coder Social home page Coder Social logo

simplebutton's Introduction

SimpleButton

Return a 1 once every time a button becomes pressed

I'm an old button masher and I found that many of the button libraries did not react quickly or reliably enough for me. The ones that did utilized hysteresis but had other features or issues I didn't care for.

This simply returns a 1 every time the button becomes pressed. It reads the button at a set interval and uses a ring buffer to record the last 8 reads giving a maximum of 7 intervals. the debounce time for both press and release is determined by the number of intervals desired for each.

The default constructor is set for a 10ms interval and uses 1 interval(10ms) for the press debounce and 5 intervals(50ms) for the release debounce. This seems to work reliably for as fast as I can press a button.

There is also an overloaded constructor where you can set all 3 of these parameters. This is demonstrated in the example sketch.

simplebutton's People

Contributors

hutkikz avatar

Watchers

 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.