6 #ifndef MIN_PULSE_WIDTH
7 #define MIN_PULSE_WIDTH 544
10 #ifndef MAX_PULSE_WIDTH
11 #define MAX_PULSE_WIDTH 2400
14 #ifndef DEFAULT_PULSE_WIDTH
15 #define DEFAULT_PULSE_WIDTH 1500
18 #ifndef REFRESH_INTERVAL
19 #define REFRESH_INTERVAL 20000
24 #define MAX_DEGREES 180l
40 if (pwm!=
nullptr)
delete pwm;
50 this->is_attached =
true;
55 void attach(
int pin,
int min,
int max) {
70 int pulse_width_ms = value;
72 pulse_width_ms = map(value,MIN_DEGREES, MAX_DEGREES, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
88 return map(pwm_value, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH, MIN_DEGREES,MAX_DEGREES);
103 int8_t min = MIN_DEGREES;
104 int8_t max = MAX_DEGREES;
105 bool is_attached =
false;
Basic PWM API based on the input and output in nano seconds The Raspberry Pico has 8 controllable PWM...
Definition: PicoPWM.h:362
void begin(pin_size_t gpio, uint64_t initialDutyCyleNanoSeconds=0, PinMode pinMode=OUTPUT)
setup the pin mode only if necessary
Definition: PicoPWM.h:378
void end(pin_size_t gpio)
sets the output pins to low
Definition: PicoPWM.h:392
void setDutyCycle(pin_size_t gpio, uint64_t dutyCyleNanoSeconds)
Defines the active period is nanoseconds.
Definition: PicoPWM.h:398
We provide an alternative Pico implementation for the Servo class which is compatible with the Arduin...
Definition: PicoPWMServo.h:34
int read()
returns current pulse width as an angle between 0 and 180 degrees
Definition: PicoPWMServo.h:87
void detach()
stops the generation of signals
Definition: PicoPWMServo.h:62
void write(int value)
if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
Definition: PicoPWMServo.h:69
bool attached()
return true if this servo is attached, otherwise false
Definition: PicoPWMServo.h:97
void attach(int pin)
attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
Definition: PicoPWMServo.h:44
void attach(int pin, int min, int max)
as above but also sets min and max values for writes.
Definition: PicoPWMServo.h:55
void writeMicroseconds(int value)
Write pulse width in microseconds.
Definition: PicoPWMServo.h:78
int readMicroseconds()
returns current pulse width in microseconds for this servo (was read_us() in first release)
Definition: PicoPWMServo.h:92
Pico Arduino Framework.
Definition: Arduino.cpp:26