1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-23 08:45:22 +03:00
Commit Graph

7 Commits

Author SHA1 Message Date
a444898900 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:
2017-01-17 10:09:08 +08:00
748f3f93fa Fix crashes when using tone()
Mark `t1IntHandler()` with ICACHE_RAM_ATTR
2016-03-12 19:21:32 +02:00
4b55ee14ef Allow indefinite duration for tone()
Bugfix: the `duration` parameter should be optional, per [`tone()`](https://www.arduino.cc/en/Reference/Tone) docs.
2016-03-12 17:42:30 +02:00
7beda37da1 Implementation of Tone API using timer1 2016-02-05 12:03:29 +00:00
b500a1f26a Made changes to allow the compiler to compile without warnings. 2015-08-09 14:10:20 -05:00
f165a0afcd use Eclipse auto Format to get rip auf the tab, space and code style inconsistency 2015-04-06 19:33:50 +02:00
04fe8e8b58 Basic support for esp8266 platform
This includes empty stubs for most core Arduino functions.
Need to actually implement all those digital reads writes whatever.
Need to prebuild toolchains (xtensa-elf-lx106) for 3 platforms and put them on some download server.
Need to do the same with esptool.
Need to fix 0x40000 binary generation and add correct upload commands.
Maybe even implement uploads over WiFi.
2014-11-15 10:45:08 +03:00