Initial commit

This commit is contained in:
Robert Marshall 2021-07-29 16:21:25 +01:00
commit 8c50498c7d
10 changed files with 312 additions and 0 deletions

22
src/LEDOutput.cpp Normal file
View file

@ -0,0 +1,22 @@
#include <Arduino.h>
#define LED_OUTPUT_FREQUENCY 490
#define LED_OUTPUT_RESOLUTION 15
#define LED_OUTPUT_PWM_RANGE 32767
class LEDOutput {
unsigned int _channel;
public:
LEDOutput(unsigned int channel) {
_channel = channel;
ledcSetup(channel, LED_OUTPUT_FREQUENCY, LED_OUTPUT_RESOLUTION);
}
void attach(unsigned int pin){
ledcAttachPin(pin, _channel);
}
void writeFraction(float fraction){
ledcWrite(_channel, fraction * LED_OUTPUT_PWM_RANGE);
}
};