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-07
- Revision:
- 4:d61f6d186db0
- Parent:
- 1:2967eac08981
- Child:
- 5:614e3ac042df
File content as of revision 4:d61f6d186db0:
#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;
}
static void _Process(void) {
_ProcessInitialize();
while ( _ProcessIsContinue() ) {
_ProcessRunning();
}
}
COMMAND_DEFINE Command_sound = {"sound", 0x01, _Initialize, _Finalize, _Process,
_ProcessInitialize, _ProcessIsContinue, _ProcessRunning
};