dev_beta_Servo #3
@ -8,7 +8,7 @@
|
||||
#include "Servo.h"
|
||||
|
||||
|
||||
static servo_t servos[MAX_SERVOS]; // static array of servA structures
|
||||
static servo_t servos[MAX_SERVOS]; // static array of servo structures
|
||||
static volatile int8_t currentServoIndex[_Nbr_16timers]; // index for the servo being pulsed for each timer (or -1 if refresh interval)
|
||||
uint8_t servoCount = 0; // the total number of attached servos
|
||||
|
||||
@ -119,7 +119,7 @@ static void finISR(timer16_Sequence_t timer)
|
||||
// is timer active?
|
||||
static bool isTimerActive(timer16_Sequence_t timer)
|
||||
{
|
||||
// returns true if any servA is active on this timer
|
||||
// returns true if any servo is active on this timer
|
||||
for(uint8_t channel = 0; channel < SERVOS_PER_TIMER; channel++) {
|
||||
if(SERVO(timer, channel).Pin.isActive == true)
|
||||
return true;
|
||||
|
||||
@ -36,16 +36,16 @@ class Servo
|
||||
{
|
||||
public:
|
||||
Servo();
|
||||
uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or INVALID_SERVA 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 it's treated as an angle, otherwise as pulse width in microseconds
|
||||
void writeMicroseconds(int value); // Write pulse width in microseconds
|
||||
int read(); // returns current pulse width as an angle between 0 and 180 degrees
|
||||
int readMicroseconds(); // returns current pulse width in microseconds for this servA (was read_us() in first release)
|
||||
bool attached(); // return true if this servA is attached, otherwise false
|
||||
int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release)
|
||||
bool attached(); // return true if this servo is attached, otherwise false
|
||||
private:
|
||||
uint8_t servoIndex; // index into the channel data for this servA
|
||||
uint8_t servoIndex; // index into the channel data for this servo
|
||||
int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH
|
||||
int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user