Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
e2a16fb8
Commit
e2a16fb8
authored
3 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
Excellon working?
parent
9e8c1f4c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/path/formats/gerber
+45
-28
45 additions, 28 deletions
modules/path/formats/gerber
with
45 additions
and
28 deletions
modules/path/formats/gerber
+
45
−
28
View file @
e2a16fb8
...
@@ -84,7 +84,6 @@ var interface = function(div){
...
@@ -84,7 +84,6 @@ var interface = function(div){
input.type = 'radio'
input.type = 'radio'
input.name = mod.div.id+'format'
input.name = mod.div.id+'format'
input.id = mod.div.id+'outline'
input.id = mod.div.id+'outline'
input.disabled = true
formats.appendChild(input)
formats.appendChild(input)
mod.drill = input
mod.drill = input
formats.appendChild(document.createTextNode('drill'))
formats.appendChild(document.createTextNode('drill'))
...
@@ -93,37 +92,44 @@ var interface = function(div){
...
@@ -93,37 +92,44 @@ var interface = function(div){
//
//
// local functions
// local functions
//
//
function format(x) {
function gformat(x) {
// 6.6 omit leading
var s = x.toFixed(6)
var s = x.toFixed(6)
s = s.substr(0,s.length-7)+s.substr(-6,6)
s = s.substr(0,s.length-7)+s.substr(-6,6)
return s
return s
}
}
//
//
function eformat(x) {
// 2.4 omit trailing
var s = (x/100).toFixed(6).substr(2)
return s
}
//
function plot() {
function plot() {
var imgwidth = mod.imageInfo.width/parseFloat(mod.imageInfo.dpi)
var imgwidth = mod.imageInfo.width/parseFloat(mod.imageInfo.dpi)
var imgheight = mod.imageInfo.height/parseFloat(mod.imageInfo.dpi)
var imgheight = mod.imageInfo.height/parseFloat(mod.imageInfo.dpi)
var x,y
var x,y
//
//
str = ''
str = ''
//
if (mod.fill.checked == true) {
str += "%MOIN*%\n" // inch units
str += "%MOIN*%\n" // inch units
str += "%LPD*%\n" // layer dark
str += "%LPD*%\n" // layer dark
str += "%FSLAX66Y66*%\n" // format absolute 6.6
str += "%FSLAX66Y66*%\n" // format absolute 6.6
str += "G01*\n" // linear interpolation
str += "G01*\n" // linear interpolation
//
if (mod.fill.checked == true) {
for (var seg = 0; seg < mod.path.length; ++seg) {
for (var seg = 0; seg < mod.path.length; ++seg) {
str += "G36*\n"
str += "G36*\n"
x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1)
y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1)
str += 'X'+format(x)+'Y'+format(y)+'D02*\n'
str += 'X'+
g
format(x)+'Y'+
g
format(y)+'D02*\n'
for (var pt = 1; pt < mod.path[seg].length; ++pt) {
for (var pt = 1; pt < mod.path[seg].length; ++pt) {
var x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1)
var x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1)
var y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
var y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
str += 'X'+format(x)+'Y'+format(y)+'D01*\n'
str += 'X'+
g
format(x)+'Y'+
g
format(y)+'D01*\n'
}
}
x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1)
y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1)
str += 'X'+format(x)+'Y'+format(y)+'D01*\n'
str += 'X'+
g
format(x)+'Y'+
g
format(y)+'D01*\n'
str += "G37*\n"
str += "G37*\n"
}
}
str += "M02*\n"
str += "M02*\n"
...
@@ -134,20 +140,24 @@ function plot() {
...
@@ -134,20 +140,24 @@ function plot() {
outputs.Gerber.event(obj)
outputs.Gerber.event(obj)
}
}
else if (mod.outline.checked == true) {
else if (mod.outline.checked == true) {
str += "%MOIN*%\n" // inch units
str += "%LPD*%\n" // layer dark
str += "%FSLAX66Y66*%\n" // format absolute 6.6
str += "G01*\n" // linear interpolation
str += "%ADD10C,0.001*%\n"
str += "%ADD10C,0.001*%\n"
str += "D10*\n"
str += "D10*\n"
for (var seg = 0; seg < mod.path.length; ++seg) {
for (var seg = 0; seg < mod.path.length; ++seg) {
x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1)
y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1)
str += 'X'+format(x)+'Y'+format(y)+'D02*\n'
str += 'X'+
g
format(x)+'Y'+
g
format(y)+'D02*\n'
for (var pt = 1; pt < mod.path[seg].length; ++pt) {
for (var pt = 1; pt < mod.path[seg].length; ++pt) {
var x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1)
var x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1)
var y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
var y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
str += 'X'+format(x)+'Y'+format(y)+'D01*\n'
str += 'X'+
g
format(x)+'Y'+
g
format(y)+'D01*\n'
}
}
x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1)
y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1)
str += 'X'+format(x)+'Y'+format(y)+'D01*\n'
str += 'X'+
g
format(x)+'Y'+
g
format(y)+'D01*\n'
}
}
str += "M02*\n"
str += "M02*\n"
var obj = {}
var obj = {}
...
@@ -167,7 +177,7 @@ function plot() {
...
@@ -167,7 +177,7 @@ function plot() {
//
//
sx = sy = 0
sx = sy = 0
for (var pt = 0; pt < mod.path[seg].length; ++pt) {
for (var pt = 0; pt < mod.path[seg].length; ++pt) {
sx += imgwidth*mod.path[seg][pt][0]
V
/(mod.imageInfo.width-1)
sx += imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1)
sy += imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
sy += imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
}
}
x0 = sx/mod.path[seg].length
x0 = sx/mod.path[seg].length
...
@@ -177,7 +187,7 @@ function plot() {
...
@@ -177,7 +187,7 @@ function plot() {
// find diameter
// find diameter
//
//
for (var pt = 0; pt < mod.path[seg].length; ++pt) {
for (var pt = 0; pt < mod.path[seg].length; ++pt) {
x = imgwidth*mod.path[seg][pt][0]
V
/(mod.imageInfo.width-1)
x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1)
y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
sd += 2*Math.sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0))
sd += 2*Math.sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0))
}
}
...
@@ -190,32 +200,39 @@ function plot() {
...
@@ -190,32 +200,39 @@ function plot() {
// sort diameters
// sort diameters
//
//
var drills = {}
var drills = {}
var tool = 0
for (var hole = 0; hole < ds.length; ++hole) {
for (var hole = 0; hole < ds.length; ++hole) {
key =
str(
ds[hole].toFixed(
2
)
key = ds[hole].toFixed(
3).toString(
)
if (key in drills)
if (key in drills)
drills[key].push(hole)
drills[key].push(hole)
else
else {
drills[key] = [hole]
tool += 1
drills[key] = [tool,hole]
}
}
}
//
//
// write file
// write file
//
//
str += "M48\n"
str += "M48\n" // start of header
str += "INCH,LZ\n"
str += "INCH,LZ\n" // inch units with leading zeros
str += "T01C0.02\n"
str += "VER,1\n" // version 1
str += "M95\n"
str += "FMAT,2\n" // format 2
str += "G05\n"
for (var key in drills) {
str += "T01\n"
str += 'T'+drills[key][0]+'C'+key+"\n" // define tools
str += "X6500Y4500\n"
}
str += "M95\n" // end of header
str += "G05\n" // drill mode
for (var key in drills) {
for (var key in drills) {
for (var hole in drills[key].length) {
str += 'T'+drills[key][0]+'\n' // tool selection
str += key+' '+hole+'\n'
for (var i = 1; i < drills[key].length; ++i) {
var hole = drills[key][i]
str += 'X'+eformat(xs[hole])+'Y'+eformat(ys[hole])+'\n'
}
}
}
}
str += "M30\n"
str += "M30\n"
// end of program
var obj = {}
var obj = {}
obj.type = 'file'
obj.type = 'file'
obj.name = mod.imageInfo.name+'-drill.
gbr
'
obj.name = mod.imageInfo.name+'-drill.
xln
'
obj.contents = str
obj.contents = str
outputs.Gerber.event(obj)
outputs.Gerber.event(obj)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment