This commit is contained in:
@@ -73,6 +73,8 @@
|
||||
#include "megaavr/ServoTimers.h"
|
||||
#elif defined(ARDUINO_ARCH_MBED)
|
||||
#include "mbed/ServoTimers.h"
|
||||
#elif defined(ARDUINO_ARCH_RENESAS)
|
||||
#include "renesas/ServoTimers.h"
|
||||
#else
|
||||
#error "This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor."
|
||||
#endif
|
||||
@@ -105,7 +107,7 @@ class Servo
|
||||
{
|
||||
public:
|
||||
Servo();
|
||||
uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
|
||||
uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or INVALID_SERVO if failure
|
||||
uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
|
||||
void detach();
|
||||
void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
#include <Servo.h>
|
||||
#include <mbed.h>
|
||||
|
||||
#if defined __has_include
|
||||
# if __has_include ("pinDefinitions.h")
|
||||
# include "pinDefinitions.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
class ServoImpl {
|
||||
mbed::DigitalOut *pin;
|
||||
mbed::Timeout timeout; // calls a callback once when a timeout expires
|
||||
@@ -40,10 +46,10 @@ public:
|
||||
static ServoImpl* servos[MAX_SERVOS]; // static array of servo structures
|
||||
uint8_t ServoCount = 0; // the total number of attached servos
|
||||
|
||||
#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min) // minimum value in uS for this servo
|
||||
#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max) // maximum value in uS for this servo
|
||||
#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min) // minimum value in us for this servo
|
||||
#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max) // maximum value in us for this servo
|
||||
|
||||
#define TRIM_DURATION 15 //callback overhead (35 uS) -> 15uS if toggle() is called after starting the timeout
|
||||
#define TRIM_DURATION 15 //callback overhead (35 us) -> 15 us if toggle() is called after starting the timeout
|
||||
|
||||
Servo::Servo()
|
||||
{
|
||||
@@ -130,4 +136,4 @@ bool Servo::attached()
|
||||
return servos[this->servoIndex] != NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define _Nbr_16timers 32
|
||||
#define _Nbr_16timers 32
|
||||
|
||||
Reference in New Issue
Block a user