marklife-label-printer-web-kit
Version:
JavaScript library for BLE label printing with Marklife printers
104 lines (86 loc) • 2.98 kB
JavaScript
const { processImageData } = require("./image_processing/image-processing");
const commands = require("./printer_commands/printer-commands");
/**
* Main Facade for the Marklife Printer SDK.
* Maps raw commands to accessible methods.
*/
module.exports = {
// --- Image Core ---
/**
* Processes raw image data (RGBA) into a compressed format for the printer.
* @param {Object} imageData - { data: Uint8Array, width: number, height: number }
* @returns {Promise<Uint8Array>} Compressed image data ready for transmission.
*/
processImageData,
// --- Print Control ---
/**
* Starts a print session (Protocol 0x1F).
* @returns {Buffer} Command buffer.
*/
startPrintjob: commands.startPrintjob,
/**
* Ends a print session.
* @returns {Buffer} Command buffer.
*/
stopPrintjob: commands.stopPrintjob,
// --- Paper Movement ---
/**
* Retracts/Aligns the paper to the start position (Align Start).
* @returns {Buffer} Command buffer.
*/
alignPaperStart: () => commands.adjustPositionAuto(0x51),
/**
* Feeds/Cuts the paper to the end position (Align End).
* @returns {Buffer} Command buffer.
*/
alignPaperEnd: () => commands.adjustPositionAuto(0x50),
adjustPosition: commands.adjustPosition,
adjustPositionAuto: commands.adjustPositionAuto,
printerLocation: commands.printerLocation,
printerLocationAuto: commands.printerLocationAuto,
// --- Configuration ---
setBTType: commands.setBTType,
/**
* Sets the paper type.
* @param {number} type - 0x20: Label (Gap), 0x10: Continuous.
* @returns {Buffer} Command buffer.
*/
setPaperType: commands.setPaperType,
getPaperType: commands.getPaperType,
/**
* Sets the print density (darkness).
* @param {number} level - 1 to 15.
* @returns {Buffer} Command buffer.
*/
setDensity: commands.setDensity,
getDensity: commands.getDensity,
/**
* Sets the print speed.
* @param {number} level - 0: Low, 1: Medium, 2: High.
* @returns {Buffer} Command buffer.
*/
setSpeed: commands.setSpeed,
getSpeed: commands.getSpeed,
// --- Maintenance ---
/**
* Prints a self-test page.
* @returns {Buffer} Command buffer.
*/
selfCheck: commands.selfCheck,
resetFactoryData: commands.resetFactoryData,
/**
* Calibrates the label sensor (Learn Paper).
* @returns {Buffer} Command buffer.
*/
learnPaper: commands.learnPaper,
// --- Status Queries ---
printerStatus: commands.printerStatus,
getPrinterBatteryVol: commands.getPrinterBatteryVol,
getPrinterVersion: commands.getPrinterVersion,
getPrinterSN: commands.getPrinterSN,
getPrinterModel: commands.getPrinterModel,
getPrinterMac: commands.getPrinterMac,
// --- Power Management ---
setShutTime: commands.setShutTime,
getShutTime: commands.getShutTime
};