Skip to content
Snippets Groups Projects
ButtonBehaviours.h 3.59 KiB
Newer Older
#ifndef BUTTON_BEHAVIOUR_h
#define BUTTON_BEHAVIOUR_h
#include "Arduino.h"
#include "Behaviours.h"
#include <WallVis.h>

class ButtonPressed : public Behaviour {
  /*
   * Class that defines a behaviour that publishes a
   * ButtonPressed message to the input topic of the
   * MQQT broker
   */
   WallVis* _node;

public:
  ButtonPressed(WallVis* node, String name = "ButtonPressed") :
    Behaviour(name), _node(node){ }

  char* args() {return "<String buttonId>"; };

  String start(String args) {
    //This is where you do your stuff for a simple behaviour
    _node->input_publish("ButtonPressed " + args);
    return "ButtonPressed behaviour " + _name + " with (" + args + ")";
  }
};

class ButtonReleased : public Behaviour {
  /*
   * Class that defines a behaviour that publishes a
   * ButtonReleased message to the input topic of the
   * MQQT broker
   */
   WallVis* _node;

public:
  ButtonReleased(WallVis* node, String name = "ButtonReleased") :
    Behaviour(name), _node(node){ }

  char* args() {return "<String buttonId>"; };

  String start(String args) {
    //This is where you do your stuff for a simple behaviour
    _node->input_publish("ButtonReleased " + args);
    return "ButtonReleased behaviour " + _name + " with (" + args + ")";
  }
};

class ButtonClicked : public Behaviour {
  /*
   * Class that defines a behaviour that publishes a
   * ButtonClicked message to the input topic of the
   * MQQT broker
   */
   WallVis* _node;

public:
  ButtonClicked(WallVis* node, String name = "ButtonClicked") :
    Behaviour(name), _node(node){ }

  char* args() {return "<String buttonId>"; };

  String start(String args) {
    //This is where you do your stuff for a simple behaviour
    _node->input_publish("ButtonClicked " + args);
    return "ButtonClicked behaviour " + _name + " with (" + args + ")";
  }
};

class ButtonDoubleClicked : public Behaviour {
  /*
   * Class that defines a behaviour that publishes a
   * ButtonDoubleClicked message to the input topic of the
   * MQQT broker
   */
   WallVis* _node;

public:
  ButtonDoubleClicked(WallVis* node, String name = "ButtonDoubleClicked") :
    Behaviour(name), _node(node){ }

  char* args() {return "<String buttonId>"; };

  String start(String args) {
    //This is where you do your stuff for a simple behaviour
    _node->input_publish("ButtonDoubleClicked " + args);
    return "ButtonDoubleClicked behaviour " + _name + " with (" + args + ")";
  }
};

class ButtonLongPressed : public Behaviour {
  /*
   * Class that defines a behaviour that publishes a
   * ButtonLongPressed message to the input topic of the
   * MQQT broker
   */
   WallVis* _node;

public:
  ButtonLongPressed(WallVis* node, String name = "ButtonLongPressed") :
    Behaviour(name), _node(node){ }

  char* args() {return "<String buttonId>"; };

  String start(String args) {
    //This is where you do your stuff for a simple behaviour
    _node->input_publish("ButtonLongPressed " + args);
    return "ButtonLongPressed behaviour " + _name + " with (" + args + ")";
  }
};

class ButtonRepeatPressed : public Behaviour {
  /*
   * Class that defines a behaviour that publishes a
   * ButtonRepeatPressed message to the input topic of the
   * MQQT broker
   */
   WallVis* _node;

public:
  ButtonRepeatPressed(WallVis* node, String name = "ButtonRepeatPressed") :
    Behaviour(name), _node(node){ }

  char* args() {return "<String buttonId>"; };

  String start(String args) {
    //This is where you do your stuff for a simple behaviour
    _node->input_publish("ButtonRepeatPressed " + args);
    return "ButtonRepeatPressed behaviour " + _name + " with (" + args + ")";
  }
};

#endif