File tree Expand file tree Collapse file tree 12 files changed +102
-19
lines changed Expand file tree Collapse file tree 12 files changed +102
-19
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,26 @@ String AdafruitIO_Block::properties()
27
27
return props;
28
28
}
29
29
30
+ String AdafruitIO_Block::dimensions ()
31
+ {
32
+ String dim = " \" ,\" size_x\" :\" " ;
33
+ dim += _width ();
34
+ dim += " \" ,\" size_y\" :\" " ;
35
+ dim += _height ();
36
+
37
+ if (_row () > 0 ) {
38
+ dim += " \" ,\" row\" :\" " ;
39
+ dim += _row ();
40
+ }
41
+
42
+ if (_column () > 0 ) {
43
+ dim += " \" ,\" column\" :\" " ;
44
+ dim += _column ();
45
+ }
46
+
47
+ return dim;
48
+ }
49
+
30
50
const char * AdafruitIO_Block::type ()
31
51
{
32
52
return _visual_type;
@@ -53,16 +73,15 @@ bool AdafruitIO_Block::save()
53
73
54
74
String body = " {\" visual_type\" :\" " ;
55
75
body += type ();
76
+ body += dimensions ();
56
77
body += " \" ,\" properties\" :" ;
57
78
body += properties ();
58
- body += " \,\" size_x\" :\" " ;
59
- body += width;
60
- body += " \" ,\" size_y\" :\" " ;
61
- body += height;
62
- body += " \" ,\" block_feeds\" :" ;
79
+ body += " ,\" block_feeds\" :" ;
63
80
body += block_feeds;
64
81
body += " }" ;
65
82
83
+ Serial.println (body);
84
+
66
85
http->startRequest (url.c_str (), HTTP_METHOD_POST);
67
86
http->sendHeader (HTTP_HEADER_CONTENT_TYPE, " application/json" );
68
87
http->sendHeader (HTTP_HEADER_CONTENT_LENGTH, body.length ());
Original file line number Diff line number Diff line change @@ -26,19 +26,27 @@ class AdafruitIO_Block {
26
26
27
27
int width = 2 ;
28
28
int height = 2 ;
29
- int row;
30
- int column;
29
+ int row = 0 ;
30
+ int column = 0 ;
31
31
32
32
virtual String properties ();
33
+ String dimensions ();
34
+
33
35
virtual const char * type ();
34
36
35
37
bool save ();
36
38
37
- private :
39
+ protected :
38
40
AdafruitIO_Dashboard *_dashboard;
39
41
AdafruitIO_Feed *_feed;
42
+
40
43
const char *_visual_type;
41
44
45
+ virtual int _width () { return width; }
46
+ virtual int _height () { return height; }
47
+ virtual int _row () { return row; }
48
+ virtual int _column () { return column; }
49
+
42
50
};
43
51
44
52
#endif // ADAFRUITIO_BLOCK_H
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class ChartBlock : public AdafruitIO_Block {
21
21
~ChartBlock ();
22
22
23
23
const char * type () { return _visual_type; }
24
+
24
25
int historyHours;
25
26
const char *xAxisLabel;
26
27
const char *yAxisLabel;
@@ -32,9 +33,14 @@ class ChartBlock : public AdafruitIO_Block {
32
33
33
34
String properties ();
34
35
35
- private :
36
+ protected :
36
37
const char *_visual_type = " line_chart" ;
37
38
39
+ int _width () { return width; }
40
+ int _height () { return height; }
41
+ int _row () { return row; }
42
+ int _column () { return column; }
43
+
38
44
};
39
45
40
46
#endif // ADAFRUITIO_CHARTBLOCK_H
Original file line number Diff line number Diff line change @@ -25,9 +25,16 @@ class ColorBlock : public AdafruitIO_Block {
25
25
26
26
const char * type () { return _visual_type; }
27
27
28
- private:
28
+ protected:
29
+
29
30
const char *_visual_type = " color_picker" ;
30
31
32
+ int _width () { return width; }
33
+ int _height () { return height; }
34
+ int _row () { return row; }
35
+ int _column () { return column; }
36
+
37
+
31
38
};
32
39
33
40
#endif // ADAFRUITIO_COLORBLOCK_H
Original file line number Diff line number Diff line change @@ -31,10 +31,14 @@ class GaugeBlock : public AdafruitIO_Block {
31
31
32
32
String properties ();
33
33
const char * type () { return _visual_type; }
34
-
35
- private:
34
+ protected:
36
35
const char *_visual_type = " gauge" ;
37
36
37
+ int _width () { return width; }
38
+ int _height () { return height; }
39
+ int _row () { return row; }
40
+ int _column () { return column; }
41
+
38
42
};
39
43
40
44
#endif // ADAFRUITIO_GAUGEBLOCK_H
Original file line number Diff line number Diff line change @@ -25,9 +25,14 @@ class ImageBlock : public AdafruitIO_Block {
25
25
26
26
const char * type () { return _visual_type; }
27
27
28
- private :
28
+ protected :
29
29
const char *_visual_type = " image" ;
30
30
31
+ int _width () { return width; }
32
+ int _height () { return height; }
33
+ int _row () { return row; }
34
+ int _column () { return column; }
35
+
31
36
};
32
37
33
38
#endif // ADAFRUITIO_IMAGEBLOCK_H
Original file line number Diff line number Diff line change @@ -29,9 +29,15 @@ class MapBlock : public AdafruitIO_Block {
29
29
String properties ();
30
30
const char * type () { return _visual_type; }
31
31
32
- private :
32
+ protected :
33
33
const char *_visual_type = " map" ;
34
34
35
+ int _width () { return width; }
36
+ int _height () { return height; }
37
+ int _row () { return row; }
38
+ int _column () { return column; }
39
+
40
+
35
41
};
36
42
37
43
#endif // ADAFRUITIO_MAPBLOCK_H
Original file line number Diff line number Diff line change @@ -30,9 +30,15 @@ class MomentaryBlock : public AdafruitIO_Block {
30
30
String properties ();
31
31
const char * type () { return _visual_type; }
32
32
33
- private :
33
+ protected :
34
34
const char *_visual_type = " momentary_button" ;
35
35
36
+ int _width () { return width; }
37
+ int _height () { return height; }
38
+ int _row () { return row; }
39
+ int _column () { return column; }
40
+
41
+
36
42
};
37
43
38
44
#endif // ADAFRUITIO_MOMENTARYBLOCK_H
Original file line number Diff line number Diff line change @@ -31,9 +31,15 @@ class SliderBlock : public AdafruitIO_Block {
31
31
String properties ();
32
32
const char * type () { return _visual_type; }
33
33
34
- private :
34
+ protected :
35
35
const char *_visual_type = " slider" ;
36
36
37
+ int _width () { return width; }
38
+ int _height () { return height; }
39
+ int _row () { return row; }
40
+ int _column () { return column; }
41
+
42
+
37
43
};
38
44
39
45
#endif // ADAFRUITIO_SLIDERBLOCK_H
Original file line number Diff line number Diff line change @@ -32,9 +32,14 @@ class StreamBlock : public AdafruitIO_Block {
32
32
String properties ();
33
33
const char * type () { return _visual_type; }
34
34
35
- private :
35
+ protected :
36
36
const char *_visual_type = " stream" ;
37
37
38
+ int _width () { return width; }
39
+ int _height () { return height; }
40
+ int _row () { return row; }
41
+ int _column () { return column; }
42
+
38
43
};
39
44
40
45
#endif // ADAFRUITIO_STREAMBLOCK_H
You can’t perform that action at this time.
0 commit comments