File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,3 +73,8 @@ SliderBlock* AdafruitIO_Dashboard::addSliderBlock(AdafruitIO_Feed *feed)
7373{
7474 return new SliderBlock (this , feed);
7575}
76+
77+ GaugeBlock* AdafruitIO_Dashboard::addGaugeBlock (AdafruitIO_Feed *feed)
78+ {
79+ return new GaugeBlock (this , feed);
80+ }
Original file line number Diff line number Diff line change 1717#include " blocks/ToggleBlock.h"
1818#include " blocks/MomentaryBlock.h"
1919#include " blocks/SliderBlock.h"
20+ #include " blocks/GaugeBlock.h"
2021
2122// forward declaration
2223class AdafruitIO ;
@@ -36,6 +37,7 @@ class AdafruitIO_Dashboard {
3637 ToggleBlock* addToggleBlock (AdafruitIO_Feed *feed);
3738 MomentaryBlock* addMomentaryBlock (AdafruitIO_Feed *feed);
3839 SliderBlock* addSliderBlock (AdafruitIO_Feed *feed);
40+ GaugeBlock* addGaugeBlock (AdafruitIO_Feed *feed);
3941
4042 private:
4143 AdafruitIO *_io;
Original file line number Diff line number Diff line change 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 " GaugeBlock.h"
13+
14+ GaugeBlock::GaugeBlock (AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
15+ {
16+ min = 0 ;
17+ max = 100 ;
18+ width = " THIN" ;
19+ label = " Value" ;
20+ }
21+
22+ GaugeBlock::~GaugeBlock (){}
23+
24+ String GaugeBlock::properties ()
25+ {
26+ int w = 0 ;
27+
28+ if (width == " THIN" ) {
29+ w = 25 ;
30+ } else {
31+ w = 50 ;
32+ }
33+
34+ String props = " {\" minValue\" :\" " ;
35+ props += min;
36+ props += " \" ,\" maxValue\" :\" " ;
37+ props += max;
38+ props += " \" ,\" ringWidth\" :\" " ;
39+ props += w;
40+ props += " \" ,\" label\" :\" " ;
41+ props += label;
42+ props += " \" }" ;
43+
44+ return props;
45+ }
Original file line number Diff line number Diff line change 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_GAUGEBLOCK_H
13+ #define ADAFRUITIO_GAUGEBLOCK_H
14+
15+ #include " AdafruitIO_Block.h"
16+
17+ class GaugeBlock : public AdafruitIO_Block {
18+
19+ public:
20+ GaugeBlock (AdafruitIO_Dashboard *d, AdafruitIO_Feed *f);
21+ ~GaugeBlock ();
22+
23+ int min;
24+ int max;
25+ const char *width;
26+ const char *label;
27+
28+ String properties ();
29+
30+ private:
31+ const char *_visual_type = " gauge" ;
32+
33+ };
34+
35+ #endif // ADAFRUITIO_GAUGEBLOCK_H
You can’t perform that action at this time.
0 commit comments