You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# importimportalarmimportboardimportpwmio#import simpleioimporttime# Time values set by userseconds=10#testingminutes=0hours=0days=0# mathminute=minutes*60hour=hours*3600day=days*86400val=minute+hour+day# power on tone# simpleio#simpleio.tone(board.A0, 1000, duration=0.5)# pwmiopiezo=pwmio.PWMOut(board.A0, duty_cycle=0, frequency=440, variable_frequency=False)
piezo.duty_cycle=65535//2# On 50%time.sleep(1)
piezo.duty_cycle=0# off# wait for timerprint("Sleeping for", val, "seconds...")
#time.sleep(seconds)time_alarm=alarm.time.TimeAlarm(monotonic_time=time.monotonic() +seconds)
alarm.light_sleep_until_alarms(time_alarm)
whileTrue:
print("Beeping...")
#simpleio.tone(board.A0, 1000, duration=0.5)piezo.duty_cycle=65535//2# On 50%time.sleep(1)
piezo.duty_cycle=0# offtime.sleep(1)
Behavior
The code runs through. In the loop, I receive unexpected behavior with my attached piezo beeper not beeping as it should.
Description
With simpleio, I will receive a beep from the piezo beeper under #power on tone. However once alarm is called and woken back up. In the loop I only get the print statement. No tone from the piezo beeper. This persists until the hardware is reset.
With pwmio, I again receive the beep under #power on tone at its stated frequency. After alarm, I will receive the print statement in console many times before I hear a tone from the piezo beeper. The tone is not at its stated frequency and is higher pitched. The tone is also on longer than one second. The tone seems to toggle off after the loop has gone around 3 times. Reloading the code in REPL, I do not receive the #power on tone, I do however eventually get beeping from the loop with the same behavior described. It takes a hardware reset to hear the #power on tone again.
I've tried both circuitpython stable release 8.2.7, and now the alpha 9.x release. Both have the same outcome.
Additional information
No response
The text was updated successfully, but these errors were encountered:
I've found a work around that requires deep sleep. I was confused as to how to implement it at first. However this is what I have and it works as intended.
# importimportalarmimportboardimportsimpleioimporttime# Time values set by userseconds=10#testingminutes=1hours=0days=0# mathminute=minutes*60hour=hours*3600day=days*86400val=seconds+minute+hour+daytime_alarm=alarm.time.TimeAlarm(monotonic_time=time.monotonic() +val)
print(alarm.wake_alarm)
ifalarm.wake_alarm==None:
# power on tone# simpleioprint("Power on tone")
simpleio.tone(board.A0, 1000, duration=0.5)
# wait for timerprint("Sleeping for", val, "seconds...")
alarm.exit_and_deep_sleep_until_alarms(time_alarm)
else:
whileTrue:
print("Beeping...")
simpleio.tone(board.A0, 1000, duration=1)
time.sleep(1)
I just encounter this issue with PWM based sound after loading alarm.
Additionally, I edited my code.py to no longer use alarm and the problem remained until I power cycled the board. Once I power cycled the board, the PWM sound worked as expected.
dhalbert
changed the title
Alarm and pwmio/simpleio
rp2040 light_sleep did not restore clocks
Jan 30, 2025
CircuitPython version
Code/REPL
Behavior
The code runs through. In the loop, I receive unexpected behavior with my attached piezo beeper not beeping as it should.
Description
With
simpleio
, I will receive a beep from the piezo beeper under#power on tone
. However once alarm is called and woken back up. In the loop I only get the print statement. No tone from the piezo beeper. This persists until the hardware is reset.With
pwmio
, I again receive the beep under#power on tone
at its stated frequency. After alarm, I will receive the print statement in console many times before I hear a tone from the piezo beeper. The tone is not at its stated frequency and is higher pitched. The tone is also on longer than one second. The tone seems to toggle off after the loop has gone around 3 times. Reloading the code in REPL, I do not receive the#power on tone
, I do however eventually get beeping from the loop with the same behavior described. It takes a hardware reset to hear the#power on tone
again.I've tried both circuitpython stable release 8.2.7, and now the alpha 9.x release. Both have the same outcome.
Additional information
No response
The text was updated successfully, but these errors were encountered: