add cut bitmask option and debug dump support

Replace auto-cut toggle with --cut bit flags (default 011), wire flags through C/Ruby APIs, and document the new cut/debug-dump behavior in both READMEs.

Made-with: Cursor
This commit is contained in:
knb
2026-04-20 04:22:27 +09:00
parent bfd6adda42
commit e10a430f9e
19 changed files with 255 additions and 38 deletions

View File

@@ -1,5 +1,7 @@
#include "libptouch_protocol.h"
#include "libptouch.h"
#include <stdio.h>
#include <stdlib.h>
@@ -38,23 +40,38 @@ int main(void)
fail |= expect_int("gf70_n2", gf[2], 0x00);
uint8_t iz[13];
ptouch_fill_esc_iz(iz, &prof_fixture_p700, 0x01u, 0x0Cu, 70u);
ptouch_fill_esc_iz(iz, &prof_fixture_p700, 0x0Cu, 70u);
fail |= expect_int("iz_cmd_0", iz[0], 0x1B);
fail |= expect_int("iz_cmd_1", iz[1], 0x69);
fail |= expect_int("iz_cmd_2", iz[2], 0x7A);
fail |= expect_int("iz_n1_flags", iz[3], 0x8E);
fail |= expect_int("iz_media_kind_passthrough", iz[4], 0x01);
fail |= expect_int("iz_n1_flags", iz[3], 0x84);
fail |= expect_int("iz_media_kind_fixed", iz[4], 0x00);
fail |= expect_int("iz_media_width", iz[5], 0x0C);
fail |= expect_int("iz_lines_lsb", iz[7], 70);
fail |= expect_int("iz_page_control_p700", iz[11], 0x00);
fail |= expect_int("iz_last_fixed", iz[12], 0x00);
ptouch_fill_esc_iz(iz, &prof_fixture_p900, 0x01u, 0x0Cu, 70u);
ptouch_fill_esc_iz(iz, &prof_fixture_p900, 0x0Cu, 70u);
fail |= expect_int("iz_page_control_p900_single", iz[11], 0x02);
/* ESC i K mode byte: 128-dot vs 560-dot families */
fail |= expect_int("esc_ik_128", ptouch_esc_ik_value(128u), 0x08);
fail |= expect_int("esc_ik_560", ptouch_esc_ik_value(560u), 0x0C);
/* ESC i K: bit2=ハーフカット、bit3=ChainPrintしない */
fail |= expect_int(
"esc_ik_p750w_half_chain",
(int)ptouch_esc_ik_extended_mode(
LIBPTOUCH_USB_PID_PTP750W, LIBPTOUCH_RASTER_FLAGS_DEFAULT),
0x04);
fail |= expect_int(
"esc_ik_p710bt_no_half",
(int)ptouch_esc_ik_extended_mode(
LIBPTOUCH_USB_PID_PTP710BT, LIBPTOUCH_RASTER_FLAGS_DEFAULT),
0x00);
fail |= expect_int(
"esc_ik_p900w_auto_half_no_chain",
(int)ptouch_esc_ik_extended_mode(
LIBPTOUCH_USB_PID_PTP900W,
LIBPTOUCH_RASTER_FLAG_AUTO_CUT |
LIBPTOUCH_RASTER_FLAG_HALF_CUT),
0x0C);
return fail ? EXIT_FAILURE : EXIT_SUCCESS;
}