I’m a newbie… At least in the world of Arduino… So stick with me. I was going through some Arduino examples on the web and attempting to get them running on the Spark Core. One of them was playing sounds (agreed not necessarily essential but fun). The examples use the Tone() and noTone(). When I attempt to compile this on the web IDE I get
../be706443cd7acffa8ea2a9abe8d964e99b36e48df442641d6018afaa0bd2/the_user_app.cpp:16:30: error: 'tone' was not declared in this scope
../be706443cd7acffa8ea2a9abe8d964e99b36e48df442641d6018afaa0bd2/the_user_app.cpp:19:20: error: 'noTone' was not declared in this scope
Is this a missing library/function that hasn’t been ported or just something stupid I’m doing.
Yup! You got it… I checked here http://docs.spark.io/#/firmware and there’s no Fun section. It’s all business… heh heh. I wouldn’t mind having tone() and noTone() functionality as well. It would probably come at the cost of losing a PWM output or two whenever you use tone() but that’s understandable.
If you use the delayMicroseconds() and direct port manipulation you might be able to roll your own for now though.
The implementation is based on Timer interrupts using Output Compare Toggle Mode of TIM peripherals. 10 timer mapped pins of the Core can be used to generate tones.
Heh, awesome. Back in the days of candybar and flip phones, I spent a lot of time transcribing music into RTTTL so that my wife and I could have custom ringtones without having to buy them at ridiculously inflated prices from our carrier. I might even still have my notes in the garage from when I did the Star Trek theme, Indiana Jones, and the Emperor’s March from Star Wars.