Skip to content

Commit adf5d6f

Browse files
committed
add stream block
1 parent 1a71348 commit adf5d6f

File tree

6 files changed

+98
-5
lines changed

6 files changed

+98
-5
lines changed

src/AdafruitIO_Dashboard.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,8 @@ MapBlock* AdafruitIO_Dashboard::addMapBlock(AdafruitIO_Feed *feed)
9898
{
9999
return new MapBlock(this, feed);
100100
}
101+
102+
StreamBlock* AdafruitIO_Dashboard::addStreamBlock(AdafruitIO_Feed *feed)
103+
{
104+
return new StreamBlock(this, feed);
105+
}

src/AdafruitIO_Dashboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "blocks/ChartBlock.h"
2323
#include "blocks/ColorBlock.h"
2424
#include "blocks/MapBlock.h"
25+
#include "blocks/StreamBlock.h"
2526

2627
// forward declaration
2728
class AdafruitIO;
@@ -46,6 +47,7 @@ class AdafruitIO_Dashboard {
4647
ChartBlock* addChartBlock(AdafruitIO_Feed *feed);
4748
ColorBlock* addColorBlock(AdafruitIO_Feed *feed);
4849
MapBlock* addMapBlock(AdafruitIO_Feed *feed);
50+
StreamBlock* addStreamBlock(AdafruitIO_Feed *feed);
4951

5052
private:
5153
AdafruitIO *_io;

src/blocks/GaugeBlock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ GaugeBlock::GaugeBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO
1515
{
1616
min = 0;
1717
max = 100;
18-
width = "THIN";
18+
width = "thin";
1919
label = "Value";
2020
}
2121

@@ -25,7 +25,7 @@ String GaugeBlock::properties()
2525
{
2626
int w = 0;
2727

28-
if(width == "THIN") {
28+
if(width == "thin") {
2929
w = 25;
3030
} else {
3131
w = 50;

src/blocks/StreamBlock.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 "StreamBlock.h"
13+
14+
StreamBlock::StreamBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
15+
{
16+
fontSize = "small";
17+
fontColor = "green";
18+
showErrors = true;
19+
showTimestamp = true;
20+
showName = true;
21+
}
22+
23+
StreamBlock::~StreamBlock(){}
24+
25+
String StreamBlock::properties()
26+
{
27+
int s = 0;
28+
29+
if(fontSize == "small") {
30+
s = 12;
31+
} else if(fontSize == "medium") {
32+
s = 18;
33+
} else {
34+
s = 24;
35+
}
36+
37+
String props = "{\"fontSize\":\"";
38+
props += s;
39+
props += "\",\"fontColor\":";
40+
props += fontColor == "white" ? "#ffffff" : "#63de00";
41+
props += "\",\"errors\":";
42+
props += showErrors ? "yes" : "no";
43+
props += "\",\"showTimestamp\":";
44+
props += showTimestamp ? "yes" : "no";
45+
props += "\",\"showName\":";
46+
props += showName ? "yes" : "no";
47+
props += "\"}";
48+
49+
return props;
50+
}

src/blocks/StreamBlock.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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_STREAMBLOCK_H
13+
#define ADAFRUITIO_STREAMBLOCK_H
14+
15+
#include "AdafruitIO_Block.h"
16+
17+
class StreamBlock : public AdafruitIO_Block {
18+
19+
public:
20+
StreamBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f);
21+
~StreamBlock();
22+
23+
const char *fontSize;
24+
const char *fontColor;
25+
bool showErrors;
26+
bool showTimestamp;
27+
bool showName;
28+
29+
String properties();
30+
31+
private:
32+
const char *_visual_type = "stream";
33+
34+
};
35+
36+
#endif // ADAFRUITIO_STREAMBLOCK_H

src/blocks/TextBlock.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
TextBlock::TextBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
1515
{
16-
fontSize = "SMALL";
16+
fontSize = "small";
1717
}
1818

1919
TextBlock::~TextBlock(){}
@@ -22,9 +22,9 @@ String TextBlock::properties()
2222
{
2323
int s = 0;
2424

25-
if(fontSize == "SMALL") {
25+
if(fontSize == "small") {
2626
s = 12;
27-
} else if(fontSize == "MEDIUM") {
27+
} else if(fontSize == "medium") {
2828
s = 18;
2929
} else {
3030
s = 24;

0 commit comments

Comments
 (0)