Removed most of the comments
Dependents: Hodak_MorseCoder LED_BOZICNE_LAMPICE
buzzer.cpp@2:857083873b09, 2020-11-19 (annotated)
- Committer:
- khodak
- Date:
- Thu Nov 19 10:41:25 2020 +0000
- Revision:
- 2:857083873b09
- Parent:
- 0:01eac446ef9f
Removing most of the comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Reniboy | 0:01eac446ef9f | 1 | #include "buzzer.h" |
Reniboy | 0:01eac446ef9f | 2 | #include "mbed.h" |
khodak | 2:857083873b09 | 3 | |
Reniboy | 0:01eac446ef9f | 4 | using namespace mbed; |
khodak | 2:857083873b09 | 5 | |
khodak | 2:857083873b09 | 6 | Beep::Beep(PinName pin) : _pwm(pin) |
khodak | 2:857083873b09 | 7 | { |
Reniboy | 0:01eac446ef9f | 8 | _pwm.write(0.0); |
Reniboy | 0:01eac446ef9f | 9 | } |
khodak | 2:857083873b09 | 10 | |
khodak | 2:857083873b09 | 11 | void Beep::nobeep() |
khodak | 2:857083873b09 | 12 | { |
khodak | 2:857083873b09 | 13 | _pwm.write(0.0); |
khodak | 2:857083873b09 | 14 | } |
khodak | 2:857083873b09 | 15 | |
Reniboy | 0:01eac446ef9f | 16 | /** Beep with given frequency and duration. |
Reniboy | 0:01eac446ef9f | 17 | * |
Reniboy | 0:01eac446ef9f | 18 | * @param frequency - the frequency of the tone in Hz |
Reniboy | 0:01eac446ef9f | 19 | * @param time - the duration of the tone in seconds |
Reniboy | 0:01eac446ef9f | 20 | */ |
khodak | 2:857083873b09 | 21 | void Beep::beep(float freq, float time) |
khodak | 2:857083873b09 | 22 | { |
khodak | 2:857083873b09 | 23 | |
Reniboy | 0:01eac446ef9f | 24 | _pwm.period(1.0/freq); |
khodak | 2:857083873b09 | 25 | _pwm.write(0.5); |
khodak | 2:857083873b09 | 26 | toff.attach(this,&Beep::nobeep, time); |
Reniboy | 0:01eac446ef9f | 27 | } |