Go to file
n loewen 98cf0a42d2 Initial commit 2023-08-09 18:06:34 +01:00
.gitignore Initial commit 2023-08-09 18:06:34 +01:00
diagram.jpg Initial commit 2023-08-09 18:06:34 +01:00
example--fill-display-program.txt Initial commit 2023-08-09 18:06:34 +01:00
readme.md Initial commit 2023-08-09 18:06:34 +01:00
square-wave-from-binary.js Initial commit 2023-08-09 18:06:34 +01:00

readme.md

Create square wave patterns from binary strings

This script turns a binary string into a square-wave pattern.

It is intended for creating embroidery patterns based on programs for my paper computer.

The output is formatted as if the data is being sent over an 8-bit data bus — see the reference image below.

Use

./square-wave-from-binary.js bin.txt

The input must be a text file containing nothing but 0s and 1s (no spaces, newlines, etc). It must be an even number of 8-bit bytes in length.

Example output

01234567  01234567  01234567  01234567
▄▀▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄  ▄▀▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄

▄▀▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄  ▄▀▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄

▄▀▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄  ▄▀▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄

▄▀▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄  ▄▀▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄

▄▀▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄  ▄▀▄▄▄▄▄▄  ▀▄▀▄▄▄▄▄

▄▀▀▄▀▄▀▄  ▀▄▀▄▄▄▄▄  ▄▀▀▄▀▄▀▄  ▄▄▄▄▄▄▄▄

▀▀▄▄▄▄▄▄  ▀▄▀▄▀▄▄▄  ▀▀▀▄▀▄▀▄  ▄▄▄▄▄▄▄▄

▀▄▀▀▀▀▀▀  ▀▀▀▀▀▀▀▄  ▀▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄

01234567  01234567  01234567  01234567

Format reference image

(From Nuts and Volts.)