Updated PWM
Removed need to include channel number in set() method. Why was this ever there? Need to update Examples and PwmPin docs. But keep stub method that includes channel for backwards compatibility.
This commit is contained in:
parent
6aba1a28e5
commit
61655845a9
|
|
@ -20,10 +20,11 @@ PwmPin::PwmPin(uint8_t channel, uint8_t pin){
|
|||
ledChannel.timer_sel=LEDC_TIMER_0;
|
||||
ledChannel.duty=0;
|
||||
ledChannel.hpoint=0;
|
||||
ledc_channel_config(&ledChannel);
|
||||
|
||||
}
|
||||
|
||||
void PwmPin::set(uint8_t channel, uint8_t level){
|
||||
void PwmPin::set(uint8_t level){
|
||||
ledChannel.duty=level*1023;
|
||||
ledChannel.duty/=100;
|
||||
ledChannel.duty&=0x03FF;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ class PwmPin {
|
|||
|
||||
public:
|
||||
PwmPin(uint8_t channel, uint8_t pin); // assigns pin to be output of one of 16 PWM channels (0-15)
|
||||
void set(uint8_t channel, uint8_t level); // sets the PWM duty of channel to level (0-100)
|
||||
void set(uint8_t level); // sets the PWM duty to level (0-100)
|
||||
void set(uint8_t channel, uint8_t level){set(level);} // sets the PWM duty to level (0-100) - deprecated, but defined for backwards compatibility
|
||||
int getPin(){return pin;} // returns the pin number
|
||||
|
||||
static void HSVtoRGB(float h, float s, float v, float *r, float *g, float *b ); // converts Hue/Saturation/Brightness to R/G/B
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@
|
|||
// This is a placeholder .ino file that allows you to easily edit the contents of this library using the Arduino IDE,
|
||||
// as well as compile and test from this point. This file is ignored when the library is included in other sketches.
|
||||
|
||||
#include "RFControl.h"
|
||||
#include "PwmPin.h"
|
||||
|
||||
PwmPin yellow(0,16);
|
||||
PwmPin red(1,17);
|
||||
|
||||
void setup(){
|
||||
|
||||
|
|
@ -11,20 +14,20 @@ void setup(){
|
|||
|
||||
Serial.print("\n\nTest sketch for HomeSpan Extras Library\n\n");
|
||||
|
||||
RFControl rf(4);
|
||||
|
||||
Serial.println("Starting...");
|
||||
|
||||
rf.clear();
|
||||
for(int i=0;i<3;i++)
|
||||
rf.add(2000,2000);
|
||||
rf.phase(10000,0);
|
||||
rf.start(5,100);
|
||||
|
||||
Serial.println("Done!");
|
||||
|
||||
}
|
||||
|
||||
void loop(){
|
||||
|
||||
for(int i=0;i<100;i++){
|
||||
red.set(22,i);
|
||||
delay(10);
|
||||
}
|
||||
|
||||
for(int i=100;i>=0;i--){
|
||||
yellow.set(i);
|
||||
delay(10);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue