Scott Lahteine 7 лет назад
Родитель
Сommit
0cb4d25431

+ 5
- 5
Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp Просмотреть файл

@@ -89,11 +89,11 @@
89 89
     this->servoIndex = INVALID_SERVO;  // too many servos
90 90
   }
91 91
 
92
-  int8_t Servo::attach(int pin) {
92
+  int8_t Servo::attach(const int pin) {
93 93
     return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
94 94
   }
95 95
 
96
-  int8_t Servo::attach(int pin, int min, int max) {
96
+  int8_t Servo::attach(const int pin, const int min, const int max) {
97 97
 
98 98
     if (this->servoIndex >= MAX_SERVOS) return -1;
99 99
 
@@ -113,7 +113,7 @@
113 113
     servo_info[this->servoIndex].Pin.isActive = false;
114 114
   }
115 115
 
116
-  void Servo::write(int value) {
116
+  void Servo::write(const int value) {
117 117
     if (value < MIN_PULSE_WIDTH) { // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
118 118
       value = map(constrain(value, 0, 180), 0, 180, SERVO_MIN(), SERVO_MAX());
119 119
         // odd - this sets zero degrees to 544 and 180 degrees to 2400 microseconds but the literature says
@@ -122,7 +122,7 @@
122 122
     this->writeMicroseconds(value);
123 123
   }
124 124
 
125
-  void Servo::writeMicroseconds(int value) {
125
+  void Servo::writeMicroseconds(const int value) {
126 126
     // calculate and store the values for the given channel
127 127
     byte channel = this->servoIndex;
128 128
     if (channel < MAX_SERVOS) {  // ensure channel is valid
@@ -146,7 +146,7 @@
146 146
 
147 147
   bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; }
148 148
 
149
-  void Servo::move(int value) {
149
+  void Servo::move(const int value) {
150 150
     if (this->attach(0) >= 0) {    // notice the pin number is zero here
151 151
       this->write(value);
152 152
       delay(SERVO_DELAY);

+ 5
- 5
Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.h Просмотреть файл

@@ -39,12 +39,12 @@
39 39
   class Servo {
40 40
     public:
41 41
       Servo();
42
-      int8_t attach(int pin);            // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
43
-      int8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
42
+      int8_t attach(const int pin);            // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
43
+      int8_t attach(const int pin, const int min, const int max); // as above but also sets min and max values for writes.
44 44
       void detach();
45
-      void write(int value);             // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
46
-      void writeMicroseconds(int value); // write pulse width in microseconds
47
-      void move(int value);              // attach the servo, then move to value
45
+      void write(const int value);             // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
46
+      void writeMicroseconds(const int value); // write pulse width in microseconds
47
+      void move(const int value);              // attach the servo, then move to value
48 48
                                          // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
49 49
                                          // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach
50 50
       int read();                        // returns current pulse width as an angle between 0 and 180 degrees

+ 7
- 10
Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp Просмотреть файл

@@ -1,20 +1,18 @@
1 1
 #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
2 2
 
3
-
4 3
 #include "HAL_Servo_Teensy.h"
5 4
 #include "../../inc/MarlinConfig.h"
6 5
 
7
-
8
-int8_t libServo::attach(int pin) {
9
-	if (this->servoIndex >= MAX_SERVOS) return -1;
10
-	return Servo::attach(pin);
6
+int8_t libServo::attach(const int pin) {
7
+  if (this->servoIndex >= MAX_SERVOS) return -1;
8
+  return Servo::attach(pin);
11 9
 }
12 10
 
13
-int8_t libServo::attach(int pin, int min, int max) {
14
-	return Servo::attach(pin, min, max);
11
+int8_t libServo::attach(const int pin, const int min, const int max) {
12
+  return Servo::attach(pin, min, max);
15 13
 }
16 14
 
17
-void libServo::move(int value) {
15
+void libServo::move(const int value) {
18 16
   if (this->attach(0) >= 0) {
19 17
     this->write(value);
20 18
     delay(SERVO_DELAY);
@@ -24,5 +22,4 @@ void libServo::move(int value) {
24 22
   }
25 23
 }
26 24
 
27
-
28
-#endif
25
+#endif // __MK64FX512__ || __MK66FX1M0__

+ 4
- 4
Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.h Просмотреть файл

@@ -6,13 +6,13 @@
6 6
 // Inherit and expand on the official library
7 7
 class libServo : public Servo {
8 8
 	public:
9
-		int8_t attach(int pin);
10
-		int8_t attach(int pin, int min, int max);
11
-		void move(int value);
9
+		int8_t attach(const int pin);
10
+		int8_t attach(const int pin, const int min, const int max);
11
+		void move(const int value);
12 12
 	private:
13 13
 	   uint16_t min_ticks;
14 14
 	   uint16_t max_ticks;
15 15
 	   uint8_t servoIndex;               // index into the channel data for this servo
16 16
 };
17 17
 
18
-#endif
18
+#endif // HAL_Servo_Teensy_h

Загрузка…
Отмена
Сохранить