NaitLee / Cat-Printer

Application supporting Bluetooth thermal “Cat Printers”, for everyone!
GNU General Public License v3.0
307 stars 31 forks source link

Weird behavior of "Strength" parameter #107

Open doragasu opened 1 month ago

doragasu commented 1 month ago

The Strength parameter behaves in a weird way with my GB03 printer. If I put it almost to the top of the slider, instead of printing darker, the printout is very light (almost non legible). If I continue and put the slider to the top, the printer does not print, because I get a TypeError:

Exception occurred during processing of request from ('127.0.0.1', 47926)
Traceback (most recent call last):
  File "/usr/lib/python3.12/socketserver.py", line 318, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.12/socketserver.py", line 349, in process_request
    self.finish_request(request, client_address)
  File "/tmp/Cat-Printer/server.py", line 329, in finish_request
    self.handler.__init__(request, client_address, self)
  File "/usr/lib/python3.12/socketserver.py", line 761, in __init__
    self.handle()
  File "/usr/lib/python3.12/http/server.py", line 436, in handle
    self.handle_one_request()
  File "/tmp/Cat-Printer/server.py", line 104, in handle_one_request
    super().handle_one_request()
  File "/usr/lib/python3.12/http/server.py", line 424, in handle_one_request
    method()
  File "/tmp/Cat-Printer/server.py", line 271, in do_POST
    self.handle_api()
  File "/tmp/Cat-Printer/server.py", line 219, in handle_api
    self.printer.print(io.BytesIO(body))
  File "/tmp/Cat-Printer/printer.py", line 414, in print
    self._print_bitmap(printer_data)
  File "/tmp/Cat-Printer/printer.py", line 478, in _print_bitmap
    self._prepare()
  File "/tmp/Cat-Printer/printer.py", line 458, in _prepare
    self.set_energy(self.energy)
  File "/tmp/Cat-Printer/printer_lib/commander.py", line 149, in set_energy
    self.send( self.make_command(0xaf, int_to_bytes(amount, length=2)) )
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/Cat-Printer/printer_lib/commander.py", line 55, in int_to_bytes
    raise f'int_to_bytes: {i} > {max_value}'
TypeError: exceptions must derive from BaseException

Putting the bar back to default position allows to continue printing.