Newer
Older
#ifndef BUTTON_BEHAVIOUR_h
#define BUTTON_BEHAVIOUR_h
#include "Arduino.h"
#include "Behaviours.h"
class ButtonPressed : public Behaviour
{
/*
* Class that defines a behaviour that publishes a
* ButtonPressed message to the input topic of the
* MQQT broker
*/
VizBlocks* _node;
ButtonPressed(VizBlocks* node, String name = "ButtonPressed")
char* args();
String start(String args);
class ButtonReleased : public Behaviour
{
/*
* Class that defines a behaviour that publishes a
* ButtonReleased message to the input topic of the
* MQQT broker
*/
VizBlocks* _node;
ButtonReleased(VizBlocks* node, String name = "ButtonReleased");
char* args()
String start(String args)
/*
* Class that defines a behaviour that publishes a
* ButtonClicked message to the input topic of the
* MQQT broker
*/
VizBlocks* _node;
ButtonClicked(VizBlocks* node, String name = "ButtonClicked");
char* args()
String start(String args);
/*
* Class that defines a behaviour that publishes a
* ButtonLongPressed message to the input topic of the
* MQQT broker
*/
VizBlocks* _node;
String start(String args)
{
//This is where you do your stuff for a simple behaviour
String str = "{\"id\":\"" + String(_node->getId()) + "\",\"Input\":{\"type\":\"" + String(name()) + "\",\"button\":\"" + args + "\"}}";
_node->announce(str);
return "ButtonHeld behaviour " + _name + " with (" + args + ")";
}
class ButtonTick : public Behaviour
{
/*
* Class that defines a behaviour that publishes a
* ButtonRepeatPressed message to the input topic of the
* MQQT broker
*/
VizBlocks* _node;
ButtonTick(VizBlocks* node, String name = "ButtonTick") :
Behaviour(name), _node(node)
{ }
char* args()
{
return "<String buttonId>";
};
String start(String args);