parent
232362c807
commit
c3d0c98e04
|
|
@ -976,7 +976,12 @@ void Span::processSerialCommand(const char *c){
|
||||||
|
|
||||||
for(auto button=PushButtons.begin(); button!=PushButtons.end(); button++){
|
for(auto button=PushButtons.begin(); button!=PushButtons.end(); button++){
|
||||||
if((*button)->service==(*svc)){
|
if((*button)->service==(*svc)){
|
||||||
Serial.printf(" \u25bc SpanButton: Pin=%d, Single=%ums, Double=%ums, Long=%ums, Type=",(*button)->pin,(*button)->singleTime,(*button)->doubleTime,(*button)->longTime);
|
|
||||||
|
if((*button)->buttonType==SpanButton::BUTTON)
|
||||||
|
Serial.printf(" \u25bc SpanButton: Pin=%d, Single=%ums, Double=%ums, Long=%ums, Type=",(*button)->pin,(*button)->singleTime,(*button)->doubleTime,(*button)->longTime);
|
||||||
|
else
|
||||||
|
Serial.printf(" \u25bc SpanToggle: Pin=%d, Toggle=%ums, Type=",(*button)->pin,(*button)->longTime);
|
||||||
|
|
||||||
if((*button)->triggerType==PushButton::TRIGGER_ON_LOW)
|
if((*button)->triggerType==PushButton::TRIGGER_ON_LOW)
|
||||||
Serial.printf("TRIGGER_ON_LOW\n");
|
Serial.printf("TRIGGER_ON_LOW\n");
|
||||||
else if((*button)->triggerType==PushButton::TRIGGER_ON_HIGH)
|
else if((*button)->triggerType==PushButton::TRIGGER_ON_HIGH)
|
||||||
|
|
|
||||||
|
|
@ -794,24 +794,35 @@ struct [[deprecated("Please use Characteristic::setRange() method instead.")]] S
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
class SpanButton : PushButton {
|
class SpanButton : public PushButton {
|
||||||
|
|
||||||
friend class Span;
|
friend class Span;
|
||||||
friend class SpanService;
|
friend class SpanService;
|
||||||
|
|
||||||
uint16_t singleTime; // minimum time (in millis) required to register a single press
|
uint16_t singleTime; // minimum time (in millis) required to register a single press
|
||||||
uint16_t longTime; // minimum time (in millis) required to register a long press
|
uint16_t longTime; // minimum time (in millis) required to register a long press
|
||||||
uint16_t doubleTime; // maximum time (in millis) between single presses to register a double press instead
|
uint16_t doubleTime; // maximum time (in millis) between single presses to register a double press instead
|
||||||
SpanService *service; // Service to which this PushButton is attached
|
SpanService *service; // Service to which this PushButton is attached
|
||||||
|
|
||||||
void check(); // check PushButton and call button() if pressed
|
void check(); // check PushButton and call button() if "pressed"
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
enum buttonType_t {
|
||||||
|
BUTTON,
|
||||||
|
TOGGLE
|
||||||
|
};
|
||||||
|
|
||||||
|
buttonType_t buttonType=BUTTON; // type of SpanButton
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SINGLE=0,
|
SINGLE=0,
|
||||||
DOUBLE=1,
|
DOUBLE=1,
|
||||||
LONG=2
|
LONG=2,
|
||||||
|
ON=3,
|
||||||
|
OFF=4
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr triggerType_t TRIGGER_ON_LOW=PushButton::TRIGGER_ON_LOW;
|
static constexpr triggerType_t TRIGGER_ON_LOW=PushButton::TRIGGER_ON_LOW;
|
||||||
|
|
@ -830,6 +841,15 @@ class SpanButton : PushButton {
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
|
class SpanToggle : SpanButton {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SpanToggle(int pin, triggerType_t triggerType=TRIGGER_ON_LOW, uint16_t toggleTime=5) : SpanButton(pin,triggerType,toggleTime){buttonType=TOGGLE;};
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////
|
||||||
|
|
||||||
class SpanUserCommand {
|
class SpanUserCommand {
|
||||||
|
|
||||||
friend class Span;
|
friend class Span;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue