Search wiring.org.co:

Libraries \ Supervisor

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Name |

### Supervisor

Examples |
    #include <Supervisor.h>

    int x = 0;

    /*
      Define the rule itself
    */
    SupervisedRule<int> ledOnFirstTenSeconds(x,checkFirstTen,handleAfterTen);

    /*
      Define the rule helpers
    */
    //this function will return true the first ten seconds
    //when it return false (aka the rule failed) the handler will be called
    boolean checkFirstTen(int x) {
      if (millis()<10000) { return true; } return false;
    }

    //the first ten seconds have passed
    //turn off the LED and remove the rule
    void handleAfterTen(int &x) {
      digitalWrite(WLED, LOW);
      Supervisor.removeRule(ledOnFirstTenSeconds);
    }

    void setup()
    {
      Supervisor.addRule(ledOnFirstTenSeconds);

      pinMode(WLED,OUTPUT);
      digitalWrite(WLED, HIGH);
    }

    void loop()
    {
      Supervisor.checkRules();
    }
Description | Supervise a set of rules that automatically fire a handler for when the rule is broken. Rules operate on a single variable, and need a supporting check function and the beforementioned handler.
Syntax |
    SupervisedRule < typename > supervisorName(val, check, handle)
Methods |

addRule() |
removeRule() |
checkRules() |

Parameters |

typename | any type
supervisorName | Name of the supervisor
val | Single variable
check | Supporting check function
handle |

Returns | None
Usage | Application

Updated on July 07, 2011 11:11:55pm PDT