noTone() if frequency = 0
This commit is contained in:
1 parent
fe4e24edea
commit
64f94ca22f
1 file changed
+10
-3
@@ -72,11 +72,18 @@ void BLEAdafruitTone::tone_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, u
|
||||
uint32_t duration;
|
||||
} tone_data;
|
||||
|
||||
PRINT_LOCATION();
|
||||
// invalid length
|
||||
if (len != sizeof(tone_data)) return;
|
||||
|
||||
// extra data
|
||||
memcpy(&tone_data, data, len);
|
||||
|
||||
PRINT_LOCATION();
|
||||
tone(svc._pin, tone_data.freq, tone_data.duration);
|
||||
// frequency = 0 means no tone
|
||||
if (tone_data.freq == 0)
|
||||
{
|
||||
noTone(svc._pin);
|
||||
}else
|
||||
{
|
||||
tone(svc._pin, tone_data.freq, tone_data.duration);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user