From 5307eea8585ce9a4a3f0282ba057cee95f074d54 Mon Sep 17 00:00:00 2001 From: Martin Zaloudek Date: Tue, 24 Oct 2023 05:16:52 +0200 Subject: [PATCH 1/2] fix: new line after bitmap image --- src/profile/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/profile/index.ts b/src/profile/index.ts index 7b9f819..95f7036 100644 --- a/src/profile/index.ts +++ b/src/profile/index.ts @@ -127,15 +127,20 @@ export abstract class Profile { async draw(image: Image): Promise { 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')); } + // Reset the line spacing to default return this.connection.write(Buffer.from('\x1B2', 'ascii')); } From 0bdbc6b851876136d90b35ecb7cb1de3706b87d5 Mon Sep 17 00:00:00 2001 From: Martin Zaloudek Date: Tue, 24 Oct 2023 05:28:13 +0200 Subject: [PATCH 2/2] chore: update test resource bin files --- __tests__/resources/cmp-20_qrcode.bin | Bin 3181 -> 3167 bytes __tests__/resources/dr800_draw_buffer.bin | Bin 4949 -> 4931 bytes .../resources/mp-4200_th_draw_buffer.bin | Bin 4950 -> 4932 bytes __tests__/resources/mp-4200_th_draw_file.bin | Bin 4950 -> 4932 bytes __tests__/resources/printid_qrcode.bin | Bin 3181 -> 3167 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/__tests__/resources/cmp-20_qrcode.bin b/__tests__/resources/cmp-20_qrcode.bin index 1db6ec89aa54bcba3159043f9d7fbeef0ce53cf3..cf4dcfb9f5a55d68524295d994f65b7f6fe83fc9 100644 GIT binary patch delta 72 zcmaDWabIG?Sw=>#%@-IC0;$Ot7|k}HV(x}8O*i+l_Q05d>>%dm2OLm!rkf9N^)Rw= KNgGKg8UO&EXBSQY delta 98 zcmcaF@m6BPSw?1QFNVnzn9U~hFvm|m$}F+Dnn?sKxOoEeL71%R=62Q|1jmyd&N17} V!`Y3H*}&Dq$N@A_+DJOl004-R8ifD= diff --git a/__tests__/resources/dr800_draw_buffer.bin b/__tests__/resources/dr800_draw_buffer.bin index ffbf404606dcf1de06037efc238cab6604f79c07..6c2b67d31ed3e220ed2e24558634be58eaef07fc 100644 GIT binary patch delta 70 zcmcbrc35qLE)yfyW&daU9Q>yYocv%)S5T3OjZ4}{I?(_C DK&cLz delta 88 zcmX@2c1>-A9uu>)7sF>yYocv%)S5T3OjZ4}{I?(_C DK&cLz delta 88 zcmX@2c1>-A9uu>)7sF#%@-IC0;$Ot7|k}HV(x}8O*i+l_Q05d>>%dm2OLm!rkf9N^)Rw= KNgGKg8UO&EXBSQY delta 98 zcmcaF@m6BPSw?1QFNVnzn9U~hFvm|m$}F+Dnn?sKxOoEeL71%R=62Q|1jmyd&N17} V!`Y3H*}&Dq$N@A_+DJOl004-R8ifD=