Hello,
I wanted to test cursors AI capabilities and I’m a bit disappointed. Here is what I tried. I coded a pong game for my Raspberry Pi Pico W a while ago and recently successfully the following Pico Mac project from Github: https://github.com/evansm7/pico-mac.
Now I have a VGA cable hard wired to my Pico W and I wanted to use this setup to run my pong game on an external VGA monitor. So I needed the appropriate MicroPython code for this. The approach of the Pico Mac team to connect a VGA cable to the Pico is not the recommended way of the Raspberry Pi Foundation. So I needed some help from the cursor AI
I chose the Claude 3.5 model (free account) and I described in detail what I wanted. I made clear that the hardware is ready to go and I just need the suitable code from the Pico Mac project to be transferred from C to MicroPython. But even after hours of try and error I got absolutely no VGA signal from the Pico to my monitor.
So either I’m expecting to much from the AI model, or I’m doing something totally wrong or it has something to do with the free cursor account. Can anyone please give me a hint what I can do?
Here is the VGA test code the model generated for me (just in case that someone is able to see if this has the chance to run successfully on boot (saved as main.py) on the Pi Pico W).
from machine import Pin
import rp2
import array
# VGA timing constants for 640x480@60Hz
H_ACTIVE = 640
V_ACTIVE = 480
H_FRONT_PORCH = 16
H_SYNC = 96
H_BACK_PORCH = 48
V_FRONT_PORCH = 10
V_SYNC = 2
V_BACK_PORCH = 33
@rp2.asm_pio(
out_init=rp2.PIO.OUT_LOW,
sideset_init=(rp2.PIO.OUT_HIGH,) * 2,
autopull=True,
pull_thresh=32,
fifo_join=rp2.PIO.JOIN_TX
)
def vga_program():
# Active video area
pull(block) .side(0b11)
out(x, 32) .side(0b11)
pull(block) .side(0b11)
label("active")
out(pins, 1) .side(0b11)
jmp(x_dec, "active") .side(0b11)
# Horizontal sync
nop() .side(0b11) # Front porch
nop() .side(0b01) # HSYNC pulse
nop() .side(0b11) # Back porch
# Create a simple test pattern (white screen)
line_words = H_ACTIVE // 32
test_line = array.array('I', [0xFFFFFFFF] * line_words)
# Initialize pins
video_pin = Pin(18, Pin.OUT) # GPIO18 -> Physical Pin 24
vsync_pin = Pin(19, Pin.OUT) # GPIO19 -> Physical Pin 25
hsync_pin = Pin(21, Pin.OUT) # GPIO21 -> Physical Pin 27
# Initialize state machine
sm = rp2.StateMachine(
0,
vga_program,
freq=25_175_000, # VGA pixel clock
sideset_base=Pin(19),
out_base=Pin(18),
set_base=Pin(21)
)
print("Starting VGA output...")
sm.active(1)
# Main loop with VSYNC handling
vsync_counter = 0
try:
while True:
# Output one complete frame
for line in range(V_ACTIVE):
# Send line data
for word in test_line:
sm.put(word)
# Handle VSYNC
vsync_counter += 1
if vsync_counter >= V_ACTIVE + V_FRONT_PORCH + V_SYNC + V_BACK_PORCH:
vsync_counter = 0
# Set VSYNC signal
if V_ACTIVE + V_FRONT_PORCH <= vsync_counter < V_ACTIVE + V_FRONT_PORCH + V_SYNC:
vsync_pin.value(0) # VSYNC active (low)
else:
vsync_pin.value(1) # VSYNC inactive (high)
except KeyboardInterrupt:
sm.active(0)
print("Stopped")