Micro:bit TinyBit BLE Python Library
Project description
Micro:bit TinyBit BLE Python Library
A Python package to control a custom Robot V2 via Bluetooth Low Energy (BLE) communication. The package provides an API for controlling the robot's movements and LED colors.
Installation
This project uses Poetry for package management. Install Poetry if you haven't already.
To install the package and its dependencies, run:
poetry install
Usage
The example.py script demonstrates how to use the package to control the robot.
from weallcode_robot import Robot
robot = Robot("WAC")
robot.led(255, 0, 0) # Set the LED color to red
robot.move(100, 100) # Move forward
robot.wait(2) # Wait for 2 seconds
robot.move(0, 0) # Stop the robot
robot.move(-100, 100) # Turn the robot
robot.wait(0.25) # Wait for 0.25 seconds
robot.move(100, 100) # Move forward
robot.wait(1) # Wait for 1 second
robot.move(0, 0) # Stop the robot
robot.move(-100, -100) # Move backward
robot.wait(1) # Wait for 1 second
robot.move(0, 0) # Stop the robot
robot.led(0, 0, 0) # Turn off the LED
a = robot.setKeyBinding('a').led(0, 0, 255, 1) # set LED color one button A
w = robot.setKeyBinding('w').move(100, 100) # bind move forward to key W
API
Robot
The Robot class is the main class to control the robot. Instantiate the class with the name of the robot.
robot = Robot("WAC")
Methods
led(red: int, green: int, blue: int, duration: int): Sets the LED color. Values should be integers between 0 and 255.move(left: int, right: int, duration: int): Sets the motor speeds. Values should be integers between -100 and 100.wait(duration: float): Adds a wait command with a given duration in seconds.run(): Executes the commands in the order they were added.
Development
The package includes development dependencies:
black: Code formatterpre-commit: Pre-commit hooks for code formatting and lintingisort: Import sorterruff: Linter
To install the development dependencies, run:
poetry install --extras dev
To run the pre-commit hooks, first install them:
pre-commit install
Then run:
pre-commit run --all-files
Authors
- Blaine Rothrock
- Ali Karbassi
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file weallcode_robot-3.1.4.tar.gz.
File metadata
- Download URL: weallcode_robot-3.1.4.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fe091ede442d798194487fe80f3ec0b76c30966d4ef931689f9e7a1186bffc9
|
|
| MD5 |
570229be57292011fbc5bd648b48fe2c
|
|
| BLAKE2b-256 |
07040501f775af062bd6108286033c4f351a7c5586efd685ffa132cb248b0b09
|
Provenance
The following attestation bundles were made for weallcode_robot-3.1.4.tar.gz:
Publisher:
publish.yml on WeAllCode/tinybit-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
weallcode_robot-3.1.4.tar.gz -
Subject digest:
7fe091ede442d798194487fe80f3ec0b76c30966d4ef931689f9e7a1186bffc9 - Sigstore transparency entry: 157251110
- Sigstore integration time:
-
Permalink:
WeAllCode/tinybit-python@808edee8f75b294c1941e7d34a622b39fc6ebd27 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/WeAllCode
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@808edee8f75b294c1941e7d34a622b39fc6ebd27 -
Trigger Event:
push
-
Statement type:
File details
Details for the file weallcode_robot-3.1.4-py3-none-any.whl.
File metadata
- Download URL: weallcode_robot-3.1.4-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c9c8baf53ba05bd60e826c9f7c314bc3e7331b2dde5124b98c0734f77d3a5c1
|
|
| MD5 |
b18c600effaf2cff4fde7f04aae93669
|
|
| BLAKE2b-256 |
fa5e2d125e5c74eeb3fa892c2c804b8f9ebb71288b116602b6e2dfcbb3f71376
|
Provenance
The following attestation bundles were made for weallcode_robot-3.1.4-py3-none-any.whl:
Publisher:
publish.yml on WeAllCode/tinybit-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
weallcode_robot-3.1.4-py3-none-any.whl -
Subject digest:
6c9c8baf53ba05bd60e826c9f7c314bc3e7331b2dde5124b98c0734f77d3a5c1 - Sigstore transparency entry: 157251111
- Sigstore integration time:
-
Permalink:
WeAllCode/tinybit-python@808edee8f75b294c1941e7d34a622b39fc6ebd27 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/WeAllCode
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@808edee8f75b294c1941e7d34a622b39fc6ebd27 -
Trigger Event:
push
-
Statement type: