mcu-delaygen
v0.2.0
Published
MCU delay routine generator with a web UI and bundled CLI
Readme
MCU Delay Generator
MCU delay routine generator with:
- a Web UI built with Vite + Preact
- a bundled CLI published as
mcu-delaygen
Features
- Generates blocking C delay routines for three MCU families:
- ATmega328P (AVR 8-bit, Arduino Uno) -- default clock 16 MHz
- STC89C52 (classic 12T 8051) -- default clock 11.0592 MHz
- STM32F103C8 (ARM Cortex-M3, Blue Pill) -- default clock 72 MHz
- Two generation modes per MCU:
- Timer mode -- uses a hardware timer (Timer1 CTC on AVR, Timer0 mode-1 on 8051, SysTick on STM32); handles delays longer than one timer period by chaining multiple timer intervals
- Software loop mode -- generates a busy-wait loop with a configurable cycles-per-iteration calibration value so the output can be tuned against hardware measurements
- Accepts arbitrary delay strings (
500us,10ms,2s) and custom clock frequencies - Supports a custom function name in the generated output
- All arithmetic uses integer
bigintthroughout -- no floating-point rounding errors - Available as a browser-based Web UI (no installation) and a Node.js CLI (
mcu-delaygen)
Requirements
- Node.js
20.19+or22.12+ - Bun for development and tests
chafazipfor generating the Web release archive
chafa is only required when regenerating the CLI icon banner from the SVG favicon.
The Node.js floor matches the current Vite 8 / Rolldown toolchain used by this repository.
Install
Install the published CLI from bun:
bun install -g mcu-delaygenor use npm:
npm install -g mcu-delaygenOr download release assets from Codeberg Releases:
https://codeberg.org/xchacha20-poly1305/mcudelay-gen/releasesDevelopment Setup
bun installDevelopment
Run the Web app in dev mode:
bun run devRun the CLI entrypoint from source:
bun run cli -- version
bun run cli -- list
bun run cli -- generate --mcu stc89c52 --delay 10msBuild Guide
Web Build
Build the Web app:
bun run buildOutput:
dist/
Preview the built Web app locally:
bun run previewCLI Build
Build the bundled CLI:
bun run build:cliOutput:
dist-cli/cli.js
Run the built CLI directly:
node ./dist-cli/cli.js versionBuild all release assets in one pass:
bun run build:releaseOutput:
- versioned single-file JS CLI
mcu-delaygen-web-v<version>.zipmcu-delaygen-v<version>-checksums.txt
Release Flow
Push a semver tag that matches package.json:
git tag v0.1.0
git push origin v0.1.0The Forgejo workflow will:
- verify the tag matches
package.json - run the test suite
- build release assets
- publish a Codeberg release
- publish the npm package
Icon Generation
The project icon source is:
public/favicon.svg
It is used in two places:
- the Web app favicon and page branding
- the CLI
versionbanner
The CLI banner is generated into:
src/adapters/cli/generated-banner.ts
When public/favicon.svg changes, regenerate the CLI banner before rebuilding the CLI:
bun run build:banner
bun run build:cliEquivalent direct command:
node ./scripts/build-cli-banner.mjsThe banner generator uses chafa with symbol output and truecolor mode to preserve the original icon colors in terminal output.
Test
Run the full test suite:
bun testLint and Format
Lint the source:
bun run lintAuto-format the source:
bun run formatBoth use Biome. Configuration is in biome.json.
