pxt-jacdac/actuator.ts

24 строки
775 B
TypeScript
Исходник Обычный вид История

2020-06-10 03:51:50 +03:00
namespace jacdac {
export class ActuatorClient extends Client {
protected state: Buffer;
constructor(deviceClass: number, stateLength: number, role: string) {
super(deviceClass, role);
2020-06-10 03:51:50 +03:00
this.state = Buffer.create(stateLength);
// TODO
// this.onDriverEvent(JDDriverEvent.Connected, () => this.notifyChange());
}
protected ensureState(length: number) {
if (length > this.state.length) {
const b = control.createBuffer(length);
b.write(0, this.state);
this.state = b;
}
}
protected notifyChange() {
this.sendCommand(JDPacket.from(CMD_SET_REG | SystemReg.Value, this.state))
2020-06-10 03:51:50 +03:00
}
}
}