-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
424 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import TSPLCommand from "../../TSPLCommand"; | ||
import { Point } from "@/commands"; | ||
|
||
export default class TSPLDiagonal extends TSPLCommand { | ||
private readonly start: Point | ||
private readonly end: Point | ||
private readonly thickness: number | ||
|
||
constructor(start: Point, end: Point, thickness: number = 3) { | ||
super() | ||
this.start = start | ||
this.end = end | ||
this.thickness = thickness | ||
} | ||
|
||
get commandString(): string { | ||
return `DIAGONAL ${this.start.x}, ${this.start.y}, ${this.end.x}, ${this.end.y}, ${this.thickness}` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import TSPLCommand from "../../TSPLCommand"; | ||
|
||
export type DisplayType = "CLS"|"IMAGE" | ||
|
||
/** | ||
* Displays the image buffer on the screen | ||
* {@link /documentsions/TSPL.pdf} | ||
*/ | ||
export default class TSPLDisplay extends TSPLCommand { | ||
private readonly type: DisplayType | ||
|
||
constructor(type: DisplayType) { | ||
super() | ||
this.type = type | ||
} | ||
|
||
get commandString(): string { | ||
return `DISPLAY ${this.type}` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { UsbDevice } from "@/helpers/USBUtils" | ||
import TSPLCommand from "../../TSPLCommand" | ||
|
||
type Data = ArrayBuffer|Uint8Array | ||
/** | ||
* A raw TSPL command. Can be used to use a command that is not yet supported | ||
*/ | ||
export default class TSPLDownload extends TSPLCommand { | ||
/** | ||
* Name of the file on the printer | ||
*/ | ||
private readonly fileName: string | ||
private readonly data: Data | ||
|
||
/** | ||
* Initialize a command with a raw body | ||
* @param body | ||
*/ | ||
constructor(fileName: string, data: Data) { | ||
super() | ||
this.fileName = fileName | ||
this.data = data | ||
} | ||
|
||
get commandString(): string { | ||
return `DOWNLOAD "${this.fileName}", ${this.data.byteLength},` | ||
} | ||
|
||
async write(device: UsbDevice): Promise<void> { | ||
await this.writeString(this.commandString, device) | ||
await this.writeBytes(this.data, device) | ||
await this.terminateCommand(device) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type Point = {x: number, y: number} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
import { UnitSystem } from "@/commands" | ||
|
||
const pointsPerInch = 72 | ||
|
||
export function valueWithUnit(value: number, unitSystem: UnitSystem) { | ||
switch(unitSystem) { | ||
case "dot": return `${value} dot` | ||
case "imperial": return value | ||
case "metric": return `${value} mm` | ||
} | ||
} | ||
|
||
/** | ||
* Convert a value from dots in points in a given dpi | ||
*/ | ||
export function dotToPoint(dots: number, dpi: number): number { | ||
const inch = dots / dpi | ||
return Math.round(inch * pointsPerInch) | ||
} |
Oops, something went wrong.