diff --git a/pxtarget.json b/pxtarget.json
index 9369f6fdc..493b6a640 100644
--- a/pxtarget.json
+++ b/pxtarget.json
@@ -231,7 +231,7 @@
"permanent": true
}
},
- "dynamicBoardDefinition": false,
+ "dynamicBoardDefinition": true,
"boardDefinition": {
"visual": "calliope",
"gpioPinBlocks": [
diff --git a/sim-maker/dalboard.ts b/sim-maker/dalboard.ts
deleted file mode 100644
index 2e6e78588..000000000
--- a/sim-maker/dalboard.ts
+++ /dev/null
@@ -1,281 +0,0 @@
-///
-///
-///
-
-namespace pxsim {
- export let pinIds: Map;
-
- export function pinByName(name: string) {
- let v = pinIds[name]
- if (v == null) {
- v = getConfig(getConfigKey("PIN_" + name))
- }
- let p = pxtcore.getPin(v)
- if (!p)
- console.error("missing pin: " + name + "(" + v + ")")
- return p
- }
-
- export class DalBoard extends CoreBoard
- implements MusicBoard,
- LightBoard,
- CapTouchBoard,
- AccelerometerBoard,
- StorageBoard,
- LightSensorBoard,
- TemperatureBoard,
- MicrophoneBoard,
- ScreenBoard,
- InfraredBoard,
- LCDBoard,
- RadioBoard,
- ControlMessageBoard {
- // state & update logic for component services
- viewHost: visuals.BoardHost;
- view: SVGElement;
- edgeConnectorState: EdgeConnectorState;
- lightSensorState: AnalogSensorState;
- buttonState: CommonButtonState;
- lightState: pxt.Map;
- audioState: AudioState;
- neopixelPin: Pin;
- touchButtonState: TouchButtonState;
- accelerometerState: AccelerometerState;
- storageState: StorageState;
- thermometerState: AnalogSensorState;
- thermometerUnitState: TemperatureUnit;
- microphoneState: AnalogSensorState;
- screenState: ScreenState;
- irState: InfraredState;
- lcdState: LCDState;
- radioState: RadioState;
- controlMessageState: ControlMessageState;
-
- constructor(public boardDefinition: BoardDefinition) {
- super();
-
- const pinList: number[] = []
- const servos: Map = {}
-
- function pinId(name: string) {
- let key = getConfigKey("PIN_" + name)
- if (key != null)
- return getConfig(key)
- // this is for P03 format used by NRF - these are direct names of CPU pins
- let m = /^P(\d+)$/.exec(name)
- if (m)
- return parseInt(m[1])
- return null
- }
-
- pinIds = {}
-
- for (let block of (boardDefinition.visual as BoardImageDefinition).pinBlocks) {
- // scan labels
- for (let lbl of block.labels) {
- for (let sublbl of lbl.split(/[\/,]/)) {
- sublbl = sublbl.replace(/[~\s]+/g, "")
- let id = pinId(sublbl)
- if (id != null) {
- if (pinList.indexOf(id) < 0) {
- pinList.push(id)
- if ((DAL.PA02 <= id && id <= DAL.PA11) ||
- (DAL.PB00 <= id && id <= DAL.PB09))
- servos[sublbl] = id;
- }
- pinIds[lbl] = id;
- pinIds[sublbl] = id;
- }
- }
- }
- }
-
- // also add pins that might not have visual representation
- for (let k of getAllConfigKeys()) {
- if (/^PIN_/.test(k)) {
- let id = getConfig(getConfigKey(k))
- if (id != null) {
- if (pinList.indexOf(id) < 0)
- pinList.push(id);
- pinIds[k.replace(/^PIN_/, "")] = id;
- }
- }
- }
-
- this.lightState = {};
- this.microphoneState = new AnalogSensorState(DAL.DEVICE_ID_MICROPHONE, 52, 120, 75, 96);
- this.storageState = new StorageState();
- this.lightSensorState = new AnalogSensorState(DAL.DEVICE_ID_LIGHT_SENSOR, 0, 255, 128 / 4, 896 / 4);
- this.thermometerState = new AnalogSensorState(DAL.DEVICE_ID_THERMOMETER, -20, 50, 10, 30);
- this.thermometerUnitState = TemperatureUnit.Celsius;
- this.irState = new InfraredState(this);
- this.lcdState = new LCDState();
- this.controlMessageState = new ControlMessageState(this);
- this.bus.setNotify(DAL.DEVICE_ID_NOTIFY, DAL.DEVICE_ID_NOTIFY_ONE);
-
- // TODO we need this.buttonState set for pxtcore.getButtonByPin(), but
- // this should be probably merged with buttonpair somehow
- this.builtinParts["radio"] = this.radioState = new RadioState(runtime, this, {
- ID_RADIO: DAL.DEVICE_ID_RADIO,
- RADIO_EVT_DATAGRAM: 1 /*DAL.DEVICE_RADIO_EVT_DATAGRAM*/
- });
- this.builtinParts["pinbuttons"] = this.builtinParts["buttons"]
- = this.buttonState = new CommonButtonState();
- this.builtinParts["touch"] = this.touchButtonState = new TouchButtonState(pinList);
-
- // components
- this.builtinParts["audio"] = this.audioState = new AudioState();
- this.builtinParts["edgeconnector"] = this.edgeConnectorState = new EdgeConnectorState({
- pins: pinList,
- servos
- });
- this.builtinParts["microservo"] = this.edgeConnectorState;
- this.builtinParts["accelerometer"] = this.accelerometerState = new AccelerometerState(runtime);;
- this.builtinParts["screen"] = this.screenState = new ScreenState([], getConfig(DAL.CFG_DISPLAY_WIDTH) || 160, getConfig(DAL.CFG_DISPLAY_HEIGHT) || 128);
-
- this.builtinVisuals["buttons"] = () => new visuals.ButtonView();
- this.builtinVisuals["microservo"] = () => new visuals.MicroServoView();
-
- this.builtinParts["neopixel"] = (pin: Pin) => { return this.neopixelState(pin.id); };
- this.builtinVisuals["neopixel"] = () => new visuals.NeoPixelView(parsePinString);
- this.builtinPartVisuals["neopixel"] = (xy: visuals.Coord) => visuals.mkNeoPixelPart(xy);
-
- this.builtinParts["dotstar"] = (pin: Pin) => { return this.neopixelState(pin.id); };
- this.builtinVisuals["dotstar"] = () => new visuals.NeoPixelView(parsePinString);
- this.builtinPartVisuals["dotstar"] = (xy: visuals.Coord) => visuals.mkNeoPixelPart(xy);
-
- this.builtinParts["lcd"] = this.lcdState;
- this.builtinVisuals["lcd"] = () => new visuals.LCDView();
- this.builtinPartVisuals["lcd"] = (xy: visuals.Coord) => visuals.mkLCDPart(xy);
-
- this.builtinPartVisuals["buttons"] = (xy: visuals.Coord) => visuals.mkBtnSvg(xy);
-
- this.builtinPartVisuals["microservo"] = (xy: visuals.Coord) => visuals.mkMicroServoPart(xy);
-
- this.builtinParts["slideswitch"] = (pin: Pin) => new ToggleState(pin);
- this.builtinVisuals["slideswitch"] = () => new visuals.ToggleComponentVisual(parsePinString);
- this.builtinPartVisuals["slideswitch"] = (xy: visuals.Coord) => visuals.mkSideSwitchPart(xy);
-
- this.builtinParts["led"] = (pin: Pin) => new ToggleState(pin);
- this.builtinVisuals["led"] = () => new visuals.LedView(parsePinString);
- this.builtinPartVisuals["led"] = (xy: visuals.Coord) => visuals.mkLedPart(xy);
-
- this.builtinVisuals["photocell"] = () => new visuals.PhotoCellView(parsePinString);
- this.builtinPartVisuals["photocell"] = (xy: visuals.Coord) => visuals.mkPhotoCellPart(xy);
-
- this.builtinVisuals["screen"] = () => new visuals.ScreenView();
- this.builtinPartVisuals["screen"] = (xy: visuals.Coord) => visuals.mkScreenPart(xy);
-
- this.neopixelPin = this.edgeConnectorState.getPin(getConfig(DAL.CFG_PIN_ONBOARD_DOTSTAR_DATA))
- || this.edgeConnectorState.getPin(getConfig(DAL.CFG_PIN_ONBOARD_NEOPIXEL))
- || this.edgeConnectorState.getPin(getConfig(DAL.CFG_PIN_DOTSTAR_DATA))
- || this.edgeConnectorState.getPin(getConfig(DAL.CFG_PIN_NEOPIXEL));
-
- if (!this.neopixelPin && (boardDefinition.visual as BoardImageDefinition)?.leds?.some(l => l.color == "neopixel"))
- this.neopixelPin = this.edgeConnectorState.getPin(getConfig(DAL.CFG_PIN_LED_B))
-
- this.builtinParts["pixels"] = (pin: Pin) => { return this.neopixelState(!!this.neopixelPin && this.neopixelPin.id); };
- this.builtinVisuals["pixels"] = () => new visuals.NeoPixelView(parsePinString);
- this.builtinPartVisuals["pixels"] = (xy: visuals.Coord) => visuals.mkNeoPixelPart(xy);
- }
-
- kill() {
- super.kill();
- AudioContextManager.stop();
- }
-
- initAsync(msg: SimulatorRunMessage): Promise {
- super.initAsync(msg);
-
- const options = (msg.options || {}) as pxt.RuntimeOptions;
-
- const boardDef = msg.boardDefinition;
- const cmpsList = msg.parts;
- cmpsList.sort();
- const cmpDefs = msg.partDefinitions || {};
- const fnArgs = msg.fnArgs;
-
- const opts: visuals.BoardHostOpts = {
- state: this,
- boardDef: boardDef,
- partsList: cmpsList,
- partDefs: cmpDefs,
- fnArgs: fnArgs,
- maxWidth: "100%",
- maxHeight: "100%",
- };
- this.viewHost = new visuals.BoardHost(pxsim.visuals.mkBoardView({
- visual: boardDef.visual,
- boardDef
- }), opts);
-
- document.body.innerHTML = ""; // clear children
- document.body.appendChild(this.view = this.viewHost.getView());
-
- this.accelerometerState.attachEvents(this.view);
-
- return Promise.resolve();
- }
-
- screenshotAsync(width?: number): Promise {
- return this.viewHost.screenshotAsync(width);
- }
-
- accelerometer(): Accelerometer {
- return this.accelerometerState.accelerometer;
- }
-
- getDefaultPitchPin() {
- // amp always on PA02, regardless which name is has
- return pxtcore.getPin(DAL.PA02);
- }
-
- tryGetNeopixelState(pinId: number): CommonNeoPixelState {
- return this.lightState[pinId];
- }
-
- neopixelState(pinId: number): CommonNeoPixelState {
- if (pinId === undefined) {
- pinId = pxtcore.getConfig(DAL.CFG_PIN_MOSI, -1);
- }
- let state = this.lightState[pinId];
- if (!state) state = this.lightState[pinId] = new CommonNeoPixelState();
- return state;
- }
- }
-
- export function initRuntimeWithDalBoard(msg: SimulatorRunMessage) {
- U.assert(!runtime.board);
- let b = new DalBoard(msg.boardDefinition);
- runtime.board = b;
- runtime.postError = (e) => {
- // TODO
- runtime.updateDisplay();
- }
- }
-
- if (!pxsim.initCurrentRuntime) {
- pxsim.initCurrentRuntime = initRuntimeWithDalBoard;
- }
-
- export function parsePinString(pinString: string): Pin {
- const pinName = pinString && pxsim.readPin(pinString);
- return pinName && pxtcore.getPin(pinIds[pinName]);
- }
-
- export namespace jacdac {
- export function _setLedChannel(ch: number, val: number) {
- const b = board() as DalBoard
- if (b.neopixelPin) {
- const state = b.neopixelState(b.neopixelPin.id);
- state.mode = NeoPixelMode.RGB_RGB;
- if (!state.buffer)
- state.buffer = new Uint8Array(3);
- if (val > 0xffff) val = 0xffff;
- if (val < 0) val = 0;
- state.buffer[ch] = val >> 8;
- runtime.updateDisplay();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/sim-maker/public/icons/jacdac.svg b/sim-maker/public/icons/jacdac.svg
deleted file mode 100644
index 37c092b21..000000000
--- a/sim-maker/public/icons/jacdac.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/sim-maker/public/parts/.gitignore b/sim-maker/public/parts/.gitignore
deleted file mode 100644
index 74a7a76ed..000000000
--- a/sim-maker/public/parts/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-# don't check in until OSS request is approved
-sparkfun-*
-raspberrypi-*
-arduino-*
-max6675*
diff --git a/sim-maker/public/parts/lightanimation/colorwipe.png b/sim-maker/public/parts/lightanimation/colorwipe.png
deleted file mode 100644
index caf950617..000000000
Binary files a/sim-maker/public/parts/lightanimation/colorwipe.png and /dev/null differ
diff --git a/sim-maker/public/parts/lightanimation/colorwipe.svg b/sim-maker/public/parts/lightanimation/colorwipe.svg
deleted file mode 100644
index e832dd8c8..000000000
--- a/sim-maker/public/parts/lightanimation/colorwipe.svg
+++ /dev/null
@@ -1,213 +0,0 @@
-
-
-
-
diff --git a/sim-maker/public/parts/lightanimation/comet.png b/sim-maker/public/parts/lightanimation/comet.png
deleted file mode 100644
index e3f254739..000000000
Binary files a/sim-maker/public/parts/lightanimation/comet.png and /dev/null differ
diff --git a/sim-maker/public/parts/lightanimation/comet.svg b/sim-maker/public/parts/lightanimation/comet.svg
deleted file mode 100644
index 92a3bee31..000000000
--- a/sim-maker/public/parts/lightanimation/comet.svg
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
-
-
diff --git a/sim-maker/public/parts/lightanimation/rainbow.png b/sim-maker/public/parts/lightanimation/rainbow.png
deleted file mode 100644
index c145d6a28..000000000
Binary files a/sim-maker/public/parts/lightanimation/rainbow.png and /dev/null differ
diff --git a/sim-maker/public/parts/lightanimation/rainbow.svg b/sim-maker/public/parts/lightanimation/rainbow.svg
deleted file mode 100644
index 8f1fe9aeb..000000000
--- a/sim-maker/public/parts/lightanimation/rainbow.svg
+++ /dev/null
@@ -1,213 +0,0 @@
-
-
-
-
diff --git a/sim-maker/public/parts/lightanimation/runninglights.png b/sim-maker/public/parts/lightanimation/runninglights.png
deleted file mode 100644
index 5642f2ae3..000000000
Binary files a/sim-maker/public/parts/lightanimation/runninglights.png and /dev/null differ
diff --git a/sim-maker/public/parts/lightanimation/runninglights.svg b/sim-maker/public/parts/lightanimation/runninglights.svg
deleted file mode 100644
index e373ce801..000000000
--- a/sim-maker/public/parts/lightanimation/runninglights.svg
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
diff --git a/sim-maker/public/parts/lightanimation/sparkle.png b/sim-maker/public/parts/lightanimation/sparkle.png
deleted file mode 100644
index fc4b8c32c..000000000
Binary files a/sim-maker/public/parts/lightanimation/sparkle.png and /dev/null differ
diff --git a/sim-maker/public/parts/lightanimation/sparkle.svg b/sim-maker/public/parts/lightanimation/sparkle.svg
deleted file mode 100644
index 8b64fa01c..000000000
--- a/sim-maker/public/parts/lightanimation/sparkle.svg
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
-
-
diff --git a/sim-maker/public/parts/lightanimation/theaterchase.png b/sim-maker/public/parts/lightanimation/theaterchase.png
deleted file mode 100644
index 3135cbdca..000000000
Binary files a/sim-maker/public/parts/lightanimation/theaterchase.png and /dev/null differ
diff --git a/sim-maker/public/parts/lightanimation/theaterchase.svg b/sim-maker/public/parts/lightanimation/theaterchase.svg
deleted file mode 100644
index a235da896..000000000
--- a/sim-maker/public/parts/lightanimation/theaterchase.svg
+++ /dev/null
@@ -1,239 +0,0 @@
-
-
-
-
diff --git a/sim-maker/public/parts/neopixel.svg b/sim-maker/public/parts/neopixel.svg
deleted file mode 100644
index 2d4b81a41..000000000
--- a/sim-maker/public/parts/neopixel.svg
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
\ No newline at end of file
diff --git a/sim-maker/public/sim.manifest b/sim-maker/public/sim.manifest
deleted file mode 100644
index ccc97b632..000000000
--- a/sim-maker/public/sim.manifest
+++ /dev/null
@@ -1,9 +0,0 @@
-CACHE MANIFEST
-
-CACHE:
-/cdn/pxtsim.js
-/sim/common-sim.js
-/sim/sim.js
-
-NETWORK:
-*
diff --git a/sim-maker/public/simulator.html b/sim-maker/public/simulator.html
deleted file mode 100644
index d34dae766..000000000
--- a/sim-maker/public/simulator.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
- Maker Simulator
-
-
-
-
-
-
-
-
diff --git a/sim-maker/public/workerConfig.js b/sim-maker/public/workerConfig.js
deleted file mode 100644
index 6386ae075..000000000
--- a/sim-maker/public/workerConfig.js
+++ /dev/null
@@ -1,5 +0,0 @@
-self.setSimulatorWorkerOptions({
- urls: [
- "/sim/common-sim.js"
- ]
-})
\ No newline at end of file
diff --git a/sim-maker/tsconfig.json b/sim-maker/tsconfig.json
deleted file mode 100644
index 1d4417226..000000000
--- a/sim-maker/tsconfig.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "compilerOptions": {
- "target": "es2017",
- "noImplicitAny": true,
- "noImplicitReturns": true,
- "declaration": true,
- "outFile": "../built/sim.js",
- "rootDir": ".",
- "newLine": "LF",
- "sourceMap": false,
- "typeRoots": ["../node_modules/@types"]
- }
-}
diff --git a/sim-maker/visuals/board.svg b/sim-maker/visuals/board.svg
deleted file mode 100644
index b01054916..000000000
--- a/sim-maker/visuals/board.svg
+++ /dev/null
@@ -1,1000 +0,0 @@
-
diff --git a/sim-maker/visuals/board.ts b/sim-maker/visuals/board.ts
deleted file mode 100644
index 8dc07b611..000000000
--- a/sim-maker/visuals/board.ts
+++ /dev/null
@@ -1,366 +0,0 @@
-namespace pxsim.visuals {
- const svg = pxsim.svg;
-
- export const VIEW_WIDTH = 372.3404255319149;
- export const VIEW_HEIGHT = 361.70212765957444;
- const TOP_MARGIN = 20;
- const MID_MARGIN = 40;
- const BOT_MARGIN = 20;
- const PIN_LBL_SIZE = PIN_DIST * 0.7;
- const PIN_LBL_HOVER_SIZE = PIN_LBL_SIZE * 1.5;
- const SQUARE_PIN_WIDTH = PIN_DIST * 0.66666;
- const SQUARE_PIN_HOVER_WIDTH = PIN_DIST * 0.66666 + PIN_DIST / 3.0;
-
- const STYLE = `
-.sim-board-pin {
- stroke: #404040;
- fill: #000000;
-}
-.sim-board-button {
- stroke: #aaa;
- stroke-width: 3px;
- fill: #666;
-}
-.sim-board-button.pressed {
- fill: #ee0;
-}
-.sim-board-button:hover {
- stroke-width: 4px;
- stroke: #ee0;
- cursor: pointer;
-}
- `
-
- export interface IBoardTheme {
- accent?: string;
- display?: string;
- pin?: string;
- pinTouched?: string;
- pinActive?: string;
- ledOn?: string;
- ledOff?: string;
- buttonOuter?: string;
- buttonUps: string[];
- buttonDown?: string;
- virtualButtonOuter?: string;
- virtualButtonUp?: string;
- virtualButtonDown?: string;
- lightLevelOn?: string;
- lightLevelOff?: string;
- soundLevelOn?: string;
- soundLevelOff?: string;
- }
-
- export var themes: IBoardTheme[] = ["#3ADCFE"].map(accent => {
- return {
- accent: accent,
- pin: "#D4AF37",
- pinTouched: "#FFA500",
- pinActive: "#FF5500",
- ledOn: "#ff7777",
- ledOff: "#fff",
- buttonOuter: "#979797",
- buttonUps: ["#000", "#000", "#000"],
- buttonDown: "#FFA500",
- virtualButtonDown: "#FFA500",
- virtualButtonOuter: "#333",
- virtualButtonUp: "#fff",
- lightLevelOn: "yellow",
- lightLevelOff: "#555",
- soundLevelOn: "#7f8c8d",
- soundLevelOff: "#555",
- }
- });
-
- export function randomTheme(): IBoardTheme {
- return themes[Math.floor(Math.random() * themes.length)];
- }
-
- export type ComputedBoardDimensions = {
- scaleFn: (n: number) => number,
- height: number,
- width: number,
- xOff: number,
- yOff: number
- };
-
- export function getBoardDimensions(vis: BoardImageDefinition): ComputedBoardDimensions {
- let scaleFn = (n: number) => n * (PIN_DIST / vis.pinDist);
- let width = scaleFn(vis.width);
- return {
- scaleFn: scaleFn,
- height: scaleFn(vis.height),
- width: width,
- xOff: (VIEW_WIDTH - width) / 2.0,
- yOff: TOP_MARGIN
- }
- }
-
- export interface MetroBoardProps extends GenericBoardProps {
- runtime?: pxsim.Runtime;
- theme?: IBoardTheme;
- disableTilt?: boolean;
- }
-
- export class MetroBoardSvg extends GenericBoardSvg {
-
- public board: pxsim.DalBoard;
- private onBoardLeds: BoardLed[];
- private onBoardNeopixels: BoardNeopixel[];
- private onBoardReset: BoardResetButton;
- private onBoardButtons: BoardButton[];
- private onBoardTouchPads: BoardTouchButton[];
-
- constructor(public props: MetroBoardProps) {
- super(props);
-
- const el = this.getView().el;
- this.addDefs(el);
-
- this.onBoardLeds = []
- this.onBoardNeopixels = [];
- this.onBoardTouchPads = [];
- this.onBoardButtons = [];
-
- // neopixels/leds
- for (const l of props.visualDef.leds || []) {
- if (l.color == "neopixel") {
- const onBoardNeopixel = new BoardNeopixel(l.label, l.x, l.y, l.w || 0);
- this.onBoardNeopixels.push(onBoardNeopixel);
- el.appendChild(onBoardNeopixel.element);
- } else {
- const pin = pinByName(l.label);
- if (pin) {
- let bl = new BoardLed(l.x, l.y, l.color, pinByName(l.label),
- l.w || 9, l.h || 8)
- this.onBoardLeds.push(bl)
- el.appendChild(bl.element)
- }
- }
- }
- this.onBoardNeopixels.sort((l, r) => {
- const li = parseInt(l.name.replace(/^[^\d]*/, '')) || 0;
- const ri = parseInt(r.name.replace(/^[^\d]*/, '')) || 0;
- return li < ri ? -1 : li > ri ? 1 : 0;
- })
-
- // reset button
- if (props.visualDef.reset) {
- this.onBoardReset = new BoardResetButton(props.visualDef.reset)
- el.appendChild(this.onBoardReset.element)
- }
-
- // touch pads
- for (const l of props.visualDef.touchPads || []) {
- const pin = pxsim.pinIds[l.label];
- if (!pin) {
- console.error(`touch pin ${pin} not found`)
- continue;
- }
- const tp = new BoardTouchButton(l, pin);
- this.onBoardTouchPads.push(tp);
- el.appendChild(tp.element);
- }
-
- // regular buttons
- for (const l of props.visualDef.buttons || []) {
- const tp = new BoardButton(l);
- this.onBoardButtons.push(tp);
- el.appendChild(tp.element);
- }
-
- if (props && props.theme)
- this.updateTheme();
-
- if (props && props.runtime) {
- this.board = this.props.runtime.board as pxsim.DalBoard;
- this.board.updateSubscribers.push(() => this.updateState());
- this.updateState();
- }
-
-
- }
-
- public updateTheme() {
- }
-
- public updateState() {
- this.onBoardLeds.forEach(l => l.updateState());
- if (this.board.neopixelPin) {
- const state = this.board.neopixelState(this.board.neopixelPin.id);
- if (state.buffer) {
- for (let i = 0; i < this.onBoardNeopixels.length; ++i) {
- const rgb = state.pixelColor(i)
- if (rgb !== null)
- this.onBoardNeopixels[i].setColor(rgb as any);
- }
- }
- }
- }
-
- private addDefs(el: SVGElement) {
- const defs = svg.child(el, "defs", {});
-
- let neopixelglow = svg.child(defs, "filter", { id: "neopixelglow", x: "-200%", y: "-200%", width: "400%", height: "400%" });
- svg.child(neopixelglow, "feGaussianBlur", { stdDeviation: "4.3", result: "coloredBlur" });
- let neopixelmerge = svg.child(neopixelglow, "feMerge", {});
- svg.child(neopixelmerge, "feMergeNode", { in: "coloredBlur" })
- svg.child(neopixelmerge, "feMergeNode", { in: "SourceGraphic" })
-
- const style = svg.child(el, "style", {});
- style.textContent = STYLE;
- }
- }
-
- class BoardResetButton {
- element: SVGElement;
- constructor(p: BoxDefinition) {
- p.w = p.w || 15;
- p.h = p.h || 15;
- this.element = svg.elt("circle", {
- cx: p.x + p.w / 2,
- cy: p.y + p.h / 2,
- r: Math.max(p.w, p.h) / 2,
- class: "sim-board-button"
- }) as SVGCircleElement
- svg.title(this.element, "RESET");
- // hooking up events
- pointerEvents.down.forEach(evid => this.element.addEventListener(evid, ev => {
- pxsim.U.addClass(this.element, "pressed");
- pxsim.Runtime.postMessage({
- type: "simulator",
- command: "restart"
- })
- }));
- this.element.addEventListener(pointerEvents.leave, ev => {
- pxsim.U.removeClass(this.element, "pressed");
- })
- this.element.addEventListener(pointerEvents.up, ev => {
- pxsim.U.removeClass(this.element, "pressed");
- })
- }
- }
-
- class BoardLed {
- private colorOff = "#aaa"
- private backElement: SVGElement;
- private ledElement: SVGElement;
- element: SVGElement;
-
- constructor(x: number, y: number, private colorOn: string, private pin: Pin, w: number, h: number) {
- this.backElement = svg.elt("rect", { x, y, width: w, height: h, fill: this.colorOff });
- this.ledElement = svg.elt("rect", { x, y, width: w, height: h, fill: this.colorOn, opacity: 0 });
- svg.filter(this.ledElement, `url(#neopixelglow)`);
- this.element = svg.elt("g", { class: "sim-led" });
- this.element.appendChild(this.backElement);
- this.element.appendChild(this.ledElement);
- }
-
- updateTheme(colorOff: string, colorOn: string) {
- if (colorOff) {
- this.colorOff = colorOff;
- }
- if (colorOn) {
- this.colorOn = colorOn;
- }
- }
-
- updateState() {
- const opacity = this.pin.mode & PinFlags.Digital ? (this.pin.value > 0 ? 1 : 0)
- : 0.1 + Math.max(0, Math.min(1023, this.pin.value)) / 1023 * 0.8;
- this.ledElement.setAttribute("opacity", opacity.toString())
- }
- }
-
- class BoardNeopixel {
- name: string;
- element: SVGCircleElement;
-
- constructor(name: string, x: number, y: number, r: number) {
- this.name = name;
- this.element = svg.elt("circle", { cx: x + r / 2, cy: y + r / 2, r: 10 }) as SVGCircleElement
- svg.title(this.element, name);
- }
-
- setColor(rgb: [number, number, number]) {
- const hsl = visuals.rgbToHsl(rgb);
- let [h, s, l] = hsl;
- const lx = Math.max(l * 1.3, 85);
-
- // at least 10% luminosity
- l = l * 90 / 100 + 10;
- this.element.style.stroke = `hsl(${h}, ${s}%, ${Math.min(l * 3, 75)}%)`
- this.element.style.strokeWidth = "1.5";
- svg.fill(this.element, `hsl(${h}, ${s}%, ${lx}%)`);
- svg.filter(this.element, `url(#neopixelglow)`);
- }
- }
-
- class BoardButton {
- element: SVGElement;
- def: ButtonDefinition;
- button: CommonButton;
- constructor(def: ButtonDefinition) {
- this.def = def;
- def.w = def.w || 15;
- def.h = def.h || 15;
- this.element = svg.elt("circle", {
- cx: def.x + def.w / 2,
- cy: def.y + def.h / 2,
- r: Math.max(def.w, def.h) / 2,
- class: "sim-board-button"
- }) as SVGCircleElement
- svg.title(this.element, def.label);
- // resolve button
- this.button = def.index !== undefined
- ? pxsim.pxtcore.getButton(def.index)
- : pxsim.pxtcore.getButtonByPin(pxsim.pinIds[def.label]);
- // hooking up events
- pointerEvents.down.forEach(evid => this.element.addEventListener(evid, ev => {
- this.button.setPressed(true);
- pxsim.U.addClass(this.element, "pressed");
- }));
- this.element.addEventListener(pointerEvents.leave, ev => {
- pxsim.U.removeClass(this.element, "pressed");
- this.button.setPressed(false);
- })
- this.element.addEventListener(pointerEvents.up, ev => {
- pxsim.U.removeClass(this.element, "pressed");
- this.button.setPressed(false);
- })
- }
- }
-
- class BoardTouchButton {
- element: SVGElement;
- def: TouchPadDefinition;
- button: TouchButton;
- constructor(def: TouchPadDefinition, pinId: number) {
- this.def = def;
- def.w = def.w || 15;
- def.h = def.h || 15;
- this.element = svg.elt("circle", {
- cx: def.x + def.w / 2,
- cy: def.y + def.h / 2,
- r: Math.max(def.w, def.h) / 2,
- class: "sim-board-button"
- }) as SVGCircleElement
- svg.title(this.element, def.label);
- // resolve button
- this.button = pxsim.pxtcore.getTouchButton(pinId);
- // hooking up events
- pointerEvents.down.forEach(evid => this.element.addEventListener(evid, ev => {
- this.button.setPressed(true);
- pxsim.U.addClass(this.element, "pressed");
- }));
- this.element.addEventListener(pointerEvents.leave, ev => {
- pxsim.U.removeClass(this.element, "pressed");
- this.button.setPressed(false);
- })
- this.element.addEventListener(pointerEvents.up, ev => {
- pxsim.U.removeClass(this.element, "pressed");
- this.button.setPressed(false);
- })
- }
- }
-}
\ No newline at end of file
diff --git a/sim-maker/visuals/boardhd.svg b/sim-maker/visuals/boardhd.svg
deleted file mode 100644
index 6eefefda2..000000000
--- a/sim-maker/visuals/boardhd.svg
+++ /dev/null
@@ -1,2324 +0,0 @@
-
-
\ No newline at end of file
diff --git a/sim-maker/visuals/boardview.ts b/sim-maker/visuals/boardview.ts
deleted file mode 100644
index 2c498d23f..000000000
--- a/sim-maker/visuals/boardview.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace pxsim.visuals {
- mkBoardView = (opts: pxsim.visuals.BoardViewOptions): BoardView => {
- return new visuals.MetroBoardSvg({
- runtime: runtime,
- theme: visuals.randomTheme(),
- visualDef: opts.visual as BoardImageDefinition,
- boardDef: opts.boardDef,
- disableTilt: false,
- wireframe: opts.wireframe
- });
- }
-}
\ No newline at end of file
diff --git a/sim-maker/visuals/buttons.ts b/sim-maker/visuals/buttons.ts
deleted file mode 100644
index 0963ca2db..000000000
--- a/sim-maker/visuals/buttons.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-///
-///
-
-namespace pxsim.visuals {
- export class ButtonView implements IBoardPart {
- public element: SVGElement;
- public defs: SVGElement[];
- public style = BUTTON_PAIR_STYLE;
- private state: CommonButtonState;
- private bus: EventBus;
- private btn: SVGGElement;
-
- private pinId: number;
- private button: CommonButton;
-
- public init(bus: EventBus, state: CommonButtonState, svgEl: SVGSVGElement, otherParams: Map) {
- this.state = state;
- this.bus = bus;
- this.defs = [];
- this.element = this.mkBtn();
- let pinStr = pxsim.readPin(otherParams["button"]);
- this.pinId = pxsim.pinIds[pinStr];
- this.button = new CommonButton(this.pinId);
- this.state.buttonsByPin[this.pinId] = this.button;
- this.updateState();
- this.attachEvents();
- }
-
- public moveToCoord(xy: Coord) {
- let btnWidth = PIN_DIST * 3;
- let [x, y] = xy;
- translateEl(this.btn, [x, y])
- }
-
- public updateState() {
-
- }
-
- public updateTheme() {}
-
- private mkBtn() {
- this.btn = mkBtnSvg([0, 0]).el;
-
- const mkVirtualBtn = () => {
- const numPins = 2;
- const w = PIN_DIST * 2.8;
- const offset = (w - (numPins * PIN_DIST)) / 2;
- const corner = PIN_DIST / 2;
- const cx = 0 - offset + w / 2;
- const cy = cx;
- const txtSize = PIN_DIST * 1.3;
- const x = -offset;
- const y = -offset;
- const txtXOff = PIN_DIST / 7;
- const txtYOff = PIN_DIST / 10;
-
- let btng = svg.elt("g");
- let btn = svg.child(btng, "rect", { class: "sim-button-virtual", x: x, y: y, rx: corner, ry: corner, width: w, height: w});
- let btnTxt = mkTxt(cx + txtXOff, cy + txtYOff, txtSize, 0, "A+B");
- pxsim.U.addClass(btnTxt, "sim-text")
- pxsim.U.addClass(btnTxt, "sim-text-virtual");
- btng.appendChild(btnTxt);
-
- return btng;
- }
-
- let el = svg.elt("g");
- pxsim.U.addClass(el, "sim-buttonpair")
- el.appendChild(this.btn);
-
- return el;
- }
-
- private attachEvents() {
- let btnSvgs = [this.btn];
-
- btnSvgs.forEach((btn, index) => {
- pointerEvents.down.forEach(evid => btn.addEventListener(evid, ev => {
- this.button.setPressed(true);
- }));
- btn.addEventListener(pointerEvents.leave, ev => {
- this.button.setPressed(false);
- })
- btn.addEventListener(pointerEvents.up, ev => {
- this.button.setPressed(false);
- })
- })
- }
- }
-}
\ No newline at end of file
diff --git a/sim/dalboard.ts b/sim/dalboard.ts
index 92f2d6ac8..32a990040 100644
--- a/sim/dalboard.ts
+++ b/sim/dalboard.ts
@@ -135,12 +135,12 @@ namespace pxsim {
const cmpDefs = msg.partDefinitions || {};
const fnArgs = msg.fnArgs;
- const v2Parts: pxt.Map = {
- "microphone": true,
- "logotouch": true,
- "builtinspeaker": true,
- "v2": true
- };
+ // const v2Parts: pxt.Map = {
+ // "microphone": true,
+ // "logotouch": true,
+ // "builtinspeaker": true,
+ // "v2": true
+ // };
// if (msg.builtinParts) {
// const v2PartsUsed = msg.builtinParts.filter(k => v2Parts[k])
// if (v2PartsUsed.length) {
diff --git a/sim/visuals/board.svg b/sim/visuals/board.svg
index e93f2a606..57409995f 100644
--- a/sim/visuals/board.svg
+++ b/sim/visuals/board.svg
@@ -33,6 +33,7 @@
.st27{fill:none;}
+
-
@@ -945,7 +924,7 @@
c0.9,0.3,1.8,0.6,2.8,0.8c0.7,0.2,1.5,0.4,2.2,0.5c1.2,0.2,2.5,0.4,3.7,0.4c0.5,0,1.1,0,1.6,0c17.3,0,31.2-14,31.2-31.3
C166.8,39.9,166.8,39.2,166.8,38.6z M135.6,54c-7.5,0-13.6-6-13.6-13.6c0-7.5,6.1-13.6,13.6-13.6s13.6,6.1,13.6,13.6
C149.2,48,143.1,54,135.6,54z"/>
-
-
-
-
+
diff --git a/sim/visuals/microbit.ts b/sim/visuals/microbit.ts
index fabe383d3..fb7bcd71f 100644
--- a/sim/visuals/microbit.ts
+++ b/sim/visuals/microbit.ts
@@ -370,7 +370,7 @@ namespace pxsim.visuals {
c0.9,0.3,1.8,0.6,2.8,0.8c0.7,0.2,1.5,0.4,2.2,0.5c1.2,0.2,2.5,0.4,3.7,0.4c0.5,0,1.1,0,1.6,0c17.3,0,31.2-14,31.2-31.3
C166.8,39.9,166.8,39.2,166.8,38.6z M135.6,54c-7.5,0-13.6-6-13.6-13.6c0-7.5,6.1-13.6,13.6-13.6s13.6,6.1,13.6,13.6
C149.2,48,143.1,54,135.6,54z"/>
-
-
-
-
+
@@ -577,7 +599,7 @@ namespace pxsim.visuals {
`;
- const BOARD_MINI2_BODY = `
+ const BOARD_MINI2_BODY = `
-
`;
@@ -2365,7 +2365,6 @@ namespace pxsim.visuals {
private buildDom() {
let SVG_CODE = BOARD_SVG_HEAD+BOARD_MINI2_BODY+BOARD_SVG_BOTTOM
if(this.props.runtime.board && this.props.runtime.board.hasOwnProperty("hardwareVersion") && this.props.runtime.board.hardwareVersion == 3) {
- console.log('BOARD VERSION 3');
this.domHardwareVersion = 3;
SVG_CODE = BOARD_SVG_HEAD+BOARD_MINI3_BODY+BOARD_SVG_BOTTOM
}