Skip to content

Commit 0b769a9

Browse files
authored
fix timer conflict between encoder and audio (#145)
1 parent a54bdca commit 0b769a9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

source/pyControl/audio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ def __init__(self, channel=1):
3636
# User functions
3737

3838
def off(self):
39-
self._DAC.write_timed(_off_buf, pyb.Timer(2, freq=10000), mode=pyb.DAC.NORMAL)
39+
self._DAC.write_timed(_off_buf, pyb.Timer(4, freq=10000), mode=pyb.DAC.NORMAL)
4040
self._timer.deinit()
4141
self._playing = False
4242

4343
def sine(self, freq): # Play a sine wave tone at the specified frequency.
44-
self._DAC.write_timed(_sine_buf, pyb.Timer(2, freq=freq * _sine_len), mode=pyb.DAC.CIRCULAR)
44+
self._DAC.write_timed(_sine_buf, pyb.Timer(4, freq=freq * _sine_len), mode=pyb.DAC.CIRCULAR)
4545

4646
def square(self, freq): # Play a square wave tone at the specified frequency.
47-
self._DAC.write_timed(_sqr_buf, pyb.Timer(2, freq=freq * 2), mode=pyb.DAC.CIRCULAR)
47+
self._DAC.write_timed(_sqr_buf, pyb.Timer(4, freq=freq * 2), mode=pyb.DAC.CIRCULAR)
4848

4949
def noise(self, freq=10000): # Play white noise with specified maximum frequency.
5050
self._DAC.noise(freq * 2)
5151

5252
def click(self, timer=None): # Play a single click.
53-
self._DAC.write_timed(_click_buf, pyb.Timer(2, freq=40000), mode=pyb.DAC.NORMAL)
53+
self._DAC.write_timed(_click_buf, pyb.Timer(4, freq=40000), mode=pyb.DAC.NORMAL)
5454

5555
def clicks(self, rate): # Play clicks at specified rate.
5656
self._timer.init(freq=rate)

source/pyControl/hardware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def get(self) -> int:
4343

4444
IO_dict = {} # Dictionary {ID: IO_object} containing all hardware inputs and outputs.
4545

46-
available_timers = [3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14] # Hardware timers not in use
47-
# Used timers; 1: Framework clock tick, 2: Audio write_timed, 6: DAC write_timed.
46+
available_timers = [3, 5, 7, 8, 9, 10, 11, 12, 13, 14] # Hardware timers not in use.
47+
# Used timers; 1: Framework clock tick, 2: Rotary encoder, 4: Audio write_timed, 6: DAC write_timed.
4848

4949
initialised = False # Set to True once hardware has been intiialised.
5050

0 commit comments

Comments
 (0)