square-wave-from-binary-string/readme.md

45 lines
1.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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](#format-reference-image).
## 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
![](https://www.nutsvolts.com/uploads/wygwam/NV_1007_Martin_Figure09.jpg)
(From [Nuts and Volts](https://www.nutsvolts.com/uploads/wygwam/NV_1007_Martin_Figure09.jpg).)