Code Monkey home page Code Monkey logo

analogbuttons's People

Contributors

fraser125 avatar rlogiacco 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

analogbuttons's Issues

configure don't run well

Hello,
I try to use the new version from a long time and hd now understood what is my issue!
I con't configure the buttons!

So i have just changed into your example the configure fonction like that:
void configure() {
int val = analogRead(ANALOG_PIN);
Serial.println(val);
delay(1000);
}

Now , i can configure the buttons and play with !!!

Button ADC Value is Zero

I'm using a fairly common LCD + Button shield designed by DFRobot and available many other places. It has 5 buttons on A0 analog pin.

The problem I seem to be having is with the Right button not firing it's press or hold functions.
I believe the problem is because the right button has an ADC reading of 0 (ZERO).
When it gets to the following line:
if (reading >= buttons[i].value - margin && reading <= buttons[i].value + margin) {
The comparison fails with the following values being tested
reading:0
buttons[i].value - margin : 65526
buttons[i].value + margin : 10
By changing a couple of variable definitions to support unsigned integers seems to fix it.

Change the following lines, sorry I don't know how to make a pull request :(

void AnalogButtons::check() {
/* other misc lines */
      uint16_t reading = analogRead(pin);

to
int16_t reading = analogRead(pin);

AND

class Button {
public:
	uint16_t value;

to
int16_t value;

I got the following values which fixed my problem.
reading:0
buttons[i].value - margin : -10
buttons[i].value + margin : 10
I'm interested in feedback on this code change, since I'm not much of a C programmer.

Click must be PUSH-DOWN plus PUSH-UP.

Currently there is no proper way to use click and hold callbacks simultaneously.
Click must be triggered on push-up-event.

And, of course, push-down and push-up callbacks must be clearly split.

AnalogButtons for ESP32

Hi Roberto,
I already sent you an email (you answered). I am trying to use the AnalogButtons library with the ESP32 board (DOIT devkit 1) but I cannot get a result. I can read the analog values of the different buttons (3) but I cannot get the library to function. I have already used the library with an Arduino Leonardo and the code works perfect.

I am using 3 buttons which give values:
161 - 164
490 - 494
1808 - 1818

I also changed the debounce value 5 - 500

so far no results yet

regards
Henk

Action on ButtonUp/ButtonDown

Not sure how difficult this would be to implement. Consider this scenario:

A group of 5 buttons, which toggle the values of 5 elements in an array, Array1

If the 5th button is 'long-pressed', it changes the target of the 5 buttons to a different array, Array2

If Button5 is long-pressed again, it switches back to Array1.

Is there currently a way to have Button5 only change the value of the 5th array element upon release of a 'click', so that, for example, if Array1[5] = '1', a long-press of Button5 won't change it back to '0' before (or after) switching to the second array?

If not, would you consider adding that functionality? Very useful for ui/menu type of functions.

Thanks.

EDIT: I was able to mod the library to do this. It's a bit of a hack, but seems to be stable. Also removed the 'repeating hold', since it was not the functionality my project needed. If anyone wants it, 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.