Support for sound on the PicoCalc has arrived!
The compilation instructions and USING_THE_PICOCALC.md have been updated. Now you have to load extra/rp_common/picocalc_sound.fs before loading extra/rp_common/picocalc_term_common.fs.
This support currently is in the form of supporting generating tones for periods of time. There is now the word picocalc-sound::play-tone-for-duration ( duration-in-ticks D: pitch-in-hz – ). The pitch is a S31.32 fixed-point value in Hz, which can be specified via the x,y notation, e.g. 1047,0 is C6. The duration is in ticks, which are 100 microsecond increments.
Currently the left and right speakers are controlled together; this is a side effect of the fact that PWM is used to generate tones, and they both fall on the same PWM slice and thus have the same top value and clock divider.
There is also a convenience word picocalc-sound::beep ( – ) which generates what is currently a 125 millisecond tone at 1397 Hz, i.e. F6. This may change if people have other preferences.
Accordingly, there is now an optional, opt-in audible bell. It can be enabled by executing:
true picocalc-term::audible-bell-enabled!
If you decide this is too annoying, you can disable it again by executing:
false picocalc-term::audible-bell-enabled!
It can be permanently enabled if you decide you really like your PicoCalc beeping at you with:
compile-to-flash
: do-enable-audible-bell true picocalc-term::audible-bell-enabled! ;
initializer do-enable-audible-bell
reboot
Edit (opinion question):
I am not entirely happy with my choice of 1397 Hz, i.e. F6, for the beep sound. However, I could not find any other notes I really liked better. Does anyone have any suggestions of a pitch to use?
Another edit:
I have switched to 1245 Hz, i.e. D6#, which I do like better than 1397 Hz. If anyone has any suggestions, though, throw them out!
Yet another update:
I have removed flashing the LED on the Pico, Pico 2, and Pimoroni Pico Plus 2 due to the conflict between the LED GPIO on those and the CS GPIO for the CYW43439 on the Pico W, Pico 2 W, and Pico Plus 2 W, which is also GPIO 25.