Initial target repo setup to move to master (v3.10)

This commit is contained in:
Sam El-Husseini
2018-04-21 10:25:43 -07:00
parent cf7767ec1c
commit 6ea0c50472
36 changed files with 2717 additions and 1459 deletions

View File

@ -31,7 +31,7 @@ namespace pxsim {
namespace pxsim.pins {
export function digitalReadPin(pinId: number): number {
let pin = getPin(pinId);
if (!pin) return;
if (!pin) return -1;
pin.mode = PinFlags.Digital | PinFlags.Input;
return pin.value > 100 ? 1 : 0;
}
@ -52,7 +52,7 @@ namespace pxsim.pins {
export function analogReadPin(pinId: number): number {
let pin = getPin(pinId);
if (!pin) return;
if (!pin) return -1;
pin.mode = PinFlags.Analog | PinFlags.Input;
return pin.value || 0;
}

View File

@ -28,7 +28,7 @@ namespace pxsim {
this.data = data;
}
public print() {
// console.debug(`Image id:${this.id} refs:${this.refcnt} size:${this.width}x${Image.height}`)
console.debug(`Image id:${this.id} refs:${this.refcnt} size:${this.width}x${Image.height}`)
}
public get(x: number, y: number): number {
if (x < 0 || x >= this.width || y < 0 || y >= 5) return 0;
@ -66,7 +66,7 @@ namespace pxsim {
export function createInternalImage(width: number): Image {
let img = createImage(width)
pxsim.noLeakTracking(img)
pxsim.runtime.unregisterLiveObject(img, true)
return img
}

View File

@ -66,13 +66,15 @@ namespace pxsim.control {
board().bus.queue(id, evid)
}
export function eventTimestamp() {
return board().bus.getLastEventTime()
}
// TODO: (microbit master)
// export function eventTimestamp() {
// return board().bus.getLastEventTime()
// }
export function eventValue() {
return board().bus.getLastEventValue()
}
// TODO: (microbit master)
// export function eventValue() {
// return board().bus.getLastEventValue()
// }
}
namespace pxsim.pxtcore {
@ -86,9 +88,10 @@ namespace pxsim.input {
return runtime.runningTime();
}
export function runningTimeMicros(): number {
return runtime.runningTimeUs();
}
// TODO: (microbit master)
// export function runningTimeMicros(): number {
// return runtime.runningTimeUs();
// }
export function calibrateCompass() {
// device calibrates...

View File

@ -154,7 +154,8 @@ namespace pxsim.radio {
board().radioState.bus.datagram.send({
type: PacketPayloadType.STRING,
groupId: board().radioState.groupId,
bufferData: data
// TODO: (microbit master)
//bufferData: data
});
}
@ -211,9 +212,10 @@ namespace pxsim.radio {
return initString(board().radioState.bus.datagram.lastReceived.payload.stringData || "");
}
export function receivedBuffer(): RefBuffer {
return new RefBuffer(board().radioState.bus.datagram.lastReceived.payload.bufferData || new Uint8Array(0))
}
// TODO: (microbit master)
// export function receivedBuffer(): RefBuffer {
// return new RefBuffer(board().radioState.bus.datagram.lastReceived.payload.bufferData || new Uint8Array(0))
// }
export function receivedTime(): number {
return board().radioState.bus.datagram.lastReceived.time;
@ -230,12 +232,13 @@ namespace pxsim.radio {
case PacketPayloadType.STRING:
b.writeSerial(`{"t":${p.time},"s":${p.serial},"n":"${p.payload.stringData}"}\r\n`)
break;
case PacketPayloadType.BUFFER:
const buf = new Uint8Array(p.payload.bufferData.buffer);
let res = "";
for (let i = 0; i < buf.length; ++i)
res += String.fromCharCode(buf[i]);
b.writeSerial(`{"t":${p.time},"s":${p.serial},"b":"${res}"}\r\n`)
// TODO: (microbit master)
// case PacketPayloadType.BUFFER:
// const buf = new Uint8Array(p.payload.bufferData.buffer);
// let res = "";
// for (let i = 0; i < buf.length; ++i)
// res += String.fromCharCode(buf[i]);
// b.writeSerial(`{"t":${p.time},"s":${p.serial},"b":"${res}"}\r\n`)
default:
// unknown type
break;