소스 검색

Change the name of servos[] and servo_t

Scott Lahteine 8 년 전
부모
커밋
eacfe132aa
2개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 10
    10
      Marlin/servo.cpp
  2. 1
    1
      Marlin/servo.h

+ 10
- 10
Marlin/servo.cpp 파일 보기

@@ -59,7 +59,7 @@
59 59
 
60 60
 //#define NBR_TIMERS        (MAX_SERVOS / SERVOS_PER_TIMER)
61 61
 
62
-static servo_t servos[MAX_SERVOS];                          // static array of servo structures
62
+static ServoInfo_t servo_info[MAX_SERVOS];                  // static array of servo info structures
63 63
 static volatile int8_t Channel[_Nbr_16timers ];             // counter for the servo being pulsed for each timer (or -1 if refresh interval)
64 64
 
65 65
 uint8_t ServoCount = 0;                                     // the total number of attached servos
@@ -69,7 +69,7 @@ uint8_t ServoCount = 0;                                     // the total number
69 69
 #define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo
70 70
 #define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER)       // returns the index of the servo on this timer
71 71
 #define SERVO_INDEX(_timer,_channel)  ((_timer*SERVOS_PER_TIMER) + _channel)     // macro to access servo index by timer and channel
72
-#define SERVO(_timer,_channel)  (servos[SERVO_INDEX(_timer,_channel)])            // macro to access servo class by timer and channel
72
+#define SERVO(_timer,_channel)  (servo_info[SERVO_INDEX(_timer,_channel)])       // macro to access servo class by timer and channel
73 73
 
74 74
 #define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4)  // minimum value in uS for this servo
75 75
 #define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4)  // maximum value in uS for this servo
@@ -232,7 +232,7 @@ static boolean isTimerActive(timer16_Sequence_t timer) {
232 232
 Servo::Servo() {
233 233
   if ( ServoCount < MAX_SERVOS) {
234 234
     this->servoIndex = ServoCount++;                    // assign a servo index to this instance
235
-    servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);   // store default values  - 12 Aug 2009
235
+    servo_info[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);   // store default values  - 12 Aug 2009
236 236
   }
237 237
   else
238 238
     this->servoIndex = INVALID_SERVO;  // too many servos
@@ -246,8 +246,8 @@ int8_t Servo::attach(int pin, int min, int max) {
246 246
 
247 247
   if (this->servoIndex >= MAX_SERVOS) return -1;
248 248
 
249
-  if (pin > 0) servos[this->servoIndex].Pin.nbr = pin;
250
-  pinMode(servos[this->servoIndex].Pin.nbr, OUTPUT); // set servo pin to output
249
+  if (pin > 0) servo_info[this->servoIndex].Pin.nbr = pin;
250
+  pinMode(servo_info[this->servoIndex].Pin.nbr, OUTPUT); // set servo pin to output
251 251
 
252 252
   // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
253 253
   this->min = (MIN_PULSE_WIDTH - min) / 4; //resolution of min/max is 4 uS
@@ -256,13 +256,13 @@ int8_t Servo::attach(int pin, int min, int max) {
256 256
   // initialize the timer if it has not already been initialized
257 257
   timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
258 258
   if (!isTimerActive(timer)) initISR(timer);
259
-  servos[this->servoIndex].Pin.isActive = true;  // this must be set after the check for isTimerActive
259
+  servo_info[this->servoIndex].Pin.isActive = true;  // this must be set after the check for isTimerActive
260 260
 
261 261
   return this->servoIndex;
262 262
 }
263 263
 
264 264
 void Servo::detach() {
265
-  servos[this->servoIndex].Pin.isActive = false;
265
+  servo_info[this->servoIndex].Pin.isActive = false;
266 266
   timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
267 267
   if (!isTimerActive(timer)) finISR(timer);
268 268
 }
@@ -290,7 +290,7 @@ void Servo::writeMicroseconds(int value) {
290 290
 
291 291
     uint8_t oldSREG = SREG;
292 292
     cli();
293
-    servos[channel].ticks = value;
293
+    servo_info[channel].ticks = value;
294 294
     SREG = oldSREG;
295 295
   }
296 296
 }
@@ -299,10 +299,10 @@ void Servo::writeMicroseconds(int value) {
299 299
 int Servo::read() { return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); }
300 300
 
301 301
 int Servo::readMicroseconds() {
302
-  return (this->servoIndex == INVALID_SERVO) ? 0 : ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION;
302
+  return (this->servoIndex == INVALID_SERVO) ? 0 : ticksToUs(servo_info[this->servoIndex].ticks) + TRIM_DURATION;
303 303
 }
304 304
 
305
-bool Servo::attached() { return servos[this->servoIndex].Pin.isActive; }
305
+bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; }
306 306
 
307 307
 int8_t Servo::move(int pin, int value) {
308 308
   int8_t ret;

+ 1
- 1
Marlin/servo.h 파일 보기

@@ -112,7 +112,7 @@ typedef struct {
112 112
 typedef struct {
113 113
   ServoPin_t Pin;
114 114
   unsigned int ticks;
115
-} servo_t;
115
+} ServoInfo_t;
116 116
 
117 117
 class Servo {
118 118
   public:

Loading…
취소
저장