Skip to content

Commit 1a71348

Browse files
committed
add map block
1 parent 4371b74 commit 1a71348

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

src/AdafruitIO_Dashboard.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,8 @@ ColorBlock* AdafruitIO_Dashboard::addColorBlock(AdafruitIO_Feed *feed)
9393
{
9494
return new ColorBlock(this, feed);
9595
}
96+
97+
MapBlock* AdafruitIO_Dashboard::addMapBlock(AdafruitIO_Feed *feed)
98+
{
99+
return new MapBlock(this, feed);
100+
}

src/AdafruitIO_Dashboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "blocks/TextBlock.h"
2222
#include "blocks/ChartBlock.h"
2323
#include "blocks/ColorBlock.h"
24+
#include "blocks/MapBlock.h"
2425

2526
// forward declaration
2627
class AdafruitIO;
@@ -44,6 +45,7 @@ class AdafruitIO_Dashboard {
4445
TextBlock* addTextBlock(AdafruitIO_Feed *feed);
4546
ChartBlock* addChartBlock(AdafruitIO_Feed *feed);
4647
ColorBlock* addColorBlock(AdafruitIO_Feed *feed);
48+
MapBlock* addMapBlock(AdafruitIO_Feed *feed);
4749

4850
private:
4951
AdafruitIO *_io;

src/blocks/MapBlock.cpp

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+
#include "MapBlock.h"
13+
14+
MapBlock::MapBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
15+
{
16+
historyHours = 0;
17+
tile = "contrast";
18+
}
19+
20+
MapBlock::~MapBlock(){}
21+
22+
String MapBlock::properties()
23+
{
24+
25+
if(tile != "contrast" && tile != "street" && tile != "sat") {
26+
tile = "contrast";
27+
}
28+
29+
String props = "{\"historyHours\":\"";
30+
props += historyHours;
31+
props += "\",\"tile\":";
32+
props += tile;
33+
props += "\"}";
34+
35+
return props;
36+
}

src/blocks/MapBlock.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_MAPBLOCK_H
13+
#define ADAFRUITIO_MAPBLOCK_H
14+
15+
#include "AdafruitIO_Block.h"
16+
17+
class MapBlock : public AdafruitIO_Block {
18+
19+
public:
20+
MapBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f);
21+
~MapBlock();
22+
23+
int historyHours;
24+
const char *tile;
25+
26+
String properties();
27+
28+
private:
29+
const char *_visual_type = "map";
30+
31+
};
32+
33+
#endif // ADAFRUITIO_MAPBLOCK_H

0 commit comments

Comments
 (0)