Skip to content

Commit dfe36cf

Browse files
committed
add toggle block class
1 parent 0160cfa commit dfe36cf

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

src/blocks/ToggleBlock.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 "ToggleBlock.h"
13+
14+
ToggleBlock::ToggleBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
15+
{
16+
onText = 0;
17+
offText = 0;
18+
}
19+
20+
ToggleBlock::~ToggleBlock(){}
21+
22+
String ToggleBlock::properties()
23+
{
24+
String props = "{\"onText\":\"";
25+
props += onText;
26+
props += "\",\"offText\":\"";
27+
props += offText;
28+
props += "\"}";
29+
30+
return props;
31+
}

src/blocks/ToggleBlock.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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_TOGGLEBLOCK_H
13+
#define ADAFRUITIO_TOGGLEBLOCK_H
14+
15+
#include "AdafruitIO_Block.h"
16+
17+
class ToggleBlock : public AdafruitIO_Block {
18+
19+
public:
20+
ToggleBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f);
21+
~ToggleBlock();
22+
23+
const char *onText;
24+
const char *offText;
25+
26+
String properties();
27+
28+
private:
29+
const char *_visual_type = "toggle_button";
30+
31+
};
32+
33+
#endif // ADAFRUITIO_TOGGLEBLOCK_H

0 commit comments

Comments
 (0)