Initial commit
This commit is contained in:
commit
8c50498c7d
10 changed files with 312 additions and 0 deletions
22
src/LEDOutput.cpp
Normal file
22
src/LEDOutput.cpp
Normal 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);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue