tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
599 stars 188 forks source link

buzzer: tone duration float64, no tone during rest #486

Closed breml closed 1 year ago

aykevl commented 1 year ago

Can you describe what bugs this fixes?

breml commented 1 year ago

Yes sure. The first commit makes all the note durations float64, such that these constants can be used with Tone(hz, duration float64) (err error), which expects the duration to be a float.

The second commit makes sure, that the note Rest works as intended. This is, Rest is a pause and and during the pause, there is no sound. The only effect of a Rest is to have a defined time of silence. Without the fix, the Rest does not have any effect, because the duration is a function of the tone (hz) and if this is 0, then everything becomes 0 and the function returns more or less imediatly.

deadprogram commented 1 year ago

Thanks for the fix here @breml now merging.