Skip to content

Commit e664744

Browse files
committed
add momentary block class
1 parent dfe36cf commit e664744

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

src/AdafruitIO_Dashboard.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ ToggleBlock* AdafruitIO_Dashboard::addToggleBlock(AdafruitIO_Feed *feed)
6363
{
6464
return new ToggleBlock(this, feed);
6565
}
66+
67+
MomentaryBlock* AdafruitIO_Dashboard::addMomentaryBlock(AdafruitIO_Feed *feed)
68+
{
69+
return new MomentaryBlock(this, feed);
70+
}

src/AdafruitIO_Dashboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Arduino.h"
1616
#include "AdafruitIO_Definitions.h"
1717
#include "blocks/ToggleBlock.h"
18+
#include "blocks/MomentaryBlock.h"
1819

1920
// forward declaration
2021
class AdafruitIO;
@@ -32,6 +33,7 @@ class AdafruitIO_Dashboard {
3233
bool create();
3334

3435
ToggleBlock* addToggleBlock(AdafruitIO_Feed *feed);
36+
MomentaryBlock* addMomentaryBlock(AdafruitIO_Feed *feed);
3537

3638
private:
3739
AdafruitIO *_io;

src/blocks/MomentaryBlock.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Adafruit invests time and resources providing this open source code.
3+
// Please support Adafruit and open source hardware by purchasing
4+
// products from Adafruit!
5+
//
6+
// Copyright (c) 2015-2016 Adafruit Industries
7+
// Authors: Tony DiCola, Todd Treece
8+
// Licensed under the MIT license.
9+
//
10+
// All text above must be included in any redistribution.
11+
//
12+
#include "MomentaryBlock.h"
13+
14+
MomentaryBlock::MomentaryBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
15+
{
16+
text = 0;
17+
value = 0;
18+
release = 0;
19+
}
20+
21+
MomentaryBlock::~MomentaryBlock(){}
22+
23+
String MomentaryBlock::properties()
24+
{
25+
String props = "{\"text\":\"";
26+
props += text;
27+
props += "\",\"value\":\"";
28+
props += value;
29+
props += "\",\"release\":\"";
30+
props += release;
31+
props += "\"}";
32+
33+
return props;
34+
}

src/blocks/MomentaryBlock.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Adafruit invests time and resources providing this open source code.
3+
// Please support Adafruit and open source hardware by purchasing
4+
// products from Adafruit!
5+
//
6+
// Copyright (c) 2015-2016 Adafruit Industries
7+
// Authors: Tony DiCola, Todd Treece
8+
// Licensed under the MIT license.
9+
//
10+
// All text above must be included in any redistribution.
11+
//
12+
#ifndef ADAFRUITIO_MOMENTARYBLOCK_H
13+
#define ADAFRUITIO_MOMENTARYBLOCK_H
14+
15+
#include "AdafruitIO_Block.h"
16+
17+
class MomentaryBlock : public AdafruitIO_Block {
18+
19+
public:
20+
MomentaryBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f);
21+
~MomentaryBlock();
22+
23+
const char *text;
24+
const char *value;
25+
const char *release;
26+
27+
String properties();
28+
29+
private:
30+
const char *_visual_type = "momentary_button";
31+
32+
};
33+
34+
#endif // ADAFRUITIO_MOMENTARYBLOCK_H
File renamed without changes.

0 commit comments

Comments
 (0)