Open pfeerick opened 7 years ago
A second tone related issue has come up on the forum on the same thread, where tone() will only work on P3. Due to a fluke in P3 aligning with GPIO3, and the tone melody example using P3, it was probably not detected that esp8266_pinToGpio was not needed in this library. I'll submit a pull request to remove these calls, along with some test code to demonstrate that it isn't needed. I'll also patch the tone '0' issue, with the same fix I proposed over on the ESP8266 github.
This bug originates from the ESP8266 Arduino core implementation, but I am also referencing it here as I will crosslink the two issues so it is easy to implement a solution once the best course of action is decided.
As per a discussion thread on the forum, an issue has been idenfied in the tone() function that caused the example sketch to fail. Whenever the tone command is issues with a frequency of 0, it will crash the sketch, and the Oak just freezes (on the pure ESP8266 core it instead reboots).
The workaround I have suggested for now at the sketch level for the example sketch is to use an if statement to catch a zero frequency call, and issue the noTone() command instead and then delay for the specified duration. In the example this happens as there is a series of notes specified in an array, and a '0' is used as a pause in the melody... with unexpected results on the ESP8266! 😢
i.e. Instead of
tone(3, melody[thisNote], noteDuration);
to use