File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,26 @@ String AdafruitIO_Block::properties()
2727 return props;
2828}
2929
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+
3050const char * AdafruitIO_Block::type ()
3151{
3252 return _visual_type;
@@ -53,16 +73,15 @@ bool AdafruitIO_Block::save()
5373
5474 String body = " {\" visual_type\" :\" " ;
5575 body += type ();
76+ body += dimensions ();
5677 body += " \" ,\" properties\" :" ;
5778 body += properties ();
58- body += " \,\" size_x\" :\" " ;
59- body += width;
60- body += " \" ,\" size_y\" :\" " ;
61- body += height;
62- body += " \" ,\" block_feeds\" :" ;
79+ body += " ,\" block_feeds\" :" ;
6380 body += block_feeds;
6481 body += " }" ;
6582
83+ Serial.println (body);
84+
6685 http->startRequest (url.c_str (), HTTP_METHOD_POST);
6786 http->sendHeader (HTTP_HEADER_CONTENT_TYPE, " application/json" );
6887 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 {
2626
2727 int width = 2 ;
2828 int height = 2 ;
29- int row;
30- int column;
29+ int row = 0 ;
30+ int column = 0 ;
3131
3232 virtual String properties ();
33+ String dimensions ();
34+
3335 virtual const char * type ();
3436
3537 bool save ();
3638
37- private :
39+ protected :
3840 AdafruitIO_Dashboard *_dashboard;
3941 AdafruitIO_Feed *_feed;
42+
4043 const char *_visual_type;
4144
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+
4250};
4351
4452#endif // ADAFRUITIO_BLOCK_H
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class ChartBlock : public AdafruitIO_Block {
2121 ~ChartBlock ();
2222
2323 const char * type () { return _visual_type; }
24+
2425 int historyHours;
2526 const char *xAxisLabel;
2627 const char *yAxisLabel;
@@ -32,9 +33,14 @@ class ChartBlock : public AdafruitIO_Block {
3233
3334 String properties ();
3435
35- private :
36+ protected :
3637 const char *_visual_type = " line_chart" ;
3738
39+ int _width () { return width; }
40+ int _height () { return height; }
41+ int _row () { return row; }
42+ int _column () { return column; }
43+
3844};
3945
4046#endif // ADAFRUITIO_CHARTBLOCK_H
Original file line number Diff line number Diff line change @@ -25,9 +25,16 @@ class ColorBlock : public AdafruitIO_Block {
2525
2626 const char * type () { return _visual_type; }
2727
28- private:
28+ protected:
29+
2930 const char *_visual_type = " color_picker" ;
3031
32+ int _width () { return width; }
33+ int _height () { return height; }
34+ int _row () { return row; }
35+ int _column () { return column; }
36+
37+
3138};
3239
3340#endif // ADAFRUITIO_COLORBLOCK_H
Original file line number Diff line number Diff line change @@ -31,10 +31,14 @@ class GaugeBlock : public AdafruitIO_Block {
3131
3232 String properties ();
3333 const char * type () { return _visual_type; }
34-
35- private:
34+ protected:
3635 const char *_visual_type = " gauge" ;
3736
37+ int _width () { return width; }
38+ int _height () { return height; }
39+ int _row () { return row; }
40+ int _column () { return column; }
41+
3842};
3943
4044#endif // ADAFRUITIO_GAUGEBLOCK_H
Original file line number Diff line number Diff line change @@ -25,9 +25,14 @@ class ImageBlock : public AdafruitIO_Block {
2525
2626 const char * type () { return _visual_type; }
2727
28- private :
28+ protected :
2929 const char *_visual_type = " image" ;
3030
31+ int _width () { return width; }
32+ int _height () { return height; }
33+ int _row () { return row; }
34+ int _column () { return column; }
35+
3136};
3237
3338#endif // ADAFRUITIO_IMAGEBLOCK_H
Original file line number Diff line number Diff line change @@ -29,9 +29,15 @@ class MapBlock : public AdafruitIO_Block {
2929 String properties ();
3030 const char * type () { return _visual_type; }
3131
32- private :
32+ protected :
3333 const char *_visual_type = " map" ;
3434
35+ int _width () { return width; }
36+ int _height () { return height; }
37+ int _row () { return row; }
38+ int _column () { return column; }
39+
40+
3541};
3642
3743#endif // ADAFRUITIO_MAPBLOCK_H
Original file line number Diff line number Diff line change @@ -30,9 +30,15 @@ class MomentaryBlock : public AdafruitIO_Block {
3030 String properties ();
3131 const char * type () { return _visual_type; }
3232
33- private :
33+ protected :
3434 const char *_visual_type = " momentary_button" ;
3535
36+ int _width () { return width; }
37+ int _height () { return height; }
38+ int _row () { return row; }
39+ int _column () { return column; }
40+
41+
3642};
3743
3844#endif // ADAFRUITIO_MOMENTARYBLOCK_H
Original file line number Diff line number Diff line change @@ -31,9 +31,15 @@ class SliderBlock : public AdafruitIO_Block {
3131 String properties ();
3232 const char * type () { return _visual_type; }
3333
34- private :
34+ protected :
3535 const char *_visual_type = " slider" ;
3636
37+ int _width () { return width; }
38+ int _height () { return height; }
39+ int _row () { return row; }
40+ int _column () { return column; }
41+
42+
3743};
3844
3945#endif // ADAFRUITIO_SLIDERBLOCK_H
Original file line number Diff line number Diff line change @@ -32,9 +32,14 @@ class StreamBlock : public AdafruitIO_Block {
3232 String properties ();
3333 const char * type () { return _visual_type; }
3434
35- private :
35+ protected :
3636 const char *_visual_type = " stream" ;
3737
38+ int _width () { return width; }
39+ int _height () { return height; }
40+ int _row () { return row; }
41+ int _column () { return column; }
42+
3843};
3944
4045#endif // ADAFRUITIO_STREAMBLOCK_H
You can’t perform that action at this time.
0 commit comments