Tested and verified PwmPin functionality
Verified fading works as expected.
This commit is contained in:
parent
fc4d8d85d1
commit
0e346be0a2
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include "Blinker.h"
|
#include "Blinker.h"
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// Blinker //
|
// Blinker //
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@
|
||||||
|
|
||||||
#include "PwmPin.h"
|
#include "PwmPin.h"
|
||||||
|
|
||||||
#warning "PwmPin.cpp Compiling"
|
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
LedC::LedC(uint8_t pin, uint16_t freq, boolean invert){
|
LedC::LedC(uint8_t pin, uint16_t freq, boolean invert){
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#warning "PwmPin.h Included"
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <driver/ledc.h>
|
#include <driver/ledc.h>
|
||||||
#include "Blinker.h"
|
#include "Blinker.h"
|
||||||
|
|
@ -95,7 +93,7 @@ class LedPin : public LedC {
|
||||||
static bool fadeCallback(const ledc_cb_param_t *param, void *arg);
|
static bool fadeCallback(const ledc_cb_param_t *param, void *arg);
|
||||||
|
|
||||||
public:
|
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)
|
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 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
|
int fadeStatus(); // returns fading state
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include "PwmPin.h"
|
#include "PwmPin.h"
|
||||||
|
|
||||||
ServoPin servo(21,0,500,2200,-60,60);
|
LedPin led(13);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
|
@ -36,29 +36,15 @@ void setup() {
|
||||||
|
|
||||||
Serial.print("\n\nReady\n\n");
|
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(){
|
void loop(){
|
||||||
|
|
||||||
|
led.fade(100,1000);
|
||||||
|
while(led.fadeStatus()==LedPin::FADING);
|
||||||
|
led.fade(0,1000);
|
||||||
|
while(led.fadeStatus()==LedPin::FADING);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue