use native units for subc

This commit is contained in:
King Kévin 2019-05-14 02:26:09 +02:00
parent a18d441d24
commit bd089ba01a
1 changed files with 24 additions and 25 deletions

View File

@ -474,13 +474,12 @@ function json2eagle(json) {
// convert CuVoodoo Land Pattern JSON to coralEDA subscircuit
function json2subc(json)
{
console.log(json)
// create file and add info
var subc = ''
subc += '# footprint generated from CuVoodoo Land Pattern\n'
subc += '# author: '+json.author+'\n'
subc += '# version: '+json.version+'\n'
subc += '# date: '+json.date+'\n'
subc += '# author: ' + json.author + '\n'
subc += '# version: ' + json.version + '\n'
subc += '# date: ' + json.date + '\n'
id = 1 // global subc id
subc += 'li:pcb-rnd-subcircuit-v6 {\n'
@ -541,11 +540,11 @@ function json2subc(json)
y2 = padstack.height / 2 - padstack.width / 2
thickness = padstack.width
}
line += ' x1 = ' + convert_unit(x1, json.unit, 'mm') + 'mm\n'
line += ' y1 = ' + convert_unit(y1, json.unit, 'mm') + 'mm\n'
line += ' x2 = ' + convert_unit(x2, json.unit, 'mm') + 'mm\n'
line += ' y2 = ' + convert_unit(y2, json.unit, 'mm') + 'mm\n'
line += ' thickness =' + convert_unit(thickness, json.unit, 'mm') + 'mm\n'
line += ' x1 = ' + x1 + json.unit + '\n'
line += ' y1 = ' + y1 + json.unit + '\n'
line += ' x2 = ' + x2 + json.unit + '\n'
line += ' y2 = ' + y2 + json.unit + '\n'
line += ' thickness =' + thickness + json.unit + '\n'
line += ' square = ' + (padstack.round ? '0' : '1') + '\n'
line += ' }\n'
subc += ' ha:ps_shape_v4 {\n'
@ -586,14 +585,14 @@ function json2subc(json)
subc += ' ha:ps_proto_v6.' + (id++) + ' {\n'
subc += ' htop = 0\n'
subc += ' hbottom = 0\n'
subc += ' hdia = ' + convert_unit(element.hole, json.unit, 'mm') + 'mm\n'
subc += ' hdia = ' + element.hole + json.unit + '\n'
subc += ' hplated = ' + (element.thickness > element.hole ? '1' : '0') + '\n'
subc += ' li:shape {\n'
var circle = ''
circle += ' ha:ps_circ {\n'
circle += ' x = 0\n'
circle += ' y = 0\n'
circle += ' dia = ' + convert_unit(element.thickness, json.unit, 'mm') + 'mm\n'
circle += ' dia = ' + element.thickness + json.unit + '\n'
circle += ' }\n'
subc += ' ha:ps_shape_v4 {\n'
subc += ' clearance = 0\n'
@ -664,8 +663,8 @@ function json2subc(json)
subc += ' ha:padstack_ref.' + (id++) + '{\n'
subc += ' proto = ' + (2 + padstack) + '\n'
subc += ' rot = 0\n'
subc += ' x = ' + convert_unit(element.x, json.unit, 'mm') + 'mm\n'
subc += ' y = ' + convert_unit(element.y, json.unit, 'mm') + 'mm\n'
subc += ' x = ' + element.x + json.unit + '\n'
subc += ' y = ' + element.y + json.unit + '\n'
subc += ' ha:attributes {\n'
subc += ' term = ' + element.number + '\n'
subc += ' name = ' + element.number + '\n'
@ -689,21 +688,21 @@ function json2subc(json)
case 'line':
subc += ' ha:line.' + (id++) + '{\n'
subc += ' clearance = 0\n'
subc += ' x1 = ' + convert_unit(element.x1, json.unit, 'mm') + 'mm\n'
subc += ' y1 = ' + convert_unit(element.y1, json.unit, 'mm') + 'mm\n'
subc += ' x2 = ' + convert_unit(element.x2, json.unit, 'mm') + 'mm\n'
subc += ' y2 = ' + convert_unit(element.y2, json.unit, 'mm') + 'mm\n'
subc += ' thickness = ' + convert_unit(element.thickness, json.unit, 'mm') + 'mm\n'
subc += ' x1 = ' + element.x1 + json.unit + '\n'
subc += ' y1 = ' + element.y1 + json.unit + '\n'
subc += ' x2 = ' + element.x2 + json.unit + '\n'
subc += ' y2 = ' + element.y2 + json.unit + '\n'
subc += ' thickness = ' + element.thickness + json.unit + '\n'
subc += ' }\n'
break
case 'arc':
subc += ' ha:arc.' + (id++) + '{\n'
subc += ' clearance = 0\n'
subc += ' x = ' + convert_unit(element.x, json.unit, 'mm') + 'mm\n'
subc += ' y = ' + convert_unit(element.y, json.unit, 'mm') + 'mm\n'
subc += ' width = ' + convert_unit(element.radius, json.unit, 'mm') + 'mm\n'
subc += ' height = ' + convert_unit(element.radius, json.unit, 'mm') + 'mm\n'
subc += ' thickness = ' + convert_unit(element.thickness, json.unit, 'mm') + 'mm\n'
subc += ' x = ' + element.x + json.unit + '\n'
subc += ' y = ' + element.y + json.unit + '\n'
subc += ' width = ' + element.radius + json.unit + '\n'
subc += ' height = ' + element.radius + json.unit + '\n'
subc += ' thickness = ' + element.thickness + json.unit + '\n'
subc += ' astart = ' + ((element.start * -1 + 180) % 360) + '\n'
subc += ' adelta = ' + (element.angle * -1) + '\n'
subc += ' }\n'
@ -719,8 +718,8 @@ function json2subc(json)
subc += ' ha:padstack_ref.' + (id++) + '{\n'
subc += ' proto = ' + (2 + padstack) + '\n'
subc += ' rot = 0\n'
subc += ' x = ' + convert_unit(element.x, json.unit, 'mm') + 'mm\n'
subc += ' y = ' + convert_unit(element.y, json.unit, 'mm') + 'mm\n'
subc += ' x = ' + element.x + json.unit + '\n'
subc += ' y = ' + element.y + json.unit + '\n'
subc += ' ha:attributes {\n'
subc += ' term = ' + element.number + '\n'
subc += ' name = ' + element.number + '\n'