thomasfredericks / Bounce2

Debouncing library for Arduino and Wiring
MIT License
592 stars 172 forks source link

Feature request: .changed() #54

Closed septillion-git closed 4 years ago

septillion-git commented 5 years ago

No idea why I didn't implement this is the past when I made changes to Bounce2 but why only let .update() return if it changed. There are situations you don't care if it's a .fell() or a .rose() but now you have to change both (which is even extra work because it's made out the current state and the fact if it changed) to simply see if the pin changed.

thomasfredericks commented 5 years ago

I am sorry, I don't understand.

septillion-git commented 5 years ago

Sorry, should have explained it a bit more. But in short 👼 :

bool Bounce::changed()
{
    return getStateFlag(CHANGED_STATE);
}
thomasfredericks commented 5 years ago

Ok, I added a protected changed() function in the testing branch: https://github.com/thomasfredericks/Bounce2/tree/Testing

Tell me if it is what you want and if it works.

septillion-git commented 5 years ago

I don't know why you want it protected? Just have it public 😃

thomasfredericks commented 5 years ago

Oups

MartinNel commented 4 years ago

The changed function()in the header uses a literal CHANGED_STATE, which is not defined in the header file. This gives a compilation error. I suggest moving the literal(s) from the H to the CPP file.

thomasfredericks commented 4 years ago

Thank you @MartinNel Fixed