Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32-S2 PWMOut Error #3713

Closed
makermelissa opened this issue Nov 18, 2020 · 2 comments
Closed

ESP32-S2 PWMOut Error #3713

makermelissa opened this issue Nov 18, 2020 · 2 comments
Labels
bug circuitpython api espressif applies to multiple Espressif chips
Milestone

Comments

@makermelissa
Copy link
Collaborator

Reported by @jedgarpark. The error comes up after a while of pressing the buttons, but he's not able to figure out if it is some specific pattern. It works fine about 95% of the time. It looks like simpleio attempts to use audiocore if there's a ValueError thrown from pulseio.PWMOut().

Here's the error:

Traceback (most recent call last):
  File "code.py", line 81, in <module>
  File "adafruit_magtag/peripherals.py", line 71, in play_tone
  File "simpleio.py", line 80, in tone
NameError: name 'audiocore' is not defined

Here's the code that triggered it:

import time
import terminalio
from adafruit_magtag.magtag import MagTag
from adafruit_slideshow import PlayBackOrder, SlideShow, PlayBackDirection
​
magtag = MagTag()
​
def blink(color, duration):
    magtag.peripherals.neopixel_disable = False
    magtag.peripherals.neopixels.fill(color)
    time.sleep(duration)
    magtag.peripherals.neopixel_disable = True
​
RED = 0x880000
GREEN = 0x008800
BLUE = 0x000088
YELLOW = 0x884400
CYAN = 0x0088BB
MAGENTA = 0x9900BB
WHITE = 0x888888
​
blink(WHITE, 0.3)
​
# pylint: disable=no-member
magtag.add_text(
    text_font=terminalio.FONT,
    text_position=(
        5,
        (magtag.graphics.display.height // 2) - 1,
    ),
    text_scale=3,
)
magtag.set_text("MagTag Slideshow")
time.sleep(5)
magtag.add_text(
    text_font=terminalio.FONT,
    text_position=(3,120),
    text_scale=1,
)
magtag.set_text("  back        mute      pause/play     fwd", 1)
time.sleep(8)
​
timestamp = time.monotonic()
sound_toggle = True  # state of sound feedback
autoplay_toggle = True  # state of autoplay
auto_pause = 60  # time between slides in auto mode
​
# Create the slideshow object that plays through alphabetically.
slideshow = SlideShow(
    magtag.graphics.display,
    None,
    auto_advance=autoplay_toggle,
    folder="/slides",
    loop=True,
    order=PlayBackOrder.ALPHABETICAL,
    dwell=auto_pause
)
​
while True:
    slideshow.update()
    if magtag.peripherals.button_a_pressed:
        if sound_toggle:
            magtag.peripherals.play_tone(220, 0.15)
        blink(YELLOW, 0.4)
        slideshow.direction = PlayBackDirection.BACKWARD
        time.sleep(5)
        slideshow.advance()
​
    if magtag.peripherals.button_b_pressed:
        if not sound_toggle:
            magtag.peripherals.play_tone(660, 0.15)
            blink(CYAN, 0.4)
            sound_toggle = True
        else:
            blink(MAGENTA, 0.4)
            sound_toggle = False
​
    if magtag.peripherals.button_c_pressed:
        if not autoplay_toggle:
            if sound_toggle:
                magtag.peripherals.play_tone(440, 0.15)
            blink(GREEN, 0.4)
            autoplay_toggle = True
            slideshow.direction = PlayBackDirection.FORWARD
            slideshow.auto_advance = True
        else:
            if sound_toggle:
                magtag.peripherals.play_tone(110, 0.15)
            blink(RED, 0.4)
            autoplay_toggle = False
            slideshow.auto_advance = False
​
    if magtag.peripherals.button_d_pressed:
        if sound_toggle:
            magtag.peripherals.play_tone(880, 0.15)
        blink(BLUE, 0.4)
        slideshow.direction = PlayBackDirection.FORWARD
        time.sleep(5)
        slideshow.advance()
​
    time.sleep(0.01)
@tannewt tannewt added bug circuitpython api espressif applies to multiple Espressif chips labels Nov 18, 2020
@tannewt tannewt added this to the 6.x.x - Bug Fixes milestone Nov 18, 2020
@tannewt
Copy link
Member

tannewt commented Nov 18, 2020

This could be caused by filesystem corruption.

@jepler
Copy link
Member

jepler commented Jul 15, 2021

Presuambly closed by #4999.

@jepler jepler closed this as completed Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug circuitpython api espressif applies to multiple Espressif chips
Projects
None yet
Development

No branches or pull requests

4 participants