32blit / 32blit-tools Goto Github PK
View Code? Open in Web Editor NEW32blit asset management and upload tool
Home Page: https://32blit.com/
License: MIT License
32blit asset management and upload tool
Home Page: https://32blit.com/
License: MIT License
The original POC used a structured language to define the metadata format, so it could be parsed in addition to being written - 32blit/32blit-sdk#292
The generated payload size is currently set to the number of bytes in the image, and doesn't include the size of the header and palette data. This means that the Surface::load_packed function misses off the last few bytes of the image.
I've raised an issue rather than fix it because I'm not sure which is the 'right' approach - if the payload size should include everything then we can fix it here, otherwise we'll need to fix it in Surface.
I'm sick of writing 32blit flash flash --file filename.blit
and I think we can hotwire the tool to accept some shorthand arguments and Do The Right Thing. As such 32blit flash filename.blit
should be made to work somehow.
Omitting name from assets results in something like:
extern const uint8_t _home_daftfreak_workspace_32blit_music_player_assets_buttons_png[];
since CMake passes an absolute path to the config file.
Config:
assets.cpp:
assets/*.png:
Don't know if there's a better way of fixing this than duplicating the name generation in the packer like this:
diff --git a/src/ttblit/tool/packer.py b/src/ttblit/tool/packer.py
index 4489ad3..1b2849c 100644
--- a/src/ttblit/tool/packer.py
+++ b/src/ttblit/tool/packer.py
@@ -1,5 +1,6 @@
import logging
import pathlib
+import re
import yaml
@@ -183,12 +184,20 @@ class AssetSource():
output = []
for file in self.input_files:
+ name = self.name
+
+ if name is None:
+ name = '_'.join(file.relative_to(self.working_path).parts)
+ name = name.replace('.', '_')
+ name = re.sub('[^0-9A-Za-z_]', '_', name)
+ name = name.lower()
+
self.builder_options.update({
'input_file': file,
'output_file': output_file,
'input_type': input_type,
'output_format': format,
- 'symbol_name': self.name,
+ 'symbol_name': name,
'prefix': prefix
})
builder.prepare_options(self.builder_options)
(With extra .relative_to(self.working_path)
)
This works:
assets/level*.tmx:
name:
This doesn't:
assets/level*.tmx:
It should. I'm pretty sure this is a bug.
Also more control over wildcard filenames would be nice, this outputs:
// Auto Generated File - DO NOT EDIT!
#pragma once
#include <cstdint>
extern const uint8_t asset_sprites[];
extern const uint32_t asset_sprites_length;
extern const uint8_t asset_assets_level01_tmx[];
extern const uint32_t asset_assets_level01_tmx_length;
extern const uint8_t asset_assets_level02_tmx[];
extern const uint32_t asset_assets_level02_tmx_length;
When really I'd want:
// Auto Generated File - DO NOT EDIT!
#pragma once
#include <cstdint>
extern const uint8_t asset_sprites[];
extern const uint32_t asset_sprites_length;
extern const uint8_t asset_level01[];
extern const uint32_t asset_level01_length;
extern const uint8_t asset_level02[];
extern const uint32_t asset_level02_length;
Noticed while trying to move palette-cycle over (Daft-Freak/32blit-beta@b255e89). VS build is failing with FileNotFoundError: [Errno 2] No such file or directory: 'assets\\fire_palette.png'
.
phil@StarLite:~/Development/32blit$ 32blit setup
Project name: platforms
Author name: gadgetoid
32Blit SDK path [/home/phil/32blit-sdk]: /home/phil/Development/32blit/32blit-sdk
Initialise a Git repository? [Y/n]: y
Create VS Code configuration? [Y/n]: y
Create Visual Studio configuration? [y/N]: y
Downloading boilerplate...
Traceback (most recent call last):
File "/usr/lib/python3.8/shutil.py", line 707, in rmtree
orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: 'platforms/.git'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/phil/.local/bin/32blit", line 8, in <module>
sys.exit(main())
File "/home/phil/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/phil/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/phil/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/phil/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/phil/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/phil/.local/lib/python3.8/site-packages/ttblit/tool/setup.py", line 192, in setup_cli
shutil.rmtree(pathlib.Path(project_name_clean) / '.git', onerror=remove_readonly)
File "/usr/lib/python3.8/shutil.py", line 709, in rmtree
onerror(os.lstat, path, sys.exc_info())
File "/home/phil/.local/lib/python3.8/site-packages/ttblit/tool/setup.py", line 189, in remove_readonly
os.chmod(path, stat.S_IWRITE)
FileNotFoundError: [Errno 2] No such file or directory: 'platforms/.git'
32blit setup
Should probably check to see if the boilerplate actually downloaded before continuing!
Error messages are currently written to stdout, along with the actual output; while this is only an issue if you're writing the output to stdout (instead of specifying an output file) it still feels wrong.
(there is also a side issue of spurious "ignoring unsupported image option" message, but I'm guessing they will go away as the tool matures!)
Presently there is no way to build the same ttf file in multiple font sizes; the filename overrides entries so you only get the last one listed in the YAML.
You can work around it by having multiple copies of the ttf file, but that is ... icky. What I don't know is whether this is a simple addition, or if it breaks some of the fundamentals of parsing YAML :-)
Should roughly use the setup provided here: https://github.com/pimoroni/boilerplate-python
This includes some changes to how linting/tests are handled and some other "improvements" that would be nice here.
Just realised this, assuming any other files referenced by an asset also don't get added.
Entire tool needs unit tests for individual components, and tool execution tests with input/output files to ensure it actually runs as a whole.
From most of my projects:
assets.cpp:
assets/buttons.png: asset_buttons
Results in AttributeError: 'str' object has no attribute 'items'
.
The dfu tool is pretty well rounded and super useful for unpacking bins from .dfu dumps if you're stuck on Windows/DfuSe Demo.
Needs merging into the tools, I think!
See: https://github.com/pimoroni/32blit-beta/blob/master/tools/dfu
Configure .travis.yml GitHub Actions to release packages to pypi and GitHub for tagged releases.
... resulting in an error about the variable not being declared later. Bit of a minor issue, but managed to confuse me for a bit when I typo'd a filename and thought that rebuilds weren't triggering...
The core of the flash command has been implemented, but all of the functionality from 32Blit C++ should be migrated over into Python world.
I am using WSL following the setup guide here:
https://github.com/32blit/32blit-sdk/blob/master/docs/Windows-WSL.md
While following the instructions and troubleshooting section of this page:
https://github.com/32blit/32blit-sdk/blob/master/docs/32blit.md#flasher-cant-find-32blit-port
I was unable to determine how to find which port to provide to successfully push a blit
to the device
Thanks to ali1234 on the discord I was finally able to manually set the port. They asked me to include the following:
python3 -m serial.tools.list_ports -v
all results return
desc: n/a
hwid: n/a
And finally:
192 ports found
You can see this with the audio-wave example (and a few others).
assets.yml:
assets.hpp:
assets/glass.bin: glass_wav
assets.cmake:
...
set(ASSET_OUTPUTS
"/home/daftfreak/programs/32blit-beta/build/examples/audio-wave/assets.None"
)
This results in the packer being run every build (apparently nothing complains if the rule to make a file doesn't actually make that file...)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.