Moving back to pxtcore v0 (#10)
* migrating to v0 * moving external repos to targetconfig * reenabling sharing * updating target * missing dependencies * updated pxt version * fixing missing file * ignore docs errors * udpated readme * bumping pxt * moving setting to correct location * missing blockly less
This commit is contained in:
		@@ -4,7 +4,7 @@ namespace pxsim {
 | 
			
		||||
        if (b) {
 | 
			
		||||
            let np = b.neopixelState;
 | 
			
		||||
            if (np) {
 | 
			
		||||
                let buf = <Uint8Array[]>(<any>buffer).data;                
 | 
			
		||||
                let buf = <Uint8Array>(<any>buffer).data;                
 | 
			
		||||
                np.updateBuffer(buf, pin);
 | 
			
		||||
                runtime.queueDisplayUpdate();
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -21,11 +21,12 @@ namespace pxsim {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        send(payload: SimulatorRadioPacketPayload) {
 | 
			
		||||
            const b = board();
 | 
			
		||||
            Runtime.postMessage(<SimulatorRadioPacketMessage>{
 | 
			
		||||
                type: "radiopacket",
 | 
			
		||||
                rssi: 0, // Not yet supported
 | 
			
		||||
                serial: board().radioState.bus.transmitSerialNumber ? board().radioState.bus.serial : 0,
 | 
			
		||||
                time: 0, // Not yet supported
 | 
			
		||||
                rssi: 70, // Not yet supported
 | 
			
		||||
                serial: b.radioState.bus.transmitSerialNumber ? pxsim.control.deviceSerialNumber() : 0,
 | 
			
		||||
                time: new Date().getTime(),
 | 
			
		||||
                payload
 | 
			
		||||
            })
 | 
			
		||||
        }
 | 
			
		||||
@@ -41,26 +42,19 @@ namespace pxsim {
 | 
			
		||||
                rssi: -1,
 | 
			
		||||
                serial: 0,
 | 
			
		||||
                time: 0,
 | 
			
		||||
                payload: { type: -1 }
 | 
			
		||||
                payload: { type: -1, groupId: 0 }
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export class RadioBus {
 | 
			
		||||
        // uint8_t radioDefaultGroup = MICROBIT_RADIO_DEFAULT_GROUP;
 | 
			
		||||
        groupId = 0; // todo
 | 
			
		||||
        power = 0;
 | 
			
		||||
        serial = 0;
 | 
			
		||||
        transmitSerialNumber = false;
 | 
			
		||||
        datagram: RadioDatagram;
 | 
			
		||||
 | 
			
		||||
        constructor(private runtime: Runtime) {
 | 
			
		||||
            this.datagram = new RadioDatagram(runtime);
 | 
			
		||||
            this.serial = Math.floor(Math.random() * Math.pow(2, 32)) - Math.pow(2, 31); // 32 bit signed integer
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setGroup(id: number) {
 | 
			
		||||
            this.groupId = id & 0xff; // byte only
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setTransmitPower(power: number) {
 | 
			
		||||
@@ -71,26 +65,37 @@ namespace pxsim {
 | 
			
		||||
            this.transmitSerialNumber = !!sn;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        broadcast(msg: number) {
 | 
			
		||||
        broadcast(msg: number, groupId: number) {
 | 
			
		||||
            Runtime.postMessage(<SimulatorEventBusMessage>{
 | 
			
		||||
                type: "eventbus",
 | 
			
		||||
                id: DAL.MES_BROADCAST_GENERAL_ID,
 | 
			
		||||
                eventid: msg,
 | 
			
		||||
                power: this.power,
 | 
			
		||||
                group: this.groupId
 | 
			
		||||
                group: groupId
 | 
			
		||||
            })
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export class RadioState {
 | 
			
		||||
        bus: RadioBus;
 | 
			
		||||
        groupId: number;
 | 
			
		||||
 | 
			
		||||
        constructor(runtime: Runtime) {
 | 
			
		||||
            this.bus = new RadioBus(runtime);
 | 
			
		||||
            this.groupId = 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public recievePacket(packet: SimulatorRadioPacketMessage) {
 | 
			
		||||
            this.bus.datagram.queue(packet)
 | 
			
		||||
        public setGroup(id: number) {
 | 
			
		||||
            this.groupId = id & 0xff; // byte only
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public broadcast(msg: number) {
 | 
			
		||||
            this.bus.broadcast(msg, this.groupId)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public receivePacket(packet: SimulatorRadioPacketMessage) {
 | 
			
		||||
            if (this.groupId == packet.payload.groupId)
 | 
			
		||||
                this.bus.datagram.queue(packet)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -103,7 +108,7 @@ namespace pxsim.radio {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export function broadcastMessage(msg: number): void {
 | 
			
		||||
        board().radioState.bus.broadcast(msg);
 | 
			
		||||
        board().radioState.broadcast(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export function onBroadcastMessageReceived(msg: number, handler: RefAction): void {
 | 
			
		||||
@@ -111,7 +116,7 @@ namespace pxsim.radio {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export function setGroup(id: number): void {
 | 
			
		||||
        board().radioState.bus.setGroup(id);
 | 
			
		||||
        board().radioState.setGroup(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export function setTransmitPower(power: number): void {
 | 
			
		||||
@@ -125,7 +130,8 @@ namespace pxsim.radio {
 | 
			
		||||
    export function sendNumber(value: number): void {
 | 
			
		||||
        board().radioState.bus.datagram.send({
 | 
			
		||||
            type: PacketPayloadType.NUMBER,
 | 
			
		||||
            numberData: value
 | 
			
		||||
            groupId: board().radioState.groupId,
 | 
			
		||||
            numberData: value,
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -133,7 +139,8 @@ namespace pxsim.radio {
 | 
			
		||||
        msg = msg.substr(0, 19);
 | 
			
		||||
        board().radioState.bus.datagram.send({
 | 
			
		||||
            type: PacketPayloadType.STRING,
 | 
			
		||||
            stringData: msg
 | 
			
		||||
            groupId: board().radioState.groupId,
 | 
			
		||||
            stringData: msg,
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -153,6 +160,7 @@ namespace pxsim.radio {
 | 
			
		||||
        msg.push()
 | 
			
		||||
        board().radioState.bus.datagram.send({
 | 
			
		||||
            type: PacketPayloadType.VALUE,
 | 
			
		||||
            groupId: board().radioState.groupId,
 | 
			
		||||
            stringData: name,
 | 
			
		||||
            numberData: value
 | 
			
		||||
        });
 | 
			
		||||
@@ -186,7 +194,7 @@ namespace pxsim.radio {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export function receivedString(): string {
 | 
			
		||||
        return board().radioState.bus.datagram.lastReceived.payload.stringData || "";
 | 
			
		||||
        return initString(board().radioState.bus.datagram.lastReceived.payload.stringData || "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export function receivedTime(): number {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user