PRINT_SWEEP specification

## Sweep data explanation It took me quite a while to understand the explanation of the sweep data from the HP Journal articles, so I will try to explain it in a little clearer terms here. The swing buffer separation applies for black as well as CMY sweeps. I have only deciphered the ordering for the black data, however. ### What's a sweep? Let's first start off by describing how the nozzles on the printhead are arranged. For the black nozzles, there are 300 total nozzles. They are numbered from 1 to 300. There are two columns of nozzles - odd and even. The odd colum consists of 150 nozzles separated by 1/300 of an inch. The even column is similar, but it is shifted down 1/600 of an inch from the odd column. Thus, we can get 300 dpi by printing with one column and 600 dpi by printing "between the lines" with the other column. For the color nozzles, each color (CMY - cyan, magenta, yellow) has 64 nozzles. They are split into two columns of 32 nozzles each. The odd column has nozzles separated by 1/150 of an inch, and the even column has the same set of nozzles, but shifted 1/300 of an inch down. This allows us to get 300 dpi color. (This may differ slightly on printers other than the 820Cse) When the printer prints a graphical image, it must convert the image data into a form that it can understand. The first task is to separate the image into swaths. Let us assume that we have a black-and-white bitmap that is X pixels wide and Y pixels tall that we want to send to the printer. We must cut this into several swaths, each of a certain height. For example, we might choose to cut it into swaths that are 300 pixels high (1/2 an inch). This produces a series of bitmaps that are X by 300 pixels in dimension. With this swath data, we can now produce a series of sweeps. A sweep is simply a set of data that tells the printhead how to move across the page and what data to print. For each swath, there may be only one sweep, or there may be multiple sweeps. ### Formatting the sweep data The sweep data is formatted in a very specific way so that the printer can understand it. The first thing that we need to do is convert the bitmap data into the correct form. The form that is required looks like this:
Columns 0-7 | Columns 8-15 | ... | Columns ceil(X/8)*8-8 to ceil(X/8)*8-1
Byte 0 | Byte 1 | ... | Byte ceil(X/8)-1
Byte ceil(X/8) | Byte ceil(X/8)+1 | ... | Byte 2*ceil(X/8)-1
... | ... | ... | ...
Each of the 8 bit values are packed into a byte in big-endian order. To give a more concrete example, assume we have a sweep that is 64 pixels wide and 8 pixels tall. Here is what our data organization will look like:
| Col 0-7 | Col 8-15 | Col 16-23 | Col 24-31 | Col 32-39 | Col 40-47 | Col 48-55 | Col 56-63
Row 0 | Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7
Row 1 | Byte 8 | Byte 9 | Byte 10 | Byte 11 | Byte 12 | Byte 13 | Byte 14 | Byte 15
Row 2 | Byte 16 | Byte 17 | Byte 18 | Byte 19 | Byte 20 | Byte 21 | Byte 22 | Byte 23
Row 3 | Byte 24 | Byte 25 | Byte 26 | Byte 27 | Byte 28 | Byte 29 | Byte 30 | Byte 31
Row 4 | Byte 32 | Byte 33 | Byte 34 | Byte 35 | Byte 36 | Byte 37 | Byte 38 | Byte 39
Row 5 | Byte 40 | Byte 41 | Byte 42 | Byte 43 | Byte 44 | Byte 45 | Byte 46 | Byte 47
Row 6 | Byte 48 | Byte 49 | Byte 50 | Byte 51 | Byte 52 | Byte 53 | Byte 54 | Byte 55
Row 7 | Byte 56 | Byte 57 | Byte 58 | Byte 59 | Byte 60 | Byte 61 | Byte 62 | Byte 63
Our next task is to separate this data into swing buffers. Since the odd and even nozzles on the printhead are physically separated, we must extract the appropriate rows of pixels to give to the printer. Two swing buffers are created for each column of bytes. The first is the odd swing buffer, and the second is the even swing buffer. These correspond to which pins will be printing the data. Thus, the odd swing buffer for the first column in the above example would look like this:
Byte 0
Byte 16
Byte 32
Byte 48
And the even swing buffer looks like this:
Byte 8
Byte 24
Byte 40
Byte 56
### Ordering the swing buffers Now we have odd and even swing buffers for each of the columns in the print sweep. The next thing for us to do is order these swing buffers and send them to the printer. From experimentation, I have determined the ordering for the black data on the 820Cse. First, the odd swing buffers for the left 12 columns are sent as sweep data. Next, the odd swing buffer for the 13th column is sent, followed by the even swing buffer for the first column. This alternates until we run out of odd swing buffers. Finally, the even swing buffers for the last 12 columns are sent. From experimentation, it seems that the values of the first and last 12 columns of data MUST be all 0's. Otherwise, strange results occur, including the repetition of a single swing buffer across the whole sweep. Here is a quick reference for the ordering of the swing buffer data, assuming X columns of data.
Odd swing buffer for column 0
Odd swing buffer for column 1
...
Odd swing buffer for column 11
Odd swing buffer for column 12
Even swing buffer for column 0
Odd swing buffer for column 13
Even swing buffer for column 1
...
Odd swing buffer for column X-1
Even swing buffer for column X-13
Even swing buffer for column X-12
Even swing buffer for column X-11
...
Even swing buffer for column X-1
For different printers and color printing, the number of columns to send before we start interleaving seems to vary.