Skip to main content

BLE interface for running Micropython on LEGO SPIKE devices

Project description

spikeble logo

(pronounced "spike-able")
Lego Spike

Installation

From PyPI:

pip install spikeble

From GitHub:

pip install git+https://github.com/MGross21/spikeble.git

⚠️ Warning:
It is highly recommended to install and use this library within a Python virtual environment. Installing spikeble will expose all MicroPython modules (such as app, color, color_matrix, color_sensor, device, distance_sensor, force_sensor, hub, motor, motor_pair, orientation, and runloop) as direct imports in your environment. Using a virtual environment prevents conflicts with other Python projects and keeps your global Python installation clean.

Making a Python Virtual Environment
python -m venv .venv

# Activate the virtual environment
# On Windows:
venv\Scripts\activate

# On macOS/Linux:
source venv/bin/activate

Once activated, you can install spikeble and other dependencies.

Running Code on SPIKE

To enable auto-complete for MicroPython APIs, place all MicroPython imports inside your main() function.
Use the template below as a starting point for your SPIKE code:

import spikeble
import asyncio

def main():
    # from app import sound, bargraph, display, linegraph, music
    import color
    import color_matrix
    import color_sensor
    import device
    import distance_sensor
    import force_sensor
    from hub import port, button, light, light_matrix, motion_sensor, sound
    import motor
    import motor_pair
    import orientation
    import runloop

    ### Insert Your Code Here ###

if __name__ == "__main__":
    asyncio.run(spikeble.run(main))

Note:
As of SPIKE™ Firmware v1.8.149 and RPC v1.0.47, using import app or from app import ... will result in an import error. The app module is currently disabled until further notice.

Other Send Methods

You can also run code on the SPIKE using the following methods:

spikeble.run_file("path/to/your_script.py")
spikeble.run_str("print('Hello from SPIKE!')")

Documentation

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

spikeble-0.1.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spikeble-0.1-py3-none-any.whl (47.1 kB view details)

Uploaded Python 3

File details

Details for the file spikeble-0.1.tar.gz.

File metadata

  • Download URL: spikeble-0.1.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for spikeble-0.1.tar.gz
Algorithm Hash digest
SHA256 dc1c0ff5b889b2587a4120fb93204d03f7f462a66c649782a83f745281ac1004
MD5 ead95e6846c0463e0a54ab8b909778d1
BLAKE2b-256 afc54169d4edcee79450271428467e38145e6d1fe155fccd641d198234817680

See more details on using hashes here.

File details

Details for the file spikeble-0.1-py3-none-any.whl.

File metadata

  • Download URL: spikeble-0.1-py3-none-any.whl
  • Upload date:
  • Size: 47.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for spikeble-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1011b8c0f9769e05e2b9b3e8ae767f6a3bef31087a0a576ba7e2847941cdf08
MD5 ab8ab42557232f89f63799094335a760
BLAKE2b-256 b38fcb35492a276901a13fbdfa0444018a0055dbd5e543f93371d4573bf4ad1c

See more details on using hashes here.

Supported by

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