Comments (8)
Cool.
For now I can live with:
class BounceExt: public Bounce
{
public:
BounceExt(uint8_t pin, uint16_t interval_millis ) :
Bounce(pin, interval_millis) {};
uint8_t get_pin() {
return pin;
}
};
It allows save byte of RAM each time Bounce is member of class, when pin must be later used in class.
from bounce2.
I will have to think about this. A more abstract class has often been requested allowing debouncing of more than just a single hardware pin. So I will not implement this right now, but later. I need to make a base class that is extended to hardware pins.
from bounce2.
Why does that save RAM? Because in most situations you can have a const in your code which you pass to Bounce2 aka it takes no space in RAM.
from bounce2.
(...) in most situations you can have a const in your code which you pass to Bounce2 aka it takes no space in RAM.
Bounce objects store pin number as their attribute, so most likely byte of RAM is used regardless how init value was passed.
Why does that save RAM?
I do not have to duplicate pin number data like:
class PushButton{
Bounce debouncer;
uint8_t pin; // duplicate value as in debouncer.pin
from bounce2.
@matkor, why do you store the debouncer and pin separately?
from bounce2.
@matkor, why do you store the debouncer and pin separately?
I do not.
I just need access pin having only Bounce instance.
from bounce2.
I merged a new version of the library where I split the hardware layer from the debouncing algorithm. It should now be easier to make custom classes.
@matkor We could now add a getPin function to the Bounce class.
from bounce2.
Was added to v2.58
from bounce2.
Related Issues (20)
- Request: Allow multiple physical pins or software-only "pin" for each Bounce2 object HOT 1
- Nit: int type used in examples instead of bool or boolean
- Request: add Button class state output method isPressed() HOT 2
- Hardware abstraction should be by composition rather than inheritance HOT 6
- error: 'class Bounce' has no member named 'setPressedState' HOT 1
- Can't compile for Arduino Zero HOT 5
- Publish version 2.55 as a GitHub release HOT 1
- Library works on arduino Due but not on Zero (same sketch). HOT 3
- Debouncer::getStateFlag() and Debouncer::read() should be const HOT 6
- Problems with currentDuration () HOT 4
- Doesn't work with framework-arduinoespressif32-release_IDF4.4? HOT 2
- New release and deprecate duration() HOT 7
- Functions do work with the array type of setup HOT 3
- Does #define BOUNCE_LOCK_OUT work? HOT 4
- Todo : Allow the selection of debounce algorithm from the sketch instead of adding a define to the source HOT 1
- Teensy 4.1 Problems
- Pressing buttons simultaneously
- define bounce in two ways? HOT 5
- Bounce reports incorrect state if button is held down when attach() is called HOT 5
- Question regarding multiple button instances in a switch statement. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bounce2.