diff --git a/package.json b/package.json index 6a3a66ba..b856db5f 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "schematic-symbols": "^0.0.224", + "transformation-matrix": "^2.16.1", "ts-node": "^10.9.2", "tsup": "^8.0.2", "typescript": "^5.4.5" diff --git a/src/fn/melf.ts b/src/fn/melf.ts index 3f5ccc71..f89ab566 100644 --- a/src/fn/melf.ts +++ b/src/fn/melf.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const melf_def = base_def.extend({ @@ -24,6 +28,16 @@ export const melf = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = melf_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.wideThickStroke, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +85,7 @@ export const melf = ( return { circuitJson: melfWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/micromelf.ts b/src/fn/micromelf.ts index 165c0b05..6ed7bf60 100644 --- a/src/fn/micromelf.ts +++ b/src/fn/micromelf.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const micromelf_def = base_def.extend({ @@ -24,6 +28,16 @@ export const micromelf = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = micromelf_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.micromelfCompact, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +85,7 @@ export const micromelf = ( return { circuitJson: microMelfWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/minimelf.ts b/src/fn/minimelf.ts index 4b032c54..ffdecd44 100644 --- a/src/fn/minimelf.ts +++ b/src/fn/minimelf.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const minimelf_def = base_def.extend({ @@ -24,6 +28,16 @@ export const minimelf = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = minimelf_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.wide, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +85,7 @@ export const minimelf = ( return { circuitJson: miniMelfWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sma.ts b/src/fn/sma.ts index 4142a555..0ba93305 100644 --- a/src/fn/sma.ts +++ b/src/fn/sma.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sma_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sma = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sma_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.smaLike, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +85,7 @@ export const sma = ( return { circuitJson: smaWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/smb.ts b/src/fn/smb.ts index 5b71080c..48f906c7 100644 --- a/src/fn/smb.ts +++ b/src/fn/smb.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const smb_def = base_def.extend({ @@ -24,6 +28,16 @@ export const smb = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = smb_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.smaLike, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +85,7 @@ export const smb = ( return { circuitJson: smbWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/smbf.ts b/src/fn/smbf.ts index 5cc68bbb..ad8d6462 100644 --- a/src/fn/smbf.ts +++ b/src/fn/smbf.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const smbf_def = base_def.extend({ @@ -24,6 +28,16 @@ export const smbf = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = smbf_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.wide, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +85,7 @@ export const smbf = ( return { circuitJson: smbfWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/smc.ts b/src/fn/smc.ts index 3444e450..7b7e5ce3 100644 --- a/src/fn/smc.ts +++ b/src/fn/smc.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const smc_def = base_def.extend({ @@ -24,6 +28,16 @@ export const smc = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = smc_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.wideThickStroke, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef(0, 3, 0.3) @@ -67,6 +81,7 @@ export const smc = ( return { circuitJson: smcWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/smf.ts b/src/fn/smf.ts index 17a3eb6c..e195848c 100644 --- a/src/fn/smf.ts +++ b/src/fn/smf.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const smf_def = base_def.extend({ @@ -24,6 +28,16 @@ export const smf = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = smf_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.smf, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +85,7 @@ export const smf = ( return { circuitJson: smfWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod110.ts b/src/fn/sod110.ts index 7e8dbae2..c96ad0ad 100644 --- a/src/fn/sod110.ts +++ b/src/fn/sod110.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -23,6 +27,16 @@ export const sod110 = ( raw_params: z.input, ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod123Wide, + }) const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, length.parse(parameters.h) / 2 + 0.5, @@ -69,6 +83,7 @@ export const sod110 = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod123.ts b/src/fn/sod123.ts index f346b7b4..2ae609a5 100644 --- a/src/fn/sod123.ts +++ b/src/fn/sod123.ts @@ -3,6 +3,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -19,6 +23,16 @@ export const sod123 = ( raw_params: z.input, ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod123, + }) const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, length.parse(parameters.h) / 4 + 0.4, @@ -39,6 +53,7 @@ export const sod123 = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, ), diff --git a/src/fn/sod123f.ts b/src/fn/sod123f.ts index bd3bf040..42d441db 100644 --- a/src/fn/sod123f.ts +++ b/src/fn/sod123f.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod123f = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod123Wide, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod123f = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod123fl.ts b/src/fn/sod123fl.ts index b1555915..bc0dd969 100644 --- a/src/fn/sod123fl.ts +++ b/src/fn/sod123fl.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod123FL_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod123fl = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod123FL_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod123Wide, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod123fl = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod123w.ts b/src/fn/sod123w.ts index b2138813..0961b9ee 100644 --- a/src/fn/sod123w.ts +++ b/src/fn/sod123w.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod123w = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod123Wide, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod123w = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod128.ts b/src/fn/sod128.ts index fb164e48..e778887f 100644 --- a/src/fn/sod128.ts +++ b/src/fn/sod128.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod128 = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.wide, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod128 = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod323.ts b/src/fn/sod323.ts index 4c7ea3aa..c9aa00e7 100644 --- a/src/fn/sod323.ts +++ b/src/fn/sod323.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod323 = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod323InsetWide, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +85,7 @@ export const sod323 = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod323f.ts b/src/fn/sod323f.ts index 74883fa2..feaaf162 100644 --- a/src/fn/sod323f.ts +++ b/src/fn/sod323f.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod323f = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.pad_spacing) / 2, + pin2PadX: length.parse(parameters.pad_spacing) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod323InsetWide, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod323f = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod323fl.ts b/src/fn/sod323fl.ts index 76fdb356..498a04f6 100644 --- a/src/fn/sod323fl.ts +++ b/src/fn/sod323fl.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod323FL_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod323fl = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod323FL_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.pad_spacing) / 2, + pin2PadX: length.parse(parameters.pad_spacing) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod323Compact, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod323fl = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod323w.ts b/src/fn/sod323w.ts index 35740742..03076450 100644 --- a/src/fn/sod323w.ts +++ b/src/fn/sod323w.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod323w_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod323w = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod323w_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.pad_spacing) / 2, + pin2PadX: length.parse(parameters.pad_spacing) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod323Compact, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod323w = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod523.ts b/src/fn/sod523.ts index edd8d5b4..7c8479d5 100644 --- a/src/fn/sod523.ts +++ b/src/fn/sod523.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod523 = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod323Compact, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod523 = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod723.ts b/src/fn/sod723.ts index 05f530fe..ee887ace 100644 --- a/src/fn/sod723.ts +++ b/src/fn/sod723.ts @@ -24,6 +24,8 @@ export const sod723 = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + const fabricationNotes: AnyCircuitElement[] = [] + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +73,7 @@ export const sod723 = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod80.ts b/src/fn/sod80.ts index 206cb917..5a661c89 100644 --- a/src/fn/sod80.ts +++ b/src/fn/sod80.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod80_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod80 = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod80_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod123Wide, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -71,6 +85,7 @@ export const sod80 = ( return { circuitJson: sod80WithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod882.ts b/src/fn/sod882.ts index 7fddcf8b..f6f157e2 100644 --- a/src/fn/sod882.ts +++ b/src/fn/sod882.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod882 = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod882Compact, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod882 = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod882d.ts b/src/fn/sod882d.ts index 0ed8447a..3c20bff3 100644 --- a/src/fn/sod882d.ts +++ b/src/fn/sod882d.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" export const sod_def = base_def.extend({ @@ -24,6 +28,16 @@ export const sod882d = ( ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod882dCompact, + }) + // Define silkscreen reference text const silkscreenRefText: SilkscreenRef = silkscreenRef( 0, @@ -72,6 +86,7 @@ export const sod882d = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/fn/sod923.ts b/src/fn/sod923.ts index 8c3b365b..53ffd79a 100644 --- a/src/fn/sod923.ts +++ b/src/fn/sod923.ts @@ -7,6 +7,10 @@ import { z } from "zod" import { rectpad } from "../helpers/rectpad" import { silkscreenRef, type SilkscreenRef } from "src/helpers/silkscreenRef" import { length } from "circuit-json" +import { + createManualDiodeFabricationNotes, + diodeFabricationTuningPresets, +} from "../helpers/manual-diode-fabrication" import { base_def } from "../helpers/zod/base_def" import { createRectUnionOutline } from "src/helpers/rect-union-outline" @@ -24,6 +28,16 @@ export const sod923 = ( raw_params: z.input, ): { circuitJson: AnyCircuitElement[]; parameters: any } => { const parameters = sod_def.parse(raw_params) + + const fabricationNotes = createManualDiodeFabricationNotes({ + pin1PadX: -length.parse(parameters.p) / 2, + pin2PadX: length.parse(parameters.p) / 2, + padWidth: length.parse(parameters.pl), + padHeight: length.parse(parameters.pw), + bodyWidth: length.parse(parameters.w), + bodyHeight: length.parse(parameters.h), + tuning: diodeFabricationTuningPresets.sod923, + }) const w = length.parse(parameters.w) const h = length.parse(parameters.h) const pl = length.parse(parameters.pl) @@ -96,6 +110,7 @@ export const sod923 = ( return { circuitJson: sodWithoutParsing(parameters).concat( + fabricationNotes as AnyCircuitElement[], silkscreenLine as AnyCircuitElement, silkscreenRefText as AnyCircuitElement, courtyard as AnyCircuitElement, diff --git a/src/helpers/apply-origin.ts b/src/helpers/apply-origin.ts index 369ace12..97a22d96 100644 --- a/src/helpers/apply-origin.ts +++ b/src/helpers/apply-origin.ts @@ -109,10 +109,22 @@ export const applyOrigin = ( } } + if (el.type === "pcb_fabrication_note_path") { + for (const pt of el.route) { + pt.x -= dx + pt.y -= dy + } + } + if (el.type === "pcb_silkscreen_text" && el.anchor_position) { el.anchor_position.x -= dx el.anchor_position.y -= dy } + + if (el.type === "pcb_fabrication_note_text" && el.anchor_position) { + el.anchor_position.x -= dx + el.anchor_position.y -= dy + } } return elements diff --git a/src/helpers/manual-diode-fabrication.ts b/src/helpers/manual-diode-fabrication.ts new file mode 100644 index 00000000..e510c665 --- /dev/null +++ b/src/helpers/manual-diode-fabrication.ts @@ -0,0 +1,581 @@ +import type { AnyCircuitElement, PcbFabricationNotePath } from "circuit-json" +import { + applyToPoint, + compose, + scale, + type Matrix, + translate, +} from "transformation-matrix" + +const clamp = (value: number, min: number, max: number) => + Math.min(max, Math.max(min, value)) + +const lerp = (from: number, to: number, amount: number) => + from + (to - from) * amount + +type RatioTuning = { + base: number + tightPitchFactor: number + min: number + max: number +} + +type SymbolHalfHeightTuning = { + bodyBase: number + bodyBoost: number + widthBase: number + widthBoost: number + min: number + maxBase: number + maxBoost: number +} + +type StrokeWidthTuning = { + heightFactor: number + widthFactor: number + min: number + max: number +} + +type LeadLineExtensionTuning = { + scale: number + min: number + max: number +} + +type RoutePoint = { + x: number + y: number +} + +type ResolvedManualDiodeFabricationNoteTuning = { + leadGap: NonNullable + leadInsetFromCenter: NonNullable< + ManualDiodeFabricationNoteTuning["leadInsetFromCenter"] + > + symbolLeadInset: ManualDiodeFabricationNoteTuning["symbolLeadInset"] + leadLineExtension: LeadLineExtensionTuning + usableSymbolWidthMin: number + arrowBaseRatio: RatioTuning + cathodeBarRatio: RatioTuning + symbolHalfHeight: SymbolHalfHeightTuning + outlineHeightScale: number + strokeWidth: StrokeWidthTuning +} + +export type ManualDiodeFabricationNoteTuning = { + leadGap?: { + scale: number + min: number + max: number + } + leadInsetFromCenter?: { + scale: number + min: number + maxScale: number + } + symbolLeadInset?: { + scale: number + min: number + max: number + } + leadLineExtension?: { + scale: number + min: number + max: number + } + usableSymbolWidthMin?: number + arrowBaseRatio?: RatioTuning + cathodeBarRatio?: RatioTuning + symbolHalfHeight?: SymbolHalfHeightTuning + outlineHeightScale?: number + strokeWidth?: StrokeWidthTuning +} + +export type ManualDiodeFabricationNoteParams = { + pin1PadX: number + pin2PadX: number + padWidth: number + padHeight: number + bodyWidth?: number + bodyHeight?: number + layer?: "top" | "bottom" + y?: number + tuning?: ManualDiodeFabricationNoteTuning +} + +const defaultTuning = { + leadGap: { + scale: 0.05, + min: 0.01, + max: 0.04, + }, + leadInsetFromCenter: { + scale: 0.16, + min: 0.04, + maxScale: 0.32, + }, + leadLineExtension: { + scale: 0, + min: 0, + max: 0, + }, + usableSymbolWidthMin: 0.2, + arrowBaseRatio: { + base: 0.14, + tightPitchFactor: 0.06, + min: 0.06, + max: 0.14, + }, + cathodeBarRatio: { + base: 0.08, + tightPitchFactor: 0.03, + min: 0.03, + max: 0.08, + }, + symbolHalfHeight: { + bodyBase: 0.24, + bodyBoost: 0.05, + widthBase: 0.28, + widthBoost: 0.08, + min: 0.1, + maxBase: 0.32, + maxBoost: 0.04, + }, + outlineHeightScale: 1, + strokeWidth: { + heightFactor: 0.055, + widthFactor: 0.035, + min: 0.025, + max: 0.06, + }, +} satisfies Omit + +const resolveTuning = ( + tuning?: ManualDiodeFabricationNoteTuning, +): ResolvedManualDiodeFabricationNoteTuning => ({ + leadGap: { ...defaultTuning.leadGap, ...tuning?.leadGap }, + leadInsetFromCenter: { + ...defaultTuning.leadInsetFromCenter, + ...tuning?.leadInsetFromCenter, + }, + symbolLeadInset: tuning?.symbolLeadInset, + leadLineExtension: { + ...defaultTuning.leadLineExtension, + ...tuning?.leadLineExtension, + }, + usableSymbolWidthMin: + tuning?.usableSymbolWidthMin ?? defaultTuning.usableSymbolWidthMin, + arrowBaseRatio: { + ...defaultTuning.arrowBaseRatio, + ...tuning?.arrowBaseRatio, + }, + cathodeBarRatio: { + ...defaultTuning.cathodeBarRatio, + ...tuning?.cathodeBarRatio, + }, + symbolHalfHeight: { + ...defaultTuning.symbolHalfHeight, + ...tuning?.symbolHalfHeight, + }, + outlineHeightScale: + tuning?.outlineHeightScale ?? defaultTuning.outlineHeightScale, + strokeWidth: { ...defaultTuning.strokeWidth, ...tuning?.strokeWidth }, +}) + +const ratioTuning = ( + base: number, + tightPitchFactor: number, + min: number, + max: number, +): RatioTuning => ({ + base, + tightPitchFactor, + min, + max, +}) + +const symbolHalfHeightTuning = ( + bodyBase: number, + bodyBoost: number, + widthBase: number, + widthBoost: number, + min: number, + maxBase: number, + maxBoost: number, +): SymbolHalfHeightTuning => ({ + bodyBase, + bodyBoost, + widthBase, + widthBoost, + min, + maxBase, + maxBoost, +}) + +const wideRatios = { + arrowBaseRatio: ratioTuning(0.34, 0.02, 0.3, 0.34), + cathodeBarRatio: ratioTuning(0.28, 0.02, 0.24, 0.28), +} satisfies Pick< + ManualDiodeFabricationNoteTuning, + "arrowBaseRatio" | "cathodeBarRatio" +> + +const smaLikeSymbolHalfHeight = { + symbolHalfHeight: symbolHalfHeightTuning( + 0.26, + 0.05, + 0.31, + 0.08, + 0.11, + 0.35, + 0.04, + ), +} satisfies Pick + +const compactOutline = { + outlineHeightScale: 2 / 3, +} satisfies Pick + +const thickStroke = { + strokeWidth: { + max: 0.075, + }, +} satisfies Pick + +const extendLeadLines = (scaleFactor: number, min: number, max: number) => + ({ + leadLineExtension: { + scale: scaleFactor, + min, + max, + }, + }) satisfies Pick + +const centeredOutlineTemplate: RoutePoint[] = [ + { x: -0.5, y: 0.5 }, + { x: 0.5, y: 0.5 }, + { x: 0.5, y: -0.5 }, + { x: -0.5, y: -0.5 }, + { x: -0.5, y: 0.5 }, +] + +const normalizedLeadTemplate: RoutePoint[] = [ + { x: 0, y: 0 }, + { x: 1, y: 0 }, +] + +const normalizedArrowTemplate: RoutePoint[] = [ + { x: 0, y: -1 }, + { x: 1, y: 0 }, + { x: 0, y: 1 }, + { x: 0, y: -1 }, +] + +const normalizedCathodeBarTemplate: RoutePoint[] = [ + { x: 0, y: -1.15 }, + { x: 0, y: 1.15 }, +] + +const transformRoute = (matrix: Matrix, route: RoutePoint[]): RoutePoint[] => + route.map((point) => applyToPoint(matrix, point)) + +const createFabPath = ( + pcb_fabrication_note_path_id: string, + route: RoutePoint[], + stroke_width: number, + layer: "top" | "bottom", + pcb_component_id = "", +): PcbFabricationNotePath => ({ + type: "pcb_fabrication_note_path", + pcb_fabrication_note_path_id, + pcb_component_id, + layer, + route, + stroke_width, +}) + +const createTransformedFabPath = ( + pcb_fabrication_note_path_id: string, + template: RoutePoint[], + matrix: Matrix, + stroke_width: number, + layer: "top" | "bottom", + pcb_component_id = "", +): PcbFabricationNotePath => + createFabPath( + pcb_fabrication_note_path_id, + transformRoute(matrix, template), + stroke_width, + layer, + pcb_component_id, + ) + +const createScaledFabPath = ( + pcb_fabrication_note_path_id: string, + template: RoutePoint[], + x: number, + y: number, + scaleX: number, + scaleY: number, + stroke_width: number, + layer: "top" | "bottom", + pcb_component_id = "", +): PcbFabricationNotePath => + createTransformedFabPath( + pcb_fabrication_note_path_id, + template, + compose(translate(x, y), scale(scaleX, scaleY)), + stroke_width, + layer, + pcb_component_id, + ) + +export const diodeFabricationTuningPresets = { + wide: wideRatios, + wideThickStroke: { + ...wideRatios, + ...thickStroke, + }, + smf: { + leadGap: { + scale: -0.03, + min: -0.04, + max: -0.02, + }, + ...wideRatios, + }, + smaLike: { + arrowBaseRatio: ratioTuning(0.24, 0.03, 0.2, 0.24), + cathodeBarRatio: ratioTuning(0.16, 0.02, 0.12, 0.16), + ...smaLikeSymbolHalfHeight, + ...extendLeadLines(0.12, 0.22, 0.3), + ...thickStroke, + }, + sod323Compact: { + arrowBaseRatio: ratioTuning(0.26, 0.03, 0.2, 0.26), + cathodeBarRatio: ratioTuning(0.2, 0.03, 0.14, 0.2), + }, + sod323InsetWide: { + symbolLeadInset: { + scale: 0.16, + min: 0.14, + max: 0.36, + }, + usableSymbolWidthMin: 0.14, + ...wideRatios, + }, + sod123Wide: { + arrowBaseRatio: ratioTuning(0.3, 0.03, 0.24, 0.3), + cathodeBarRatio: ratioTuning(0.24, 0.03, 0.18, 0.24), + }, + sod123: { + arrowBaseRatio: ratioTuning(0.31, 0.03, 0.25, 0.31), + cathodeBarRatio: ratioTuning(0.25, 0.03, 0.19, 0.25), + }, + sod923: { + arrowBaseRatio: ratioTuning(0.31, 0.02, 0.28, 0.31), + cathodeBarRatio: ratioTuning(0.25, 0.02, 0.22, 0.25), + }, + sod882Compact: { + ...compactOutline, + ...extendLeadLines(0.18, 0.05, 0.07), + }, + sod882dCompact: { + arrowBaseRatio: ratioTuning(0.17, 0.05, 0.12, 0.17), + cathodeBarRatio: ratioTuning(0.1, 0.02, 0.07, 0.1), + ...compactOutline, + ...extendLeadLines(0.18, 0.04, 0.06), + }, + micromelfCompact: { + arrowBaseRatio: ratioTuning(0.22, 0.04, 0.19, 0.22), + cathodeBarRatio: ratioTuning(0.14, 0.02, 0.12, 0.14), + symbolHalfHeight: symbolHalfHeightTuning( + 0.28, + 0.05, + 0.38, + 0.08, + 0.13, + 0.38, + 0.04, + ), + ...compactOutline, + ...extendLeadLines(0.12, 0.05, 0.08), + }, +} satisfies Record + +export const createManualDiodeFabricationNotes = ( + params: ManualDiodeFabricationNoteParams, +): AnyCircuitElement[] => { + const { + pin1PadX, + pin2PadX, + padWidth, + padHeight, + bodyHeight, + layer = "top", + y = 0, + tuning, + } = params + + const resolvedTuning = resolveTuning(tuning) + const direction = pin2PadX >= pin1PadX ? 1 : -1 + const padDistance = Math.abs(pin2PadX - pin1PadX) + const tightPitchBoost = clamp((1.3 - padDistance) / 0.75, 0, 1) + + const leadGap = clamp( + Math.min(padWidth, padHeight) * resolvedTuning.leadGap.scale, + resolvedTuning.leadGap.min, + resolvedTuning.leadGap.max, + ) + const leadEdgeLeftX = pin1PadX + direction * (padWidth / 2 + leadGap) + const leadEdgeRightX = pin2PadX - direction * (padWidth / 2 + leadGap) + const leadInsetFromCenter = clamp( + padWidth * resolvedTuning.leadInsetFromCenter.scale, + resolvedTuning.leadInsetFromCenter.min, + padWidth * resolvedTuning.leadInsetFromCenter.maxScale, + ) + const leadHalfPadLeftX = pin1PadX + direction * leadInsetFromCenter + const leadHalfPadRightX = pin2PadX - direction * leadInsetFromCenter + const leadLeftX = lerp(leadEdgeLeftX, leadHalfPadLeftX, tightPitchBoost) + const leadRightX = lerp(leadEdgeRightX, leadHalfPadRightX, tightPitchBoost) + + let symbolLeadLeftX = leadLeftX + let symbolLeadRightX = leadRightX + if (resolvedTuning.symbolLeadInset) { + const symbolLeadInsetX = clamp( + padDistance * resolvedTuning.symbolLeadInset.scale, + resolvedTuning.symbolLeadInset.min, + resolvedTuning.symbolLeadInset.max, + ) + symbolLeadLeftX = leadLeftX + direction * symbolLeadInsetX + symbolLeadRightX = leadRightX - direction * symbolLeadInsetX + } + + const leadLineExtensionX = clamp( + padWidth * resolvedTuning.leadLineExtension.scale, + resolvedTuning.leadLineExtension.min, + resolvedTuning.leadLineExtension.max, + ) + const leadLineLeftX = symbolLeadLeftX - direction * leadLineExtensionX + const leadLineRightX = symbolLeadRightX + direction * leadLineExtensionX + + const computedBodyHeight = Math.max(padHeight * 1.35, 0.9) + const verticalMargin = clamp( + Math.min( + padHeight * (0.18 + tightPitchBoost * 0.12), + (bodyHeight ?? computedBodyHeight) * 0.18, + ), + 0.03, + 0.2, + ) + const provisionalBodyHeight = Math.max(padHeight + verticalMargin * 2, 0.18) + const usableSymbolWidth = Math.max( + resolvedTuning.usableSymbolWidthMin, + Math.abs(symbolLeadRightX - symbolLeadLeftX), + ) + const arrowBaseRatio = clamp( + resolvedTuning.arrowBaseRatio.base - + tightPitchBoost * resolvedTuning.arrowBaseRatio.tightPitchFactor, + resolvedTuning.arrowBaseRatio.min, + resolvedTuning.arrowBaseRatio.max, + ) + const cathodeBarRatio = clamp( + resolvedTuning.cathodeBarRatio.base - + tightPitchBoost * resolvedTuning.cathodeBarRatio.tightPitchFactor, + resolvedTuning.cathodeBarRatio.min, + resolvedTuning.cathodeBarRatio.max, + ) + const arrowBaseX = + symbolLeadLeftX + direction * usableSymbolWidth * arrowBaseRatio + const cathodeBarX = + symbolLeadRightX - direction * usableSymbolWidth * cathodeBarRatio + const leftX = Math.min(pin1PadX, pin2PadX) - leadLineExtensionX + const rightX = Math.max(pin1PadX, pin2PadX) + leadLineExtensionX + const finalBodyWidth = rightX - leftX + + const symbolHalfHeight = clamp( + Math.min( + provisionalBodyHeight * + (resolvedTuning.symbolHalfHeight.bodyBase + + tightPitchBoost * resolvedTuning.symbolHalfHeight.bodyBoost), + usableSymbolWidth * + (resolvedTuning.symbolHalfHeight.widthBase + + tightPitchBoost * resolvedTuning.symbolHalfHeight.widthBoost), + ), + resolvedTuning.symbolHalfHeight.min, + provisionalBodyHeight * + (resolvedTuning.symbolHalfHeight.maxBase + + tightPitchBoost * resolvedTuning.symbolHalfHeight.maxBoost), + ) + const baseBodyHeight = Math.max( + provisionalBodyHeight, + symbolHalfHeight * 2 + verticalMargin * 2, + ) + const finalBodyHeight = baseBodyHeight * resolvedTuning.outlineHeightScale + + const strokeWidth = clamp( + Math.min( + finalBodyHeight * resolvedTuning.strokeWidth.heightFactor, + finalBodyWidth * resolvedTuning.strokeWidth.widthFactor, + ), + resolvedTuning.strokeWidth.min, + resolvedTuning.strokeWidth.max, + ) + + const fabPaths: PcbFabricationNotePath[] = [ + createScaledFabPath( + "diode_symbol_outline", + centeredOutlineTemplate, + (leftX + rightX) / 2, + y, + finalBodyWidth, + finalBodyHeight, + strokeWidth, + layer, + ), + createScaledFabPath( + "diode_symbol_lead_in", + normalizedLeadTemplate, + leadLineLeftX, + y, + arrowBaseX - leadLineLeftX, + 1, + strokeWidth, + layer, + ), + createScaledFabPath( + "diode_symbol_arrow", + normalizedArrowTemplate, + arrowBaseX, + y, + cathodeBarX - arrowBaseX, + symbolHalfHeight, + strokeWidth, + layer, + ), + createScaledFabPath( + "diode_symbol_cathode_bar", + normalizedCathodeBarTemplate, + cathodeBarX, + y, + 1, + symbolHalfHeight, + strokeWidth, + layer, + "pin_2", + ), + createScaledFabPath( + "diode_symbol_lead_out", + normalizedLeadTemplate, + cathodeBarX, + y, + leadLineRightX - cathodeBarX, + 1, + strokeWidth, + layer, + ), + ] + + return [...fabPaths] +} diff --git a/src/helpers/passive-fn.ts b/src/helpers/passive-fn.ts index a4d8d718..5f89abf8 100644 --- a/src/helpers/passive-fn.ts +++ b/src/helpers/passive-fn.ts @@ -9,8 +9,72 @@ import { platedhole } from "./platedhole" import { z } from "zod" import { length, distance } from "circuit-json" import { type SilkscreenRef, silkscreenRef } from "./silkscreenRef" +import { + createManualDiodeFabricationNotes, + type ManualDiodeFabricationNoteTuning, +} from "./manual-diode-fabrication" import { base_def } from "./zod/base_def" +const getPassiveDiodeFabricationTuning = ( + footprintSize?: string, +): ManualDiodeFabricationNoteTuning | undefined => { + if (footprintSize === "2512") { + return { + arrowBaseRatio: { + base: 0.3, + tightPitchFactor: 0.03, + min: 0.27, + max: 0.3, + }, + cathodeBarRatio: { + base: 0.22, + tightPitchFactor: 0.02, + min: 0.2, + max: 0.22, + }, + } + } + + if (footprintSize === "0201") { + return { + arrowBaseRatio: { + base: 0.18, + tightPitchFactor: 0.055, + min: 0.12, + max: 0.18, + }, + cathodeBarRatio: { + base: 0.11, + tightPitchFactor: 0.03, + min: 0.07, + max: 0.11, + }, + leadLineExtension: { + scale: 0.18, + min: 0.04, + max: 0.06, + }, + } + } + + if (footprintSize === "0402") { + return { + arrowBaseRatio: { + base: 0.16, + tightPitchFactor: 0.06, + min: 0.1, + max: 0.16, + }, + cathodeBarRatio: { + base: 0.1, + tightPitchFactor: 0.03, + min: 0.06, + max: 0.1, + }, + } + } +} + type StandardSize = { imperial: string metric: string @@ -334,11 +398,24 @@ export const passive = (params: PassiveDef): AnyCircuitElement[] => { sz?.courtyard_width_mm && sz.courtyard_height_mm ? createCourtyardRect(sz.courtyard_width_mm, sz.courtyard_height_mm) : null + const fabricationNotes = + fn === "diode" && sz?.imperial !== "01005" + ? createManualDiodeFabricationNotes({ + pin1PadX: -p / 2, + pin2PadX: p / 2, + padWidth: pw, + padHeight: ph, + bodyWidth: w, + bodyHeight: h, + tuning: getPassiveDiodeFabricationTuning(sz?.imperial), + }) + : [] if (tht) { return [ platedhole(1, -p / 2, 0, pw, (pw * 1) / 0.8), platedhole(2, p / 2, 0, pw, (pw * 1) / 0.8), + ...fabricationNotes, ...silkscreenLines, silkscreenRefText, ...(courtyard ? [courtyard] : []), @@ -347,6 +424,7 @@ export const passive = (params: PassiveDef): AnyCircuitElement[] => { return [ rectpad(["1", "left"], -p / 2, 0, pw, ph), rectpad(["2", "right"], p / 2, 0, pw, ph), + ...fabricationNotes, ...silkscreenLines, silkscreenRefText, ...(courtyard ? [courtyard] : []), diff --git a/tests/__snapshots__/diode.snap.svg b/tests/__snapshots__/diode.snap.svg index 0b60b957..99c73e86 100644 --- a/tests/__snapshots__/diode.snap.svg +++ b/tests/__snapshots__/diode.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/diode0201.snap.svg b/tests/__snapshots__/diode0201.snap.svg index 3e5ea3af..93ecf185 100644 --- a/tests/__snapshots__/diode0201.snap.svg +++ b/tests/__snapshots__/diode0201.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/diode0603.snap.svg b/tests/__snapshots__/diode0603.snap.svg index 1bbda6e0..ee8a3bcd 100644 --- a/tests/__snapshots__/diode0603.snap.svg +++ b/tests/__snapshots__/diode0603.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/diode1210.snap.svg b/tests/__snapshots__/diode1210.snap.svg index c37c0ad8..4ac6655b 100644 --- a/tests/__snapshots__/diode1210.snap.svg +++ b/tests/__snapshots__/diode1210.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/diode2512.snap.svg b/tests/__snapshots__/diode2512.snap.svg index b1a70c07..1a6646be 100644 --- a/tests/__snapshots__/diode2512.snap.svg +++ b/tests/__snapshots__/diode2512.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/melf.snap.svg b/tests/__snapshots__/melf.snap.svg index 0f92e0d5..b71ccc95 100644 --- a/tests/__snapshots__/melf.snap.svg +++ b/tests/__snapshots__/melf.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/micromelf.snap.svg b/tests/__snapshots__/micromelf.snap.svg index 0777a53a..96ed40ec 100644 --- a/tests/__snapshots__/micromelf.snap.svg +++ b/tests/__snapshots__/micromelf.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/minimelf.snap.svg b/tests/__snapshots__/minimelf.snap.svg index 2d770d1c..98bcb51a 100644 --- a/tests/__snapshots__/minimelf.snap.svg +++ b/tests/__snapshots__/minimelf.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sma.snap.svg b/tests/__snapshots__/sma.snap.svg index 8bb1c437..3cf67f3b 100644 --- a/tests/__snapshots__/sma.snap.svg +++ b/tests/__snapshots__/sma.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/smb.snap.svg b/tests/__snapshots__/smb.snap.svg index a023f486..97ec03ac 100644 --- a/tests/__snapshots__/smb.snap.svg +++ b/tests/__snapshots__/smb.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/smbf.snap.svg b/tests/__snapshots__/smbf.snap.svg index 713685d7..14d29775 100644 --- a/tests/__snapshots__/smbf.snap.svg +++ b/tests/__snapshots__/smbf.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/smc.snap.svg b/tests/__snapshots__/smc.snap.svg index 36b1b93e..3acdf598 100644 --- a/tests/__snapshots__/smc.snap.svg +++ b/tests/__snapshots__/smc.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/smf.snap.svg b/tests/__snapshots__/smf.snap.svg index 0e4a8197..0af3c1ce 100644 --- a/tests/__snapshots__/smf.snap.svg +++ b/tests/__snapshots__/smf.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod110.snap.svg b/tests/__snapshots__/sod110.snap.svg index 87d9a294..fd2c9be1 100644 --- a/tests/__snapshots__/sod110.snap.svg +++ b/tests/__snapshots__/sod110.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod123.snap.svg b/tests/__snapshots__/sod123.snap.svg index be674646..2b78f0d1 100644 --- a/tests/__snapshots__/sod123.snap.svg +++ b/tests/__snapshots__/sod123.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod123f.snap.svg b/tests/__snapshots__/sod123f.snap.svg index 66409c57..4571ec10 100644 --- a/tests/__snapshots__/sod123f.snap.svg +++ b/tests/__snapshots__/sod123f.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod123fl.snap.svg b/tests/__snapshots__/sod123fl.snap.svg index 768d6b4c..5b32d050 100644 --- a/tests/__snapshots__/sod123fl.snap.svg +++ b/tests/__snapshots__/sod123fl.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod123w.snap.svg b/tests/__snapshots__/sod123w.snap.svg index 0d9ce4c8..0e651a4d 100644 --- a/tests/__snapshots__/sod123w.snap.svg +++ b/tests/__snapshots__/sod123w.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod128.snap.svg b/tests/__snapshots__/sod128.snap.svg index 221ad88a..72f22bee 100644 --- a/tests/__snapshots__/sod128.snap.svg +++ b/tests/__snapshots__/sod128.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod323.snap.svg b/tests/__snapshots__/sod323.snap.svg index f3827cf3..2e46f72c 100644 --- a/tests/__snapshots__/sod323.snap.svg +++ b/tests/__snapshots__/sod323.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod323f.snap.svg b/tests/__snapshots__/sod323f.snap.svg index 553c0813..2fde59fb 100644 --- a/tests/__snapshots__/sod323f.snap.svg +++ b/tests/__snapshots__/sod323f.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod323fl.snap.svg b/tests/__snapshots__/sod323fl.snap.svg index 0f799bee..2a2bf663 100644 --- a/tests/__snapshots__/sod323fl.snap.svg +++ b/tests/__snapshots__/sod323fl.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod323w.snap.svg b/tests/__snapshots__/sod323w.snap.svg index 14396708..bed26a3c 100644 --- a/tests/__snapshots__/sod323w.snap.svg +++ b/tests/__snapshots__/sod323w.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod523.snap.svg b/tests/__snapshots__/sod523.snap.svg index 36f79e59..2e03870a 100644 --- a/tests/__snapshots__/sod523.snap.svg +++ b/tests/__snapshots__/sod523.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod80.snap.svg b/tests/__snapshots__/sod80.snap.svg index 8799fe57..44af238d 100644 --- a/tests/__snapshots__/sod80.snap.svg +++ b/tests/__snapshots__/sod80.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod882.snap.svg b/tests/__snapshots__/sod882.snap.svg index 0ccf0914..f9d6eea5 100644 --- a/tests/__snapshots__/sod882.snap.svg +++ b/tests/__snapshots__/sod882.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod882d.snap.svg b/tests/__snapshots__/sod882d.snap.svg index 7580f80f..24de8e37 100644 --- a/tests/__snapshots__/sod882d.snap.svg +++ b/tests/__snapshots__/sod882d.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/__snapshots__/sod923.snap.svg b/tests/__snapshots__/sod923.snap.svg index 2012a033..b33ccd7e 100644 --- a/tests/__snapshots__/sod923.snap.svg +++ b/tests/__snapshots__/sod923.snap.svg @@ -1 +1 @@ -{REF} \ No newline at end of file +{REF} \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/melf.snap.svg b/tests/kicad-parity/__snapshots__/melf.snap.svg index bed1ab1d..8393b3ea 100644 --- a/tests/kicad-parity/__snapshots__/melf.snap.svg +++ b/tests/kicad-parity/__snapshots__/melf.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/micromelf.snap.svg b/tests/kicad-parity/__snapshots__/micromelf.snap.svg index 830f5195..44562e41 100644 --- a/tests/kicad-parity/__snapshots__/micromelf.snap.svg +++ b/tests/kicad-parity/__snapshots__/micromelf.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/minimelf.snap.svg b/tests/kicad-parity/__snapshots__/minimelf.snap.svg index db93e6b7..765ebe4b 100644 --- a/tests/kicad-parity/__snapshots__/minimelf.snap.svg +++ b/tests/kicad-parity/__snapshots__/minimelf.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sma.snap.svg b/tests/kicad-parity/__snapshots__/sma.snap.svg index 2943c11b..d120f8b8 100644 --- a/tests/kicad-parity/__snapshots__/sma.snap.svg +++ b/tests/kicad-parity/__snapshots__/sma.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/smb.snap.svg b/tests/kicad-parity/__snapshots__/smb.snap.svg index a014b419..c462a671 100644 --- a/tests/kicad-parity/__snapshots__/smb.snap.svg +++ b/tests/kicad-parity/__snapshots__/smb.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/smc.snap.svg b/tests/kicad-parity/__snapshots__/smc.snap.svg index 568dd7aa..f47b51bb 100644 --- a/tests/kicad-parity/__snapshots__/smc.snap.svg +++ b/tests/kicad-parity/__snapshots__/smc.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod110.snap.svg b/tests/kicad-parity/__snapshots__/sod110.snap.svg index 83532844..dc7002b9 100644 --- a/tests/kicad-parity/__snapshots__/sod110.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod110.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod123.snap.svg b/tests/kicad-parity/__snapshots__/sod123.snap.svg index 0490d493..feabf377 100644 --- a/tests/kicad-parity/__snapshots__/sod123.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod123.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod123f.snap.svg b/tests/kicad-parity/__snapshots__/sod123f.snap.svg index a0c4fb1a..10cea2b7 100644 --- a/tests/kicad-parity/__snapshots__/sod123f.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod123f.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod123w.snap.svg b/tests/kicad-parity/__snapshots__/sod123w.snap.svg index f97632ac..ff81d9a9 100644 --- a/tests/kicad-parity/__snapshots__/sod123w.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod123w.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod128.snap.svg b/tests/kicad-parity/__snapshots__/sod128.snap.svg index 7583e18c..bbf8b22a 100644 --- a/tests/kicad-parity/__snapshots__/sod128.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod128.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod323.snap.svg b/tests/kicad-parity/__snapshots__/sod323.snap.svg index ebe22399..73d0fd42 100644 --- a/tests/kicad-parity/__snapshots__/sod323.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod323.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod323f.snap.svg b/tests/kicad-parity/__snapshots__/sod323f.snap.svg index 261376e6..42924254 100644 --- a/tests/kicad-parity/__snapshots__/sod323f.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod323f.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod523.snap.svg b/tests/kicad-parity/__snapshots__/sod523.snap.svg index 9c050d49..2aec6862 100644 --- a/tests/kicad-parity/__snapshots__/sod523.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod523.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod882.snap.svg b/tests/kicad-parity/__snapshots__/sod882.snap.svg index 257f07ce..dcadcbc2 100644 --- a/tests/kicad-parity/__snapshots__/sod882.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod882.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod882d.snap.svg b/tests/kicad-parity/__snapshots__/sod882d.snap.svg index fc29e92a..49ce0f8d 100644 --- a/tests/kicad-parity/__snapshots__/sod882d.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod882d.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/__snapshots__/sod923.snap.svg b/tests/kicad-parity/__snapshots__/sod923.snap.svg index 8f2c2777..7d617587 100644 --- a/tests/kicad-parity/__snapshots__/sod923.snap.svg +++ b/tests/kicad-parity/__snapshots__/sod923.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/d_0201_0603metric.snap.svg b/tests/kicad-parity/diodes/__snapshots__/d_0201_0603metric.snap.svg index 2dcaf193..67061052 100644 --- a/tests/kicad-parity/diodes/__snapshots__/d_0201_0603metric.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/d_0201_0603metric.snap.svg @@ -1 +1 @@ -{REF}REF** \ No newline at end of file +{REF}REF** \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/melf.snap.svg b/tests/kicad-parity/diodes/__snapshots__/melf.snap.svg index bed1ab1d..8393b3ea 100644 --- a/tests/kicad-parity/diodes/__snapshots__/melf.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/melf.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/micromelf.snap.svg b/tests/kicad-parity/diodes/__snapshots__/micromelf.snap.svg index 830f5195..44562e41 100644 --- a/tests/kicad-parity/diodes/__snapshots__/micromelf.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/micromelf.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/minimelf.snap.svg b/tests/kicad-parity/diodes/__snapshots__/minimelf.snap.svg index db93e6b7..765ebe4b 100644 --- a/tests/kicad-parity/diodes/__snapshots__/minimelf.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/minimelf.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sma.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sma.snap.svg index 7ee73dc9..d120f8b8 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sma.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sma.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/smb.snap.svg b/tests/kicad-parity/diodes/__snapshots__/smb.snap.svg index e5670960..c462a671 100644 --- a/tests/kicad-parity/diodes/__snapshots__/smb.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/smb.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/smc.snap.svg b/tests/kicad-parity/diodes/__snapshots__/smc.snap.svg index cc25a2f1..f47b51bb 100644 --- a/tests/kicad-parity/diodes/__snapshots__/smc.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/smc.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod110.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod110.snap.svg index 83532844..dc7002b9 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod110.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod110.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod123.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod123.snap.svg index 0490d493..feabf377 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod123.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod123.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod123f.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod123f.snap.svg index a0c4fb1a..10cea2b7 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod123f.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod123f.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod123w.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod123w.snap.svg index 35fc4fd0..ff81d9a9 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod123w.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod123w.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod128.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod128.snap.svg index 7583e18c..bbf8b22a 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod128.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod128.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod323.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod323.snap.svg index ebe22399..73d0fd42 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod323.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod323.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod323f.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod323f.snap.svg index 261376e6..42924254 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod323f.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod323f.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod523.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod523.snap.svg index 9c050d49..2aec6862 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod523.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod523.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod882.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod882.snap.svg index a4c72abc..dcadcbc2 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod882.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod882.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod882d.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod882d.snap.svg index fc29e92a..49ce0f8d 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod882d.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod882d.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/kicad-parity/diodes/__snapshots__/sod923.snap.svg b/tests/kicad-parity/diodes/__snapshots__/sod923.snap.svg index 8f2c2777..7d617587 100644 --- a/tests/kicad-parity/diodes/__snapshots__/sod923.snap.svg +++ b/tests/kicad-parity/diodes/__snapshots__/sod923.snap.svg @@ -1 +1 @@ -{REF}REF**Diff: 0.00% \ No newline at end of file +{REF}REF**Diff: 0.00% \ No newline at end of file diff --git a/tests/origin.test.ts b/tests/origin.test.ts index 83d1e436..1640b202 100644 --- a/tests/origin.test.ts +++ b/tests/origin.test.ts @@ -131,3 +131,55 @@ test("res origin bottomleft snapshot", () => { "0603_bottomleft_origin", ) }) + +test("diode origin bottomleft shifts fabrication notes and symbol", () => { + const baseCircuit = fp().diode().imperial("0603").circuitJson() + const shiftedCircuit = fp() + .diode() + .imperial("0603") + .origin("bottomleft") + .circuitJson() + const basePad1 = baseCircuit.find( + (el) => el.type === "pcb_smtpad" && el.port_hints?.[0] === "1", + )! + const shiftedPad1 = shiftedCircuit.find( + (el) => el.type === "pcb_smtpad" && el.port_hints?.[0] === "1", + )! + const baseOutline = baseCircuit.find( + (el) => + el.type === "pcb_fabrication_note_path" && + el.pcb_fabrication_note_path_id === "diode_symbol_outline", + )! + const shiftedOutline = shiftedCircuit.find( + (el) => + el.type === "pcb_fabrication_note_path" && + el.pcb_fabrication_note_path_id === "diode_symbol_outline", + )! + const baseCathodeBar = baseCircuit.find( + (el) => + el.type === "pcb_fabrication_note_path" && + el.pcb_fabrication_note_path_id === "diode_symbol_cathode_bar", + )! + const shiftedCathodeBar = shiftedCircuit.find( + (el) => + el.type === "pcb_fabrication_note_path" && + el.pcb_fabrication_note_path_id === "diode_symbol_cathode_bar", + )! + const dx = basePad1.x - shiftedPad1.x + const dy = basePad1.y - shiftedPad1.y + + expect(shiftedOutline.route[0].x).toBeCloseTo(baseOutline.route[0].x - dx) + expect(shiftedOutline.route[0].y).toBeCloseTo(baseOutline.route[0].y - dy) + expect(shiftedCathodeBar.route[0].x).toBeCloseTo( + baseCathodeBar.route[0].x - dx, + ) + expect(shiftedCathodeBar.route[0].y).toBeCloseTo( + baseCathodeBar.route[0].y - dy, + ) + expect(shiftedCathodeBar.route[1].x).toBeCloseTo( + baseCathodeBar.route[1].x - dx, + ) + expect(shiftedCathodeBar.route[1].y).toBeCloseTo( + baseCathodeBar.route[1].y - dy, + ) +}) diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 00000000..34d450a4 --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from "tsup" + +export default defineConfig({ + entry: ["src/index.ts"], + format: ["esm"], + dts: true, + sourcemap: true, + noExternal: ["transformation-matrix"], +})