Table of Contents

Pickle Ball Scoreboard

To do

IR imports

from ir_rx import IR_RX
from nec import NEC_8
import print_error
#from ir_rx.print_error import print_error
#from ir_rx.nec import NEC_8  # Adjust based on your remote's protocol

Wires

2026 03 24

2026 03 21

2025 03 20

2026 03 19

2026 03 18

2026 03 17

2026 03 16

2026 03 15

2026 03 14

# xy conversion for the -right- matrix
def xy_to_index(x, y):
    """Top-left origin + reversed serpentine zigzag
    - Even rows (y even): right-to-left (x=15 to x=0)
    - Odd rows (y odd): left-to-right (x=0 to x=15)
    """
    if y % 2 == 0:          # ← Changed: even rows reverse
        x = 15 - x
    return y * 16 + x

2026 03 13

# works - does a soft reboot
        if  button == "menu":
            machine.reset()

2026 03 12

2026 03 10

2026 03 07

2026 03 05

2026 03 04

2026 03 03

xy_to_index(x, y)

def xy_to_index(x, y):
    """Top-left origin + reversed serpentine zigzag
    - Even rows (y even): right-to-left (x=15 to x=0)
    - Odd rows (y odd): left-to-right (x=0 to x=15)
    """
    if y % 2 == 0:          # ← Changed: even rows reverse
        x = 15 - x
    return y * 16 + x

wire gauge

Yes, 0.75 mm is a real and very common wire size — it refers to the cross-sectional area 
of the conductor in square millimeters (mm²), which is the standard way wire is specified 
in most of the world (especially Europe, Asia, and metric countries).Quick conversion & 
context0.75 mm² ≈ AWG 18 (very close)  Exact AWG 18 = 0.823 mm²  
0.75 mm² is slightly thinner but commonly grouped with AWG 18 in practice

Typical current rating (for low-voltage DC like your 5 V LED project):~6–10 A (depending 
on insulation, temperature, length, and safety margin)
Safe for most hobby LED matrix projects (your two 16×16 WS2812B panels likely draw 5–12 A 
max at full brightness)

Common uses of 0.75 mm² wirePower distribution in low-voltage DC projects (5 V, 12 V, 24 V)
LED strip power injection (common in WS2812B setups)
Automotive and marine wiring (12 V accessories)
Household low-power lighting (e.g. LED downlights, 230 V but low amps)
Speaker wire (short runs, 8–16 ohm)

Comparison to other common sizes
**Wire size    Cross-section    Closest AWG     Typical max current (5 V DC)    Usage**
0.3 mm²          0.3 mm²         AWG 22          ~3–5 A                    Signal/data lines only
0.75 mm²         0.75 mm²        AWG 18          ~6–10 A                   Good for power to matrices
1.0–1.5 mm²      1.0–1.5 mm²     AWG 16–14       ~10–15 A+                 High current / long runs
2.5 mm²          2.5 mm²         AWG 12          20 A+                     Heavy power injection

Recommendation for your LED matrices projectUse 0.75 mm² wire for:5 V power wires 
from Baseus bank to power distribution point
Power injection wires to matrices (middle and end of strips)

Use thicker (1.0–1.5 mm² / AWG 16–14) if:Runs > 1–2 meters
Full brightness on all LEDs at once (>10 A draw)

Use thinner (0.3–0.5 mm² / AWG 22–20) for:Data lines (GP16/GP17 to matrix DIN)
IR receiver wiring

Color coding tip (very common convention):Red = +5 V
Black = GND
Green/Yellow = data (WS2812B DIN)
Other colors = signals, control lines

So yes — 0.75 mm (meaning 0.75 mm²) is a standard and very useful wire gauge/size 
for your project. It's widely available and called "0.75 mm² hookup wire" or "0.75 mm² 
flexible cable" when shopping.Let me know if you're asking about a specific wire you 
have (photo/link?) or what part of the project you're wiring — I can recommend exact 
lengths/colors/gauge! 

clear() and show()

From Grok: Yes, that's correct — in the code structure we've been using, the clear() and show() functions work together in exactly the way you described.Here's a precise breakdown of what each does:clear()python

def clear():
    for i in range(NUM_LEDS):
        leds[i] = 0

What it does:
It resets the software buffer (leds array) by setting every LED's 
color value to 0 (black/off).
→ This is just changing values in memory (the Python array leds).
→ Nothing is sent to the LEDs yet — the physical matrix stays unchanged 
until you call show().
Purpose: Prepares a "blank" state before drawing new content (prevents 
old pixels from remaining lit).

show()python

def show():
    dimmed = array.array("I", [0] * NUM_LEDS)
    for i, color in enumerate(leds):
        r = int(((color >>  8) & 0xFF) * BRIGHTNESS)
        g = int(((color >> 16) & 0xFF) * BRIGHTNESS)
        b = int( (color       & 0xFF) * BRIGHTNESS)
        dimmed[i] = (g << 16) + (r << 8) + b
    sm.put(dimmed, 8)
    time.sleep_ms(10)

What it does:  Takes the current values from the software buffer (leds).  
Applies brightness scaling (creates a temporary dimmed array).  
Sends the final color data to the PIO state machine via sm.put(...).  
The PIO hardware then sends the WS2812B protocol bitstream to the 
matrix → the physical LEDs update.

Key point:
show() is the only function that actually transfers data from the 
buffer to the LEDs.
Any change to leds (clearing, setting pixels, drawing digits, etc.) 
is invisible until show() is called.

Summary – Correct SequenceModify the buffer (leds array):  clear() → sets all to 0  
set_pixel(), draw_digit(), set_bottom_stripe(), etc. → sets desired colors

Call show() → sends the buffer to the state machine → LEDs update on the matrix

So yes:
clear() prepares the state in memory → show() displays it on the hardware.
If you ever change the LEDs but forget to call show(), nothing visible 
happens — that's a very common debugging gotcha.Let me know if you want 
to add auto-refresh (e.g., call show() inside every drawing function) or any other tweaks! 

PIO State Machine

PIO (Programmable I/O) state machines are one of the most powerful and unique 
features of the Raspberry Pi Pico (RP2040 chip). They allow you to create 
custom, high-performance peripherals in hardware, running independently of 
the CPU.Here’s a clear, practical explanation of what PIO state machines are, 
how they work, and why they’re used (especially for WS2812B/NeoPixel LEDs in 
your project).What is a PIO State Machine?A PIO state machine is a small, 
programmable processor inside the RP2040 chip. Each state machine can:Run its 
own tiny program (up to 32 instructions)
Execute instructions in parallel with the CPU
Interact directly with GPIO pins
Transfer data to/from memory via DMA (Direct Memory Access)
Run at system clock speed (up to 133 MHz)

The RP2040 has 8 PIO state machines (divided into two PIO blocks of 4 each), 
so you can run up to 8 independent custom peripherals at once.Why PIO is 
Perfect for WS2812B LEDsWS2812B LEDs require a very precise, high-speed serial 
protocol:Each bit is sent as a pulse: ~0.4 µs high for 0, ~0.8 µs high for 1
24 bits per LED (GRB order)
Strict timing (no CPU interrupts allowed to break the stream)

If you try to bit-bang this in normal Python/MicroPython code, timing glitches 
occur (CPU is too busy).
PIO solves this by running the bit protocol in hardware, with perfect timing, 
while the CPU just prepares data.How a PIO State Machine Works (Simplified)
You write a tiny assembly program (in PIO assembly language) that describes 
the waveform you want.
Example: the WS2812 code you’ve been using:pio

.side_set 1
out x, 1            .side 0   [T3-1]
jmp !x do_zero      .side 1   [T1-1]
jmp bitloop         .side 1   [T2-1]
do_zero:
nop                 .side 0   [T2-1]

This is the “send one bit” loop — high for longer on 1, shorter on 0.
You load the program into one of the 8 state machines:python

sm = rp2.StateMachine(0, ws2812, freq=8000000, sideset_base=Pin(16))
sm.active(1)

0 = state machine number (0–7)
ws2812 = your PIO program
freq=8000000 = clock speed tuned for WS2812 timing
sideset_base=Pin(16) = GPIO pin where the data signal goes

You feed it data:python

sm.put(buffer, 8)   # send 32-bit words, shifted by 8 bits

The state machine automatically turns your color buffer into 
the exact WS2812 pulse train — no CPU involvement.

Main Advantages of PIO for LEDsPerfect timing — no jitter, even if CPU is busy
Very low CPU usage — CPU just prepares data and calls put()
High speed — can drive long chains or multiple strips
Flexible — same PIO hardware can do WS2812, I2S audio, VGA, DVI, SPI, I2C, UART, etc.

Summary – What PIO State Machines AreTiny hardware processors inside the RP2040
Run custom programs you write in PIO assembly
Control GPIO pins with precise timing
Used for WS2812B LEDs because they need exact pulse widths the CPU can’t reliably produce
Your code uses one state machine (sm = StateMachine(0, ...)) to drive the matrix

If you want:Code to drive two matrices with two state machines (one per panel)
Explanation of any line in the PIO assembly
How to add IR control or other effects using PIO

2026 03 01