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

This commit is contained in:
Bot 2024-08-22 01:00:02 +03:00 committed by multimote
parent 14de9bccdb
commit 75e22d2f2c
3 changed files with 7 additions and 2 deletions

View File

@ -146,7 +146,7 @@ export class NiimbotBluetoothClient extends NiimbotAbstractClient {
if (this.channel === undefined) {
throw new Error("Channel is closed");
}
await Utils.sleep(10); // https://github.com/MultiMote/niimblue/issues/5
await Utils.sleep(this.packetIntervalMs); // https://github.com/MultiMote/niimblue/issues/5
await this.channel.writeValueWithoutResponse(data);
this.dispatchTypedEvent("rawpacketsent", new RawPacketSentEvent(data));
};

View File

@ -32,6 +32,7 @@ export abstract class NiimbotAbstractClient extends TypedEventTarget<ClientEvent
public readonly abstraction: Abstraction;
protected info: PrinterInfo = {};
private heartbeatTimer?: NodeJS.Timeout;
protected packetIntervalMs: number = 10;
constructor() {
super();
@ -135,6 +136,10 @@ export abstract class NiimbotAbstractClient extends TypedEventTarget<ClientEvent
return getPrintTaskVersion(meta.model);
}
public setPacketInterval(milliseconds: number) {
this.packetIntervalMs = milliseconds;
}
}
export * from "./events";

View File

@ -170,7 +170,7 @@ export class NiimbotSerialClient extends NiimbotAbstractClient {
if (this.writer === undefined) {
throw new Error("Port is not writable");
}
await Utils.sleep(10); // https://github.com/MultiMote/niimblue/issues/5
await Utils.sleep(this.packetIntervalMs); // https://github.com/MultiMote/niimblue/issues/5
await this.writer.write(data);
this.dispatchTypedEvent("rawpacketsent", new RawPacketSentEvent(data));
};