@@ -69,13 +69,8 @@ uint8_t Servo::attach(int pin, uint16_t minUs, uint16_t maxUs)
69
69
uint8_t Servo::attach (int pin, uint16_t minUs, uint16_t maxUs, int value)
70
70
{
71
71
if (!_attached) {
72
- #ifdef WAVEFORM_LOCKED_PHASE
73
72
pinMode (pin, OUTPUT);
74
73
digitalWrite (pin, LOW);
75
- #else
76
- digitalWrite (pin, LOW);
77
- pinMode (pin, OUTPUT);
78
- #endif
79
74
_pin = pin;
80
75
_attached = true ;
81
76
}
@@ -95,11 +90,7 @@ void Servo::detach()
95
90
{
96
91
if (_attached) {
97
92
_servoMap &= ~(1 << _pin);
98
- #ifdef WAVEFORM_LOCKED_PHASE
99
93
startWaveform (_pin, 0 , REFRESH_INTERVAL, 1 );
100
- #else
101
- // TODO - timeHigh == 0 is illegal in _PWM code branch. Do nothing for now.
102
- #endif
103
94
delay (REFRESH_INTERVAL / 1000 ); // long enough to complete active period under all circumstances.
104
95
stopWaveform (_pin);
105
96
_attached = false ;
@@ -124,13 +115,9 @@ void Servo::writeMicroseconds(int value)
124
115
_valueUs = value;
125
116
if (_attached) {
126
117
_servoMap &= ~(1 << _pin);
127
- #ifdef WAVEFORM_LOCKED_PHASE
128
118
// Find the first GPIO being generated by checking GCC's find-first-set (returns 1 + the bit of the first 1 in an int32_t)
129
119
int phaseReference = __builtin_ffs (_servoMap) - 1 ;
130
120
if (startWaveform (_pin, _valueUs, REFRESH_INTERVAL - _valueUs, 0 , phaseReference))
131
- #else
132
- if (startWaveform (_pin, _valueUs, REFRESH_INTERVAL - _valueUs, 0 ))
133
- #endif
134
121
{
135
122
_servoMap |= (1 << _pin);
136
123
}
0 commit comments