Skip to content

Instantly share code, notes, and snippets.

View samneggs's full-sized avatar

Sam samneggs

View GitHub Profile
@samneggs
samneggs / boulderdash.py
Last active May 17, 2025 15:40
Boulder Dash on Pi Pico 2 in MicroPython
# Boulder Dash Pico2
from st7796 import LCD_3inch5
from gfx import Gfx
from machine import Pin, PWM, SPI
from uctypes import addressof
from time import sleep, sleep_ms, ticks_us, ticks_diff, ticks_ms
import gc, array, re, _thread
from random import randint, random
@samneggs
samneggs / led7seg240.py
Created August 2, 2025 17:15
Display number in 'LED 7 segment' format, fast, variable size
# template 240x160 on core 1
from st7796 import LCD_3inch5
from random import randint
from machine import freq, I2C, Pin, mem32
import time, _thread, gc, framebuf , array
from time import sleep_ms, sleep_us
MAXSCREEN_X = const(240)
MAXSCREEN_Y = const(160)
SHOWING = const(0)
@samneggs
samneggs / bytecode.txt
Last active September 2, 2025 04:53
Robot War on Pi Pico 2 in MicroPython
================================================================================
ROBOT CODE DEBUG - 32-bit Opcode Format
================================================================================
Robot: ROBOT1
Active: True
--------------------------------------------------------------------------------
1: ; SAMPLE ROBOT 'SCANNER' ; (comment/empty)
2: ]START ; LABEL -> addr 0
3: ] DAMAGE TO D ; [ 0] MOV op1: 4 REG op2: 30 imm: 0
4: ]SCAN ; LABEL -> addr 1
@samneggs
samneggs / StarRaiders.py
Created October 21, 2025 14:55
Star Raiders on Pi Pico 2 in MicroPython
# Star Raiders 240x160 on core 1
from st7796 import LCD_3inch5
from gt911 import GT911
from random import randint
from machine import freq, I2C, Pin
import time, _thread, gc, framebuf , array, math, sys
from time import sleep_ms, sleep_us
from math import sin, cos, radians
from draw_number import Draw_number
from joystick import Joystick
@samneggs
samneggs / pacman.py
Created December 15, 2025 00:32
Pac-Man on Pi Pico2 in MicroPython
# Pac Man v14 240x160 on core 1
import sys
sys.path.append("/pacman")
from st7796_240 import LCD_3inch5
from random import randint
from machine import freq, I2C, Pin
import time, _thread, gc, framebuf , array
from time import sleep_ms, sleep_us
from draw_number import Draw_number
from wav_lite import PIOPWM
@samneggs
samneggs / StarCastleDVI.py
Created June 11, 2026 15:32
Star Castle with DVI output on Fruit Jam
# Star Castle — DVI port (640×480 BGR233, RP2350 HSTX)
from dvi_rp2_hstx_frame_sync_v2 import DVI_RP2_HSTX
import colors as rv_colors
from gamepadfast import Gamepad
import machine, framebuf
from machine import Pin, PWM
from uctypes import addressof
from time import sleep, ticks_us, ticks_diff, ticks_ms, sleep_ms
import gc, _thread, array
from sys import exit