https://github.com/rbaron/catprinter Skip to content Sign up * Product + Features + Mobile + Actions + Codespaces + Packages + Security + Code review + Issues + Integrations + GitHub Sponsors + Customer stories * Team * Enterprise * Explore + Explore GitHub + Learn and contribute + Topics + Collections + Trending + Learning Lab + Open source guides + Connect with others + The ReadME Project + Events + Community forum + GitHub Education + GitHub Stars program * Marketplace * Pricing + Plans + Compare plans + Contact Sales + Education [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} rbaron / catprinter Public * Notifications * Fork 20 * Star 344 MIT License 344 stars 20 forks Star Notifications * Code * Issues 2 * Pull requests 7 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 9 branches 0 tags Code Latest commit @rbaron rbaron Merge pull request #16 from c7h/feature/text_mode ... 2339984 Jan 1, 2022 Merge pull request #16 from c7h/feature/text_mode 2339984 Git stats * 35 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github Create codeql-analysis.yml Sep 20, 2021 catprinter Added dark mode for advanced print quality Dec 31, 2021 media added halftone dithering algorithm Dec 20, 2021 .gitignore fix: install of macOS-only requirements Sep 24, 2021 LICENSE Initial commit Aug 14, 2021 README.md added halftone dithering algorithm Dec 20, 2021 print.py Added dark mode for advanced print quality Dec 31, 2021 requirements.txt Update requirements.txt Dec 9, 2021 View code Installation Usage Example Different Algorithms README.md 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 git@github.com: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 $ python print.py --help usage: print.py [-h] [--devicename] [--log-level {debug,info,warn,error}] [--img-binarization-algo {mean-threshold,floyd-steinberg}] [--show-preview] filename prints an image on your cat thermal printer positional arguments: filename optional arguments: -h, --help show this help message and exit --devicename Specify the Bluetooth device name to search for. Default value is GT01. --log-level {debug,info,warn,error} --img-binarization-algo {mean-threshold,floyd-steinberg, halftone} Which image binarization algorithm to use. --show-preview If set, displays the final image and asks the user for confirmation before printing. Example % python 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 About Resources Readme License MIT License Stars 344 stars Watchers 6 watching Forks 20 forks Releases No releases published Packages 0 No packages published Contributors 6 * @rbaron * @jauderho * @dependabot[bot] * @c7h * @David-Lor * @omgmog Languages * Python 100.0% * (c) 2022 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.