Skip to main content

Simple game framework for CircuitPython embedded hardware

Project description


Simple "game" framework for CircuitPython embedded hardware.


cpgame provides a number of decorators and a simple event loop to provide a responsive framework for building applications and games on embedded hardware using CircuitPython.

Run a function on every "tick" of the event loop:

from cpgame import start, tick

def loop(now):


Blink a Neopixel every second:

def periodic(now):
    pixel[0] = RED if int(now) % 2 else OFF

Turn a Neopixel on and off with a button press:

@on(board.BUTTON_A, DOWN)
def pressed(now):
    pixel[0] = RED

@on(board.BUTTON_A, UP)
def released(now):
    pixel[0] = OFF

Create or reset timers:

def flood(now):
    delay = random.randint(20, 100) / 10  # between 2 and 10 seconds
    after(delay, flood)

def halt(now):

Play sound:

middle_a = sample(440)

def noise(now):
    play_sound(middle_a, 1)


  • Support more boards than Circuit Playground Express.
  • Add helper functions for animating NeoPixels, raw audio clips, and LCD displays.


aiosqlite is copyright John Reese, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cpgame-0.5.tar.gz (4.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page