Code Monkey home page Code Monkey logo

button's People

Contributors

elektronikworkshop avatar jbellue avatar madleech avatar per1234 avatar scls19fr avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

button's Issues

Possible softlock on millis() overflow

Hello, looks like it's possible to softlock button in read() method.
If button changes at time:
millis_max_value - _delay - some_small_value
and doesn't change state back until millis() overflow, then _ignore_until will be almost always bigger then millis().

For an example: if button has been unpressed at millis_max_value - _delay, then state will be saved us unpressed, _ignore_until will be millis_max_value. And right after millis overflow, condition:
if (_ignore_until > millis()) { // ignore any changes during this period }
almost always will be true, and it will lock execution of next condition.
And the only possible exit, except reset, will be holding button down around overflow, hoping not to miss it =)

Enable continuous integration / run unit test

Hello,

Ensuring that this library can still be compiled (using a continuous integration service such as Travis) could be a nice improvement.

Running some unit tests to ensure that code works correctly could help to ensure that contribution doesn't break anything.

I have been using https://github.com/ianfixes/arduino_ci recently, (this is quite new in Arduino library development). It can help to achieve this.

Are you interested in a pull request to enable such a feature?
If so I can submit it.

Kind regards

Support for repeated/long press detection

Hi, Thanks for maintaining this library! I want to use it in an alarm clock example I'm building for GoodArduinoCode, and for that, I'd need an option to detect long presses and generate repeated events as long as the button is held down.

I imagine something like:

#include <Button.h>

Button hourButton = Button(A0);

void setup() {
  Serial.begin(115200);
  hourButton.begin();

  // After 500ms delay, generate repeated press every 200ms:
  hourButton.setRepeat(500, 200);
}

void loop() {
  if (hourButton.pressed()) {
    Serial.print("Pressed! Repeat count");
    Serial.println(hourButton.repeatCount());
  }
  if (hourButton.release()) {
     Serial.println("Released!");
  }
}

So if you press the button, hold it down for 1 second, and release, you'll see something like:

[0000] Pressed! Repeat count: 0
[0500] Pressed! Repeat count: 1
[0700] Pressed! Repeat count: 2
[0900] Pressed! Repeat count: 3
[1000] Release

(the numbers in the square brackets are just the milliseconds since the button was pressed).

If you are interested, I can also send a PullRequest which adds this functionality, simply let me know.

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.