Files
IoTManager/include/items/PwmOutClass.h

31 lines
712 B
C
Raw Normal View History

2020-09-02 22:34:49 +03:00
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
2020-09-03 01:12:43 +03:00
class PwmOutClass : public LineParsing {
2020-09-02 22:34:49 +03:00
public:
2020-09-03 01:12:43 +03:00
PwmOutClass() : LineParsing(){};
2020-09-02 22:34:49 +03:00
void pwmModeSet() {
if (_pin != "") {
pinMode(_pin.toInt(), INPUT);
}
}
void pwmStateSetDefault() {
if (_state != "") {
pwmChange(_key, _pin, _state);
}
}
void pwmChange(String key, String pin, String state) {
int pinInt = pin.toInt();
analogWrite(pinInt, state.toInt());
eventGen(key, "");
jsonWriteInt(configLiveJson, key, state.toInt());
MqttClient::publishStatus(key, state);
}
};
2020-09-03 02:07:12 +03:00
extern PwmOutClass myPwmOut;