Tested and verified PwmPin functionality

Verified fading works as expected.
This commit is contained in:
Gregg 2024-07-20 12:27:06 -05:00
parent fc4d8d85d1
commit 0e346be0a2
4 changed files with 10 additions and 28 deletions

View File

@ -27,7 +27,7 @@
#include "Blinker.h"
////////////////////////////////
////////////////////////////////
// Blinker //
////////////////////////////////

View File

@ -27,8 +27,6 @@
#include "PwmPin.h"
#warning "PwmPin.cpp Compiling"
///////////////////
LedC::LedC(uint8_t pin, uint16_t freq, boolean invert){

View File

@ -42,8 +42,6 @@
#pragma once
#warning "PwmPin.h Included"
#include <Arduino.h>
#include <driver/ledc.h>
#include "Blinker.h"
@ -95,7 +93,7 @@ class LedPin : public LedC {
static bool fadeCallback(const ledc_cb_param_t *param, void *arg);
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
LedPin(uint8_t pin, float level=0, uint16_t freq=DEFAULT_PWM_FREQ, boolean invert=false); // assigns LED pin
void set(float level); // sets the PWM duty to level (0-100)
int fade(float level, uint32_t fadeTime, int fadeType=ABSOLUTE); // sets the PWM duty to level (0-100) within fadeTime in milliseconds, returns success (0) or fail (1)
int fadeStatus(); // returns fading state

View File

@ -27,7 +27,7 @@
#include "PwmPin.h"
ServoPin servo(21,0,500,2200,-60,60);
LedPin led(13);
void setup() {
@ -35,30 +35,16 @@ void setup() {
delay(1000);
Serial.print("\n\nReady\n\n");
for(int count=0;count<3;count++){
for(int i=-60;i<61;i++){
servo.set(i);
delay(10);
}
for(int i=60;i>-61;i--){
servo.set(i);
delay(10);
}
}
delay(5000);
servo.set(NAN);
delay(10000);
servo.set(0);
}
//////////////////////////////////////
void loop(){
led.fade(100,1000);
while(led.fadeStatus()==LedPin::FADING);
led.fade(0,1000);
while(led.fadeStatus()==LedPin::FADING);
}