File evamPwmDriver.h¶
File List > src > evamPwmDriver.h
Go to the documentation of this file
#pragma once
#include <Arduino.h>
#include <evamUtils.h>
namespace evam
{
struct PwmConfig
{
int pin;
PwmConfig(int pin) : pin(pin) {}
};
template <int tPin = 0>
class PwmDriver
{
private:
PwmConfig mConfig;
public:
PwmDriver() : mConfig(tPin)
{
pinMode(tPin, OUTPUT);
}
template <typename... Args>
PwmDriver(PwmConfig config, Args... args) : mConfig(config)
{
pinMode(mConfig.pin, OUTPUT);
}
int GetPin() const
{
return mConfig.pin;
}
protected:
void actUnipolar(unsigned short aValue)
{
universalWrite(mConfig.pin, map(constrain(aValue, 0, 1000), 0, 1000, 0, 255));
}
};
}