npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

blocklypy

v0.0.39

Published

Blocklypy: SPIKE to Pybricks - word-block converter to Pybricks python code

Downloads

846

Readme

BlocklyPy

LEGO SPIKE and Mindstorms Code to Pybricks - block-code converter to Pybricks python code

This library will convert the LEGO standard graphical blockly files to Pybricks python files.

SPIKE Prime (45678) and SPIKE Essentials (45345) kit and Robot Inventor (51515) kit for word-blocks and icon-blocks transformation.

  • SPIKE v2 (.llsp) files.
  • SPIKE v3 (.llsp3) files.
  • Robot Inventor files (.lms).

EV3 Mindstorms kit (31313) LabView EV3-G code transformation:

  • EV3Classroom files (.lmsp).
  • EV3 Lab (.ev3) files.
  • EV3 Lab Compiled Binary (.rbf) files.

Usage

const { convertProjectToPython } = require('blocklypy');

const file = fs.readFileSync(__FILE__);

const options = { filename: 'sample.llsp3' };

convertProjectToPython(file, options).then((retval) => {
    console.log(retval.pycode);
});

Result

Type: PyProjectResult

pycode

Type: string

Python representation of the blockly code in Pybricks flavour.

"""
Project:    test1
Slot:       0
Created:    2024-09-02T09:08:14.079Z
Last saved: 2024-09-03T16:57:06.369Z
"""

#region ========================== SECTION: IMPORTS ========================== #
from pybricks.hubs import PrimeHub
from pybricks.tools import wait
#endregion
...
#region ======================= SECTION: PROGRAM CODE ======================== #
# ------------------------------- GROUP: START ------------------------------- #
# STACK #1: flipperevents_whenProgramStarts()
def stack1_whenprogramstarts_fn():
    hub.display.pixel(0, 0, 100)
    hub.display.icon(convert_icon_matrix("9909999099000009000909990", g_pixel_brightness))
    wait(convert_time(g_aa))
    hub.display.off()

#endregion

#region ====================== SECTION: MAIN CODE ============================ #
stack1_whenprogramstarts_fn()
#endregion

plaincode

Type: string

Pseudo code of the blockly code.

flipperevents_whenProgramStarts()
    flipperlight_lightDisplaySetPixel(x: "1", y: "1", brightness: 100)
    flipperlight_lightDisplayImageOnForTime(matrix: "9909999099000009000909990", value: g_aa)

flippermove_movementSpeed(speed: 50)
    flippermove_startMove(direction: "back")

data_setvariableto(value: "0", variable: "aa")

data_changevariableby(value: 13, variable: "aa")

flipperlight_lightDisplayImageOn(matrix: "9909999099000009000909990")

additionalFields

blockly.slot

Type: number

Project slot information of the specified program.

blockly.svg

Type: string

SVG snapshot of the canvas.

<svg
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    version="1.1"
    preserveAspectRatio="xMidYMid meet"
    viewBox="0 0 628 223"><g xmlns="http://www.w3.org/2000/svg" class="blocklyWorkspace" transform="translate(-402.1000061035156,-144.5)"><g class="blocklyBlockCanvas" transform="translate(309.9999999999993,102.99999999999989) scale(0.675)"><g data-id=";KLd5R]$I`vV1#%|zmC(" class="blocklyDraggable" data-shapes="stack" data-category="flippermove" transform="translate(757.1851851851851,270.6666666666666)"><path class="blocklyPath blocklyBlockBackground" stroke="#B2248A" fill="#FF4CCD" fill-opacity="1" d="m 0,4 A 4,4 0 0,1 4,0 H 12 c 2,0 3,1 4,2 l 4,4 c 1,1 2,2 4,2 h 12 c 2,0 3,-1 4,-2 l 4,-4 c 1,-1 2,-2 4,-2 H 305.5812768936157 a 4,4 0 0,1 4,4 v 48  a 4,4 0 0,1 -4,4 H 48   c -2,0 -3,1 -4,2 l -4,4 c -1,1 -2,2 -4,2 h -12 c -2,0 -3,-1 -4,-2 l -4,-4 c -1,-1 -2,-2 -4,-2 H 4 a 4,4 0 0,1 -4,-4 z"/><g transform="translate(8, 12) "><use xlink:href="#23791e70ccbd66ad86ec73ee6ff26211e0bb5feb"/></g>
...