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

@@ -84,10 +84,33 @@ libptouch_err_t libptouch_open_usb(libptouch_ctx *ctx);
void libptouch_close(libptouch_ctx *ctx);
/**
* デバッグ用: USB bulk OUT へ実際に送ったバイト列を path に保存する。
* 各 @ref libptouch_print_raster ごとにファイルを上書きし直す(ジョブ先頭のチャンクで wb
* path が NULL または空文字で無効化。転送が成功したチャンクのみ追記する。
*/
void libptouch_set_debug_dump_path(libptouch_ctx *ctx, const char *path);
/** @ref libptouch_raster_params_t.flags 用: ESC i M bit6 でオートカット ON */
#define LIBPTOUCH_RASTER_FLAG_AUTO_CUT 0x01u
/** @ref libptouch_raster_params_t.flags 用: ESC i K bit2 でハーフカット ON */
#define LIBPTOUCH_RASTER_FLAG_HALF_CUT 0x02u
/** @ref libptouch_raster_params_t.flags 用: ChainPrint するESC i K bit3=0 */
#define LIBPTOUCH_RASTER_FLAG_CHAIN_PRINT 0x04u
/** 既定: 011オートカットしない・ハーフカットする・つなげて印刷する */
#define LIBPTOUCH_RASTER_FLAGS_DEFAULT \
(LIBPTOUCH_RASTER_FLAG_HALF_CUT | LIBPTOUCH_RASTER_FLAG_CHAIN_PRINT)
typedef struct {
uint32_t width_dots; /**< ラスター幅(ドット) */
uint32_t width_dots; /**< ラスター幅(ドット) */
uint32_t height_dots; /**< ラスター高さ(ドット・走査方向は実装と機種に依存) */
uint8_t margin_mm; /**< 余白など(機種・仕様に合わせて使用) */
uint8_t margin_mm; /**< 余白など(機種・仕様に合わせて使用) */
/**
* LIBPTOUCH_RASTER_FLAG_*。未使用ビットは 0。
* 既定は @ref LIBPTOUCH_RASTER_FLAGS_DEFAULT011: オートカットしない・ハーフカットする・つなげて印刷する)。
*/
uint8_t flags;
uint8_t _reserved[2]; /**< 将来用。0 にすること */
} libptouch_raster_params_t;
typedef struct {
@@ -135,6 +158,8 @@ libptouch_err_t libptouch_trim_right_blank_columns(
* width_dots は装着テープの印刷可能幅以下であること。系統は @ref libptouch_get_current_media_info
* の printer_family で判別できるP900 系は主に 360dpi 相当ドット列、P700 系は 180dpi 相当)。
* @param margin_mm 余白フィード量。0 のとき PDF の最小 1mm14 ドット)相当を送る。
* @param params->flags bit0=オートカット、bit1=ハーフカット、bit2=チェーンプリントする。
* 指定なしは @ref LIBPTOUCH_RASTER_FLAGS_DEFAULT011
* 印刷時は内部でドット列を転置する(テープ幅方向とバッファの縦横の対応)。
* @param data 1 行あたり width_dots ビットを ceil(width_dots/8) バイトで並べた連続領域
* @param data_len 期待値: height * row_bytes, row_bytes = (width_dots + 7) / 8