forked from sinara-hw/kirdyAdapter
Compare commits
7 Commits
kirdy_LD_a
...
master
Author | SHA1 | Date | |
---|---|---|---|
b07ec77847 | |||
05ca688af6 | |||
b119e04c73 | |||
bf536b1b1e | |||
fa31ec4c41 | |||
082aa8521f | |||
ee2e86d796 |
10
flake.lock
generated
10
flake.lock
generated
@ -9,20 +9,20 @@
|
|||||||
"rev": "72686f5556785c9aa13678dc42757dddfb7d7c23",
|
"rev": "72686f5556785c9aa13678dc42757dddfb7d7c23",
|
||||||
"revCount": 2,
|
"revCount": 2,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.m-labs.hk/linuswck/KiCAD_BOM_Generator.git"
|
"url": "https://git.m-labs.hk/M-Labs/KiCAD_BOM_Generator.git"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.m-labs.hk/linuswck/KiCAD_BOM_Generator.git"
|
"url": "https://git.m-labs.hk/M-Labs/KiCAD_BOM_Generator.git"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1702233072,
|
"lastModified": 1703467016,
|
||||||
"narHash": "sha256-H5G2wgbim2Ku6G6w+NSaQaauv6B6DlPhY9fMvArKqRo=",
|
"narHash": "sha256-/5A/dNPhbQx/Oa2d+Get174eNI3LERQ7u6WTWOlR1eQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "781e2a9797ecf0f146e81425c822dca69fe4a348",
|
"rev": "d02d818f22c777aa4e854efc3242ec451e5d462a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
124
flake.nix
124
flake.nix
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
||||||
inputs.kicad_bom_generator = {
|
inputs.kicad_bom_generator = {
|
||||||
url = "git+https://git.m-labs.hk/linuswck/KiCAD_BOM_Generator.git";
|
url = "git+https://git.m-labs.hk/M-Labs/KiCAD_BOM_Generator.git";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -9,76 +9,90 @@
|
|||||||
let
|
let
|
||||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||||
|
|
||||||
build = { variant }:
|
adapter_production_files = variant: pkgs.stdenv.mkDerivation {
|
||||||
let
|
name = "production-files";
|
||||||
production_files = pkgs.stdenv.mkDerivation {
|
src = ./kirdy_LD_adapter_${variant};
|
||||||
name = "production-files";
|
|
||||||
src = ./kirdy_LD_adapter_${variant};
|
|
||||||
|
|
||||||
nativeBuildInputs = [ pkgs.kicad pkgs.zip pkgs.python3 ];
|
nativeBuildInputs = [ pkgs.kicad pkgs.zip pkgs.python3 ];
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
# kicad-cli requires the use of $HOME
|
# kicad-cli requires the use of $HOME
|
||||||
export HOME=/tmp
|
TMP_DIR="$(mktemp --tmpdir -d kicad-kirdy.XXXXXXX)"
|
||||||
|
export HOME=$TMP_DIR
|
||||||
|
|
||||||
if [ "${variant}" != "copper_plate" ]; then
|
SCH=kirdy_LD_adapter_${variant}.kicad_sch
|
||||||
SCH=kirdy_LD_adapter_${variant}.kicad_sch
|
PCB=kirdy_LD_adapter_${variant}.kicad_pcb
|
||||||
PCB=kirdy_LD_adapter_${variant}.kicad_pcb
|
|
||||||
|
|
||||||
# Get Revision Number from the Title Block in KiCAD Top Schematics
|
# Get Revision Number from the Title Block in KiCAD Top Schematics
|
||||||
REV=$(cat $SCH | grep rev | cut -d'"' -f 2)
|
REV=$(cat $SCH | grep rev | cut -d'"' -f 2)
|
||||||
PREFIX=kirdy_LD_adapter_${variant}_$REV
|
PREFIX=kirdy_LD_adapter_${variant}_$REV
|
||||||
|
|
||||||
kicad-cli sch export python-bom $SCH -o $PREFIX"_bom".xml
|
kicad-cli sch export python-bom $SCH -o $PREFIX"_bom".xml
|
||||||
export PYTHONPATH=${pkgs.kicad.base}/share/kicad/plugins
|
export PYTHONPATH=${pkgs.kicad.base}/share/kicad/plugins
|
||||||
python ${kicad_bom_generator}/generate_bom_from_xml.py $PREFIX"_bom".xml $PREFIX"_bom".csv
|
python ${kicad_bom_generator}/generate_bom_from_xml.py $PREFIX"_bom".xml $PREFIX"_bom".csv
|
||||||
|
|
||||||
kicad-cli sch export pdf $SCH -o $PREFIX.pdf
|
kicad-cli sch export pdf $SCH -o $PREFIX.pdf
|
||||||
kicad-cli pcb export pos $PCB --format csv --units mm -o $PREFIX"_pos".csv
|
kicad-cli pcb export pos $PCB --format csv --units mm -o $PREFIX"_pos".csv
|
||||||
|
|
||||||
export KICAD7_3DMODEL_DIR=${pkgs.kicad.libraries.packages3d}/share/kicad/3dmodels
|
export KICAD7_3DMODEL_DIR=${pkgs.kicad.libraries.packages3d}/share/kicad/3dmodels
|
||||||
kicad-cli pcb export step $PCB --subst-models --force -o $PREFIX.step
|
kicad-cli pcb export step $PCB --subst-models --force -o $PREFIX.step
|
||||||
|
|
||||||
mkdir -p $PREFIX"_gerber_drill"
|
mkdir -p $PREFIX"_gerber_drill"
|
||||||
kicad-cli pcb export gerbers $PCB -l 'F.Cu,B.Cu,F.Paste,B.Paste,F.Silkscreen,B.Silkscreen,F.Mask,B.Mask,Edge.Cuts' --no-x2 --subtract-soldermask -o ./$PREFIX"_gerber_drill"
|
kicad-cli pcb export gerbers $PCB -l 'F.Cu,B.Cu,F.Paste,B.Paste,F.Silkscreen,B.Silkscreen,F.Mask,B.Mask,Edge.Cuts' --no-x2 --subtract-soldermask -o ./$PREFIX"_gerber_drill"
|
||||||
|
|
||||||
# The additional trailing slash is due to a bug in the kicad-cli tool. https://gitlab.com/kicad/code/kicad/-/issues/14438
|
# The additional trailing slash is due to a bug in the kicad-cli tool. https://gitlab.com/kicad/code/kicad/-/issues/14438
|
||||||
kicad-cli pcb export drill $PCB -u mm --generate-map --map-format gerberx2 -o ./$PREFIX"_gerber_drill"/
|
kicad-cli pcb export drill $PCB -u mm --generate-map --map-format gerberx2 -o ./$PREFIX"_gerber_drill"/
|
||||||
|
|
||||||
zip -r -j $PREFIX"_gerber_drill" $PREFIX"_gerber_drill"
|
zip -r -j $PREFIX"_gerber_drill" $PREFIX"_gerber_drill"
|
||||||
else
|
'';
|
||||||
PCB=kirdy_LD_adapter_${variant}.kicad_pcb
|
|
||||||
|
|
||||||
# Get Revision Number from the Title Block in KiCAD PCB
|
installPhase = ''
|
||||||
REV=$(cat $PCB | grep rev | cut -d'"' -f 2)
|
mkdir -p $out/production_files
|
||||||
PREFIX=kirdy_LD_adapter_${variant}_$REV
|
cp $PREFIX"_bom".csv $out/production_files/$PREFIX"_bom".csv
|
||||||
|
cp $PREFIX.pdf $out/production_files/$PREFIX.pdf
|
||||||
|
cp $PREFIX"_pos".csv $out/production_files/$PREFIX"_pos.csv"
|
||||||
|
cp $PREFIX.step $out/production_files/$PREFIX.step
|
||||||
|
cp $PREFIX"_gerber_drill".zip $out/production_files/$PREFIX"_gerber_drill".zip
|
||||||
|
|
||||||
export KICAD7_3DMODEL_DIR=${pkgs.kicad.libraries.packages3d}/share/kicad/3dmodels
|
cp $PREFIX.step $out/production_files/$PREFIX.step
|
||||||
kicad-cli pcb export step $PCB --subst-models --force -o $PREFIX.step
|
'';
|
||||||
fi
|
};
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
copper_plate_production_files = pkgs.stdenv.mkDerivation {
|
||||||
mkdir -p $out/production_files
|
name = "production-files";
|
||||||
if [ ${variant} != "copper_plate" ]; then
|
src = ./kirdy_LD_adapter_copper_plate;
|
||||||
cp $PREFIX"_bom".csv $out/production_files/$PREFIX"_bom".csv
|
|
||||||
cp $PREFIX.pdf $out/production_files/$PREFIX.pdf
|
|
||||||
cp $PREFIX"_pos".csv $out/production_files/$PREFIX"_pos.csv"
|
|
||||||
cp $PREFIX.step $out/production_files/$PREFIX.step
|
|
||||||
cp $PREFIX"_gerber_drill".zip $out/production_files/$PREFIX"_gerber_drill".zip
|
|
||||||
else
|
|
||||||
cp $PREFIX.step $out/production_files/$PREFIX.step
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in { "LD_adapter_${variant}" = production_files; };
|
|
||||||
|
|
||||||
in rec {
|
nativeBuildInputs = [ pkgs.kicad pkgs.python3 ];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
# kicad-cli requires the use of $HOME
|
||||||
|
TMP_DIR="$(mktemp --tmpdir -d kicad-kirdy.XXXXXXX)"
|
||||||
|
export HOME=$TMP_DIR
|
||||||
|
|
||||||
|
PCB=kirdy_LD_adapter_copper_plate.kicad_pcb
|
||||||
|
|
||||||
|
# Get Revision Number from the Title Block in KiCAD PCB
|
||||||
|
REV=$(cat $PCB | grep rev | cut -d'"' -f 2)
|
||||||
|
PREFIX=kirdy_LD_adapter_copper_plate_$REV
|
||||||
|
|
||||||
|
export KICAD7_3DMODEL_DIR=${pkgs.kicad.libraries.packages3d}/share/kicad/3dmodels
|
||||||
|
kicad-cli pcb export step $PCB --subst-models --force -o $PREFIX.step
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/production_files
|
||||||
|
cp $PREFIX.step $out/production_files/$PREFIX.step
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
in {
|
||||||
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
|
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
|
||||||
|
|
||||||
packages.x86_64-linux = (build { variant = "type_1"; })
|
packages.x86_64-linux = {
|
||||||
// (build { variant = "type_2"; })
|
"LD_adapter_type_1_PCB" = adapter_production_files "type_1";
|
||||||
// (build { variant = "copper_plate"; });
|
"LD_adapter_type_2_PCB" = adapter_production_files "type_2";
|
||||||
|
"LD_adapter_copper_plate" = copper_plate_production_files;
|
||||||
|
};
|
||||||
|
|
||||||
devShells.x86_64-linux.default =
|
devShells.x86_64-linux.default =
|
||||||
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
|
|
||||||
(paper "A4")
|
(paper "A4")
|
||||||
(title_block
|
(title_block
|
||||||
(rev "v0_1rc1")
|
(rev "v0_1rc2")
|
||||||
(comment 1 "v0_1rc1: Changed the location of silkscreen markings of Bias-T Modulation Input")
|
(comment 1 "v0_1rc1: Changed the location of silkscreen markings of Bias-T Modulation Input")
|
||||||
|
(comment 2 "v0_1rc2: Correct Silkscreen Markings of LD9 and LD11")
|
||||||
)
|
)
|
||||||
|
|
||||||
(layers
|
(layers
|
||||||
@ -2761,19 +2762,19 @@
|
|||||||
(gr_text "Use Bias-T" (at -40.4 -1.39 270) (layer "B.SilkS") (tstamp 27273078-f90b-42d9-aa8d-6b3b1a0d97c4)
|
(gr_text "Use Bias-T" (at -40.4 -1.39 270) (layer "B.SilkS") (tstamp 27273078-f90b-42d9-aa8d-6b3b1a0d97c4)
|
||||||
(effects (font (size 0.8 0.8) (thickness 0.15)) (justify left mirror))
|
(effects (font (size 0.8 0.8) (thickness 0.15)) (justify left mirror))
|
||||||
)
|
)
|
||||||
(gr_text "LD-: 9" (at -32.258 4.582) (layer "B.SilkS") (tstamp 4cc0ef08-f92c-4c13-bdf4-4ed9b0d668f1)
|
(gr_text "LD-: 11" (at -32.258 4.582) (layer "B.SilkS") (tstamp 4cc0ef08-f92c-4c13-bdf4-4ed9b0d668f1)
|
||||||
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
||||||
)
|
)
|
||||||
(gr_text "PD+: 3" (at -27.25 11.01) (layer "B.SilkS") (tstamp c5025ffb-4132-40ad-9ba2-5a426d255675)
|
(gr_text "PD+: 3" (at -27.25 11.01) (layer "B.SilkS") (tstamp c5025ffb-4132-40ad-9ba2-5a426d255675)
|
||||||
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
||||||
)
|
)
|
||||||
(gr_text "Kirdy Adapter for Type-1 Laser Diode \nRev: 0_1" (at 41.148 32.014) (layer "B.SilkS") (tstamp d9185641-8167-4841-b540-088303848472)
|
(gr_text "Kirdy Adapter for Type-1 Laser Diode \nRev: 0_1rc2" (at 41.148 32.014) (layer "B.SilkS") (tstamp d9185641-8167-4841-b540-088303848472)
|
||||||
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
||||||
)
|
)
|
||||||
(gr_text "PD-: 7" (at -27.25 9.01) (layer "B.SilkS") (tstamp e9305944-d283-4481-a373-483045d7de6d)
|
(gr_text "PD-: 7" (at -27.25 9.01) (layer "B.SilkS") (tstamp e9305944-d283-4481-a373-483045d7de6d)
|
||||||
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
||||||
)
|
)
|
||||||
(gr_text "LD-: 11" (at -32.258 1.998) (layer "B.SilkS") (tstamp f8a1f124-6566-4a42-92b0-87395200e1f8)
|
(gr_text "LD-: 9" (at -32.258 1.998) (layer "B.SilkS") (tstamp f8a1f124-6566-4a42-92b0-87395200e1f8)
|
||||||
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
(effects (font (size 1 1) (thickness 0.15)) (justify left mirror))
|
||||||
)
|
)
|
||||||
(gr_text "Type-1 LD" (at 0 29.01) (layer "F.SilkS") (tstamp 6b833559-6474-4221-aa6a-78219e45b6af)
|
(gr_text "Type-1 LD" (at 0 29.01) (layer "F.SilkS") (tstamp 6b833559-6474-4221-aa6a-78219e45b6af)
|
||||||
|
Loading…
Reference in New Issue
Block a user