Skip to content

Latest commit

 

History

History
61 lines (47 loc) · 1.61 KB

PropAction.md

File metadata and controls

61 lines (47 loc) · 1.61 KB

PropAction class reference

See also:

PropAction (see PropAction.h) brings asynchronous-like behavior to sketch loop().

Constructors

  • PropAction()
  • PropAction(unsigned long interval, void (*function)())

function is the callback executed at every interval milliseconds.

Members

  • void reset(unsigned long interval)
  • void disable()
  • void enable()
  • void check()
  • bool tick()
  • unsigned long getInterval()

Usage

Create a callback

void clignote()
{
  if (clignoter.value()) {
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
    led.setValue(digitalRead(LED_BUILTIN));
  }
}

Create a PropAction instance

PropAction clignoteAction = PropAction(1000, clignote); // interval every 1000 milliseconds

Call the instance check() method ine the sketch loop()

void loop()
{
  ...

  clignoteAction.check(); // do your stuff, don't freeze the loop with delay() calls

  ...
}

Author

Faure Systems (Oct 18th, 2019)