28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
# PyBricks Loader
|
|
# Helper program loaded onto the hub to handle multiple programs to present as much of a SPIKE interface as possible.
|
|
import content
|
|
import pybricks
|
|
|
|
LOADER_MAJOR=1
|
|
LOADER_MINOR=0
|
|
LOADER_PATCH=0
|
|
LOADER_VERSION='1.0.0'
|
|
|
|
COUNTER_TX=0
|
|
COUNTER_RX=0
|
|
|
|
def tx(cmd, data):
|
|
print(f'{COUNTER_TX}:{cmd}:{data}')
|
|
COUNTER_TX += 1
|
|
|
|
# Send message to the host machine, if present, to inform it that PyBricks Loader is present and booted.
|
|
# Example: message 0, pbl 1.0.0, on primehub, 3.2.0b5
|
|
# 0:pyblocks-loader-info:1.0.0|primehub|3.2.0b5
|
|
tx('pyblocks-loader-info', f'{LOADER_MAJOR}.{LOADER_MINOR}.{LOADER_PATCH}|{pybricks.version()[0]}|{pybricks.version()[1]}')
|
|
# Send message to the host machine, if present, to give it information about the current status of PyBlocks.
|
|
# Example: message 1, project loaded, project ID 0, project name Hello, world, 18 scripts loaded
|
|
# 1:pyblocks-project-info:True|0|Hello, world|18
|
|
# or, on first install:
|
|
# 1:pyblocks-project-info:False|None|None|0
|
|
tx('pybricks-project-info', f'{HAS_PROJECT}|{PROJECT_ID}|{PROJECT_NAME}|{SCRIPTS_LOADED}')
|