Git Product home page Git Product logo

Comments (8)

matkor avatar matkor commented on August 20, 2024 1

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.

thomasfredericks avatar thomasfredericks commented on August 20, 2024

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.

septillion-git avatar septillion-git commented on August 20, 2024

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.

matkor avatar matkor commented on August 20, 2024

(...) 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.

jamesmyatt avatar jamesmyatt commented on August 20, 2024

@matkor, why do you store the debouncer and pin separately?

from bounce2.

matkor avatar matkor commented on August 20, 2024

@matkor, why do you store the debouncer and pin separately?

I do not.
I just need access pin having only Bounce instance.

from bounce2.

thomasfredericks avatar thomasfredericks commented on August 20, 2024

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.

thomasfredericks avatar thomasfredericks commented on August 20, 2024

Was added to v2.58

from bounce2.

Related Issues (20)

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.