diff --git a/README.md b/README.md index bbf30d6..c12cdd9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ English | [Deutsch](./readme.i18n/README.de_DE.md) | [简体中文](./readme.i18 # Cat-Printer -🐱🖨 A project that provides support to some Bluetooth "Cat Printer" models, on *many* platforms! +🐱🖨 A project that provides support to some Bluetooth “Cat Printer” models, on *many* platforms! [![cat-printer-poster](https://repository-images.githubusercontent.com/403563361/93e32942-856c-4552-a8b0-b03c0976a3a7)](https://repository-images.githubusercontent.com/403563361/93e32942-856c-4552-a8b0-b03c0976a3a7) @@ -45,7 +45,7 @@ It may work! - and also Android! - Free, as in [freedom](https://www.gnu.org/philosophy/free-sw.html)! - - Unlike those proprietary "apps" around, + - Unlike those proprietary “apps” around, this project is for everyone that concerns *open-mind and freedom*! - and Fun! @@ -64,20 +64,20 @@ Recommend to set scan time to 1 second. ### Windows -Get the newest release archive with "windows" in the file name, +Get the newest release archive with “windows” in the file name, extract to somewhere and run `start.bat` Windows typically needs longer scan time. Defaults to 4 seconds, try to find your case. ### GNU/Linux -You can get the "pure" release, extract it, fire up a terminal and run: +You can get the “pure” release, extract it, fire up a terminal and run: ```bash python3 server.py ``` It is recommended to set the scan time to 2 seconds. -On Arch Linux based distros you may first install `bluez`, as it may not be installled by default +On Arch Linux based distros you may install `bluez` first, as it may not be installed by default ```bash sudo pacman -S bluez bluez-utils ``` @@ -92,7 +92,7 @@ then install `pyobjc` and `bleak` via `pip` in terminal: pip3 install pyobjc bleak ``` -After that, fetch & use a "bare" release: +After that, fetch & use a “bare” release: ```bash python3 server.py ``` @@ -102,8 +102,8 @@ Currently the web browser will not open automatically in MacOS. Please run manua ### Worth to Note For all supported platforms, -You can also use "pure" edition once you have [Python 3](https://www.python.org/) installed, -or "bare" edition if you also managed to install `bleak` via `pip`. +You can also use “pure” edition once you have [Python 3](https://www.python.org/) installed, +or “bare” edition if you also managed to install `bleak` via `pip`. If you like command-line, installing [ImageMagick](https://imagemagick.org/) and [Ghostscript](https://ghostscript.com/) could be very helpful. @@ -111,7 +111,7 @@ See the [releases](https://github.com/NaitLee/Cat-Printer/releases) now! ## Problems? -Please use Issue or Discussion if there's something in your mind! +Please use Issue or Discussion if there’s something in your mind! Of course Pull Requests are welcome if you can handle them! @@ -148,7 +148,7 @@ After that, give yourself a credit in `www/about.html`, if you prefer. - [Bleak](https://bleak.readthedocs.io/en/latest/) Bluetooth-Low-Energy library! The overall Hero! - [roddeh-i18n](https://github.com/roddeh/i18njs), the current built-in i18n is inspired by this - [PF2 font](http://grub.gibibit.com/New_font_format), great minimal raster font idea -- ImageMagick & Ghostscript, never mention other if something useful is already in one's system +- ImageMagick & Ghostscript, never mention other if something useful is already in one’s system - [python-for-android](https://python-for-android.readthedocs.io/en/latest/), though there are some painful troubles - [AdvancedWebView](https://github.com/delight-im/Android-AdvancedWebView) for saving my life from Java - Stack Overflow & the whole Internet, you let me know Android `Activity` all from beginning diff --git a/printer.py b/printer.py index 136aba6..56e653d 100644 --- a/printer.py +++ b/printer.py @@ -285,7 +285,8 @@ class PrinterDriver(Commander): font_scale: int = 1 energy: int = None - quality: int = 24 + 'Thermal strength of printer, range 0x0000 to 0xffff' + speed: int = 32 mtu: int = 200 @@ -445,10 +446,10 @@ class PrinterDriver(Commander): else: self.start_printing() self.set_dpi_as_200() - if self.quality: # well, slower makes stable heating - self.set_speed(self.quality) + if self.speed: # well, slower makes stable heating + self.set_speed(self.speed) if self.energy is not None: - self.set_energy(self.energy * 0x100) + self.set_energy(self.energy) self.apply_energy() self.update_device() self.flush() @@ -656,13 +657,13 @@ def _main(): printer.scan_time = float(scan_param[0]) identifier = ','.join(scan_param[1:]) if args.energy is not None: - printer.energy = int(args.energy * 0xff) + printer.energy = int(args.energy * 0xffff) elif args.convert == 'text' or args.text: printer.energy = 96 else: printer.energy = 64 if args.quality is not None: - printer.quality = 4 * (args.quality + 5) + printer.speed = 4 * (args.quality + 5) image_param = args.image.split(',') if 'flip' in image_param: diff --git a/printer_lib/commander.py b/printer_lib/commander.py index 27f26e4..6604707 100644 --- a/printer_lib/commander.py +++ b/printer_lib/commander.py @@ -130,8 +130,9 @@ class Commander(metaclass=ABCMeta): def set_speed(self, value: int): ''' Set how quick to feed/retract paper. **The lower, the quicker.** - My test shows that, a value below 4 would make printer - unable to feed/retract, for it's way too quick. + My printer with value < 4 set would make it unable to feed/retract, + maybe it's way too quick. + Speed also affects the quality, for heat time/stability reasons. ''' self.send( self.make_command(0xbd, int_to_bytes(value)) ) diff --git a/server.py b/server.py index b10030b..9f4fa11 100644 --- a/server.py +++ b/server.py @@ -78,7 +78,8 @@ class PrinterServerHandler(BaseHTTPRequestHandler): 'is_android': False, 'scan_time': 4.0, 'dry_run': False, - 'energy': 64 + 'energy': 64, + 'quality': 32 }) _settings_blacklist = ( 'printer', 'is_android' @@ -198,9 +199,9 @@ class PrinterServerHandler(BaseHTTPRequestHandler): self.printer.fake = self.settings.fake self.printer.dump = self.settings.dump if self.settings.energy is not None: - self.printer.energy = int(self.settings.energy) + self.printer.energy = int(self.settings.energy) * 0x100 if self.settings.quality is not None: - self.printer.quality = int(self.settings.quality) + self.printer.speed = int(self.settings.quality) self.printer.flip_h = self.settings.flip_h or self.settings.flip self.printer.flip_v = self.settings.flip_v or self.settings.flip self.printer.rtl = self.settings.force_rtl