31 lines
766 B
C++
31 lines
766 B
C++
#ifndef OUTPUTENDPOINT_H
|
|
#define OUTPUTENDPOINT_H value
|
|
|
|
#include <Endpoint.h>
|
|
|
|
class OutputEndpoint : public Endpoint {
|
|
private:
|
|
int pin;
|
|
bool inverted;
|
|
bool currentValue;
|
|
|
|
public:
|
|
OutputEndpoint(int _pin, bool _inverted = false) : Endpoint("output"),
|
|
pin(_pin), inverted(_inverted), currentValue(inverted) {
|
|
pinMode(pin, OUTPUT);
|
|
digitalWrite(pin, currentValue);
|
|
}
|
|
|
|
EndpointResult onValue(String property, String value);
|
|
|
|
static Endpoint* fromJSON(JsonObject& obj) {
|
|
if (String(obj["type"].asString()) == "output" && obj.containsKey("gpio")) {
|
|
return new OutputEndpoint(obj["gpio"], obj["inverted"]);
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
};
|
|
|
|
#endif /* ifndef OUTPUTENDPOINT_H */
|