Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/base/sim/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace pxsim.BufferMethods {
}

export function hash(buf: RefBuffer, bits: number) {
BufferMethods.typeCheck(buf);
bits |= 0
if (bits < 1)
return 0
Expand Down
3 changes: 2 additions & 1 deletion libs/cable/sim/cable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace pxsim.network {
export function cableSendPacket(buf: RefBuffer): void {
BufferMethods.typeCheck(buf);
const state = getCableState();
state.send(buf);
}
Expand All @@ -12,7 +13,7 @@ namespace pxsim.network {
export function onCablePacket(body: RefAction): void {
const state = getCableState();
state.listen(body);
}
}

export function onCableError(body: RefAction): void {
const state = getCableState();
Expand Down
2 changes: 2 additions & 0 deletions libs/core/sim/neopixel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace pxsim {
}

export function sendBufferAsm(buffer: RefBuffer, pin: number) {
BufferMethods.typeCheck(buffer);
const b = board();
if (!b) return;
const p = b.edgeConnectorState.getPin(pin);
Expand All @@ -63,6 +64,7 @@ namespace pxsim {
namespace pxsim.light {
// Currently only modifies the builtin pixels
export function sendBuffer(pin: { id: number }, clk: { id: number }, mode: number, b: RefBuffer) {
BufferMethods.typeCheck(b);
const state = neopixelState(pin.id);
if (!state) return;
state.mode = mode & 0xff;
Expand Down
5 changes: 4 additions & 1 deletion libs/core/sim/pins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace pxsim.pins {
markUsed(scl);
return b && b.edgeConnectorState && b.edgeConnectorState.createI2C(sda, scl);
}

export function createSPI(mosi: DigitalInOutPin, miso: DigitalInOutPin, sck: DigitalInOutPin) {
const b = board() as EdgeConnectorBoard;
markUsed(mosi);
Expand All @@ -168,6 +168,7 @@ namespace pxsim.I2CMethods {
}

export function writeBuffer(i2c: I2C, address: number, buf: RefBuffer, repeat?: boolean): number {
BufferMethods.typeCheck(buf);
return 0;
}
}
Expand All @@ -179,6 +180,8 @@ namespace pxsim.SPIMethods {
}

export function transfer(device: pxsim.SPI, command: RefBuffer, response: RefBuffer) {
BufferMethods.typeCheck(command);
BufferMethods.typeCheck(response);
device.transfer(command, response);
}

Expand Down
1 change: 1 addition & 0 deletions libs/core/sim/serial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace pxsim.SerialDeviceMethods {
}

export function writeBuffer(device: SerialDevice, buffer: RefBuffer) {
BufferMethods.typeCheck(buffer);
device.writeBuffer(buffer);
}

Expand Down
3 changes: 2 additions & 1 deletion libs/infrared/sim/ir.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace pxsim.network {
export function infraredSendPacket(buf: RefBuffer): void {
BufferMethods.typeCheck(buf);
const state = getInfraredState();
state.send(buf);
}
Expand All @@ -12,7 +13,7 @@ namespace pxsim.network {
export function onInfraredPacket(body: RefAction): void {
const state = getInfraredState();
state.listen(body);
}
}

export function onInfraredError(body: RefAction): void {
const state = getInfraredState();
Expand Down
1 change: 1 addition & 0 deletions libs/music/sim/music.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace pxsim.music {
}

export function setTone(buffer: RefBuffer) {
BufferMethods.typeCheck(buffer);
// TODO: implement set tone in the audio context
}

Expand Down
3 changes: 2 additions & 1 deletion libs/radio/sim/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ namespace pxsim.radio {
state.setTransmitPower(power);
}

export function setFrequencyBand(band: number) {
export function setFrequencyBand(band: number) {
const state = pxsim.getRadioState();
state.setFrequencyBand(band);
}

export function sendRawPacket(buf: RefBuffer) {
BufferMethods.typeCheck(buf);
let cb = getResume();
const state = pxsim.getRadioState();
if (state.enable) {
Expand Down
Loading
Loading