Skip to content
Snippets Groups Projects
RotaryEncoderBehaviours.cpp 894 B
Newer Older
RotaryEncoderUpdated::RotaryEncoderUpdated(VizBlocks* node, String name = "RotaryEncoderUpdated") :
  Behaviour(name), _node(node){ }

Matthew's avatar
Matthew committed
int RotaryEncoderUpdated::start(String args) {
    //This is where you do your stuff for a simple behaviour
Joe Revans's avatar
Joe Revans committed
    int index = args.indexOf(" ");
    String encoder = "";
    String position = "";

    if ( index > 0 ) {
      encoder = args.substring(0, index);
      position = args.substring(index+1);
    } else {
      return "RotaryEncoderUpdated behaviour args error!";
    }

    String str = "{\"id\":\"" + String(_node->getId()) + "\",\"Input\":{\"type\":\"" + String(name()) + "\",\"encoder\":\"" + encoder + "\",\"position\":\"" + position + "\"}}";
    _node->announce(str);
    return "RotaryEncoderUpdated behaviour " + _name + " with (" + args + ")";
Matthew's avatar
Matthew committed
  };
char * RotaryEncoderUpdated::args() {return "<String rotaryEncoderId> <int position>"; };