restarting beep
This commit is contained in:
parent
40853a0d4c
commit
a056678346
12
src/beep.c
12
src/beep.c
@ -141,9 +141,15 @@ void msleep(int d){
|
|||||||
|
|
||||||
int beep(double freq_hz, double duration_sec)
|
int beep(double freq_hz, double duration_sec)
|
||||||
{
|
{
|
||||||
buzzer_set_freq(freq_hz);
|
if (freq_hz > 0.0) {
|
||||||
msleep(duration_sec*1000.);
|
buzzer_set_freq(freq_hz);
|
||||||
buzzer_set_freq(0.);
|
msleep(duration_sec*1000.);
|
||||||
|
buzzer_set_freq(0.);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msleep(duration_sec*1000.);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int beep_init()
|
int beep_init()
|
||||||
|
@ -296,7 +296,9 @@ int main(int argc, char *argv[])
|
|||||||
inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),
|
inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),
|
||||||
s, sizeof s);
|
s, sizeof s);
|
||||||
fprintf(stderr, "Connected to %s.\n", s);
|
fprintf(stderr, "Connected to %s.\n", s);
|
||||||
|
|
||||||
beep_init();
|
beep_init();
|
||||||
|
|
||||||
if ((strcmp (serialport, "")) != 0)
|
if ((strcmp (serialport, "")) != 0)
|
||||||
tx_method = TX_SERIAL;
|
tx_method = TX_SERIAL;
|
||||||
|
|
||||||
@ -354,7 +356,9 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(length < 0) {
|
if(length < 0) {
|
||||||
|
buzzer_close();
|
||||||
beep(0.0, abs(length)/1000.);
|
beep(0.0, abs(length)/1000.);
|
||||||
|
buzzer_start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user