arduino-audio-tools
AudioTimerBase.h
1 #pragma once
2 #include "AudioConfig.h"
3 #ifdef USE_TIMER
4 #include "AudioTools/CoreAudio/AudioTypes.h"
5 
12 namespace audio_tools {
13 
14 typedef void (*repeating_timer_callback_t)(void* obj);
15 
16 enum TimerFunction {
17  DirectTimerCallback,
18  TimerCallbackInThread,
19  SimpleThreadLoop
20 };
21 
23  public:
24  virtual ~TimerAlarmRepeatingDriverBase() { end(); }
25 
26  virtual bool begin(repeating_timer_callback_t callback_f, uint32_t time,
27  TimeUnit unit = MS) = 0;
28  virtual bool end() { return false; };
29 
30  void setCallbackParameter(void* obj) { object = obj; }
31 
32  void* callbackParameter() { return object; }
33 
34  virtual void setTimer(int timer) {}
35  virtual void setTimerFunction(TimerFunction function = DirectTimerCallback) {}
37  virtual void setIsSave(bool is_save) {}
38 
39  protected:
40  void* object = nullptr;
41 
42  const char* toString(TimeUnit unit){
43  return TimeUnitStr[(int)unit];
44  }
45 };
46 
47 } // namespace audio_tools
48 
49 #endif
Definition: AudioTimerBase.h:22
virtual void setIsSave(bool is_save)
Not used.
Definition: AudioTimerBase.h:37
TimeUnit
Time Units.
Definition: AudioTypes.h:45
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AudioConfig.h:823