Skip to content

Commit

Permalink
ESP Timer Optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Nov 9, 2023
1 parent 040eeb9 commit 41c4d1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/AudioConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@
#define LOG_PRINTF_BUFFER_SIZE 303
#define LOG_METHOD __PRETTY_FUNCTION__

// cheange USE_CHECK_MEMORY to 1 to activate memory checks
#define USE_CHECK_MEMORY 0
// cheange USE_CHECK_MEMORY to true to activate memory checks
#define USE_CHECK_MEMORY false

#if USE_CHECK_MEMORY
# define CHECK_MEMORY() checkMemory(true)
#else
Expand Down
6 changes: 4 additions & 2 deletions src/AudioTimer/AudioTimerESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ class TimerAlarmRepeatingDriverESP32 : public TimerAlarmRepeatingDriverBase {
#endif
}



/// direct timer callback
void setupDirectTimerCallback(repeating_timer_callback_t callback_f){
TRACED();
Expand Down Expand Up @@ -305,6 +303,7 @@ class TimerAlarmRepeatingDriverESP32 : public TimerAlarmRepeatingDriverBase {
if (thread_notification){
cb->call();
}
yield();
}
}

Expand All @@ -317,6 +316,9 @@ class TimerAlarmRepeatingDriverESP32 : public TimerAlarmRepeatingDriverBase {
unsigned long end = micros() + ta->timeUs;
ta->user_callback.call();
long waitUs = end - micros();
long waitMs = waitUs / 1000;
waitUs = waitUs - (waitMs * 1000);
delay(waitMs);
if (waitUs>0){
delayMicroseconds(waitUs);
}
Expand Down

0 comments on commit 41c4d1f

Please sign in to comment.