Revert "Added fadeTime parameter to LedPin::set()"
This reverts commit c2df57815c.
This commit is contained in:
parent
c2df57815c
commit
fab94722d8
|
|
@ -102,7 +102,7 @@ LedPin::LedPin(uint8_t pin, float level, uint16_t freq, boolean invert) : LedC(p
|
|||
|
||||
///////////////////
|
||||
|
||||
void LedPin::set(float level, uint32_t fadeTime){
|
||||
void LedPin::set(float level){
|
||||
|
||||
if(!channel)
|
||||
return;
|
||||
|
|
@ -112,12 +112,23 @@ void LedPin::set(float level, uint32_t fadeTime){
|
|||
|
||||
float d=level*(pow(2,(int)timer->duty_resolution)-1)/100.0;
|
||||
|
||||
if(fadeTime==0){
|
||||
channel->duty=d;
|
||||
ledc_channel_config(channel);
|
||||
} else {
|
||||
ledc_set_fade_time_and_start(channel->speed_mode,channel->channel,(uint32_t)d,fadeTime,LEDC_FADE_NO_WAIT);
|
||||
}
|
||||
|
||||
///////////////////
|
||||
|
||||
void LedPin::fade(float level, uint32_t fadeTime){
|
||||
|
||||
if(!channel)
|
||||
return;
|
||||
|
||||
if(level>100)
|
||||
level=100;
|
||||
|
||||
float d=level*(pow(2,(int)timer->duty_resolution)-1)/100.0;
|
||||
|
||||
ledc_set_fade_time_and_start(channel->speed_mode,channel->channel,(uint32_t)d,fadeTime,LEDC_FADE_NO_WAIT);
|
||||
}
|
||||
|
||||
///////////////////
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ class LedPin : public LedC {
|
|||
|
||||
public:
|
||||
LedPin(uint8_t pin, float level=0, uint16_t freq=DEFAULT_PWM_FREQ, boolean invert=false); // assigns pin to be output of one of 16 PWM channels initial level and frequency
|
||||
void set(float level, uint32_t fadeTime=0); // sets the PWM duty to level (0-100) within fadeTime in milliseconds
|
||||
void set(float level); // sets the PWM duty to level (0-100)
|
||||
void fade(float level, uint32_t fadeTime); // sets the PWM duty to level (0-100) within fadeTime in milliseconds
|
||||
|
||||
static void HSVtoRGB(float h, float s, float v, float *r, float *g, float *b ); // converts Hue/Saturation/Brightness to R/G/B
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,13 +38,9 @@ void setup() {
|
|||
|
||||
Serial.println("\n\nHomeSpan LED Fade Test\n");
|
||||
|
||||
LedPin led(26);
|
||||
for(int i=10;i<=100;i+=10){
|
||||
led.set(i);
|
||||
delay(1000);
|
||||
}
|
||||
LedPin led(26,50);
|
||||
Serial.printf("Start\n");
|
||||
led.set(0,5000);
|
||||
led.fade(0,10000);
|
||||
Serial.printf("End\n");
|
||||
|
||||
while(1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue