Move components to lib folder

This commit is contained in:
Robert Marshall 2022-09-08 13:20:51 +01:00
parent ae3c20b59d
commit b9b68f08cb
8 changed files with 1 additions and 0 deletions

View file

@ -1,33 +0,0 @@
#ifndef LEDOutput_cpp
#define LEDOutput_cpp
#include <Arduino.h>
#define LED_OUTPUT_FREQUENCY 490
#define LED_OUTPUT_RESOLUTION 15
#define LED_OUTPUT_PWM_RANGE 32767
class LEDOutput {
unsigned int _channel;
bool _invert;
public:
LEDOutput(unsigned int channel, bool invert = false) {
_channel = channel;
_invert = invert;
ledcSetup(channel, LED_OUTPUT_FREQUENCY, LED_OUTPUT_RESOLUTION);
}
void attach(unsigned int pin){
ledcAttachPin(pin, _channel);
}
void writeFraction(float fraction){
auto value = fraction * LED_OUTPUT_PWM_RANGE;
if (_invert)
value = LED_OUTPUT_PWM_RANGE - value;
ledcWrite(_channel, value);
}
};
#endif