Skip to content

Commit 64f94ca

Browse files
committed
noTone() if frequency = 0
1 parent fe4e24e commit 64f94ca

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

libraries/BLEAdafruitService/src/services/BLEAdafruitTone.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,18 @@ void BLEAdafruitTone::tone_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, u
7272
uint32_t duration;
7373
} tone_data;
7474

75-
PRINT_LOCATION();
7675
// invalid length
7776
if (len != sizeof(tone_data)) return;
77+
78+
// extra data
7879
memcpy(&tone_data, data, len);
7980

80-
PRINT_LOCATION();
81-
tone(svc._pin, tone_data.freq, tone_data.duration);
81+
// frequency = 0 means no tone
82+
if (tone_data.freq == 0)
83+
{
84+
noTone(svc._pin);
85+
}else
86+
{
87+
tone(svc._pin, tone_data.freq, tone_data.duration);
88+
}
8289
}

0 commit comments

Comments
 (0)