Skip to content

Commit

Permalink
Initial provisions for un-tented vias (fusion/eagle)
Browse files Browse the repository at this point in the history
new 'drillsize' parameter added to tracks, only included for un-tented vias as determined by relevant design rule

Render un-tented vias like through-hole pads

Simplify rendering code
  • Loading branch information
Funkenjaeger authored and qu1ck committed Sep 24, 2023
1 parent 77eb20b commit a05f4ac
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 37 deletions.
4 changes: 3 additions & 1 deletion DATAFORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ pcbdata = {
// Common fields
"width": w,
// Optional net name
"net": netname
"net": netname,
// Optional drill diameter (un-tented vias only)
"drillsize": x
},
...
],
Expand Down
57 changes: 36 additions & 21 deletions InteractiveHtmlBom/ecad/fusion_eagle.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ def _add_track(self, el, net):
trk['width'] = float(el.attrib['drill']) + 2 * self.min_via_w \
if 'diameter' not in el.attrib else float(
el.attrib['diameter'])
if float(el.attrib['drill']) >= self.min_drill_via_untented:
trk['drillsize'] = float(el.attrib['drill'])
self.pcbdata['tracks']['F'].append(trk)
self.pcbdata['tracks']['B'].append(trk)

Expand Down Expand Up @@ -715,6 +717,31 @@ def _add_parsed_font_data(self):
if c not in self.pcbdata['font_data']:
self.pcbdata['font_data'][c] = wl

def _parse_param_length(self, name, root, default):
# parse named parameter (typically a design rule) assuming it is in
# length units (mil or mm)
p = [el.attrib['value'] for el in root.iter('param') if
el.attrib['name'] == name]
if len(p) == 0:
self.logger.warning("{0} not found, defaulting to {1}"
.format(name, default))
return default
else:
if len(p) > 1:
self.logger.warning(
"Multiple {0} found, using first occurrence".format(name))
p = p[0]
p_val = float(''.join(d for d in p if d in string.digits + '.'))
p_units = (''.join(d for d in p if d in string.ascii_lowercase))

if p_units == 'mm':
return p_val
elif p_units == 'mil':
return p_val * 0.0254
else:
self.logger.error("Unsupported units {0} on {1}"
.format(p_units, name))

def parse(self):
ext = os.path.splitext(self.file_name)[1]

Expand Down Expand Up @@ -752,28 +779,16 @@ def _parse(self, brdfile):
# Build library mapping elements' pads to nets
self._parse_pad_nets(signals)

# Determine minimum via annular ring from board design rules
# Parse needed design rules

# Minimum via annular ring
# (Needed in order to calculate through-hole pad diameters correctly)
mv = [el.attrib['value'] for el in root.iter('param') if
el.attrib['name'] == 'rlMinViaOuter']
if len(mv) == 0:
self.logger.warning("rlMinViaOuter not found, defaulting to 0")
self.min_via_w = 0
else:
if len(mv) > 1:
self.logger.warning(
"Multiple rlMinViaOuter found, using first occurrence")
mv = mv[0]
mv_val = float(''.join(d for d in mv if d in string.digits + '.'))
mv_units = (''.join(d for d in mv if d in string.ascii_lowercase))

if mv_units == 'mm':
self.min_via_w = mv_val
elif mv_units == 'mil':
self.min_via_w = mv_val * 0.0254
else:
self.logger.error("Unsupported units %s on rlMinViaOuter",
mv_units)
self.min_via_w = (
self._parse_param_length('rlMinViaOuter', root, default=0))

# Minimum drill diameter above which vias will be un-tented
self.min_drill_via_untented = (
self._parse_param_length('mlViaStopLimit', root, default=0))

# Signals --> nets
if self.config.include_nets:
Expand Down
44 changes: 29 additions & 15 deletions InteractiveHtmlBom/web/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,20 +419,34 @@ function drawTracks(canvas, layer, defaultColor, highlight) {
ctx.lineCap = "round";
for (var track of pcbdata.tracks[layer]) {
if (highlight && highlightedNet != track.net) continue;
ctx.strokeStyle = highlight ? defaultColor : settings.netColors[track.net] || defaultColor;
ctx.lineWidth = track.width;
ctx.beginPath();
if ('radius' in track) {
ctx.arc(
...track.center,
track.radius,
deg2rad(track.startangle),
deg2rad(track.endangle));
} else {
if ('drillsize' in track && track.start[0] == track.end[0] && track.start[1] == track.end[1]) {
var style = getComputedStyle(topmostdiv);
ctx.strokeStyle = highlight ? defaultColor : settings.netColors[track.net] || defaultColor;
ctx.lineWidth = track.width;
ctx.beginPath();
ctx.moveTo(...track.start);
ctx.lineTo(...track.end);
ctx.stroke();
ctx.strokeStyle = style.getPropertyValue('--pad-hole-color');
ctx.lineWidth = track.drillsize;
ctx.lineTo(...track.end);
ctx.stroke();
} else {
ctx.strokeStyle = highlight ? defaultColor : settings.netColors[track.net] || defaultColor;
ctx.lineWidth = track.width;
ctx.beginPath();
if ('radius' in track) {
ctx.arc(
...track.center,
track.radius,
deg2rad(track.startangle),
deg2rad(track.endangle));
} else {
ctx.moveTo(...track.start);
ctx.lineTo(...track.end);
}
ctx.stroke();
}
ctx.stroke();
}
}

Expand Down Expand Up @@ -470,14 +484,14 @@ function clearCanvas(canvas, color = null) {

function drawNets(canvas, layer, highlight) {
var style = getComputedStyle(topmostdiv);
if (settings.renderTracks) {
var trackColor = style.getPropertyValue(highlight ? '--track-color-highlight' : '--track-color');
drawTracks(canvas, layer, trackColor, highlight);
}
if (settings.renderZones) {
var zoneColor = style.getPropertyValue(highlight ? '--zone-color-highlight' : '--zone-color');
drawZones(canvas, layer, zoneColor, highlight);
}
if (settings.renderTracks) {
var trackColor = style.getPropertyValue(highlight ? '--track-color-highlight' : '--track-color');
drawTracks(canvas, layer, trackColor, highlight);
}
if (highlight && settings.renderPads) {
var padColor = style.getPropertyValue('--pad-color-highlight');
var padHoleColor = style.getPropertyValue('--pad-hole-color');
Expand Down

0 comments on commit a05f4ac

Please sign in to comment.