personal_site/_posts/2024-09-09-micropython-simulator.md
2025-01-06 11:44:18 +00:00

1.5 KiB

title, layout, excerpt, image, thumbnail, assets, alt, image_class, head
title layout excerpt image thumbnail assets alt image_class head
MicroPython Simulator post A simulator for my USB C Power supply project using Micropython running in websassembly. /assets/blog/micropython/simulated_display.png /assets/blog/micropython/simulated_display.png /assets/blog/micropython A 240x240 pixel (so low res) image of a slightly sci-fiesque looking circular display showing so linear and curved bars, 24.4 volts, in bigger font 213w and 8.7A. invertable <script src="/assets/blog/micropython/micropython.min.mjs" type="module"></script>

This simulator lets me quickly try out micropython code drawing to a 240x240 pixel color lcd display.

This particular display uses 5, 6 and 5 bits for each channel, respectively. The raw pixel data gets passed from micropython to javascript where it gets converted to normal RGB before being blitted to the <canvas> tag. Under the hood it uses the fact that the micropython VM supports being compiled to WASM.

I'm using a ttf font called gunship converted to bitmap format and frozen into the firmware along with other library code.

Building the code looks like:

cd /ports/webassembly
make min FROZEN_MANIFEST=/path/to/custom/manifest.py
cp ...wasm and ....min.mjs to your webserver directory