Skip to content

Commit 94e432a

Browse files
committed
add slider block
1 parent e664744 commit 94e432a

File tree

6 files changed

+84
-5
lines changed

6 files changed

+84
-5
lines changed

src/AdafruitIO_Dashboard.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,8 @@ MomentaryBlock* AdafruitIO_Dashboard::addMomentaryBlock(AdafruitIO_Feed *feed)
6868
{
6969
return new MomentaryBlock(this, feed);
7070
}
71+
72+
SliderBlock* AdafruitIO_Dashboard::addSliderBlock(AdafruitIO_Feed *feed)
73+
{
74+
return new SliderBlock(this, feed);
75+
}

src/AdafruitIO_Dashboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "AdafruitIO_Definitions.h"
1717
#include "blocks/ToggleBlock.h"
1818
#include "blocks/MomentaryBlock.h"
19+
#include "blocks/SliderBlock.h"
1920

2021
// forward declaration
2122
class AdafruitIO;
@@ -34,6 +35,7 @@ class AdafruitIO_Dashboard {
3435

3536
ToggleBlock* addToggleBlock(AdafruitIO_Feed *feed);
3637
MomentaryBlock* addMomentaryBlock(AdafruitIO_Feed *feed);
38+
SliderBlock* addSliderBlock(AdafruitIO_Feed *feed);
3739

3840
private:
3941
AdafruitIO *_io;

src/blocks/MomentaryBlock.cpp

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

1414
MomentaryBlock::MomentaryBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
1515
{
16-
text = 0;
17-
value = 0;
18-
release = 0;
16+
text = "RESET";
17+
value = "1";
18+
release = "0";
1919
}
2020

2121
MomentaryBlock::~MomentaryBlock(){}

src/blocks/SliderBlock.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 "SliderBlock.h"
13+
14+
SliderBlock::SliderBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
15+
{
16+
min = 0;
17+
max = 100;
18+
step = 10;
19+
label = "Value";
20+
}
21+
22+
SliderBlock::~SliderBlock(){}
23+
24+
String SliderBlock::properties()
25+
{
26+
String props = "{\"min\":\"";
27+
props += min;
28+
props += "\",\"max\":\"";
29+
props += max;
30+
props += "\",\"step\":\"";
31+
props += step;
32+
props += "\",\"label\":\"";
33+
props += label;
34+
props += "\"}";
35+
36+
return props;
37+
}

src/blocks/SliderBlock.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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_SLIDERBLOCK_H
13+
#define ADAFRUITIO_SLIDERBLOCK_H
14+
15+
#include "AdafruitIO_Block.h"
16+
17+
class SliderBlock : public AdafruitIO_Block {
18+
19+
public:
20+
SliderBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f);
21+
~SliderBlock();
22+
23+
int min;
24+
int max;
25+
int step;
26+
const char *label;
27+
28+
String properties();
29+
30+
private:
31+
const char *_visual_type = "slider";
32+
33+
};
34+
35+
#endif // ADAFRUITIO_SLIDERBLOCK_H

src/blocks/ToggleBlock.cpp

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

1414
ToggleBlock::ToggleBlock(AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
1515
{
16-
onText = 0;
17-
offText = 0;
16+
onText = "1";
17+
offText = "0";
1818
}
1919

2020
ToggleBlock::~ToggleBlock(){}

0 commit comments

Comments
 (0)