Skip to content

Commit ee36bdb

Browse files
committed
optimize DriverPWMBase
1 parent fc48d78 commit ee36bdb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/AudioPWM/PWMAudioBase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ class DriverPWMBase {
138138
}
139139

140140
// initialize if necessary
141-
if (!isTimerStarted()) {
141+
if (!isTimerStarted() || !cfg.equals(actual_info)) {
142142
audio_config.logConfig();
143143
setupPWM();
144144
setupTimer();
145+
actual_info = cfg;
145146
}
146147

147148
// reset class variables
@@ -225,6 +226,7 @@ class DriverPWMBase {
225226

226227
protected:
227228
PWMConfig audio_config;
229+
AudioInfo actual_info;
228230
BaseBuffer<uint8_t> *buffer = nullptr;
229231
uint32_t underflow_count = 0;
230232
uint32_t underflow_per_second = 0;

0 commit comments

Comments
 (0)