mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
pwm add
This commit is contained in:
33
include/Class/Pwm.h
Normal file
33
include/Class/Pwm.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
class Pwm : public LineParsing {
|
||||
public:
|
||||
Pwm() : LineParsing(){};
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
extern Pwm* myPwm;
|
||||
@@ -10,7 +10,6 @@ class Button : public LineParsing {
|
||||
|
||||
void pinModeSet() {
|
||||
if (_pin != "") {
|
||||
Serial.println(_pin);
|
||||
pinMode(_pin.toInt(), OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user