Prevent divide by zero error causing tone() to crash (#2780)
Prevent divide by zero error causing tone() to crash (#2780)

* Prevent divide by zero error causing code to crash

As per the issue at #2491, there is a divide by error issue resulting from the specification of 0 as the frequency. This does not appear to affect the AVR implementation, but it crashes on ESP8266s. I have merely removed the division if the frequency is zero, which appears to be giving the expected results (no tone), without any code crashes. 

To test, simply load the toneMelody sketch included with the Arduino IDE (Examples -> 02. Digital -> toneMelody) and change the piezo to something else if you need to. On the Witty module used to test this, I could also tell by the wifi led blinking every time the code crashed as the ESP8266 immediately rebooted.

* Use noTone when frequency is zero

When a frequency of zero is given to tone(), instead call noTone() and exit. Placed after some of the initialisation stuff to ensure the pin is mapped as a output, etc. Tested as functional against a Node MCU 1.0 board and the toneMelody example sketch, using GPIO5 (pin D1).

* Errant tab in formatting

* Rest of tabs that crept in from web editor

Defaulted to tabs and 8 indent :sigh:

me-no-dev/Arduino,Adam5Wu/Arduino,lrmoreno007/Arduino,me-no-dev/Arduino,Juppit/Arduino,lrmoreno007/Arduino,Adam5Wu/Arduino,esp8266/Arduino,hallard/Arduino,esp8266/Arduino,wemos/Arduino,jes/Arduino,Juppit/Arduino,Lan-Hekary/Arduino,sticilface/Arduino,esp8266/Arduino,Adam5Wu/Arduino,esp8266/Arduino,me-no-dev/Arduino,Juppit/Arduino,Adam5Wu/Arduino,jes/Arduino,jes/Arduino,me-no-dev/Arduino,jes/Arduino,wemos/Arduino,sticilface/Arduino,sticilface/Arduino,wemos/Arduino,esp8266/Arduino,jes/Arduino,Adam5Wu/Arduino,sticilface/Arduino,sticilface/Arduino,hallard/Arduino,Lan-Hekary/Arduino,lrmoreno007/Arduino,Lan-Hekary/Arduino,wemos/Arduino,Juppit/Arduino,lrmoreno007/Arduino,hallard/Arduino,me-no-dev/Arduino,hallard/Arduino,Lan-Hekary/Arduino,wemos/Arduino,lrmoreno007/Arduino,Juppit/Arduino,Lan-Hekary/Arduino,hallard/Arduino