Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 2.82 KB

PropData.md

File metadata and controls

80 lines (58 loc) · 2.82 KB

PropData reference

See also:

PropData tracks data changes and provides escape room 2.0 propocol DATA ready string format.

See 4. Application protocol for escape room 2.0 prop in README.md.

PropData (see PropData.h) is an interface (base class) implemented by 4 classes:

  • PropDataDecimal
  • PropDataInteger
  • PropDataLogical
  • PropDataText

Constructors

  • PropDataDecimal(const char *, uint8_t digits = 2, double precision = 0.1, double initial = 0)
  • PropDataInteger(const char *, double precision = 0.1, long initial = 0)
  • PropDataLogical(const char *, const char *trueval = NULL, const char *falseval = NULL, bool initial = false)
  • PropDataText(const char *)

By default for PropDataLogical, trueval is "1" band falseval is "0".

For PropDataDecimal, digits is the number of decimal digits in the display string.

For PropDataDecimal and PropDataInteger, precision is the percentage threshold for deciding whether a change has occurred or not.

Interface

  • String fetch()
  • String fetchChange()

fetch() always returns the "var=value " string ready to be sent in a DATA protocol message and update the _previous value.

fetchChange() checks whether a change has occurred or not. If a change occured, returns the "var=value " string ready to be sent in a DATA protocol message and update the _previous value. If no change occured, returns and empty string.

Accessors and Mutators

  • void setValue(const double|long|bool|String)
  • double|long|bool|String value() const

Accessors and Mutators are typed according to PropData type.

Usage

Create a PropData instance

PropDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);

Add the PropData instance to managed data of the Props

void setup()
{
  ...

  Props::addManagedLogicalData(&clignoter);

  ...
}

Use the PropData instance anywhere

clignoter.setValue(true);

...

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

Author

Faure Systems (Oct 18th, 2019)