Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image paper feed #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified __tests__/resources/cmp-20_qrcode.bin
Binary file not shown.
Binary file modified __tests__/resources/dr800_draw_buffer.bin
Binary file not shown.
Binary file modified __tests__/resources/mp-4200_th_draw_buffer.bin
Binary file not shown.
Binary file modified __tests__/resources/mp-4200_th_draw_file.bin
Binary file not shown.
Binary file modified __tests__/resources/printid_qrcode.bin
Binary file not shown.
7 changes: 6 additions & 1 deletion src/profile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,20 @@ export abstract class Profile {
async draw(image: Image): Promise<void> {
const low = String.fromCharCode(image.width & 0xff);
const high = String.fromCharCode((image.width >> 8) & 0xff);
// Set correct line spacing
await this.connection.write(Buffer.from('\x1B3\x10', 'ascii'));
// Print image slice by slice
for (let y = 0; y < image.lines; y++) {
// Bit-image slice
const data = image.lineData(y);
await this.connection.write(
Buffer.from(this.bitmapCmd + low + high, 'ascii'),
);
await this.connection.write(data);
await this.connection.write(Buffer.from('\x1BJ\x00', 'ascii'));
// Paper feed
await this.connection.write(Buffer.from('\x0A', 'ascii'));
ma-zal marked this conversation as resolved.
Show resolved Hide resolved
}
// Reset the line spacing to default
return this.connection.write(Buffer.from('\x1B2', 'ascii'));
}

Expand Down