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.
Fork of PWM_Tone_Library by
pwm_tone.cpp
00001 /* Includes ------------------------------------------------------------------*/ 00002 #include "pwm_tone.h" 00003 00004 /* Private typedef -----------------------------------------------------------*/ 00005 /* Private define ------------------------------------------------------------*/ 00006 /* Private variables ---------------------------------------------------------*/ 00007 /* Private function prototypes -----------------------------------------------*/ 00008 /* Private functions ---------------------------------------------------------*/ 00009 00010 /** 00011 * @brief Tune Function 00012 * @param name : Choose the PwmOut 00013 period : this param is tune value. (C_3...B_5) 00014 beat : this param is beat value. (1..16) 1 means 1/16 beat 00015 * @retval None 00016 */ 00017 void Tune(PwmOut name, int period, int beat) 00018 { 00019 int delay; 00020 00021 delay = beat*63; 00022 name.period_us(period); 00023 name.write(0.50f); // 50% duty cycle 00024 Thread::wait(delay); // 1 beat 00025 name.period_us(0); // Sound off 00026 } 00027 00028 /** 00029 * @brief Auto tunes Function 00030 * @param name : Choose the PwmOut 00031 period : this param is tune value. (C_3...B_5) 00032 beat : this param is beat value. (1..16) 1 means 1/16 beat 00033 * @retval None 00034 */ 00035 void Auto_tunes(PwmOut name, int period, int beat) 00036 { 00037 int delay; 00038 00039 delay = beat*63; 00040 name.period_us(period); 00041 name.write(0.50f); // 50% duty cycle 00042 Thread::wait(delay); 00043 } 00044 00045 /** 00046 * @brief Stop tunes Function 00047 * @param name : Choose the PwmOut 00048 * @retval None 00049 */ 00050 void Stop_tunes(PwmOut name) 00051 { 00052 name.period_us(0); 00053 }
Generated on Tue Jul 12 2022 19:10:49 by
1.7.2
