We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents bc88462 + 9dd7e17 commit b3fd0efCopy full SHA for b3fd0ef
adafruit_magtag/peripherals.py
@@ -65,10 +65,19 @@ def __init__(self):
65
def play_tone(self, frequency, duration):
66
"""Automatically Enable/Disable the speaker and play
67
a tone at the specified frequency for the specified duration
68
-
+ It will attempt to play the sound up to 3 times in the case of
69
+ an error.
70
"""
71
self._speaker_enable.value = True
- simpleio.tone(board.SPEAKER, frequency, duration)
72
+ attempt = 0
73
+ # Try up to 3 times to play the sound
74
+ while attempt < 3:
75
+ try:
76
+ simpleio.tone(board.SPEAKER, frequency, duration)
77
+ break
78
+ except NameError:
79
+ pass
80
+ attempt += 1
81
self._speaker_enable.value = False
82
83
@property
0 commit comments