Skip to content

Commit b10fb54

Browse files
authored
Merge pull request #16 from tasmota/2.7.4.3
2.7.4.3
2 parents f6e2b2f + f18a251 commit b10fb54

5 files changed

+490
-174
lines changed

cores/esp8266/Tone.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@
2525
#include "core_esp8266_waveform.h"
2626
#include "user_interface.h"
2727

28-
// Which pins have a tone running on them?
29-
static uint32_t _toneMap = 0;
30-
31-
3228
static void _startTone(uint8_t _pin, uint32_t high, uint32_t low, uint32_t duration) {
3329
if (_pin > 16) {
3430
return;
3531
}
3632

33+
// Stop any analogWrites (PWM) because they are a different generator
34+
_stopPWM(_pin);
35+
// If there's another Tone or startWaveform on this pin
36+
// it will be changed on-the-fly (no need to stop it)
37+
3738
pinMode(_pin, OUTPUT);
3839

3940
high = std::max(high, (uint32_t)microsecondsToClockCycles(25)); // new 20KHz maximum tone frequency,
@@ -42,9 +43,7 @@ static void _startTone(uint8_t _pin, uint32_t high, uint32_t low, uint32_t durat
4243
duration = microsecondsToClockCycles(duration * 1000UL);
4344
duration += high + low - 1;
4445
duration -= duration % (high + low);
45-
if (startWaveformClockCycles(_pin, high, low, duration)) {
46-
_toneMap |= 1 << _pin;
47-
}
46+
startWaveformClockCycles(_pin, high, low, duration);
4847
}
4948

5049

@@ -86,6 +85,5 @@ void noTone(uint8_t _pin) {
8685
return;
8786
}
8887
stopWaveform(_pin);
89-
_toneMap &= ~(1 << _pin);
9088
digitalWrite(_pin, 0);
9189
}

0 commit comments

Comments
 (0)