Comments (4)
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.
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.
Hopefully this lastest commit bafeb0e makes the pin assignments more obvious.
from micropython-i2s-examples.
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)
- Support for int. ADC via I2S ? HOT 2
- Examples broken under esp-idf V4.4 HOT 4
- Add support for stm32 H7 series boards HOT 2
- RP2040 + ICS-43432 issue HOT 9
- Possible to play multiple .wav's simultaneously? HOT 5
- What triggers the callback, etc.? HOT 1
- "ValueError: music-16k-16bits-stereo.wav: not found"
- Sd library HOT 3
- stereo on rp2040 using I2S PCM5102 Stereo DAC Decoder HOT 6
- Shift before writing to speaker HOT 2
- play the Audio file from a URL HOT 4
- Support PCM5100A ? HOT 5
- ESP32 with 32bitdepth not working
- no change on INMP441 microphone result HOT 8
- What license does this project use? HOT 2
- examples doesnt work with PCM5102A.
- Having trouble porting play_tone.py to non-blocking HOT 3
- can i control volume on max98357a?
- INMP441 sound quality issue with Pico.
- Gain Factor on wav file in wavplayer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropython-i2s-examples.