diff --git a/frontend/src/__tests__/examples-pico-doom.test.ts b/frontend/src/__tests__/examples-pico-doom.test.ts index ea67a671..9fd78f23 100644 --- a/frontend/src/__tests__/examples-pico-doom.test.ts +++ b/frontend/src/__tests__/examples-pico-doom.test.ts @@ -71,18 +71,25 @@ describe('pico-doom-raycaster example', () => { expect(offenders).toEqual([]); }); - it('SPI wires connect the Pico GP18/GP19/GP17/GP20/GP21/GP22 to the ILI9341 pins the sketch expects', () => { + it('SPI + control + power wires connect Pico → ILI9341 with the pinout the sketch + hardware expect', () => { const e = findExample()!; - // (pico-pin, ili9341-pin) pairs the sketch hard-codes. If any of these - // get re-routed in the example, the sketch's #define block has to - // match — fail loud here so the mismatch can't slip into prod. + // (pico-pin, ili9341-pin) pairs. Everything except GP16↔MISO comes + // from the sketch's #define block. GP16↔MISO is hardware SPI0's + // MISO line — the 3-arg Adafruit_ILI9341(CS, DC, RST) constructor + // selects hardware SPI0, so this pin is fixed even though the + // driver never reads back. If any pair gets re-routed in the + // example, the sketch + this list have to move together — fail + // loud here so the mismatch can't slip into prod. const expected: Array<[string, string]> = [ - ['GP18', 'SCK'], - ['GP19', 'MOSI'], - ['GP17', 'CS'], - ['GP20', 'D/C'], - ['GP21', 'RST'], - ['GP22', 'LED'], + ['3V3', 'VCC'], + ['GND.5', 'GND'], + ['GP18', 'SCK'], + ['GP19', 'MOSI'], + ['GP16', 'MISO'], + ['GP17', 'CS'], + ['GP20', 'D/C'], + ['GP21', 'RST'], + ['GP22', 'LED'], ]; for (const [picoPin, tftPin] of expected) { const match = e.wires.find( diff --git a/frontend/src/data/examples.ts b/frontend/src/data/examples.ts index 6496f260..914ef626 100644 --- a/frontend/src/data/examples.ts +++ b/frontend/src/data/examples.ts @@ -956,9 +956,17 @@ void loop() { { type: 'wokwi-pushbutton', id: 'btn-right', x: 310, y: 470, properties: { color: 'green', label: 'RIGHT' } }, ], wires: [ - // SPI bus + control lines to the ILI9341 + // Power + { id: 'w-tft-vcc', start: { componentId: 'raspberry-pi-pico', pinName: '3V3' }, end: { componentId: 'tft1', pinName: 'VCC' }, color: '#ff0000' }, + { id: 'w-tft-gnd', start: { componentId: 'raspberry-pi-pico', pinName: 'GND.5' }, end: { componentId: 'tft1', pinName: 'GND' }, color: '#000000' }, + // SPI bus + control lines to the ILI9341. MISO is GP16 — the + // sketch's 3-arg Adafruit_ILI9341(CS, DC, RST) constructor uses + // hardware SPI0, whose MISO pin is GP16. The driver writes only + // (no register reads), so MISO is electrically idle, but the + // wire is included so the circuit is didactically complete. { id: 'w-tft-sck', start: { componentId: 'raspberry-pi-pico', pinName: 'GP18' }, end: { componentId: 'tft1', pinName: 'SCK' }, color: '#ff8800' }, { id: 'w-tft-mosi', start: { componentId: 'raspberry-pi-pico', pinName: 'GP19' }, end: { componentId: 'tft1', pinName: 'MOSI' }, color: '#ff8800' }, + { id: 'w-tft-miso', start: { componentId: 'raspberry-pi-pico', pinName: 'GP16' }, end: { componentId: 'tft1', pinName: 'MISO' }, color: '#ffaa44' }, { id: 'w-tft-cs', start: { componentId: 'raspberry-pi-pico', pinName: 'GP17' }, end: { componentId: 'tft1', pinName: 'CS' }, color: '#00aaff' }, { id: 'w-tft-dc', start: { componentId: 'raspberry-pi-pico', pinName: 'GP20' }, end: { componentId: 'tft1', pinName: 'D/C' }, color: '#00cc00' }, { id: 'w-tft-rst', start: { componentId: 'raspberry-pi-pico', pinName: 'GP21' }, end: { componentId: 'tft1', pinName: 'RST' }, color: '#cc0000' },