Skip to content

Instantly share code, notes, and snippets.

View samneggs's full-sized avatar

Sam samneggs

View GitHub Profile
@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 / 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 / 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 / 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 / st7796.py
Created November 29, 2024 20:55
Pi Pico 2 st7796 double buffer, double pixel display driver
from machine import Pin,SPI,PWM, freq, I2C
import framebuf
import time
from time import sleep_ms
import os
'''
GP2 CLK
GP3 DIN
GP5 CS x
@samneggs
samneggs / Julia2350.py
Created September 14, 2024 06:34
Mandelbrot, Julia and Metaballs Assembly Routines for the RP2350
# template
from lcd_1_8 import LCD_1inch8
import machine, math
from machine import Pin, PWM, SPI
from uctypes import addressof
from time import sleep, ticks_us, ticks_diff, ticks_ms
import gc, _thread, array
from micropython import const
from random import randint
from math import sin,cos,tan,radians,sqrt
@samneggs
samneggs / minesweeper.py
Created April 20, 2024 04:20
Minesweeper Game in MicroPython on Pi Pico
# minesweeper
from lcd_1_8 import LCD_1inch8
import machine
from machine import Pin, PWM
from time import sleep, ticks_us, ticks_diff, ticks_ms
import gc, array
from sys import exit
from micropython import const
from random import randint
@samneggs
samneggs / bubble_darts.py
Created April 20, 2024 04:08
Balloon Pop Game in MicroPython on Pi Pico
# Bubble Darts
from lcd_1_8 import LCD_1inch8
import machine
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
from micropython import const
from random import randint
@samneggs
samneggs / snake_asm.py
Created April 20, 2024 03:36
Classic Snake Game In Assembly on Pi Pico
# snake_asm
from lcd_1_8 import LCD_1inch8
import machine, math
from machine import Pin, PWM
from uctypes import addressof
from time import sleep, ticks_us, ticks_diff, ticks_ms
import gc, _thread, array
from sys import exit
from micropython import const
from random import randint
@samneggs
samneggs / Space Invaders for Pico2.py
Last active October 29, 2025 08:59
Space Invaders game on Pi Pico in MicroPython
# Space Invaders
from lcd_1_8 import LCD_1inch8
import machine
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
from micropython import const
from random import randint