This is the description

Dependencies:   mbed Menu Joystick

Committer:
mrkang
Date:
Mon Apr 27 14:22:07 2020 +0000
Revision:
1:099632454013
Parent:
0:59cbc5800eb6
Star wars; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mrkang 0:59cbc5800eb6 1 #include "Sound.h"
mrkang 0:59cbc5800eb6 2 #include "mbed.h"
mrkang 0:59cbc5800eb6 3 Sound::Sound()
mrkang 0:59cbc5800eb6 4 :
mrkang 0:59cbc5800eb6 5 _timeout(new Timeout()),
mrkang 0:59cbc5800eb6 6 _buzzer(new PwmOut(PTC10))
mrkang 0:59cbc5800eb6 7 {}
mrkang 0:59cbc5800eb6 8
mrkang 0:59cbc5800eb6 9 Sound::~Sound()
mrkang 0:59cbc5800eb6 10 {
mrkang 0:59cbc5800eb6 11
mrkang 0:59cbc5800eb6 12 }
mrkang 0:59cbc5800eb6 13 void Sound::tone(float frequency, float duration)
mrkang 0:59cbc5800eb6 14 {
mrkang 0:59cbc5800eb6 15 _buzzer->period(1.0f/frequency);
mrkang 0:59cbc5800eb6 16 _buzzer->write(0.5);
mrkang 0:59cbc5800eb6 17 _timeout->attach(callback(this,&Sound::tone_off),duration);
mrkang 0:59cbc5800eb6 18 }
mrkang 0:59cbc5800eb6 19 void Sound::welcome(){
mrkang 0:59cbc5800eb6 20 tone(1000.0f,0.5f);
mrkang 0:59cbc5800eb6 21 wait(0.5f);
mrkang 0:59cbc5800eb6 22 tone(2000.0f,0.1f);
mrkang 0:59cbc5800eb6 23 wait(0.5f);
mrkang 0:59cbc5800eb6 24 tone(2000.0f,0.2f);
mrkang 0:59cbc5800eb6 25 wait(0.5f);
mrkang 0:59cbc5800eb6 26 tone(3000.0f,0.3f);
mrkang 0:59cbc5800eb6 27 wait(0.5f);
mrkang 0:59cbc5800eb6 28 tone(1200.0f,0.2f);
mrkang 0:59cbc5800eb6 29 wait(0.5f);
mrkang 0:59cbc5800eb6 30 tone(1000.0f,0.3f);
mrkang 0:59cbc5800eb6 31 wait(0.5f);
mrkang 0:59cbc5800eb6 32 tone(2000.0f,0.2f);
mrkang 0:59cbc5800eb6 33 wait(0.5f);
mrkang 0:59cbc5800eb6 34 tone(1000.0f,0.5f);
mrkang 0:59cbc5800eb6 35 wait(0.5f);
mrkang 0:59cbc5800eb6 36
mrkang 0:59cbc5800eb6 37 }
mrkang 0:59cbc5800eb6 38 void Sound::tone_off()
mrkang 0:59cbc5800eb6 39 {
mrkang 0:59cbc5800eb6 40 _buzzer->write(0.0);
mrkang 0:59cbc5800eb6 41 }