Adafruit QT Py RP2040 (ADA4900)

@Michael I’m redirecting to this thread. :slight_smile:
Linking from the below because this isn’t really relevant to that guide any more.

My build chain

Here is the guide I’m following.

https://git.emacinc.com/micropython-public/micropython-i2s-examples/-/blob/emac-support/examples/easy_wav_player.py

I have had to swap to a different SD card library since the code above no longer works.

Here is the wrapper around the guide above.

### THIS NEEDS TO BE A CLASS

from wavplayer import WavPlayer
import os
from machine import Pin, SPI, I2S
import sdcard

def play():
    wp.play("hello.wav", loop=True)
    return is_playing()

def pause():
    wp.pause()
    
def resume():
    wp.resume()
    
def is_playing():
    return wp.isplaying()
    
    
# ======= SD CARD CONFIGURATION =======
#sd = SDCard(slot=1, sck=Pin(6), mosi=Pin(3), miso=Pin(4), cs=Pin(29))
sd_pin = Pin(29)
sd_spi = SPI(0)
sd = sdcard.SDCard(sd_spi, sd_pin)
os.mount(sd, "/sd")

# Read files from SD card
print("my list:")
for filename in os.listdir("/sd"):
    print(filename)

# Init Audio
'''
    A1 - This is used for audio data, or DAT.
    A2 - This is used for wordselect clock, or LR.
    A3 - This is used for bitclock, or BCLK.
'''
audio_clk_pin = Pin(26)
audio_word_pin = Pin(27)
audio_data_pin = Pin(28)

#Construct the wp
wp = WavPlayer(id=0, sck_pin=Pin(audio_clk_pin), ws_pin=Pin(audio_word_pin), sd_pin=Pin(audio_data_pin), ibuf=44100)

Here is the offending code.

play() #<----
while is_playing():
    if button.is_pressed:
        pause()

Goal

It’s all feeling like I’m on the wrong path entirely in terms of my build chain.
I will entertaining loading from SD onto flash first and reading from flash. :slight_smile:
Nothing here is real time. 99% of the time this chip will be idle so I have plenty of time of read-write blocking code.

Thanks.
Pix :heavy_heart_exclamation:

1 Like