Closed SpenceKonde closed 3 years ago
hum... it also doesn't appear to get the frequency right...
/facepalm yes, of course it does , but not if your whole loop body consists of one call to tone() so it's continually restarting the tone...
Okay the non-duration caases are sorted out....
Hmmm, @hamsterdave - I can't reproduce your reported issue with it failing when a duration was specified. - but I don't think any of the fixes I put in would have mae a difference on that front.....
Maybe I'll go try with a 1604....Nope, working there too. Though there was definitely a bug with it leaving outputs high, no question
@hamsterdave - I have corrected github version, but I was never able to reproduce the behavior you saw with it just leaving the pin high for the duration instead of outputting a tone... Is that one still reproducing for you with latest code? If it is, let me know and post or send me a sketch that causes it
It seems there's a bug in the tone() function on the ATTiny1604 (possibly others, I don't have any others handy to test on at the moment). If you call the tone function with a duration specified:
tone(TONE_PIN, 440, 500);
It doesn't actually generate a tone output, it just toggles the specified pin high for the specified duration and then low again.
If you call the function with no duration, it generates the tone as it should, however if you then call noTone(); it stops generating the tone output, but it leaves the pin high, pumping DC into the speaker coil. The pin has to be manually set low again following noTone();
Originally posted by @hamsterdave in https://github.com/SpenceKonde/megaTinyCore/discussions/362