towards pin placement

This commit is contained in:
Peli de Halleux 2016-10-14 06:46:56 -07:00
parent 7d4b800637
commit e2fe660012
3 changed files with 15 additions and 6 deletions

View File

@ -157,8 +157,8 @@
{"x": 395, "y": 48} ] {"x": 395, "y": 48} ]
}, },
"pinDefinitions": [ "pinDefinitions": [
{ "target": "P1", "style": "croc", "orientation": "-Z"}, { "target": "M_OUT1", "style": "croc", "orientation": "-Z"},
{ "target": "ground", "style": "croc", "orientation": "-Z"} { "target": "M_OUT2", "style": "croc", "orientation": "-Z"}
], ],
"instantiation": {"kind": "singleton"}, "instantiation": {"kind": "singleton"},
"assembly": [ "assembly": [

View File

@ -146,7 +146,13 @@
"P15": "P15", "P15": "P15",
"P16": "P16", "P16": "P16",
"P19": "P19", "P19": "P19",
"P20": "P20" "P20": "P20",
"EXT_PWR":"EXT_PWR",
"SPKR":"EXT_PWR",
"BTN_A": "BTN_A",
"BTN_B": "BTN_B",
"M_OUT1": "M_OUT1",
"M_OUT2": "M_OUT2"
}, },
"spiPins": { "spiPins": {
"MOSI": "P15", "MOSI": "P15",

View File

@ -1060,11 +1060,10 @@ namespace pxsim.visuals {
private thermometerText: SVGTextElement; private thermometerText: SVGTextElement;
private shakeButton: SVGElement; private shakeButton: SVGElement;
public board: pxsim.DalBoard; public board: pxsim.DalBoard;
private pinNmToCoord: Map<Coord> = {}; private pinNmToCoord: Map<Coord>;
private rgbLed: SVGElement; private rgbLed: SVGElement;
constructor(public props: IBoardProps) { constructor(public props: IBoardProps) {
this.recordPinCoords();
this.buildDom(); this.buildDom();
if (props && props.wireframe) if (props && props.wireframe)
svg.addClass(this.element, "sim-wireframe"); svg.addClass(this.element, "sim-wireframe");
@ -1091,6 +1090,7 @@ namespace pxsim.visuals {
} }
public getCoord(pinNm: string): Coord { public getCoord(pinNm: string): Coord {
if (!this.pinNmToCoord) this.recordPinCoords();
return this.pinNmToCoord[pinNm]; return this.pinNmToCoord[pinNm];
} }
@ -1103,9 +1103,12 @@ namespace pxsim.visuals {
} }
public recordPinCoords() { public recordPinCoords() {
this.pinNmToCoord = {};
pinNames.forEach((nm,i) => { pinNames.forEach((nm,i) => {
// TODO: position pins from SVG // TODO: position pins from SVG
this.pinNmToCoord[nm] = [0,0]; const p = this.pins[i];
const r = p.getBoundingClientRect();
this.pinNmToCoord[nm] = [r.left + r.width / 2, r.top + r.height / 2];
}); });
} }