Try to fix incorrect printing “energy”;

use `“”` in readme, better desc of a function
This commit is contained in:
NaitLee 2022-10-07 20:25:01 +08:00
parent 70cdd84359
commit 204719d936
4 changed files with 24 additions and 21 deletions

View File

@ -2,7 +2,7 @@ English | [Deutsch](./readme.i18n/README.de_DE.md) | [简体中文](./readme.i18
# Cat-Printer # 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) [![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! - and also Android!
- Free, as in [freedom](https://www.gnu.org/philosophy/free-sw.html)! - 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*! this project is for everyone that concerns *open-mind and freedom*!
- and Fun! - and Fun!
@ -64,20 +64,20 @@ Recommend to set scan time to 1 second.
### Windows ### 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` extract to somewhere and run `start.bat`
Windows typically needs longer scan time. Defaults to 4 seconds, try to find your case. Windows typically needs longer scan time. Defaults to 4 seconds, try to find your case.
### GNU/Linux ### 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 ```bash
python3 server.py python3 server.py
``` ```
It is recommended to set the scan time to 2 seconds. 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 ```bash
sudo pacman -S bluez bluez-utils sudo pacman -S bluez bluez-utils
``` ```
@ -92,7 +92,7 @@ then install `pyobjc` and `bleak` via `pip` in terminal:
pip3 install pyobjc bleak pip3 install pyobjc bleak
``` ```
After that, fetch & use a "bare" release: After that, fetch & use a “bare” release:
```bash ```bash
python3 server.py python3 server.py
``` ```
@ -102,8 +102,8 @@ Currently the web browser will not open automatically in MacOS. Please run manua
### Worth to Note ### Worth to Note
For all supported platforms, For all supported platforms,
You can also use "pure" edition once you have [Python 3](https://www.python.org/) installed, 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`. 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. 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? ## Problems?
Please use Issue or Discussion if there's something in your mind! Please use Issue or Discussion if theres something in your mind!
Of course Pull Requests are welcome if you can handle them! 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! - [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 - [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 - [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 ones system
- [python-for-android](https://python-for-android.readthedocs.io/en/latest/), though there are some painful troubles - [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 - [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 - Stack Overflow & the whole Internet, you let me know Android `Activity` all from beginning

View File

@ -285,7 +285,8 @@ class PrinterDriver(Commander):
font_scale: int = 1 font_scale: int = 1
energy: int = None energy: int = None
quality: int = 24 'Thermal strength of printer, range 0x0000 to 0xffff'
speed: int = 32
mtu: int = 200 mtu: int = 200
@ -445,10 +446,10 @@ class PrinterDriver(Commander):
else: else:
self.start_printing() self.start_printing()
self.set_dpi_as_200() self.set_dpi_as_200()
if self.quality: # well, slower makes stable heating if self.speed: # well, slower makes stable heating
self.set_speed(self.quality) self.set_speed(self.speed)
if self.energy is not None: if self.energy is not None:
self.set_energy(self.energy * 0x100) self.set_energy(self.energy)
self.apply_energy() self.apply_energy()
self.update_device() self.update_device()
self.flush() self.flush()
@ -656,13 +657,13 @@ def _main():
printer.scan_time = float(scan_param[0]) printer.scan_time = float(scan_param[0])
identifier = ','.join(scan_param[1:]) identifier = ','.join(scan_param[1:])
if args.energy is not None: 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: elif args.convert == 'text' or args.text:
printer.energy = 96 printer.energy = 96
else: else:
printer.energy = 64 printer.energy = 64
if args.quality is not None: if args.quality is not None:
printer.quality = 4 * (args.quality + 5) printer.speed = 4 * (args.quality + 5)
image_param = args.image.split(',') image_param = args.image.split(',')
if 'flip' in image_param: if 'flip' in image_param:

View File

@ -130,8 +130,9 @@ class Commander(metaclass=ABCMeta):
def set_speed(self, value: int): def set_speed(self, value: int):
''' Set how quick to feed/retract paper. **The lower, the quicker.** ''' Set how quick to feed/retract paper. **The lower, the quicker.**
My test shows that, a value below 4 would make printer My printer with value < 4 set would make it unable to feed/retract,
unable to feed/retract, for it's way too quick. 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)) ) self.send( self.make_command(0xbd, int_to_bytes(value)) )

View File

@ -78,7 +78,8 @@ class PrinterServerHandler(BaseHTTPRequestHandler):
'is_android': False, 'is_android': False,
'scan_time': 4.0, 'scan_time': 4.0,
'dry_run': False, 'dry_run': False,
'energy': 64 'energy': 64,
'quality': 32
}) })
_settings_blacklist = ( _settings_blacklist = (
'printer', 'is_android' 'printer', 'is_android'
@ -198,9 +199,9 @@ class PrinterServerHandler(BaseHTTPRequestHandler):
self.printer.fake = self.settings.fake self.printer.fake = self.settings.fake
self.printer.dump = self.settings.dump self.printer.dump = self.settings.dump
if self.settings.energy is not None: 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: 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_h = self.settings.flip_h or self.settings.flip
self.printer.flip_v = self.settings.flip_v or self.settings.flip self.printer.flip_v = self.settings.flip_v or self.settings.flip
self.printer.rtl = self.settings.force_rtl self.printer.rtl = self.settings.force_rtl