mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Servo library to format 1.5 rev.2
This commit is contained in:
@ -1,10 +1,8 @@
|
|||||||
name=Servo
|
name=Servo
|
||||||
author=
|
version=1.0
|
||||||
email=
|
author=Michael Margolis, Arduino
|
||||||
|
maintainer=Arduino <info@arduino.cc>
|
||||||
sentence=Controls a lot of Servos.
|
sentence=Controls a lot of Servos.
|
||||||
paragraph=This library can control a great number of servos.<br />It makes careful use of timers: the library can control 12 servos using only 1 timer.<br />On the Arduino Due you can control up to 60 servos.<br />
|
paragraph=This library can control a great number of servos.<br />It makes careful use of timers: the library can control 12 servos using only 1 timer.<br />On the Arduino Due you can control up to 60 servos.<br />
|
||||||
url=http://arduino.cc/en/Reference/Servo
|
url=http://arduino.cc/en/Reference/Servo
|
||||||
architectures=avr,sam
|
architectures=avr,sam
|
||||||
version=1.0
|
|
||||||
dependencies=
|
|
||||||
core-dependencies=arduino (>=1.5.0)
|
|
||||||
|
@ -59,7 +59,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Architecture specific include
|
// Architecture specific include
|
||||||
#include <ServoTimers.h>
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
|
#include "avr/ServoTimers.h"
|
||||||
|
#elif defined(ARDUINO_ARCH_SAM)
|
||||||
|
#include "sam/ServoTimers.h"
|
||||||
|
#else
|
||||||
|
#error "This library only supports boards with an AVR or SAM processor."
|
||||||
|
#endif
|
||||||
|
|
||||||
#define Servo_VERSION 2 // software version of this library
|
#define Servo_VERSION 2 // software version of this library
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
|
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
@ -311,3 +313,5 @@ bool Servo::attached()
|
|||||||
return servos[this->servoIndex].Pin.isActive ;
|
return servos[this->servoIndex].Pin.isActive ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // ARDUINO_ARCH_AVR
|
||||||
|
|
@ -36,24 +36,24 @@
|
|||||||
#define _useTimer1
|
#define _useTimer1
|
||||||
#define _useTimer3
|
#define _useTimer3
|
||||||
#define _useTimer4
|
#define _useTimer4
|
||||||
typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
|
typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t;
|
||||||
|
|
||||||
#elif defined(__AVR_ATmega32U4__)
|
#elif defined(__AVR_ATmega32U4__)
|
||||||
#define _useTimer1
|
#define _useTimer1
|
||||||
typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
|
typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;
|
||||||
|
|
||||||
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
||||||
#define _useTimer3
|
#define _useTimer3
|
||||||
#define _useTimer1
|
#define _useTimer1
|
||||||
typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
|
typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t;
|
||||||
|
|
||||||
#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
|
#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
|
||||||
#define _useTimer3
|
#define _useTimer3
|
||||||
#define _useTimer1
|
#define _useTimer1
|
||||||
typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
|
typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t;
|
||||||
|
|
||||||
#else // everything else
|
#else // everything else
|
||||||
#define _useTimer1
|
#define _useTimer1
|
||||||
typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
|
typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers - Version 2
|
Copyright (c) 2013 Arduino LLC. All right reserved.
|
||||||
Copyright (c) 2009 Michael Margolis. All right reserved.
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
@ -15,7 +14,9 @@
|
|||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_SAM)
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Servo.h>
|
#include <Servo.h>
|
||||||
@ -23,7 +24,6 @@
|
|||||||
#define usToTicks(_us) (( clockCyclesPerMicrosecond() * _us) / 32) // converts microseconds to tick
|
#define usToTicks(_us) (( clockCyclesPerMicrosecond() * _us) / 32) // converts microseconds to tick
|
||||||
#define ticksToUs(_ticks) (( (unsigned)_ticks * 32)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds
|
#define ticksToUs(_ticks) (( (unsigned)_ticks * 32)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds
|
||||||
|
|
||||||
|
|
||||||
#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays
|
#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays
|
||||||
|
|
||||||
static servo_t servos[MAX_SERVOS]; // static array of servo structures
|
static servo_t servos[MAX_SERVOS]; // static array of servo structures
|
||||||
@ -43,9 +43,6 @@ static volatile int8_t Channel[_Nbr_16timers ]; // counter for the s
|
|||||||
|
|
||||||
/************ static functions common to all instances ***********************/
|
/************ static functions common to all instances ***********************/
|
||||||
|
|
||||||
|
|
||||||
//timer16_Sequence_t timer;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/// Interrupt handler for the TC0 channel 1.
|
/// Interrupt handler for the TC0 channel 1.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@ -282,3 +279,5 @@ bool Servo::attached()
|
|||||||
return servos[this->servoIndex].Pin.isActive;
|
return servos[this->servoIndex].Pin.isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // ARDUINO_ARCH_SAM
|
||||||
|
|
@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
|
Copyright (c) 2013 Arduino LLC. All right reserved.
|
||||||
Copyright (c) 2009 Michael Margolis. All right reserved.
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
Reference in New Issue
Block a user