It's not my library, i just want to publish my program.
Fork of PWM_Tone_Library by
pwm_tone.cpp@3:b3ee09f3ff8f, 2017-03-31 (annotated)
- Committer:
- Lapita
- Date:
- Fri Mar 31 14:51:06 2017 +0000
- Revision:
- 3:b3ee09f3ff8f
- Parent:
- 2:dd4ed6c28c87
recepcion de datos del iphone, and buzzer activado desactivado
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
justinkim | 0:d06af372d384 | 1 | /* Includes ------------------------------------------------------------------*/ |
justinkim | 0:d06af372d384 | 2 | #include "pwm_tone.h" |
justinkim | 0:d06af372d384 | 3 | |
justinkim | 0:d06af372d384 | 4 | /* Private typedef -----------------------------------------------------------*/ |
justinkim | 0:d06af372d384 | 5 | /* Private define ------------------------------------------------------------*/ |
justinkim | 0:d06af372d384 | 6 | /* Private variables ---------------------------------------------------------*/ |
justinkim | 0:d06af372d384 | 7 | /* Private function prototypes -----------------------------------------------*/ |
justinkim | 0:d06af372d384 | 8 | /* Private functions ---------------------------------------------------------*/ |
justinkim | 0:d06af372d384 | 9 | |
justinkim | 0:d06af372d384 | 10 | /** |
justinkim | 0:d06af372d384 | 11 | * @brief Tune Function |
justinkim | 0:d06af372d384 | 12 | * @param name : Choose the PwmOut |
justinkim | 0:d06af372d384 | 13 | period : this param is tune value. (C_3...B_5) |
justinkim | 0:d06af372d384 | 14 | beat : this param is beat value. (1..16) 1 means 1/16 beat |
justinkim | 0:d06af372d384 | 15 | * @retval None |
justinkim | 0:d06af372d384 | 16 | */ |
justinkim | 0:d06af372d384 | 17 | void Tune(PwmOut name, int period, int beat) |
justinkim | 0:d06af372d384 | 18 | { |
justinkim | 0:d06af372d384 | 19 | int delay; |
justinkim | 0:d06af372d384 | 20 | |
justinkim | 0:d06af372d384 | 21 | delay = beat*63; |
justinkim | 0:d06af372d384 | 22 | name.period_us(period); |
Lapita | 3:b3ee09f3ff8f | 23 | name.write(0.50f); // 50% duty cycle |
justinkim | 0:d06af372d384 | 24 | wait_ms(delay); // 1 beat |
justinkim | 0:d06af372d384 | 25 | name.period_us(0); // Sound off |
Lapita | 3:b3ee09f3ff8f | 26 | name.write(0.00f); // 50% duty cycle |
Lapita | 3:b3ee09f3ff8f | 27 | name.period_us(0); // Sound off |
justinkim | 0:d06af372d384 | 28 | } |
justinkim | 0:d06af372d384 | 29 | |
justinkim | 0:d06af372d384 | 30 | /** |
justinkim | 0:d06af372d384 | 31 | * @brief Auto tunes Function |
justinkim | 0:d06af372d384 | 32 | * @param name : Choose the PwmOut |
justinkim | 0:d06af372d384 | 33 | period : this param is tune value. (C_3...B_5) |
justinkim | 0:d06af372d384 | 34 | beat : this param is beat value. (1..16) 1 means 1/16 beat |
justinkim | 0:d06af372d384 | 35 | * @retval None |
justinkim | 0:d06af372d384 | 36 | */ |
justinkim | 0:d06af372d384 | 37 | void Auto_tunes(PwmOut name, int period, int beat) |
justinkim | 0:d06af372d384 | 38 | { |
justinkim | 0:d06af372d384 | 39 | int delay; |
justinkim | 0:d06af372d384 | 40 | |
justinkim | 0:d06af372d384 | 41 | delay = beat*63; |
justinkim | 0:d06af372d384 | 42 | name.period_us(period); |
Lapita | 3:b3ee09f3ff8f | 43 | name.write(0.50f); // 50% duty cycle |
justinkim | 0:d06af372d384 | 44 | wait_ms(delay); |
justinkim | 0:d06af372d384 | 45 | } |
justinkim | 0:d06af372d384 | 46 | |
justinkim | 0:d06af372d384 | 47 | /** |
justinkim | 0:d06af372d384 | 48 | * @brief Stop tunes Function |
justinkim | 0:d06af372d384 | 49 | * @param name : Choose the PwmOut |
justinkim | 0:d06af372d384 | 50 | * @retval None |
justinkim | 0:d06af372d384 | 51 | */ |
justinkim | 0:d06af372d384 | 52 | void Stop_tunes(PwmOut name) |
justinkim | 0:d06af372d384 | 53 | { |
justinkim | 0:d06af372d384 | 54 | name.period_us(0); |
justinkim | 0:d06af372d384 | 55 | } |