Giter Club home page Giter Club logo

Comments (4)

miketeachman avatar miketeachman commented on June 3, 2024

That's a good point. I can see how this would be confusing. I can change the scripts to indicate that a port-specific pin designation is needed, for example:

SCK_PIN = <enter SCK pin designation>
WS_PIN = <enter WS pin designation>
SD_PIN = <enter SD pin designation>
I2S_ID =<enter I2S peripheral ID designation>

The scripts could also include comments pointing users to the port-specific pin and ID possibilities, eg:
https://github.com/miketeachman/micropython-i2s-examples#pyboard-gpio-mappings-for-sck-ws-sd

What do you think would work best to lead new users down the right path?

from micropython-i2s-examples.

peterhinch avatar peterhinch commented on June 3, 2024

The approach I use is to detect the platform at runtime (as you are doing) and assign appropriate pins accordingly. Then document which platforms work "out of the box" and which pins to use. Crudely (you might want to extend to other platforms):

_stm = True
if uos.uname().machine.find("PYBv1") == 0:
    pass
elif uos.uname().machine.find("PYBD") == 0:
    import pyb
    pyb.Pin("EN_3V3").on()  # provide 3.3V on 3V3 output pin
elif uos.uname().machine.find("ESP32") == 0:
    _stm = False
else:
    print("Warning: program not tested with this board")  # +stm = ???

# ======= AUDIO CONFIGURATION =======
WAV_FILE = "side-to-side-8k-16bits-stereo.wav"
WAV_SAMPLE_SIZE_IN_BITS = 16
FORMAT = I2S.STEREO
SAMPLE_RATE_IN_HZ = 8000
# ======= AUDIO CONFIGURATION =======

# ======= I2S CONFIGURATION =======
if _stm:
    SCK_PIN = "Y9"
    WS_PIN = "Y4"
    SD_PIN = "X22"
else:
    SCK_PIN = 33
    WS_PIN = 25
    SD_PIN = 32
I2S_ID = 1

from micropython-i2s-examples.

miketeachman avatar miketeachman commented on June 3, 2024

Hopefully this lastest commit bafeb0e makes the pin assignments more obvious.

from micropython-i2s-examples.

peterhinch avatar peterhinch commented on June 3, 2024

Great improvement, and to the docs. Easily run demos will save you a lot of hassle in the future :)

from micropython-i2s-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.