Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C12832 MMA7660 mbed
sound.cpp
- Committer:
- ksaito
- Date:
- 2018-03-14
- Revision:
- 5:614e3ac042df
- Parent:
- 4:d61f6d186db0
- Child:
- 9:35c816293400
File content as of revision 5:614e3ac042df:
#include "mbed.h"
#include "commands.h"
PwmOut spkr(p26);
static void _Initialize(void) {
spkr=0.0;
}
static void _Finalize(void) {
_Initialize();
}
static float _SoundRange = 2000.0;
static void _ProcessInitialize(void) {
_SoundRange = 2000.0;
}
static bool _ProcessIsContinue(void) {
return _SoundRange < 10000.0;
}
static void _ProcessRunning(void) {
spkr.period(1.0 / _SoundRange);
spkr = 0.5;
wait(0.1);
_SoundRange += 100;
}
COMMAND_DEFINE Command_sound = {"sound", 0x01, _Initialize, _Finalize,
_ProcessInitialize, _ProcessIsContinue, _ProcessRunning
};