Working tree changes 2024-08-03 01:00
All checks were successful
Test project build / Build (push) Successful in 1m13s

This commit is contained in:
Bot 2024-08-03 01:00:01 +03:00 committed by multimote
parent 2b4a98a221
commit 0f2bd55538
10 changed files with 70 additions and 827 deletions

View File

@ -87,18 +87,34 @@
on:change={onChangePre} on:change={onChangePre}
/> />
<span class="input-group-text">px</span> <span class="input-group-text">px</span>
{#if $printerMeta !== undefined}
{@const headSide = labelProps.printDirection == "left" ? labelProps.size.height : labelProps.size.width}
{#if headSide > $printerMeta.printheadPixels}
<span class="input-group-text text-warning" title="Label size is too big for your printer ({headSide} > {$printerMeta.printheadPixels})">
<FaIcon icon="warning" />
</span>
{/if}
{/if}
</div> </div>
<div class="input-group flex-nowrap input-group-sm mb-3"> <div class="input-group flex-nowrap input-group-sm mb-3">
<span class="input-group-text">Print from</span> <span class="input-group-text">Print from</span>
<select class="form-select" bind:value={labelProps.printDirection} on:change={onChangePre}> <select class="form-select" bind:value={labelProps.printDirection} on:change={onChangePre}>
<option value="left">Left</option> <option value="left"
<option value="top">Top</option> >{#if $printerMeta?.printDirection === "left"}{/if} Left</option
>
<option value="top"
>{#if $printerMeta?.printDirection === "top"}{/if} Top</option
>
</select> </select>
{#if $printerMeta !== undefined && $printerMeta.printDirection !== labelProps.printDirection } {#if $printerMeta !== undefined && $printerMeta.printDirection !== labelProps.printDirection}
<span class="input-group-text text-warning" title="Recommended direction for your printer is {labelProps.printDirection}" > <span
<FaIcon icon="warning"/> class="input-group-text text-warning"
</span> title="Recommended direction for your printer is {labelProps.printDirection}"
>
<FaIcon icon="warning" />
</span>
{/if} {/if}
</div> </div>
<!-- <button class="btn btn-sm btn-primary" on:click={onSubmit}>Update</button> --> <!-- <button class="btn btn-sm btn-primary" on:click={onSubmit}>Update</button> -->

View File

@ -27,6 +27,7 @@
let labelType: LabelType = LabelType.WithGaps; let labelType: LabelType = LabelType.WithGaps;
let statusTimer: NodeJS.Timeout | undefined = undefined; let statusTimer: NodeJS.Timeout | undefined = undefined;
let error: string = ""; let error: string = "";
let taskVer = $printerClient?.getPrintTaskVersion();
const disconnected = derived(connectionState, ($connectionState) => $connectionState !== "connected"); const disconnected = derived(connectionState, ($connectionState) => $connectionState !== "connected");
@ -107,7 +108,7 @@
onClosed(); onClosed();
}); });
const taskVer = $printerClient?.getPrintTaskVersion();
if (taskVer !== undefined) { if (taskVer !== undefined) {
console.log(`Detected print task version: ${ProtocolVersion[taskVer]}`); console.log(`Detected print task version: ${ProtocolVersion[taskVer]}`);
@ -179,13 +180,13 @@
</div> </div>
<div class="input-group flex-nowrap input-group-sm"> <div class="input-group flex-nowrap input-group-sm">
<span class="input-group-text">Density</span> <span class="input-group-text">Copies</span>
<input class="form-control" type="number" min="1" max="6" bind:value={density} /> <input class="form-control" type="number" min="1" bind:value={quantity} />
</div> </div>
<div class="input-group flex-nowrap input-group-sm"> <div class="input-group flex-nowrap input-group-sm">
<span class="input-group-text">Quantity</span> <span class="input-group-text">Density</span>
<input class="form-control" type="number" min="1" bind:value={quantity} /> <input class="form-control" type="number" min="1" max="6" bind:value={density} />
</div> </div>
<div class="input-group input-group-sm"> <div class="input-group input-group-sm">
@ -205,11 +206,11 @@
<div class="input-group input-group-sm"> <div class="input-group input-group-sm">
<span class="input-group-text">Print task version</span> <span class="input-group-text">Print task version</span>
<select class="form-select" bind:value={printTaskVersion}> <select class="form-select" bind:value={printTaskVersion}>
<option value={ProtocolVersion.V1} disabled>V1 - NOT IMPLEMENTED</option> <option value={ProtocolVersion.V1} disabled>{#if taskVer === ProtocolVersion.V1}{/if} V1 - NOT IMPLEMENTED</option>
<option value={ProtocolVersion.V2} disabled>V2 - NOT IMPLEMENTED</option> <option value={ProtocolVersion.V2} disabled>{#if taskVer === ProtocolVersion.V2}{/if} V2 - NOT IMPLEMENTED</option>
<option value={ProtocolVersion.V3}>V3 - D110</option> <option value={ProtocolVersion.V3}>{#if taskVer === ProtocolVersion.V3}{/if} V3 - D110</option>
<option value={ProtocolVersion.V4}>V4 - B1</option> <option value={ProtocolVersion.V4}>{#if taskVer === ProtocolVersion.V4}{/if} V4 - B1</option>
<option value={ProtocolVersion.V5} disabled>V5 - NOT IMPLEMENTED</option> <option value={ProtocolVersion.V5} disabled>{#if taskVer === ProtocolVersion.V5}{/if} V5 - NOT IMPLEMENTED</option>
</select> </select>
</div> </div>

View File

@ -41,6 +41,10 @@
await $printerClient.abstraction.setSoundEnabled(SoundSettingsItemType.BluetoothConnectionSound, false); await $printerClient.abstraction.setSoundEnabled(SoundSettingsItemType.BluetoothConnectionSound, false);
await $printerClient.abstraction.setSoundEnabled(SoundSettingsItemType.PowerSound, false); await $printerClient.abstraction.setSoundEnabled(SoundSettingsItemType.PowerSound, false);
}; };
const fetchInfo = async () => {
await $printerClient.fetchPrinterInfo()
};
</script> </script>
<div class="input-group flex-nowrap justify-content-end"> <div class="input-group flex-nowrap justify-content-end">
@ -79,6 +83,7 @@
<button class="btn btn-sm btn-primary" on:click={stopHeartbeat}>Heartbeat off</button> <button class="btn btn-sm btn-primary" on:click={stopHeartbeat}>Heartbeat off</button>
<button class="btn btn-sm btn-primary" on:click={soundOn}>Sound on</button> <button class="btn btn-sm btn-primary" on:click={soundOn}>Sound on</button>
<button class="btn btn-sm btn-primary" on:click={soundOff}>Sound off</button> <button class="btn btn-sm btn-primary" on:click={soundOff}>Sound off</button>
<button class="btn btn-sm btn-primary" on:click={fetchInfo}>Fetch info again</button>
</div> </div>
<span class="input-group-text">{$connectedPrinterName}</span> <span class="input-group-text">{$connectedPrinterName}</span>
{:else} {:else}

File diff suppressed because it is too large Load Diff

View File

@ -12,10 +12,11 @@
"private": false, "private": false,
"scripts": { "scripts": {
"clean-build": "yarn clean && yarn build", "clean-build": "yarn clean && yarn build",
"build": "tsc", "build": "tsc --build",
"test": "yarn build && node dist/test.js", "test": "yarn build && node utils/test.mjs",
"parse-dump": "yarn build && node utils/parse-dump.mjs",
"clean": "node clean-dist.mjs", "clean": "node clean-dist.mjs",
"gen-printers-list": "node utils/gen-printers-list.js > src/printer_models.ts" "gen-printer-models": "node utils/gen-printer-models.js > src/printer_models.ts"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.14.2", "@types/node": "^20.14.2",

View File

@ -3,6 +3,7 @@ import {
BatteryChargeLevel, BatteryChargeLevel,
ConnectResult, ConnectResult,
getPrintTaskVersion, getPrintTaskVersion,
LabelType,
NiimbotPacket, NiimbotPacket,
ProtocolVersion, ProtocolVersion,
} from "../packets"; } from "../packets";
@ -24,6 +25,7 @@ export interface PrinterInfo {
mac?: string; mac?: string;
charge?: BatteryChargeLevel; charge?: BatteryChargeLevel;
autoShutdownTime?: AutoShutdownTime; autoShutdownTime?: AutoShutdownTime;
labelType?: LabelType;
} }
export abstract class NiimbotAbstractClient extends TypedEventTarget<ClientEventMap> { export abstract class NiimbotAbstractClient extends TypedEventTarget<ClientEventMap> {
@ -83,6 +85,7 @@ export abstract class NiimbotAbstractClient extends TypedEventTarget<ClientEvent
this.info.mac = await this.abstraction.getPrinterBluetoothMacAddress(); this.info.mac = await this.abstraction.getPrinterBluetoothMacAddress();
this.info.charge = await this.abstraction.getBatteryChargeLevel(); this.info.charge = await this.abstraction.getBatteryChargeLevel();
this.info.autoShutdownTime = await this.abstraction.getAutoShutDownTime(); this.info.autoShutdownTime = await this.abstraction.getAutoShutDownTime();
this.info.labelType = await this.abstraction.getLabelType();
this.dispatchTypedEvent("printerinfofetched", new PrinterInfoFetchedEvent(this.info)); this.dispatchTypedEvent("printerinfofetched", new PrinterInfoFetchedEvent(this.info));
return this.info; return this.info;
} }

View File

@ -34,6 +34,7 @@ export enum ResponseCommandId {
Invalid = -1, Invalid = -1,
In_NotSupported = 0x00, In_NotSupported = 0x00,
In_Connect = 0xc2, In_Connect = 0xc2,
In_AntiFake = 0x0c,
In_HeartbeatAdvanced1 = 0xdd, In_HeartbeatAdvanced1 = 0xdd,
In_HeartbeatBasic = 0xde, In_HeartbeatBasic = 0xde,
In_HeartbeatUnknown = 0xdf, In_HeartbeatUnknown = 0xdf,

View File

@ -67,14 +67,13 @@ export enum PrinterModel {
B11 = "B11", B11 = "B11",
B50 = "B50", B50 = "B50",
ET10 = "ET10", ET10 = "ET10",
} };
export interface PrinterModelMeta { export interface PrinterModelMeta {
model: PrinterModel; model: PrinterModel;
id: [number, ...number[]]; id: [number, ...number[]];
dpi: number; dpi: number;
printDirection: PrintDirection; printDirection: PrintDirection;
maxPrintWidth: number;
printheadPixels: number; printheadPixels: number;
paperTypes: number[]; paperTypes: number[];
} }
@ -85,7 +84,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [272], id: [272],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 576, printheadPixels: 576,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent],
}, },
@ -94,7 +92,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [53250], id: [53250],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 107,
printheadPixels: 832, printheadPixels: 832,
paperTypes: [LT.WithGaps, LT.Black], paperTypes: [LT.WithGaps, LT.Black],
}, },
@ -103,7 +100,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [3586], id: [3586],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 120, printheadPixels: 120,
paperTypes: [LT.WithGaps, LT.HeatShrinkTube, LT.Transparent, LT.BlackMarkGap], paperTypes: [LT.WithGaps, LT.HeatShrinkTube, LT.Transparent, LT.BlackMarkGap],
}, },
@ -112,7 +108,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [4609], id: [4609],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 591, printheadPixels: 591,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -121,7 +116,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [5632], id: [5632],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 77,
printheadPixels: 600, printheadPixels: 600,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -130,7 +124,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [785], id: [785],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 591, printheadPixels: 591,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent],
}, },
@ -139,7 +132,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [3585], id: [3585],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 120, printheadPixels: 120,
paperTypes: [LT.WithGaps, LT.Transparent, LT.BlackMarkGap, LT.HeatShrinkTube], paperTypes: [LT.WithGaps, LT.Transparent, LT.BlackMarkGap, LT.HeatShrinkTube],
}, },
@ -148,7 +140,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [528], id: [528],
dpi: 300, dpi: 300,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 178, printheadPixels: 178,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -157,7 +148,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [784], id: [784],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 567, printheadPixels: 567,
paperTypes: [LT.WithGaps, LT.Transparent, LT.Continuous, LT.Black], paperTypes: [LT.WithGaps, LT.Transparent, LT.Continuous, LT.Black],
}, },
@ -166,7 +156,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2305], id: [2305],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 120, printheadPixels: 120,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -175,7 +164,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2320], id: [2320],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 120, printheadPixels: 120,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -184,7 +172,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [4608], id: [4608],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 591, printheadPixels: 591,
paperTypes: [LT.WithGaps, LT.Transparent, LT.Black, LT.BlackMarkGap], paperTypes: [LT.WithGaps, LT.Transparent, LT.Black, LT.BlackMarkGap],
}, },
@ -193,7 +180,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2817], id: [2817],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 400, printheadPixels: 400,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -202,7 +188,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [4867], id: [4867],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 82,
printheadPixels: 656, printheadPixels: 656,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -211,7 +196,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2818], id: [2818],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 400, printheadPixels: 400,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -220,7 +204,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [4866], id: [4866],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 82,
printheadPixels: 656, printheadPixels: 656,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -229,7 +212,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [4865], id: [4865],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 82,
printheadPixels: 656, printheadPixels: 656,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -238,7 +220,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [4864], id: [4864],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 82,
printheadPixels: 656, printheadPixels: 656,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -247,7 +228,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2561], id: [2561],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 25,
printheadPixels: 192, printheadPixels: 192,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -256,7 +236,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2053], id: [2053],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 851, printheadPixels: 851,
paperTypes: [LT.WithGaps], paperTypes: [LT.WithGaps],
}, },
@ -265,7 +244,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [777], id: [777],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent],
}, },
@ -274,7 +252,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [769], id: [769],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -283,7 +260,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [514], id: [514],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 96, printheadPixels: 96,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -292,7 +268,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2054], id: [2054],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 851, printheadPixels: 851,
paperTypes: [LT.WithGaps, LT.Transparent, LT.Black], paperTypes: [LT.WithGaps, LT.Transparent, LT.Black],
}, },
@ -301,7 +276,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [513], id: [513],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 96, printheadPixels: 96,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -310,7 +284,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [1024], id: [1024],
dpi: 300, dpi: 300,
printDirection: "left", printDirection: "left",
maxPrintWidth: 80,
printheadPixels: 697, printheadPixels: 697,
paperTypes: [LT.PvcTag], paperTypes: [LT.PvcTag],
}, },
@ -319,7 +292,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [1026], id: [1026],
dpi: 300, dpi: 300,
printDirection: "left", printDirection: "left",
maxPrintWidth: 87,
printheadPixels: 662, printheadPixels: 662,
paperTypes: [LT.PvcTag], paperTypes: [LT.PvcTag],
}, },
@ -328,7 +300,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [261], id: [261],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 576, printheadPixels: 576,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -337,7 +308,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [776], id: [776],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -346,7 +316,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [1025], id: [1025],
dpi: 300, dpi: 300,
printDirection: "left", printDirection: "left",
maxPrintWidth: 87,
printheadPixels: 662, printheadPixels: 662,
paperTypes: [LT.PvcTag], paperTypes: [LT.PvcTag],
}, },
@ -355,7 +324,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [4096], id: [4096],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -364,7 +332,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [256], id: [256],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 600, printheadPixels: 600,
paperTypes: [LT.Black, LT.WithGaps, LT.Continuous], paperTypes: [LT.Black, LT.WithGaps, LT.Continuous],
}, },
@ -373,7 +340,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [771, 775], id: [771, 775],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Continuous, LT.Transparent, LT.Black], paperTypes: [LT.WithGaps, LT.Continuous, LT.Transparent, LT.Black],
}, },
@ -382,7 +348,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2051], id: [2051],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 851, printheadPixels: 851,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -391,7 +356,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [1792], id: [1792],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 96, printheadPixels: 96,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -400,7 +364,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2050], id: [2050],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 851, printheadPixels: 851,
paperTypes: [LT.WithGaps], paperTypes: [LT.WithGaps],
}, },
@ -409,7 +372,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2049], id: [2049],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 851, printheadPixels: 851,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -418,7 +380,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [51460], id: [51460],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated],
}, },
@ -427,7 +388,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [51461], id: [51461],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated],
}, },
@ -436,7 +396,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [256], id: [256],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 576, printheadPixels: 576,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent],
}, },
@ -445,7 +404,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2816], id: [2816],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 400, printheadPixels: 400,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -454,7 +412,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [51458], id: [51458],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated],
}, },
@ -463,7 +420,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2304, 2305], id: [2304, 2305],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 96, printheadPixels: 96,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -472,7 +428,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [768], id: [768],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent],
}, },
@ -481,7 +436,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [2560], id: [2560],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 25,
printheadPixels: 192, printheadPixels: 192,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -490,7 +444,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [512], id: [512],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 14,
printheadPixels: 120, printheadPixels: 120,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -499,7 +452,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [273], id: [273],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 616, printheadPixels: 616,
paperTypes: [LT.WithGaps, LT.Black, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Transparent],
}, },
@ -508,7 +460,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [274], id: [274],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 600, printheadPixels: 600,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -517,7 +468,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [51715], id: [51715],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated],
}, },
@ -526,7 +476,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [51714], id: [51714],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated],
}, },
@ -535,7 +484,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [51717], id: [51717],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated],
}, },
@ -544,7 +492,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [51718], id: [51718],
dpi: 300, dpi: 300,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 567, printheadPixels: 567,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated],
}, },
@ -553,7 +500,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [256, 260, 262], id: [256, 260, 262],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 576, printheadPixels: 576,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent],
}, },
@ -562,7 +508,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [52993], id: [52993],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 75,
printheadPixels: 600, printheadPixels: 600,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Transparent],
}, },
@ -571,7 +516,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [3584], id: [3584],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 120, printheadPixels: 120,
paperTypes: [LT.WithGaps, LT.Transparent, LT.BlackMarkGap, LT.HeatShrinkTube], paperTypes: [LT.WithGaps, LT.Transparent, LT.BlackMarkGap, LT.HeatShrinkTube],
}, },
@ -580,7 +524,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [512], id: [512],
dpi: 203, dpi: 203,
printDirection: "left", printDirection: "left",
maxPrintWidth: 15,
printheadPixels: 96, printheadPixels: 96,
paperTypes: [LT.WithGaps, LT.Transparent], paperTypes: [LT.WithGaps, LT.Transparent],
}, },
@ -589,7 +532,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [51457], id: [51457],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 384, printheadPixels: 384,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated, LT.Transparent], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated, LT.Transparent],
}, },
@ -598,7 +540,6 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [51713], id: [51713],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 50,
printheadPixels: 400, printheadPixels: 400,
paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated], paperTypes: [LT.WithGaps, LT.Black, LT.Continuous, LT.Perforated],
}, },
@ -607,16 +548,15 @@ export const modelsLibrary: PrinterModelMeta[] = [
id: [5376], id: [5376],
dpi: 203, dpi: 203,
printDirection: "top", printDirection: "top",
maxPrintWidth: 200,
printheadPixels: 1600, printheadPixels: 1600,
paperTypes: [LT.Continuous], paperTypes: [LT.Continuous],
}, },
]; ];
export const getPrinterMetaById = (id: number): PrinterModelMeta | undefined => { export const getPrinterMetaById = (id: number): PrinterModelMeta | undefined => {
return modelsLibrary.find((o) => o.id.includes(id)); return modelsLibrary.find((o) => o.id.includes(id));
}; };
export const getPrinterMetaByModel = (model: PrinterModel): PrinterModelMeta | undefined => { export const getPrinterMetaByModel = (model: PrinterModel): PrinterModelMeta | undefined => {
return modelsLibrary.find((o) => o.model === model); return modelsLibrary.find((o) => o.model === model);
}; };

View File

@ -1,31 +0,0 @@
// import { NiimbotPacket, Utils } from ".";
// const data = Uint8Array.of(0xF0, 0x10);
// const result = ImageEncoder.indexPixels(data);
// console.log(Utils.bufToHex(result));
// // 00 00 00 0E
// const canvas = createCanvas(16, 8);
// const ctx = canvas.getContext("2d");
// ctx.fillStyle = "white";
// ctx.fillRect(0, 0, canvas.width, canvas.height);
// ctx.fillStyle = "black";
// ctx.fillRect(0, 0, 1, 1);
// ctx.fillRect(canvas.width-1, 0, 1, 1);
// ctx.fillRect(1, 1, 3, 1);
// ctx.fillRect(1, 3, 1, 1);
// const data = ImageEncoder.encodeCanvas(canvas, "top");
// data.rowsData.forEach(e => console.log(e))
// console.log("")
// ImageEncoder.encodeCanvasV2(canvas, "top");
// 55 55 d3 03 00 9f 01 4e aa aa 55 55 e4 01 01 e4 aa aa 55 55 e4 01 01 e4 aa aa
// const data = Uint8Array.from([0x55, 0x55, 0xd3, 0x03, 0x00, 0x9f, 0x01, 0x4e, 0xaa, 0xaa, 0x55, 0x55, 0xe4, 0x01, 0x01, 0xe4, 0xaa, 0xaa, 0x55, 0x55, 0xe4, 0x01, 0x01, 0xe4, 0xaa, 0xaa]);
// console.log(Utils.bufToHex(data));
// NiimbotPacket.fromBytesMultiPacket(data);

View File

@ -9,6 +9,20 @@ export class Utils {
return arr.map((n) => Utils.numberToHex(n)).join(separator); return arr.map((n) => Utils.numberToHex(n)).join(separator);
} }
public static hexToBuf(str: string): Uint8Array {
const match = str.match(/[\da-f]{2}/gi);
if (!match) {
return new Uint8Array();
}
return new Uint8Array(
match.map((h) => {
return parseInt(h, 16);
})
);
}
public static dataViewToNumberArray(dw: DataView): number[] { public static dataViewToNumberArray(dw: DataView): number[] {
const a: number[] = []; const a: number[] = [];
for (let i = 0; i < dw.byteLength; i++) { for (let i = 0; i < dw.byteLength; i++) {