ba63 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # package
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run index.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.3.5. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
@@ -0,0 +1,23 @@
1
+ import HID from "node-hid";
2
+ export declare class BA63 {
3
+ private device;
4
+ /** Current cursor position in [row, column] format */
5
+ protected cursorPos: [number, number];
6
+ /**
7
+ * **NOTE**: This constructor should only be used if you already have an open HID device to interface with.
8
+ */
9
+ constructor(device: HID.HIDAsync);
10
+ static create(): Promise<BA63>;
11
+ private run;
12
+ render(message: string): Promise<void>;
13
+ renderInCenter(message: string): Promise<void>;
14
+ testRender(): Promise<void>;
15
+ setCharset(charset: number): Promise<void>;
16
+ deleteToEOL(): Promise<void>;
17
+ setCursorPosition(row: number, column: number): Promise<void>;
18
+ setCursorColumn(column: number): Promise<void>;
19
+ setCursorRow(row: number): Promise<void>;
20
+ clearDisplay(): Promise<void>;
21
+ get lengthToEnd(): number;
22
+ }
23
+ //# sourceMappingURL=BA63.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BA63.d.ts","sourceRoot":"","sources":["../../src/classes/BA63.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAK3B,qBAAa,IAAI;IACf,OAAO,CAAC,MAAM,CAAe;IAE7B,sDAAsD;IACtD,SAAS,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAU;IAE/C;;OAEG;gBACS,MAAM,EAAE,GAAG,CAAC,QAAQ;WAInB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;YAgCtB,GAAG;IAUX,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc7D,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAKnC,IAAI,WAAW,IAAI,MAAM,CAExB;CACF"}
@@ -0,0 +1,2 @@
1
+ export * from "./classes/BA63";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,83 @@
1
+ // src/classes/BA63.ts
2
+ import HID from "node-hid";
3
+ var vendorId = 2727;
4
+ var productId = 512;
5
+
6
+ class BA63 {
7
+ device;
8
+ cursorPos = [0, 0];
9
+ constructor(device) {
10
+ this.device = device;
11
+ }
12
+ static async create() {
13
+ const devices = HID.devices();
14
+ const ba63Devices = devices.filter((device2) => device2.vendorId === vendorId && device2.productId === productId);
15
+ if (ba63Devices.length === 0) {
16
+ throw new Error("BA63 device not found");
17
+ }
18
+ const displayInterface = ba63Devices.find((d) => d.interface === 1);
19
+ if (!displayInterface) {
20
+ throw new Error("BA63 display interface (Interface 1) not found!");
21
+ }
22
+ const device = await HID.HIDAsync.open(displayInterface.path);
23
+ return new BA63(device);
24
+ }
25
+ async run(command) {
26
+ const writeComment = [2, 0, command.length, ...command];
27
+ while (writeComment.length < 32) {
28
+ writeComment.push(0);
29
+ }
30
+ await this.device.write(writeComment);
31
+ }
32
+ async render(message) {
33
+ const trimmedMessage = message.slice(0, this.lengthToEnd);
34
+ const data = Buffer.from(trimmedMessage, "ascii");
35
+ const arr = Array.from(data);
36
+ await this.run(arr);
37
+ }
38
+ async renderInCenter(message) {
39
+ const trimmedMessage = message.slice(0, 20);
40
+ const padding = Math.floor((20 - trimmedMessage.length) / 2);
41
+ this.setCursorPosition(this.cursorPos[0], padding);
42
+ await this.render(trimmedMessage);
43
+ }
44
+ async testRender() {
45
+ const testMessage = "Hello from BA63!";
46
+ await this.renderInCenter(testMessage);
47
+ await this.setCursorRow(1);
48
+ await this.renderInCenter("- Caleb");
49
+ }
50
+ async setCharset(charset) {
51
+ const command = [27, 82, charset];
52
+ await this.run(command);
53
+ }
54
+ async deleteToEOL() {
55
+ const command = [27, 91, 48, 75];
56
+ await this.run(command);
57
+ }
58
+ async setCursorPosition(row, column) {
59
+ this.cursorPos = [row, column];
60
+ const asciiRow = (row + 1).toString().charCodeAt(0);
61
+ const asciiColumn = (column + 1).toString().split("").map((char) => char.charCodeAt(0));
62
+ const command = [27, 91, asciiRow, 59, ...asciiColumn, 72];
63
+ await this.run(command);
64
+ }
65
+ async setCursorColumn(column) {
66
+ this.setCursorPosition(this.cursorPos[0], column);
67
+ }
68
+ async setCursorRow(row) {
69
+ this.setCursorPosition(row, this.cursorPos[1]);
70
+ }
71
+ async clearDisplay() {
72
+ const command = [27, 91, 50, 74];
73
+ await this.run(command);
74
+ }
75
+ get lengthToEnd() {
76
+ return 20 - this.cursorPos[1];
77
+ }
78
+ }
79
+ export {
80
+ BA63
81
+ };
82
+
83
+ //# debugId=2318C4E4063EB96A64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/classes/BA63.ts"],
4
+ "sourcesContent": [
5
+ "import HID from \"node-hid\";\n\nconst vendorId = 2727;\nconst productId = 512;\n\nexport class BA63 {\n private device: HID.HIDAsync;\n\n /** Current cursor position in [row, column] format */\n protected cursorPos: [number, number] = [0, 0];\n\n /**\n * **NOTE**: This constructor should only be used if you already have an open HID device to interface with.\n */\n constructor(device: HID.HIDAsync) {\n this.device = device;\n }\n\n static async create(): Promise<BA63> {\n const devices = HID.devices();\n const ba63Devices = devices.filter(\n (device) => device.vendorId === vendorId && device.productId === productId\n );\n\n if (ba63Devices.length === 0) {\n throw new Error(\"BA63 device not found\");\n }\n\n /*\n * When connecting to a BA63, you'll find that there are two different interfaces\n * to connect to. Interface 0 is for updating the BA63's firmware whereas interface 1\n * is for communicating with the display itself.\n */\n const displayInterface = ba63Devices.find((d) => d.interface === 1);\n\n if (!displayInterface) {\n throw new Error(\"BA63 display interface (Interface 1) not found!\");\n }\n\n const device = await HID.HIDAsync.open(displayInterface.path!);\n // device.on(\"data\", (data) => {\n // console.log(\"Data received:\", data);\n // });\n\n // device.on(\"error\", (err) => {\n // console.error(\"Error:\", err);\n // });\n return new BA63(device);\n }\n\n private async run(command: number[]): Promise<void> {\n // Pad to 32 bytes (HID report size)\n const writeComment = [0x02, 0x00, command.length, ...command];\n while (writeComment.length < 32) {\n writeComment.push(0x00);\n }\n\n await this.device.write(writeComment);\n }\n\n async render(message: string): Promise<void> {\n const trimmedMessage = message.slice(0, this.lengthToEnd);\n const data = Buffer.from(trimmedMessage, \"ascii\");\n const arr = Array.from(data);\n\n await this.run(arr);\n }\n\n async renderInCenter(message: string): Promise<void> {\n const trimmedMessage = message.slice(0, 20);\n const padding = Math.floor((20 - trimmedMessage.length) / 2);\n this.setCursorPosition(this.cursorPos[0], padding);\n\n await this.render(trimmedMessage);\n }\n\n async testRender(): Promise<void> {\n const testMessage = \"Hello from BA63!\";\n await this.renderInCenter(testMessage);\n await this.setCursorRow(1);\n await this.renderInCenter(\"- Caleb\");\n }\n\n async setCharset(charset: number): Promise<void> {\n const command = [0x1b, 0x52, charset];\n await this.run(command);\n }\n\n async deleteToEOL(): Promise<void> {\n const command = [0x1b, 0x5b, 0x30, 0x4b];\n await this.run(command);\n }\n\n async setCursorPosition(row: number, column: number): Promise<void> {\n this.cursorPos = [row, column];\n\n const asciiRow = (row + 1).toString().charCodeAt(0);\n // asciiColumn can be more than one digit\n const asciiColumn = (column + 1)\n .toString()\n .split(\"\")\n .map((char) => char.charCodeAt(0));\n\n const command = [0x1b, 0x5b, asciiRow, 0x3b, ...asciiColumn, 0x48];\n await this.run(command);\n }\n\n async setCursorColumn(column: number): Promise<void> {\n this.setCursorPosition(this.cursorPos[0], column);\n }\n\n async setCursorRow(row: number): Promise<void> {\n this.setCursorPosition(row, this.cursorPos[1]);\n }\n\n async clearDisplay(): Promise<void> {\n const command = [0x1b, 0x5b, 0x32, 0x4a];\n await this.run(command);\n }\n\n get lengthToEnd(): number {\n return 20 - this.cursorPos[1];\n }\n}\n"
6
+ ],
7
+ "mappings": ";AAAA;AAEA,IAAM,WAAW;AACjB,IAAM,YAAY;AAAA;AAEX,MAAM,KAAK;AAAA,EACR;AAAA,EAGE,YAA8B,CAAC,GAAG,CAAC;AAAA,EAK7C,WAAW,CAAC,QAAsB;AAAA,IAChC,KAAK,SAAS;AAAA;AAAA,cAGH,OAAM,GAAkB;AAAA,IACnC,MAAM,UAAU,IAAI,QAAQ;AAAA,IAC5B,MAAM,cAAc,QAAQ,OAC1B,CAAC,YAAW,QAAO,aAAa,YAAY,QAAO,cAAc,SACnE;AAAA,IAEA,IAAI,YAAY,WAAW,GAAG;AAAA,MAC5B,MAAM,IAAI,MAAM,uBAAuB;AAAA,IACzC;AAAA,IAOA,MAAM,mBAAmB,YAAY,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC;AAAA,IAElE,IAAI,CAAC,kBAAkB;AAAA,MACrB,MAAM,IAAI,MAAM,iDAAiD;AAAA,IACnE;AAAA,IAEA,MAAM,SAAS,MAAM,IAAI,SAAS,KAAK,iBAAiB,IAAK;AAAA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AA,IAE7B,MAAM,YAAY,MAAM,GAAG,SAAS,EAAE,WAAW,CAAC;AAAA,IAElD,MAAM,eAAe,SAAS,GAC3B,SAAS,EACT,MAAM,EAAE,EACR,IAAI,CAAC,SAAS,KAAK,WAAW,CAAC,CAAC;AAAA,IAEnC,MAAM,UAAU,CAAC,IAAM,IAAM,UAAU,IAAM,GAAG,aAAa,EAAI;AAAA,IACjE,MAAM,KAAK,IAAI,OAAO;AAAA;AAAA,OAGlB,gBAAe,CAAC,QAA+B;AAAA,IACnD,KAAK,kBAAkB,KAAK,UAAU,IAAI,MAAM;AAAA;AAAA,OAG5C,aAAY,CAAC,KAA4B;AAAA,IAC7C,KAAK,kBAAkB,KAAK,KAAK,UAAU,EAAE;AAAA;AAAA,OAGzC,aAAY,GAAkB;AAAA,IAClC,MAAM,UAAU,CAAC,IAAM,IAAM,IAAM,EAAI;AAAA,IACvC,MAAM,KAAK,IAAI,OAAO;AAAA;AAAA,MAGpB,WAAW,GAAW;AAAA,IACxB,OAAO,KAAK,KAAK,UAAU;AAAA;AAE/B;",
8
+ "debugId": "2318C4E4063EB96A64756E2164756E21",
9
+ "names": []
10
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "ba63",
3
+ "version": "1.0.0",
4
+ "author": {
5
+ "name": "Caleb Perry",
6
+ "url": "https://github.com/foxtrotperry",
7
+ "email": "caleb@foxtrotperry.com"
8
+ },
9
+ "type": "module",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "main": "./dist/index.cjs",
14
+ "module": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js",
19
+ "require": "./dist/index.cjs"
20
+ },
21
+ "scripts": {
22
+ "build:js": "bun run build.ts",
23
+ "build:types": "tsc",
24
+ "build": "bun run build:js && bun run build:types",
25
+ "package": "rm -rf ./dist && bun run build && bun pm pack",
26
+ "test": "bun test"
27
+ },
28
+ "keywords": [
29
+ "bun",
30
+ "ba63",
31
+ "vfd",
32
+ "wincor",
33
+ "nixdorf",
34
+ "wincor-nixdorf",
35
+ "wincor nixdorf",
36
+ "node-hid"
37
+ ],
38
+ "devDependencies": {
39
+ "@types/bun": "latest"
40
+ },
41
+ "peerDependencies": {
42
+ "typescript": "^5",
43
+ "node-hid": "^3.2.0"
44
+ },
45
+ "dependencies": {
46
+ "node-hid": "^3.2.0"
47
+ }
48
+ }