Adding CircuitPython support for PICO dv

I’ve created a branch of CircuitPython with the board and pin definitions for the Pimoroni PICO dv board.

I’ve built CircuitPython using this update and the DVI output, SD Card and I2S audio all seem to work well.

I’m not sure what Adafruit’s policy will be with respect to adding a “demo base” like this as a board since my update will only work if an RP2040 based board is installed as apposed to something like an ESP32-S2 board with a Pico form factor.

But before I submitted the PR asking Adafruit if this approach was appropriate, I thought I should run it by someone at Pimoroni and see if you had any objections to me submitting the PR or perhaps you would prefer to look over/update my attempt at the PR and submit it yourselves.

Thanks!
RetiredWizard

1 Like

Here is the test script I ran which mounts an SD card from which you can play a .WAV file by entering “/sd/filename.wav” when prompted.

Using the “absolute newest” version of CircuitPython (8.1.0 Beta 1) and the board updates from above plugging in an HDMI monitor results in REPL output being displayed. The board.DISPLAY object can be used normally with the displayio, adafruit_turtle, gifio, etc… libraries.

import board
import bitbangio
import adafruit_sdcard
import digitalio
import storage
import audiocore
import audiobusio
fname = input("Filename:")
spi = bitbangio.SPI(board.SD_SCK,board.SD_MOSI,board.SD_MISO)
cs = digitalio.DigitalInOut(board.SD_CS)
sd = adafruit_sdcard.SDCard(spi,cs)
vfs = storage.VfsFat(sd)
storage.mount(vfs,'/sd')
f = open(fname, "rb")
wav = audiocore.WaveFile(f)
a = audiobusio.I2SOut(board.I2S_BCLK, board.I2S_OUT, board.I2S_WS)
try:
    a.play(wav)
    while a.playing:
        pass
except:
    pass
f.close()
a.deinit()
1 Like

Ooh - the CircuitPython DV stuff looks really cool, looking forward to playing with that.

I’ve dropped you a DM :)

I also have a number of “ready for PR” board definitions for Pimoroni products. Currently for the Badger2040w, the Plasma2040w, InkyFrame 5.7 (WIP).

You can find the UF2 for the Pico DV Base using a Pi Pico on the Circuitpython.org download page now.

It doesn’t work yet with a Pico W but I’m hoping that I’ll work that out eventually as well.

2 Likes

hey! just curious if there has been any work on getting the Pico W working with this?

I just got my Pimoroni Pico DV Demo Base and only have a Pico W on hand and when I loaded up Circuitpython 8.2.0, not getting any response.

I haven’t looked at the problem any further. Trying to build CircuitPython with both the Wifi and DV features enabled ends up using a lot of the memory space and I suspect the problem I was seeing is somehow connected to memory management.

There has been some memory management work done in CP recently so it may be worth trying to rebuild with the latest version but it will be a few days before I’m able to give it a try.

If you load the released UF2 for the Pico dv from circuitpython.org it should work on the Pico W as well as it does on a standard Pico, you obviously won’t have access to any WiFi capabilities.

ahhh – that makes sense about the wifi.

also, tells me I must be bumping up again another issue, since I am getting nothing after loading circuitpython 8.2 for Pimoroni Pico DV Demo Base for Pico Download

it’d be great to get pico W wifi working at some point. but, I guess it would also be possible to use an esp32 co-processor for wifi? would it be possible, with the PICO dv, for the rp2040 to use SPI to communicate with an adafruit airlift type device for wifi?

looking forward to hearing about your adventures in CP memory ;-)

I don’t think a version for the normal Pico will work for the Pico W. E.G. CP for the latter will always try to drive the on-board LED differently than the CP for the normal PIco. And this is for good reason, since the GP is in use for other things.

Regarding a co-processor: I am successfully using an ESP-01S controlled via UART as a co-processor for Wifi. Works like a charm and it is very efficient. But if you need HTTPS, you might be better of with an esp32.

I finally had a chance to build with the latest CP bits and unfortunately the issue appears to be worse, the build with the latest bits doesn’t even start. I’ll have to block off some time to dig into it again.

In the mean time, if you want to play around with a Pico W on the DV Demo Base, in my earlier attempts I did find a messy work around which was to remove the DV initialization during CP startup. This hack still seems to work but that means you need to initialize the output using python code. I’ve uploaded a build with CP 8.2 on my github site here: cp-8.2-PICOdv-w.uf2
and the code to initialize the DV output is:

import displayio
displayio.release_displays()

import board
import picodvi
import framebufferio

w=640
h=480
cd=1

fb = picodvi.Framebuffer(
    width=w, height=h, color_depth=cd,
    clk_dp=board.CKP, clk_dn=board.CKN,
    red_dp=board.D0P, red_dn=board.D0N,
    green_dp=board.D1P, green_dn=board.D1N,
    blue_dp=board.D2P, blue_dn=board.D2N)

display = framebufferio.FramebufferDisplay(fb)

BTW, if you’re interested the original PR for this board is here: PR#7915

1 Like

I just took another look to see what Adafruit was doing with the PiCowbell DVI board and it looks like they are using the standard Pico/Pico W circuitpython builds. So I guess that’s another option, you can just grab the latest build from circuitpython.org and used the GPn pin names for the DVI output.

fb = picodvi.Framebuffer(
    width=w, height=h, color_depth=cd,
    clk_dp=board.GP7, clk_dn=board.GP6,
    red_dp=board.GP9, red_dn=board.GP8,
    green_dp=board.GP11, green_dn=board.GP10,
    blue_dp=board.GP13, blue_dn=board.GP12)

The PiCowbell DVI learning guide should apply to the Pimoroni Pico DV Demo Base pretty well, it just won’t address all the additional features of the Pimoroni board (SD Card, I2C audio, buttons…). Those features should all work though, you just have to use the GPn pin names in your code.

awesome! thanks so much. that all makes perfect sense and is exactly what I need to be able to dig into it.

I have that adafruit board as well, I’m really enjoying all the video DVI video out stuff, it’s really amazing what you and the whole community have done.

thanks again!

It looks like an update to the display system changed how the framebuffer processes the display dimensions. If you’re using CircuitPython 8.2.0 or later you need to set the screen width to 320, height to 240 and the color depth to 8 not the 640,480,1 used in the examples above.

1 Like

I’ve posted a PR to Circuitpython for using the Pico W on the PICO dv Demo Base. It turns out that if WiFi and the DVI output are enabled on the Pico W, there isn’t enough memory remaining to really use the board.

I’ve suggested essentially using the Pico W like a standard Pico (disabling the WiFi) but asked for suggestions from the Circuitpython Devs/Community.

Regardless of what happens with the Pico W version Circuitpython for the dv Demo Base, I did test that loading the current (8.2.4) version of the dv Demo Base firmware for the Pico (no networking) onto the Pico W works fine. You obviously lose any networking capablities and the LED can’t be accessed but all the Pimoroni Pico dv Demo Base features work including the DVI output.

Circuit Python changed how it handled the dimensions and color depth of DVI framebuffers which broke the dv Demo Base firmware for a couple 8.x.x releases before @brandonthetinkerer noticed and reported the problem so be sure you grab at least 8.2.4 from circuitpython.org.

1 Like

I have a pico right, well it isnt working(the sd part)

I just tried with CircuitPython 8.2.9 and 9.0.0 Alpha 6 and was able to mount an SD card fine.

If you’re trying to run the test script listed above (Apr 20, 2023), the CircuitPython I2S pin names were renamed to be more standard. You will need to replace the audiobusio line with the following:

a = audiobusio.I2SOut(board.I2S_I2S_BIT_CLOCK, board.I2S_DATA, board.I2S_WORD_SELECT)

EDIT: Successfully mounting SD cards can depend on the SD card being used. If you’re having trouble try a different card and make sure it’s been formatted FAT16/FAT32.

The I2S pin names have been renamed so the audiobusio line needs to be updated as follows: