@@ -12,33 +12,33 @@ void Motor::Initialisation(MotorBaseType _motorBaseType, float _centerToWheel)
12
12
centerToWheel = _centerToWheel;
13
13
14
14
// Sets the two pins as Outputs
15
- pinMode (stepPinM1 , OUTPUT);
16
- pinMode (dirPinM1 , OUTPUT);
17
- digitalWrite (stepPinM1 , LOW);
18
- digitalWrite (dirPinM1 , LOW);
15
+ pinMode (PIN_STEP_M1 , OUTPUT);
16
+ pinMode (PIN_DIR_M1 , OUTPUT);
17
+ digitalWrite (PIN_STEP_M1 , LOW);
18
+ digitalWrite (PIN_DIR_M1 , LOW);
19
19
20
- pinMode (stepPinM2 , OUTPUT);
21
- pinMode (dirPinM2 , OUTPUT);
22
- digitalWrite (stepPinM2 , LOW);
23
- digitalWrite (dirPinM2 , LOW);
20
+ pinMode (PIN_STEP_M2 , OUTPUT);
21
+ pinMode (PIN_DIR_M2 , OUTPUT);
22
+ digitalWrite (PIN_STEP_M2 , LOW);
23
+ digitalWrite (PIN_DIR_M2 , LOW);
24
24
25
25
if (motorBaseType == OMNIDIRECTIONAL_3_MOTORS)
26
26
{
27
- pinMode (stepPinM3 , OUTPUT);
28
- pinMode (dirPinM3 , OUTPUT);
29
- digitalWrite (stepPinM3 , LOW);
30
- digitalWrite (dirPinM3 , LOW);
27
+ pinMode (PIN_STEP_M3 , OUTPUT);
28
+ pinMode (PIN_DIR_M3 , OUTPUT);
29
+ digitalWrite (PIN_STEP_M3 , LOW);
30
+ digitalWrite (PIN_DIR_M3 , LOW);
31
31
}
32
32
print (" Starting ESP32_FAST_PWM: " );
33
33
println (ESP32_FAST_PWM_VERSION);
34
34
35
35
// pin, frequency = 500 Hz, dutyCycle = 0 %, choose channel with independent timer, resolution to go up to desire frequency
36
- stepper1 = new ESP32_FAST_PWM (stepPinM1 , 500 , 0 , 2 , BIT_RESOLUTION);
36
+ stepper1 = new ESP32_FAST_PWM (PIN_STEP_M1 , 500 , 0 , 2 , BIT_RESOLUTION);
37
37
38
- stepper2 = new ESP32_FAST_PWM (stepPinM2 , 500 , 0 , 4 , BIT_RESOLUTION);
38
+ stepper2 = new ESP32_FAST_PWM (PIN_STEP_M2 , 500 , 0 , 4 , BIT_RESOLUTION);
39
39
if (motorBaseType == OMNIDIRECTIONAL_3_MOTORS)
40
40
{
41
- stepper3 = new ESP32_FAST_PWM (stepPinM3 , 500 , 0 , 6 , BIT_RESOLUTION);
41
+ stepper3 = new ESP32_FAST_PWM (PIN_STEP_M3 , 500 , 0 , 6 , BIT_RESOLUTION);
42
42
}
43
43
}
44
44
@@ -137,7 +137,7 @@ void Motor::SetMotorSpeed(int motor_ID, float speed_mms)
137
137
else
138
138
{
139
139
// Set the frequency of the PWM output and a duty cycle of 50%
140
- digitalWrite (dirPinM1 , direction);
140
+ digitalWrite (PIN_DIR_M1 , direction);
141
141
stepper1->setPWM (freq, 50 );
142
142
}
143
143
}
@@ -150,7 +150,7 @@ void Motor::SetMotorSpeed(int motor_ID, float speed_mms)
150
150
else
151
151
{
152
152
// Set the frequency of the PWM output and a duty cycle of 50%
153
- digitalWrite (dirPinM2 , direction);
153
+ digitalWrite (PIN_DIR_M2 , direction);
154
154
stepper2->setPWM (freq, 50 );
155
155
}
156
156
}
@@ -163,7 +163,7 @@ void Motor::SetMotorSpeed(int motor_ID, float speed_mms)
163
163
else
164
164
{
165
165
// Set the frequency of the PWM output and a duty cycle of 50%
166
- digitalWrite (dirPinM3 , direction);
166
+ digitalWrite (PIN_DIR_M3 , direction);
167
167
stepper3->setPWM (freq, 50 );
168
168
}
169
169
}
@@ -183,7 +183,7 @@ float Motor::GetMotorSpeed(int motor_ID)
183
183
{
184
184
if (stepper1->getActualDutyCycle () == 0 )
185
185
return 0 ;
186
- direction = digitalRead (dirPinM1 );
186
+ direction = digitalRead (PIN_DIR_M1 );
187
187
if (direction)
188
188
return stepper1->getActualFreq () * MM_PER_STEP_MOTOR;
189
189
else
@@ -193,7 +193,7 @@ float Motor::GetMotorSpeed(int motor_ID)
193
193
{
194
194
if (stepper1->getActualDutyCycle () == 0 )
195
195
return 0 ;
196
- direction = digitalRead (dirPinM2 );
196
+ direction = digitalRead (PIN_DIR_M2 );
197
197
if (direction)
198
198
return stepper2->getActualFreq () * MM_PER_STEP_MOTOR;
199
199
else
@@ -203,7 +203,7 @@ float Motor::GetMotorSpeed(int motor_ID)
203
203
{
204
204
if (stepper1->getActualDutyCycle () == 0 )
205
205
return 0 ;
206
- direction = digitalRead (dirPinM3 );
206
+ direction = digitalRead (PIN_DIR_M3 );
207
207
if (direction)
208
208
return stepper3->getActualFreq () * MM_PER_STEP_MOTOR;
209
209
else
0 commit comments