mirror of
https://github.com/NaitLee/Cat-Printer.git
synced 2025-05-27 20:50:27 -07:00
Try to fix incorrect printing “energy”;
use `“”` in readme, better desc of a function
This commit is contained in:
parent
70cdd84359
commit
204719d936
20
README.md
20
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!
|
||||
|
||||
[](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
|
||||
|
13
printer.py
13
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:
|
||||
|
@ -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)) )
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user