{"id":14967309,"url":"https://github.com/3110/uiflow-custom-block-generator","last_synced_at":"2025-10-25T19:30:50.733Z","repository":{"id":37020320,"uuid":"458707504","full_name":"3110/uiflow-custom-block-generator","owner":"3110","description":"Translating a custom block file(the M5B flie) for UIFlow from/to the JSON file and MicroPython files","archived":false,"fork":false,"pushed_at":"2023-09-02T18:55:54.000Z","size":54,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-01T05:13:33.931Z","etag":null,"topics":["m5stack","micropython","python","uiflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/3110.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-13T04:20:09.000Z","updated_at":"2024-08-08T04:47:18.000Z","dependencies_parsed_at":"2024-09-14T04:02:28.942Z","dependency_job_id":null,"html_url":"https://github.com/3110/uiflow-custom-block-generator","commit_stats":{"total_commits":43,"total_committers":1,"mean_commits":43.0,"dds":0.0,"last_synced_commit":"50bb1e2802ad23278b541bc56c840042ac9d1a4a"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3110%2Fuiflow-custom-block-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3110%2Fuiflow-custom-block-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3110%2Fuiflow-custom-block-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3110%2Fuiflow-custom-block-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3110","download_url":"https://codeload.github.com/3110/uiflow-custom-block-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219865145,"owners_count":16555931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["m5stack","micropython","python","uiflow"],"created_at":"2024-09-24T13:37:49.654Z","updated_at":"2025-10-25T19:30:50.726Z","avatar_url":"https://github.com/3110.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[日本語版](README_ja_JP.md)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://speakerdeck.com/3110/atom-babiestouiflow-custom-block-generatortosi\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://files.speakerdeck.com/presentations/ef509fde25924b86b992a7a947861d0c/slide_0.jpg\" alt=\"ATOM BabiesとUIFlow Custom Block Generatorと私\" width=\"600\"/\u003e\u003c/a\u003e\n  \u003cbr\u003e\n  \u003ccaption\u003e\"ATOM Babies, UIFlow Custom Block Generator, and Me\" (In Japanese)\u003cbr\u003e(My Lightning Talk at \u003ca href=\"https://m5stack.connpass.com/event/297120/\"\u003eM5 Japan Tour 2023 Autumn Tokyo\u003c/a\u003e)\u003c/caption\u003e\n  \u003c/p\u003e\n\n# Generating a custom block file for [UIFlow](https://flow.m5stack.com)\n\nThis script generates a custom block file(the M5B file) from a JSON file for setting custom blocks, and [MicroPython](https://micropython.org/) files defined codes for custom blocks.\n\nYou can also generate the JSON and MicroPython files from an existing M5B file.\n\n## Installation\n\nI have developed and tested this script using VS Code, Git Bash, and Python v3.10.4 on the Windows 11 environment.\n\nTo install this script, execute the following:\n\n```bash\npip install git+https://github.com/3110/uiflow-custom-block-generator\n```\n\n## Setting Custom Blocks\n\nThe structure of the JSON file for setting custom blocks is the following:\n\n```json\n{\n  \"category\": \"ATOM_Babies\",\n  \"color\": \"#115f07\",\n  \"blocks\": [\n    {\n      \"name\": \"init_atom_babies\",\n      \"type\": \"execute\",\n      \"params\": [\n        { \"name\": \"Initialize ATOM Babies\", \"type\": \"label\" },\n        { \"name\": \"_eye_color\", \"type\": \"variable\" },\n        { \"name\": \"_cheek_color\", \"type\": \"variable\" },\n        { \"name\": \"_background_color\", \"type\": \"variable\" }\n      ]\n    },\n    {\n      \"name\": \"rgb\",\n      \"type\": \"value\",\n      \"params\": [\n        { \"name\": \"Specify the color\", \"type\": \"label\" },\n        { \"name\": \"_r\", \"type\": \"number\" },\n        { \"name\": \"_g\", \"type\": \"number\" },\n        { \"name\": \"_b\", \"type\": \"number\" }\n      ]\n    }\n  ]\n}\n```\n\n- `category`: Same as Namespace on the [UIFlow Block Maker](http://block-maker.m5stack.com/).\n- `color`: Specify the color of custom blocks with `#RRGGBB`.\n- `blocks`: Define custom blocks. They are arranged in the order in which they appear here.\n\nTo define custom blocks, specify the following items in `blocks`:\n\n- `name`: Filename of MicroPython codes for the custom block. The setting `\"name\": \"rgb\"` means `rgb.py` is read from the same directory as the JSON file.\n- `type`: Type of the custom block. You can specify the two types of blocks: `value`(the block returns a value) and `execute`(the block does not return any value).\n- `params`: Arguments for the custom block. They are arranged in the order in witch they appear here.\n\nTo define arguments of the custom block, specify the following items in `params`.\n\n- `name`: The name of the argument. If `type` is `label`, this is the label shown on the block.\n- `type`: The type of the argument. There are four types:\n  - `label`: The label displayed on the block. Multiple specifications are allowed.\n  - `string`: String.\n  - `number`: Number.\n  - `variable`: Variable.\n\nPlease refer to `examples/atom_babies` for the sample.\n\n## Execution\n\n### Generating the M5B file from the JSON file and MicroPython files\n\nTo generate `atom_babies.m5b` on the same directory as the JSON file, execute the following:\n\n```bash\npython -m uiflow_custom_block_generator examples/atom_babies/atom_babies.json\n```\n\nYou can specify `--target_dir`(`-t`) option to change the output directory of the M5B file.\n\nFor example, `atom_babies.m5b` is generated on the current directory if you execute the following:\n\n```bash\npython -m uiflow_custom_block_generator examples/atom_babies/atom_babies.json -t .\n```\n\n**Caution**: [UIFlow Block Maker](http://block-maker.m5stack.com/) cannot read the M5B file generated from this script.\n\n### Generating the JSON file and MicroPython files from the M5B file\n\nThe following command creates the `atom_babies` directory in the same directory as the M5B file and generates `atom_babies.json` and the MicroPython files in the `atom_babies` directory.\n\n```bash\npython -m uiflow_custom_block_generator example/atom_babies/atom_babies.m5b\n```\n\nYou can specify `--target_dir`(`-t`) option to change the output directory of the JSON file and MicroPython files. The following command creates `atom_babies` directory in the current directory.\n\n```bash\npython -m uiflow_custom_block_generator examples/atom_babies/atom_babies.m5b -t .\n```\n\n## Notes on VS Code\n\n- Because Flake8 detects Invalid Syntax(E999) for `${}`(the reference to the argument of the custom block), the setting in `.vscode/settings.json` suppresses E999.\n- If you use `rgb` modules in the custom block codes, you have to specify `# type: ignore # noqa: F821` to ignore undefined name errors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3110%2Fuiflow-custom-block-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3110%2Fuiflow-custom-block-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3110%2Fuiflow-custom-block-generator/lists"}