VizBlocks
ButtonBehaviours.hpp
Go to the documentation of this file.
1 #ifndef BUTTON_BEHAVIOUR_h
2 #define BUTTON_BEHAVIOUR_h
3 #include "Arduino.h"
4 #include "Behaviours.h"
5 #include <VizBlocks.h>
6 
7 class ButtonPressed : public Behaviour
8 {
9  /*
10  * Class that defines a behaviour that publishes a
11  * ButtonPressed message to the input topic of the
12  * MQQT broker
13  */
14  VizBlocks* _node;
15 
16 public:
17  ButtonPressed(VizBlocks* node, String name = "ButtonPressed")
18  char* args();
19  String start(String args);
20 }
21 
22 class ButtonReleased : public Behaviour
23 {
24  /*
25  * Class that defines a behaviour that publishes a
26  * ButtonReleased message to the input topic of the
27  * MQQT broker
28  */
30 
31 public:
32  ButtonReleased(VizBlocks* node, String name = "ButtonReleased");
33  char* args()
34  String start(String args)
35 };
36 
37 class ButtonClicked : public Behaviour
38 {
39  /*
40  * Class that defines a behaviour that publishes a
41  * ButtonClicked message to the input topic of the
42  * MQQT broker
43  */
45 
46 public:
47  ButtonClicked(VizBlocks* node, String name = "ButtonClicked");
48  char* args()
49  String start(String args);
50 };
51 
52 class ButtonHeld : public Behaviour
53 {
54  /*
55  * Class that defines a behaviour that publishes a
56  * ButtonLongPressed message to the input topic of the
57  * MQQT broker
58  */
60 
61 public:
62  ButtonHeld(VizBlocks* node, String name = "ButtonHeld")
66  char* args()
67  {
68  return "<String buttonId>";
69  };
70 
74  String start(String args)
75  {
76  //This is where you do your stuff for a simple behaviour
77  String str = "{\"id\":\"" + String(_node->getId()) + "\",\"Input\":{\"type\":\"" + String(name()) + "\",\"button\":\"" + args + "\"}}";
78  _node->announce(str);
79 
80  return "ButtonHeld behaviour " + _name + " with (" + args + ")";
81  }
82 };
83 
84 class ButtonTick : public Behaviour
85 {
86  /*
87  * Class that defines a behaviour that publishes a
88  * ButtonRepeatPressed message to the input topic of the
89  * MQQT broker
90  */
92 
93 public:
94  ButtonTick(VizBlocks* node, String name = "ButtonTick") :
95  Behaviour(name), _node(node)
96  { }
97 
101  char* args()
102  {
103  return "<String buttonId>";
104  };
105  String start(String args);
106 };
107 
108 #endif
ButtonTick::ButtonTick
ButtonTick(VizBlocks *node, String name="ButtonTick")
Definition: ButtonBehaviours.hpp:94
ButtonTick::start
String start(String args)
ButtonPressed::ButtonPressed
ButtonPressed(VizBlocks *node, String name="ButtonPressed") char *args()
Behaviour::name
virtual String name()
Behaviour::args
virtual char * args()
Behaviour::_name
String _name
Definition: Behaviours.hpp:16
Behaviour
Definition: Behaviours.hpp:9
ButtonClicked::ButtonClicked
ButtonClicked(VizBlocks *node, String name="ButtonClicked")
ButtonPressed
Definition: ButtonBehaviours.hpp:8
ButtonTick::args
char * args()
What does this do?
Definition: ButtonBehaviours.hpp:101
ButtonHeld::start
String start(String args)
What does this do?
Definition: ButtonBehaviours.hpp:74
ButtonReleased
ButtonReleased(VizBlocks *node, String name="ButtonReleased")
ButtonClicked::args
char * args() String start(String args)
ButtonClicked
Definition: ButtonBehaviours.hpp:38
ButtonHeld::ButtonHeld
ButtonHeld(VizBlocks *node, String name="ButtonHeld") char *args()
What does this do?
Definition: ButtonBehaviours.hpp:62
VizBlocks
Definition: VizBlocks.hpp:18
ButtonTick
Definition: ButtonBehaviours.hpp:85
ButtonPressed::start
String start(String args)
_node
ButtonPressed * _node
ButtonHeld
Definition: ButtonBehaviours.hpp:53