diff --git a/docs/static/hardware/arduino-zero-outline.svg b/docs/static/hardware/arduino-zero-outline.svg deleted file mode 100644 index b5aef4d8..00000000 --- a/docs/static/hardware/arduino-zero-outline.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/docs/static/hardware/arduino-zero.png b/docs/static/hardware/arduino-zero.png deleted file mode 100644 index a88dbfc0..00000000 Binary files a/docs/static/hardware/arduino-zero.png and /dev/null differ diff --git a/sim/allocator.ts b/sim/allocator.ts index a29fe4e6..de1b0cd4 100644 --- a/sim/allocator.ts +++ b/sim/allocator.ts @@ -2,7 +2,7 @@ namespace pxsim { export interface AllocatorOpts { boardDef: BoardDefinition, - cmpDefs: Map, + cmpDefs: Map, fnArgs: any, getBBCoord: (loc: BBRowCol) => visuals.Coord, cmpList: string[] @@ -21,7 +21,7 @@ namespace pxsim { breadboardStartColumn: number, breadboardStartRow: string, assemblyStep: number, - visual: string | ComponentVisualDefinition, + visual: string | PartVisualDefinition, microbitPins: string[], otherArgs?: string[], } @@ -33,7 +33,7 @@ namespace pxsim { }; interface PartialCmpAlloc { name: string, - def: ComponentDefinition, + def: PartDefinition, pinsAssigned: string[], pinsNeeded: number | number[], breadboardColumnsNeeded: number, @@ -95,7 +95,7 @@ namespace pxsim { this.opts = opts; } - private allocateLocation(location: LocationDefinition, opts: AllocLocOpts): Loc { + private allocateLocation(location: WireLocationDefinition, opts: AllocLocOpts): Loc { if (location === "ground" || location === "threeVolt") { U.assert(!!opts.nearestBBPin); let nearLoc = opts.nearestBBPin; @@ -213,7 +213,7 @@ namespace pxsim { return {start: endInsts[0], end: endInsts[1], color: wireDef.color, assemblyStep: wireDef.assemblyStep}; } private allocatePartialCmps(): PartialCmpAlloc[] { - let cmpNmAndDefs = this.opts.cmpList.map(cmpName => <[string, ComponentDefinition]>[cmpName, this.opts.cmpDefs[cmpName]]).filter(d => !!d[1]); + let cmpNmAndDefs = this.opts.cmpList.map(cmpName => <[string, PartDefinition]>[cmpName, this.opts.cmpDefs[cmpName]]).filter(d => !!d[1]); let cmpNmsList = cmpNmAndDefs.map(p => p[0]); let cmpDefsList = cmpNmAndDefs.map(p => p[1]); let partialCmps: PartialCmpAlloc[] = []; diff --git a/sim/dalboard.ts b/sim/dalboard.ts index 64db2f0b..b5305fa6 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -78,7 +78,7 @@ namespace pxsim { // let boardDef = RASPBERRYPI_MODELB; let cmpsList = msg.parts; - let cmpDefs = COMPONENT_DEFINITIONS; //TODO: read from pxt.json/pxttarget.json + let cmpDefs = PART_DEFINITIONS; //TODO: read from pxt.json/pxttarget.json let fnArgs = msg.fnArgs; let viewHost = new visuals.BoardHost(this, boardDef, cmpsList, cmpDefs, fnArgs); diff --git a/sim/definitions.ts b/sim/definitions.ts index 9007215b..3521bf2c 100644 --- a/sim/definitions.ts +++ b/sim/definitions.ts @@ -40,10 +40,10 @@ namespace pxsim { type: "auto", gpioPinsNeeded: number | number[], } - export interface ComponentVisualDefinition { + export interface PartVisualDefinition { } - export interface ComponentDefinition { - visual: string | ComponentVisualDefinition, + export interface PartDefinition { + visual: string | PartVisualDefinition, breadboardColumnsNeeded: number, breadboardStartRow: string, wires: WireDefinition[], @@ -51,12 +51,12 @@ namespace pxsim { pinAllocation: FactoryFunctionPinAlloc | PredefinedPinAlloc | AutoPinAlloc, } export interface WireDefinition { - start: LocationDefinition, - end: LocationDefinition, + start: WireLocationDefinition, + end: WireLocationDefinition, color: string, assemblyStep: number }; - export type LocationDefinition = + export type WireLocationDefinition = ["breadboard", string, number] | ["GPIO", number] | "ground" | "threeVolt"; export const MICROBIT_DEF: BoardDefinition = { @@ -95,131 +95,7 @@ namespace pxsim { attachPowerOnRight: true, onboardComponents: ["buttonpair", "ledmatrix"], } - export const RASPBERRYPI_MODELB: BoardDefinition = { - visual: { - image: "/static/hardware/raspberrypi-model-b.svg", - outlineImage: "/static/hardware/raspberrypi-model-b-outline.svg", - width: 331, - height: 230, - pinDist: 9, - pinBlocks: [ - { x: 5, y: 31, labels: ["3V3", "SDA", "SCL", "#4", "--", "#17", "#21", "#22", "--", "MOSI", "MISO", "SCLK", "--"]}, - { x: 5, y: 39, labels: ["5V", "--", "GND", "TXD", "RXD", "#18", "--", "#23", "#24", "--", "#25", "CS0", "CS1"]} - ], - }, - gpioPinBlocks: [ - ["SDA", "SCL", "#4"], - ["#17", "#21", "#22"], - ["MOSI", "MISO", "SCLK"], - ["TXD", "RXD", "#18"], - ["#23", "#24"], - ["#25", "CS0", "CS1"], - ], - gpioPinMap: { - "P0": "SDA", - "P1": "SCL", - "P2": "#4", - "P3": "MOSI", - "P4": "MISO", - "P5": "SCLK", - "P6": "TXD", - "P7": "RXD", - "P8": "#18", - "P9": "#23", - "P10": "#24", - "P11": "#25", - "P12": "CS0", - "P13": "CS1", - }, - groundPins: ["GND"], - threeVoltPins: ["3V3"], - } - export const SPARKFUN_PHOTON: BoardDefinition = { - visual: { - image: "/static/hardware/sparkfun-photon.svg", - outlineImage: "/static/hardware/sparkfun-photon-outline.svg", - width: 264.4, - height: 202.4, - pinDist: 9.5, - pinBlocks: [ - {x: 72, y: 6, labels: ["~SCL/D1", "~SDA/D0", " ", "GND0", "SCK/A3", "~MISO/A4", "~MOSI/A5", "SS/A2", "~WKP", "DAC"]}, - {x: 174, y: 6, labels: ["D7", "D6", "D5", "D4", "~D3", "~D2", "~TX", "~RX"]}, - {x: 107, y: 188, labels: [" ", " ", "RESET", "3.3V", "V-USB", "GND1", "GND2", "VIN"]}, - {x: 193, y: 188, labels: ["A0", "A1", "A2", "A3", "A4", "A5"]}, - ], - }, - gpioPinBlocks: [ - ["~SCL/D1", "~SDA/D0", "SCK/A3", "~MISO/A4", "~MOSI/A5", "SS/A2"], - ["D7", "D6", "D5", "D4", "~D3", "~D2", "~TX", "~RX"], - ["A0", "A1", "A2", "A3", "A4", "A5"], - ], - gpioPinMap: { - "P0": "A0", - "P1": "A1", - "P2": "A2", - "P3": "A3", - "P4": "A4", - "P5": "A5", - "P6": "~SDA/D0", - "P7": "~SCL/D1", - "P8": "~D2", - "P9": "~D3", - "P10": "D4", - "P11": "D5", - "P12": "D6", - "P13": "D7", - "P14": "SS/A2", - "P15": "SCK/A3", - "P16": "~MISO/A4", - "P19": "~MOSI/A5", - }, - groundPins: ["GND0", "GND1", "GND2"], - threeVoltPins: ["3.3V"], - } - export const ARDUINO_ZERO: BoardDefinition = { - visual: { - image: "/static/hardware/arduino-zero.png", - outlineImage: "/static/hardware/arduino-zero-outline.svg", - width: 1000, - height: 762, - pinDist: 35.5, - pinBlocks: [ - {x: 276.8, y: 17.8, labels: ["SCL", "SDA", "AREF", "GND0", "~13", "~12", "~11", "~10", "~9", "~8"]}, - {x: 655.5, y: 17.8, labels: ["7", "~6", "~5", "~4", "~3", "2", "TX->1", "RX<-0"]}, - {x: 411.7, y: 704.6, labels: ["ATN", "IOREF", "RESET", "3.3V", "5V", "GND1", "GND2", "VIN"]}, - {x: 732.9, y: 704.6, labels: ["A0", "A1", "A2", "A3", "A4", "A5"]}, - ], - }, - gpioPinBlocks: [ - ["A0", "A1", "A2", "A3", "A4", "A5"], - ["~13", "~12", "~11", "~10", "~9", "~8"], - ["7", "~6", "~5", "~4", "~3", "2", "TX->1", "RX<-0"], - ], - gpioPinMap: { - "P0": "A0", - "P1": "A1", - "P2": "A2", - "P3": "A3", - "P4": "A4", - "P5": "A5", - "P6": "RX<-0", - "P7": "TX->1", - "P8": "2", - "P9": "~3", - "P10": "~4", - "P11": "~5", - "P12": "~6", - "P13": "7", - "P14": "~8", - "P15": "~9", - "P16": "~10", - "P19": "~11", - "P20": "~12", - }, - groundPins: ["GND0", "GND1", "GND2"], - threeVoltPins: ["3.3V"], - } - export const COMPONENT_DEFINITIONS: Map = { + export const PART_DEFINITIONS: Map = { "ledmatrix": { visual: "ledmatrix", breadboardColumnsNeeded: 8, diff --git a/sim/instructions/instructions.ts b/sim/instructions/instructions.ts index cb1d1f36..45e9a4e0 100644 --- a/sim/instructions/instructions.ts +++ b/sim/instructions/instructions.ts @@ -289,7 +289,7 @@ namespace pxsim.instructions { } type BoardProps = { boardDef: BoardDefinition, - cmpDefs: Map, + cmpDefs: Map, allAlloc: AllocatorResult, stepToWires: WireInst[][], stepToCmps: CmpInst[][] @@ -348,7 +348,7 @@ namespace pxsim.instructions { allWireColors: allWireColors, }; } - function mkBoard(boardDef: BoardDefinition, cmpDefs: Map, width: number, buildMode: boolean = false): visuals.GenericBoardSvg { + function mkBoard(boardDef: BoardDefinition, cmpDefs: Map, width: number, buildMode: boolean = false): visuals.GenericBoardSvg { let board = new visuals.GenericBoardSvg({ runtime: pxsim.runtime, boardDef: boardDef, @@ -642,8 +642,8 @@ namespace pxsim.instructions { style.textContent += STYLE; - let boardDef = ARDUINO_ZERO; - let cmpDefs = COMPONENT_DEFINITIONS; + const boardDef = MICROBIT_DEF; + const cmpDefs = PART_DEFINITIONS; //props let dummyBreadboard = new visuals.Breadboard(); diff --git a/sim/visuals/boardhost.ts b/sim/visuals/boardhost.ts index 1a4c4b8a..1f47ee39 100644 --- a/sim/visuals/boardhost.ts +++ b/sim/visuals/boardhost.ts @@ -11,28 +11,27 @@ namespace pxsim.visuals { private defs: SVGDefsElement; private state: DalBoard; - constructor(state: DalBoard, boardDef: BoardDefinition, cmpsList: string[], cmpDefs: Map, fnArgs: any) { + constructor(state: DalBoard, boardDef: BoardDefinition, cmpsList: string[], cmpDefs: Map, fnArgs: any) { this.state = state; let onboardCmps = boardDef.onboardComponents || []; let activeComponents = (cmpsList || []).filter(c => onboardCmps.indexOf(c) < 0); activeComponents.sort(); - // if (boardDef.visual === "microbit") { - this.boardView = new visuals.MicrobitBoardSvg({ - runtime: runtime, - theme: visuals.randomTheme(), - disableTilt: false - }); - // } else { - //TODO: port Arduino/generic board - // this.boardView = new visuals.GenericBoardSvg({ - // boardDef: boardDef, - // activeComponents: activeComponents, - // componentDefinitions: cmpDefs, - // runtime: runtime, - // fnArgs: fnArgs - // }) - // } + // boardDef.visual === "microbit" + this.boardView = new visuals.MicrobitBoardSvg({ + runtime: runtime, + theme: visuals.randomTheme(), + disableTilt: false + }); + //TODO: port Arduino/generic board + // this.boardView = new visuals.GenericBoardSvg({ + // boardDef: boardDef, + // activeComponents: activeComponents, + // componentDefinitions: cmpDefs, + // runtime: runtime, + // fnArgs: fnArgs + // }) + // } const VIEW_WIDTH = "100%"; const VIEW_HEIGHT = "100%"; diff --git a/sim/visuals/genericboard.ts b/sim/visuals/genericboard.ts index 3023bbec..dabda29e 100644 --- a/sim/visuals/genericboard.ts +++ b/sim/visuals/genericboard.ts @@ -11,7 +11,7 @@ namespace pxsim.visuals { disableTilt?: boolean; activeComponents: string[]; fnArgs?: any; - componentDefinitions: Map; + componentDefinitions: Map; } export const VIEW_WIDTH = 498; @@ -192,7 +192,7 @@ namespace pxsim.visuals { private underboard: SVGGElement; public boardDef: BoardDefinition; private boardDim: ComputedBoardDimensions; - public componentDefs: Map; + public componentDefs: Map; private boardEdges: number[]; private id: number; public bbX: number;