catprinter icon indicating copy to clipboard operation
catprinter copied to clipboard

cmd_feed_paper, cmd_set_energy, dark_mode seem to have no effect

Open 8bitben opened this issue 2 years ago • 13 comments

When trying to implement cmd_set_energy and cmd_feed_paper in my own application, changing the values used in cmds_print_img function appears to have no effect. The paper doesn't feed any further, and/or the text is not any darker if I increase the values in these fields.

Printing a demo page from the iOS App (or the built-in debug QR code print mechanism) provides much darker prints than printing a black text on white BG PNG from catprinter. I suspect that these values are not being properly set when I print from the function vs. the App.

Printer model: GB02

8bitben avatar Mar 28 '22 02:03 8bitben

Thanks for filing the issue @8bitben.

I just did some quick tests here and realized something interesting. The argument of cmd_feed_paper seems to actually be more related to the speed at which the paper is pushed out (try changing it to 10 or 100 here).

To actually feed more paper, repeating the command a few times seems to do the trick:

data += \
    cmd_feed_paper(10) + \
    CMD_SET_PAPER + \
    CMD_SET_PAPER + \
    cmd_feed_paper(10) + \
    CMD_SET_PAPER + \
    CMD_SET_PAPER + \
    cmd_feed_paper(10) + \
    CMD_SET_PAPER + \
    CMD_SET_PAPER + \
    cmd_feed_paper(10) + \
    CMD_SET_PAPER + \
    CMD_SET_PAPER + \
    cmd_feed_paper(10) + \
    CMD_LATTICE_END + \
    CMD_GET_DEV_STATE

rbaron avatar Mar 28 '22 19:03 rbaron

As for the cmd_set_energy, it seems that indeed it doesn't have much of an effect. It's likely that there's something missing before/after it. You can try using the --darker switch and see if it makes a difference.

rbaron avatar Mar 28 '22 19:03 rbaron

Thanks @rbaron!

So I've found the following:

CMD_SET_PAPER can be chained an unlimited amount of times to push more paper after using cmd_feed_paper(<speed>) to set the feed speed.

Leaving out this section that has to do with power settings seems to provide a much darker, far superior print quality:

cmd_set_energy(12000) + \ PRINTER_MODE + \ cmd_feed_paper(50)

I omitted it entirely and the print still proceeded at normal speed with great quality!

There is some more research to be done on what exactly those commands are intended to do.

8bitben avatar Mar 29 '22 02:03 8bitben

That's a great find @8bitben! I printed a couple of images and it really seems like omitting these commands causes it to print darker.

I can also confirm that we can just chain CMD_SET_PAPERs like this:

data = \
        cmd_feed_paper(25) + \
        CMD_SET_PAPER + \
        CMD_SET_PAPER + \
        CMD_SET_PAPER + \
        CMD_SET_PAPER + \
        CMD_SET_PAPER

Nice!

rbaron avatar Mar 29 '22 20:03 rbaron

@rbaron Commit 044eab6 makes PRINTER_MODE an unused variable, and thus dark_mode an unused parameter, and thus the --darker command line argument a no-op.

akx avatar Apr 25 '22 05:04 akx

Just for reference, here is also a discussion about this: https://github.com/rbaron/catprinter/commit/044eab65426117027a8c9b11fe2c072b21042a5c#r70920006

danielfomin96 avatar Apr 25 '22 06:04 danielfomin96

I believe we can get rid of the --darker switch altogether. From my tests it seems the changes in https://github.com/rbaron/catprinter/commit/044eab65426117027a8c9b11fe2c072b21042a5c result in a darker and better quality print, as discovered by @8bitben.

rbaron avatar Apr 25 '22 17:04 rbaron

Hello, i am using the GB03 model and I can also say that using the original Android App prints way better than using the python script. I have tried to add the cmd_set_energy and/or CMD_PRINT_TEXT, but didn't improved the printing quality.

radu022003 avatar May 18 '22 13:05 radu022003

Actually CMD_SET_PAPER is the real feed_paper a command with argument. see https://github.com/NaitLee/Cat-Printer/blob/cbfd904152cc4a8049a40d4948edbd5e42a28df0/printer_lib/commander.py#L127 here 0xa1 is -95.

cmd_feed_paper just set the speed (-67 is 0xbd): https://github.com/NaitLee/Cat-Printer/blob/cbfd904152cc4a8049a40d4948edbd5e42a28df0/printer_lib/commander.py#L131

there's also a retract_paper which make it backwards: https://github.com/NaitLee/Cat-Printer/blob/cbfd904152cc4a8049a40d4948edbd5e42a28df0/printer_lib/commander.py#L123

I suggest changing the naming and make CMD_SET_PAPER a function with argument.

Wang-Yue avatar Sep 06 '22 05:09 Wang-Yue

First of all thanks @rbaron for this project. I want to second @radu022003 regarding print quality. See a direct comparison between the python script and the Fun Print iOS app

python_vs_ios

Also, the iOS app offers Text vs Graphics options for printing. All above samples were printed with the "Pattern: Text" option, see the iOS app's print dialog below

Fun_Print_app-options

wahlatlas avatar Nov 19 '22 10:11 wahlatlas

So I bought myself a bluetooth sniffer...

And with it was finally possible to find all the necessary commands to control the catprinter. I could not work out how to encode the commands in to the decimal form currently used in this project, but I do not think this is essential for now. Maybe we can bring them to a common form to compare them. There are always five commands used to configure the next print:

  • Intensity
  • ??? (1)
  • Text/Image
  • ??? (2)
  • Lattice Start

The two ??? commands do not change with different printing configurations, so they are probably something like "CMD_GET_DEV_STATE". In my tests I found that the intensity can be controlled with the following commands used as an intensity command:

  • DEEPEN: "\x51\x78\xa4\x00\x01\x00\x35\x8b\xff"
  • NORMAL: "\x51\x78\xa4\x00\x01\x00\x33\x99\xff"
  • FADED: "\x51\x78\xa4\x00\x01\x00\x32\x9e\xff"

The difference between Text and Image can be made with:

  • IMAGE: "\x51\x78\xbe\x00\x01\x00\x00\x00\xff"
  • TEXT: "\x51\x78\xbe\x00\x01\x00\x01\x07\xff"

Lattice Start is:

"\x51\x78\xbf\x00\x04\x00\x7f\x7f\x7f\x03\xa8\xff"
"\x51\x78\xbf\x00\x04\x00\x7f\x7f\x7f\x03\xa8"

??? (1):

\x51\x78\xaf\x00\x02\x00\x28\x23\xef\xff

??? (2):

\x51\x78\xbd\x00\x01\x00\x14\x6c\xff

The tests were done by sniffing with wireshark while printing through the iprint ios app and the printer GB03.

danielfomin96 avatar Mar 01 '23 21:03 danielfomin96

Thanks for the elaborate research. Meanwhile I found that for the MX06 printer model (samples in above photo) this other project resulted in decent print quality: https://github.com/NaitLee/Cat-Printer

wahlatlas avatar Mar 02 '23 10:03 wahlatlas

I replaced CMD_SET_QUALITY_200_DPI with @danielfomin96 values for "deepen" i.e. CMD_SET_QUALITY_200_DPI = bs([0x51, 0x78, 0xa4, 0x0, 0x1, 0x0, 0x35, 0x8b, 0xff]) and so far my prints are both more even in color and darker.

Not sure what DPI setting is active, I just wanted to make a quick test.

yosh-se avatar Feb 22 '24 23:02 yosh-se