Skip to content

errnerr/catprinter-1

 
 

Repository files navigation

Cat Printer CLI (Node.js + Go)

This project lets you print text messages to an MXW01 Cat Printer using a Node.js CLI and a Go BLE print worker.

Requirements

  • Node.js (v16+ recommended)
  • Go (v1.18+ recommended)
  • canvas Node.js package
  • github.com/go-ble/ble Go package
  • DotMatrix and DotMatrixBold TTF fonts in fonts/ directory
  • MXW01 Cat Printer (or compatible)
  • Linux or macOS (tested on Ubuntu)

Setup

1. Clone the repository

git clone <this-repo-url>
cd <repo-directory>

2. Install Node.js dependencies

npm install canvas express body-parser

3. Install Go and build the print worker

  • Install Go (or see below):
    sudo apt install golang-go  # or use the official Go tarball for latest version
  • Build the Go print worker:
    go get github.com/go-ble/ble/linux/att@v0.0.0-20240122180141-8c5522f54333
    go get github.com/go-ble/ble/linux/hci/socket@v0.0.0-20240122180141-8c5522f54333
    go build -o catprinter catprinter.go
    chmod +x catprinter

4. Install TTF Fonts

  • Place dotmatrix.ttf and dotmatrixbold.ttf in the fonts/ directory.
  • These are required for the Node.js script to render text in the correct style.

5. Usage

Print a message to your Cat Printer:

node print.js <printer-mac-address> "Your message here"
  • Example:
    node print.js 48:0F:57:12:30:9D "Hello, Cat Printer!"
  • This will:
    1. Render the message as a PNG (rotated 180°, black text on white background)
    2. Call the Go print worker to send the image to your printer via BLE

Run the server

   node server.js

Open http://:3000 on your machine to print

6. Troubleshooting

  • Make sure your printer is on and not connected to any other device.
  • If you see BLE errors, try running as root or with BLE permissions:
    sudo ./catprinter debug-receipt.png <printer-mac-address>
  • If the printout is blank or garbled, check the generated debug-receipt.png for correct orientation and contrast.

7. Customization

  • You can adjust font size, line height, and intensity in the scripts.
  • The Go print worker expects a 384px wide, 1-bit PNG image.

Enjoy your Cat Printer!

About

MXW01 Catprinter website for receipts and images.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 37.0%
  • Go 33.2%
  • HTML 25.5%
  • Shell 4.3%