@@ -12,6 +12,21 @@ void _setHighFrequency(const long freq, const int pin){
12
12
}
13
13
14
14
15
+ // function setting the high pwm frequency to the supplied pins
16
+ // - Stepper motor - 2PWM setting
17
+ // - hardware speciffic
18
+ void * _configure1PWM (long pwm_frequency, const int pinA) {
19
+ if (!pwm_frequency || !_isset (pwm_frequency) ) pwm_frequency = _PWM_FREQUENCY; // default frequency 25khz
20
+ else pwm_frequency = _constrain (pwm_frequency, 0 , _PWM_FREQUENCY_MAX); // constrain to 50kHz max
21
+ _setHighFrequency (pwm_frequency, pinA);
22
+ GenericDriverParams* params = new GenericDriverParams {
23
+ .pins = { pinA },
24
+ .pwm_frequency = pwm_frequency
25
+ };
26
+ return params;
27
+ }
28
+
29
+
15
30
// function setting the high pwm frequency to the supplied pins
16
31
// - Stepper motor - 2PWM setting
17
32
// - hardware speciffic
@@ -60,6 +75,17 @@ void* _configure4PWM(long pwm_frequency, const int pinA, const int pinB, const i
60
75
return params;
61
76
}
62
77
78
+
79
+
80
+ // function setting the pwm duty cycle to the hardware
81
+ // - Stepper motor - 2PWM setting
82
+ // - hardware speciffic
83
+ void _writeDutyCycle1PWM (float dc_a, void * params) {
84
+ // transform duty cycle from [0,1] to [0,255]
85
+ analogWrite (((GenericDriverParams*)params)->pins [0 ], 255 .0f *dc_a);
86
+ }
87
+
88
+
63
89
// function setting the pwm duty cycle to the hardware
64
90
// - Stepper motor - 2PWM setting
65
91
// - hardware speciffic
@@ -68,6 +94,8 @@ void _writeDutyCycle2PWM(float dc_a, float dc_b, void* params) {
68
94
analogWrite (((GenericDriverParams*)params)->pins [0 ], 255 .0f *dc_a);
69
95
analogWrite (((GenericDriverParams*)params)->pins [1 ], 255 .0f *dc_b);
70
96
}
97
+
98
+
71
99
// function setting the pwm duty cycle to the hardware
72
100
// - BLDC motor - 3PWM setting
73
101
// - hardware speciffic
0 commit comments