• Stars
    star
    730
  • Rank 62,081 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ðŸąðŸ–Ļ

Cat Printer

Cat printer is a portable thermal printer sold on AliExpress for around $20.

This repository contains Python code for talking to the cat printer over Bluetooth Low Energy (BLE). The code has been reverse engineered from the official Android app.

Installation

# Clone the repository.
$ git clone [email protected]:rbaron/catprinter.git
$ cd catprinter
# Create a virtualenv on venv/ and activate it.
$ virtualenv --python=python3 venv
$ source venv/bin/activate
# Install requirements from requirements.txt.
$ pip install -r requirements.txt

Usage

$ ./print.py --help
usage: print.py [-h] [-l {debug,info,warn,error}]
                [-b {mean-threshold,floyd-steinberg,halftone,none}] [-s]
                [-d DEVICE] [-t]
                filename

prints an image on your cat thermal printer

positional arguments:
  filename

optional arguments:
  -h, --help            show this help message and exit
  -l {debug,info,warn,error}, --log-level {debug,info,warn,error}
  -b {mean-threshold,floyd-steinberg,halftone,none}, --img-binarization-algo {mean-threshold,floyd-steinberg,halftone,none}
                        Which image binarization algorithm to use. If 'none'
                        is used, no binarization will be used. In this case
                        the image has to have a width of 384 px.
  -s, --show-preview    If set, displays the final image and asks the user for
                        confirmation before printing.
  -d DEVICE, --device DEVICE
                        The printer's Bluetooth Low Energy (BLE) address (MAC
                        address on Linux; UUID on macOS) or advertisement name
                        (e.g.: "GT01", "GB02", "GB03"). If omitted, the the
                        script will try to auto discover the printer based on
                        its advertised BLE services.
  -t, --darker          Print the image in text mode. This leads to more
                        contrast, but slower speed.

Example

% ./print.py --show-preview test.png
âģ Applying Floyd-Steinberg dithering to image...
✅ Done.
â„đïļ Displaying preview.
ðŸĪ” Go ahead with print? [Y/n]?
✅ Read image: (42, 384) (h, w) pixels
✅ Generated BLE commands: 2353 bytes
âģ Looking for a BLE device named GT01...
✅ Got it. Address: 09480C21-65B5-477B-B475-C797CD0D6B1C: GT01
âģ Connecting to 09480C21-65B5-477B-B475-C797CD0D6B1C: GT01...
✅ Connected: True; MTU: 104
âģ Sending 2353 bytes of data in chunks of 101 bytes...
✅ Done.

Different Algorithms

Mean Threshold: Mean threshold

Floyd Steinberg (default) Floyd Steinberg

Halftone dithering Halftone

More Repositories

1

b-parasite

ðŸŒąðŸ’§ An open source DIY soil moisture sensor
C
1,822
star
2

awesomenes

ðŸŽŪ A NES emulator written in Go
Go
275
star
3

omr

Optical Mark Recognition in Python
Python
207
star
4

dict.cc.py

📘 Unofficial command line client for dict.cc
Python
156
star
5

w-parasite

ðŸŠī💧A WiFi-enabled soil moisture sensor
C++
135
star
6

elink

A daisy chain of electronic shelf labels
C
101
star
7

deskmate

A tiny MQTT-powered dashboard and control center.
C++
67
star
8

fitless

A collection of toy firmwares for the ID115 fitness tracker
C
60
star
9

eink-ha

A hacky e-ink display for Home Assistant sensors
C
56
star
10

m6-reveng

Info & tools for reverse engineering the M6 smart fitness band
C
54
star
11

HS6620D-smartwatch-reveng

51
star
12

pricetag-printer

Python script for printing to the Hanshow price-tag
Python
50
star
13

sugarboat

A digital hydrometer
C++
38
star
14

remotebox

A Rhythmbox plugin for remote control via a TCP socket
Python
20
star
15

secret

Shamir secret sharing scheme in zero-dependency C
C
15
star
16

lir2450-charger

A tiny USB C charger for LIR2450 coin cell batteries
13
star
17

parasite-scanner

A bridge for b-parasites
Go
12
star
18

ikea-macropad

Python
9
star
19

clack

Minimalist Slack bot framework for clojure
Clojure
8
star
20

pyRemoteControl

Remote control server for linux. Control your X session through a TCP socket.
Python
7
star
21

sos

the helplessly useless operating system
Assembly
6
star
22

pyS3fs

Mount Amazon's S3 storage as a filesystem
Python
4
star
23

st-peter-esp8266

The ESP8266 sketch for the Slack bot controlled AC
Eagle
3
star
24

stpeter

Clojure
3
star
25

ble-led

A minimal ESP32 Arduino BLE service that turns an LED on/off
C++
3
star
26

react-native-dform

Schema-based dynamic forms for React Native
JavaScript
3
star
27

dform-editor

dform JSON schema editor
JavaScript
2
star
28

react-dform

Schema-based dynamic forms for React
JavaScript
2
star
29

advent-of-code-2021

My solutions to adventofcode.com
Python
2
star
30

dform

Schema-based dynamic forms
JavaScript
2
star
31

stacky

A programming language with a RPN-like syntax
Python
2
star
32

advent-of-code-2023

Python
2
star
33

advent-of-code-2017

Haskell
2
star
34

advent-of-code-2022

My solutions to adventofcode.com
Python
2
star
35

pyMonitor

Periodically checks if webpages are online and display their statuses using GTK widgets.
Python
2
star
36

sicp

My solutions to SICP exercises
Scheme
2
star
37

0

Quick, dirty and RPN-ish calculations on your terminal
C
2
star
38

tinycolor

A tiny python2 and python3 module for printing in colors
Python
2
star
39

qche

Python2 filesystem-persisted cache with a dead simple interface
Python
2
star
40

advent-of-code-2020

🎅 My solutions to adventofcode.com
Python
1
star
41

advent-of-code-2019

My solutions to adventofcode.com 2019
C++
1
star
42

spellcaster

🊄 A home automation magic wand
Jupyter Notebook
1
star
43

gimme-danger

A USB-PD trigger board & controller, powered by ESPHome
1
star
44

dotfiles

Shell
1
star
45

compiler_studies

ðŸ’Ą
Python
1
star
46

scam

A toy Lisp interpreter in C
C
1
star
47

d2r-tracker-ha-custom-component

A Diablo 2 Resurrected DClone tracker custom component for Home Assistant
Python
1
star