Funhouse tone error "All timers in use"

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
plitog
 
Posts: 5
Joined: Tue May 25, 2021 8:24 pm

Funhouse tone error "All timers in use"

Post by plitog »

I have the below code running on my Funhouse. The first three calls to simpleio.tone work fine but the fourth throws an error stating "All timers in use." If I stick to just three frequencies it runs without issue so it seems each distinct frequency uses a separate "timer" resource. Is there a way to free up the resource after calling tone? Or perhaps a better way to play a wider range of frequencies?

Code: Select all

import board
import simpleio
import time

while True:
    simpleio.tone(board.SPEAKER, 300, 0.5)
    time.sleep(1)
    simpleio.tone(board.SPEAKER, 400, 0.5)
    time.sleep(1)
    simpleio.tone(board.SPEAKER, 500, 0.5)
    time.sleep(1)
    ''' This next call fails with 'all timers in use' '''
    simpleio.tone(board.SPEAKER, 600, 0.5)
    time.sleep(1)

User avatar
blnkjns
 
Posts: 963
Joined: Fri Oct 02, 2020 3:33 am

Re: Funhouse tone error "All timers in use"

Post by blnkjns »

What happens if you put pwm.deinit() on the position of your comment?

User avatar
plitog
 
Posts: 5
Joined: Tue May 25, 2021 8:24 pm

Re: Funhouse tone error "All timers in use"

Post by plitog »

pwm isn't defined in my code so it fails when it hits that line.

I looked at the code for the tone method in simpleio. It calls PWMOut within a "with" block so in theory it should clean up the resources after it falls out of scope. Just in case, I copied that method into my code and modified it to call deinit() explicitly, both inside the "with" block and in place of the block. In both cases I got the same error.

It seems there is an underlying issue causing it to hold on to the resource even after attempting to free it.

Locked
Please be positive and constructive with your questions and comments.

Return to “AdaBox! Show us what you made!”