Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit f76854f

Browse files
authored
v1.1.0
### Releases v1.1.0 1. Fix bug. See [Fixed count >= min comparison for servo enable](#1) 2. Clean-up all compiler warnings possible. 3. Add Table of Contents 4. Add Version String 5. Fix and Optimize old examples
1 parent 5087565 commit f76854f

File tree

3 files changed

+3
-39
lines changed

3 files changed

+3
-39
lines changed

src/ESP32FastTimerInterrupt.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,8 @@ class ESP32FastTimerInterrupt
171171
_timerCount = (uint64_t) _frequency / frequency;
172172
// count up
173173

174-
//#if (TIMER_INTERRUPT_DEBUG > 0)
175-
//Serial.println("ESP32TimerInterrupt: _timerNo = " + String(_timerNo) + ", _fre = " + String(_frequency)
176-
// + ", _count = " + String((uint32_t) (_timerCount >> 32) ) + " - " + String((uint32_t) (_timerCount)));
177174
ISR_SERVO_LOGERROR3("ESP32FastTimerInterrupt: _timerNo =", _timerNo, ", _fre =", _frequency);
178175
ISR_SERVO_LOGERROR3("_count =",(uint32_t) (_timerCount >> 32), " -", (uint32_t) (_timerCount));
179-
//#endif
180176

181177
// Clock to timer (prescaler) is F_CPU / 3 = 240MHz / 3 = 80MHz
182178
_timer = timerBegin(_timerNo, F_CPU / (_frequency * 3), true);

src/ESP32_ISR_Servo.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ void IRAM_ATTR ESP32_ISR_Servo::run()
7777
// Reset when reaching 20000us / 10us = 2000
7878
if (timerCount++ >= REFRESH_INTERVAL / TIMER_INTERVAL_MICRO)
7979
{
80-
//#if (ISR_SERVO_DEBUG > 1)
81-
//Serial.println("Reset count");
8280
ISR_SERVO_LOGDEBUG("Reset count");
83-
//#endif
8481

8582
timerCount = 1;
8683
}
@@ -103,11 +100,7 @@ int ESP32_ISR_Servo::findFirstFreeSlot()
103100
{
104101
if (servo[servoIndex].enabled == false)
105102
{
106-
//#if (ISR_SERVO_DEBUG > 1)
107-
//Serial.print("Index = ");
108-
//Serial.println(servoIndex);
109103
ISR_SERVO_LOGDEBUG1("Index =", servoIndex);
110-
//#endif
111104

112105
return servoIndex;
113106
}
@@ -143,12 +136,8 @@ int ESP32_ISR_Servo::setupServo(uint8_t pin, int min, int max)
143136

144137
numServos++;
145138

146-
//#if (ISR_SERVO_DEBUG > 0)
147-
//Serial.print("Index = " + String(servoIndex) + ", count = " + String(servo[servoIndex].count));
148139
ISR_SERVO_LOGDEBUG3("Index =", servoIndex, ", count =", servo[servoIndex].count);
149-
//Serial.println(", min = " + String(servo[servoIndex].min) + ", max = " + String(servo[servoIndex].max));
150140
ISR_SERVO_LOGDEBUG3("min =", servo[servoIndex].min, ", max =", servo[servoIndex].max);
151-
//#endif
152141

153142
return servoIndex;
154143
}
@@ -172,11 +161,8 @@ bool ESP32_ISR_Servo::setPosition(unsigned servoIndex, int position)
172161
// It is mandatory to disable task switches during modifying shared vars
173162
portEXIT_CRITICAL(&timerMux);
174163

175-
//#if (ISR_SERVO_DEBUG > 0)
176-
//Serial.println("Idx = " + String(servoIndex) + ", cnt = " + String(servo[servoIndex].count) + ", pos = " + String(servo[servoIndex].position));
177164
ISR_SERVO_LOGERROR1("Idx =", servoIndex);
178165
ISR_SERVO_LOGERROR3("cnt =", servo[servoIndex].count, ", pos =",servo[servoIndex].position);
179-
//#endif
180166

181167
return true;
182168
}
@@ -194,11 +180,8 @@ int ESP32_ISR_Servo::getPosition(unsigned servoIndex)
194180
// Updates interval of existing specified servo
195181
if ( servo[servoIndex].enabled && (servo[servoIndex].pin <= ESP32_MAX_PIN) )
196182
{
197-
//#if (ISR_SERVO_DEBUG > 0)
198-
//Serial.println("Idx = " + String(servoIndex) + ", cnt = " + String(servo[servoIndex].count) + ", pos = " + String(servo[servoIndex].position));
199183
ISR_SERVO_LOGERROR1("Idx =", servoIndex);
200184
ISR_SERVO_LOGERROR3("cnt =", servo[servoIndex].count, ", pos =",servo[servoIndex].position);
201-
//#endif
202185

203186
return (servo[servoIndex].position);
204187
}
@@ -236,11 +219,8 @@ bool ESP32_ISR_Servo::setPulseWidth(unsigned servoIndex, unsigned int pulseWidth
236219
// It is mandatory to disable task switches during modifying shared vars
237220
portEXIT_CRITICAL(&timerMux);
238221

239-
//#if (ISR_SERVO_DEBUG > 0)
240-
//Serial.println("Idx = " + String(servoIndex) + ", cnt = " + String(servo[servoIndex].count) + ", pos = " + String(servo[servoIndex].position));
241222
ISR_SERVO_LOGERROR1("Idx =", servoIndex);
242223
ISR_SERVO_LOGERROR3("cnt =", servo[servoIndex].count, ", pos =",servo[servoIndex].position);
243-
//#endif
244224

245225
return true;
246226
}
@@ -258,11 +238,8 @@ unsigned int ESP32_ISR_Servo::getPulseWidth(unsigned servoIndex)
258238
// Updates interval of existing specified servo
259239
if ( servo[servoIndex].enabled && (servo[servoIndex].pin <= ESP32_MAX_PIN) )
260240
{
261-
//#if (ISR_SERVO_DEBUG > 0)
262-
//Serial.println("Idx = " + String(servoIndex) + ", cnt = " + String(servo[servoIndex].count) + ", pos = " + String(servo[servoIndex].position));
263241
ISR_SERVO_LOGERROR1("Idx =", servoIndex);
264242
ISR_SERVO_LOGERROR3("cnt =", servo[servoIndex].count, ", pos =",servo[servoIndex].position);
265-
//#endif
266243

267244
return (servo[servoIndex].count * TIMER_INTERVAL_MICRO );
268245
}

src/ESP32_ISR_Servo.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,12 @@ class ESP32_ISR_Servo
161161

162162
// Interval in microsecs
163163
if ( ESP32_ITimer && ESP32_ITimer->attachInterruptInterval(TIMER_INTERVAL_MICRO, (timer_callback) ESP32_ISR_Servo_Handler ) )
164-
//if ( ESP32_ITimer.attachInterruptInterval(TIMER_INTERVAL_MICRO, (timer_callback) ESP32_ISR_Servo_Handler ) )
165164
{
166-
//#if (ISR_SERVO_DEBUG > 0)
167-
//Serial.println("Starting ITimer OK");
168165
ISR_SERVO_LOGERROR("Starting ITimer OK");
169-
//#endif
170166
}
171167
else
172168
{
173-
//#if (ISR_SERVO_DEBUG > 0)
174-
// Can't set ESP32_ITimer correctly. Select another freq. or interval
175-
//Serial.println("Fail setup ESP32_ITimer");
176-
ISR_SERVO_LOGERROR("Fail setup ESP32_ITimer");
177-
//#endif
178-
}
169+
ISR_SERVO_LOGERROR("Fail setup ESP32_ITimer"); }
179170

180171
for (int servoIndex = 0; servoIndex < MAX_SERVOS; servoIndex++)
181172
{
@@ -203,8 +194,8 @@ class ESP32_ISR_Servo
203194
unsigned long count; // In microsecs
204195
int position; // In degrees
205196
bool enabled; // true if enabled
206-
int16_t min;
207-
int16_t max;
197+
uint16_t min;
198+
uint16_t max;
208199
} servo_t;
209200

210201
volatile servo_t servo[MAX_SERVOS];

0 commit comments

Comments
 (0)