Update based off work done in diceshaker.

This commit is contained in:
ac
2023-05-11 11:38:56 +10:00
parent 95d9e1ef85
commit d1307c4e3d
6 changed files with 142 additions and 159 deletions

View File

@@ -2,3 +2,4 @@
submodulesummary = 1 submodulesummary = 1
[submodule] [submodule]
recurse = true recurse = true
propogateBranches = true

17
.gitignore vendored
View File

@@ -27,6 +27,7 @@ fp-info-cache
# Exported BOM files # Exported BOM files
*.xml *.xml
*.csv *.csv
*.xlsx*
# Backup Folders # Backup Folders
**/*backups/** **/*backups/**
@@ -37,3 +38,19 @@ fp-info-cache
# CAD # CAD
*.FCStd *.FCStd
*.dxf *.dxf
*.step
*.stp
# CI
Fabrication/
.gitlab-ci-local/
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
*.pyc

View File

@@ -5,13 +5,18 @@ workflow:
when: never when: never
- if: $CI_COMMIT_BRANCH - if: $CI_COMMIT_BRANCH
variables:
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
GIT_SUBMODULE_DEPTH: 1
GIT_SUBMODULE_FORCE_HTTPS: "true"
stages: stages:
- run_erc - gen_mech
- run_drc
- gen_fab - gen_fab
image: image:
name: ghcr.io/inti-cmnb/kicad7_auto:latest name: ghcr.io/inti-cmnb/kicad7_auto:1.6.2
.main_rules: .main_rules:
rules: rules:
@@ -50,25 +55,34 @@ image:
- | - |
for i in $(seq 1 $END) for i in $(seq 1 $END)
do do
if [[ ${dir_arr[i-1]} == "./Frame" ]]; then
continue
fi
echo ${dir_arr[i-1]} echo ${dir_arr[i-1]}
echo ${sch_arr[i-1]}
cd $CI_PROJECT_DIR/${dir_arr[i-1]} cd $CI_PROJECT_DIR/${dir_arr[i-1]}
kibot -e ${sch_arr[i-1]} -c $CI_PROJECT_DIR/default.kibot.yaml -d $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]} -s $SUFFIX kibot -e ${sch_arr[i-1]} -c $CI_PROJECT_DIR/default.kibot.yaml -d $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]} -s $SUFFIX
done done
- cd $CI_PROJECT_DIR
panel: panel:
- 'SEARCH="boards.json"' - 'SEARCH="_panel.json"'
- !reference [.commands, get_dirs] - !reference [.commands, get_dirs]
- | - |
for d in $DIRS for d in $DIRS
do do
echo $d echo $d
cd $CI_PROJECT_DIR/$d cd $CI_PROJECT_DIR/$d
JSON=$(find panel_*.json ) JSON=$(find *_panel.json)
NAME=$(echo "${JSON%.json}") NAME=$(echo "${JSON%.json}")
mkdir panel PCB=$(find *.kicad_pcb)
kikit -p $JSON boards.json panel/$NAME.kicad_pcb mkdir $CI_PROJECT_DIR/$NAME
touch panel/$NAME.kicad_sch kikit panelize -p $JSON $PCB $CI_PROJECT_DIR/$NAME/$NAME.kicad_pcb
touch $CI_PROJECT_DIR/$NAME/$NAME.kicad_sch
cp fp-lib-table $CI_PROJECT_DIR/$NAME/
python3 $CI_PROJECT_DIR/.scripts/post_panel.py $CI_PROJECT_DIR/$NAME/$NAME.kicad_pro
done done
- cd $CI_PROJECT_DIR
neo: neo:
- 'SEARCH=".kicad_pro"' - 'SEARCH=".kicad_pro"'
@@ -76,35 +90,31 @@ image:
- | - |
for d in $DIRS for d in $DIRS
do do
python3 scripts/neo.py $d if [[ $d == "./Frame" ]]; then
continue
fi
echo $d
python3 .scripts/neo.py $d
done done
.template: templates:
rules: - if [ $GITLAB_CI == 'true' ]; then git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/Micromelon/kicad-project.git .templates; fi
- !reference [.main_rules, rules] - cd .templates
variables: - shopt -s extglob
SUFFIX: "" - rm -rf !(*.kicad_wks)
- cd $CI_PROJECT_DIR
output_mech:
stage: gen_mech
artifacts:
when: always
paths:
- Fabrication/
variables:
SUFF_MECH: run_erc,run_drc step
script: script:
- SUFFIX=$SUFF_MECH
- !reference [.commands, kibot] - !reference [.commands, kibot]
dependencies: []
.temprc:
extends: .template
rules:
- !reference [.main_rules, rules]
- !reference [.dev_rules, rules]
erc:
extends: .temprc
stage: run_erc
variables:
SUFFIX: update_xml,run_drc -i
drc:
extends: .temprc
stage: run_drc
variables:
SUFFIX: update_xml,run_erc -i
outputs_dev: outputs_dev:
rules: rules:
@@ -115,9 +125,10 @@ outputs_dev:
paths: paths:
- Fabrication/ - Fabrication/
variables: variables:
SUFF_SCH: run_drc,run_erc print_sch step SUFF_SCH: run_drc print_sch
SUFF_PCB: all print_front SUFF_PCB: run_erc,update_xml print_front
script: script:
- !reference [.commands, templates]
- SUFFIX=$SUFF_SCH - SUFFIX=$SUFF_SCH
- !reference [.commands, kibot] - !reference [.commands, kibot]
- SUFFIX=$SUFF_PCB - SUFFIX=$SUFF_PCB
@@ -128,15 +139,14 @@ outputs_all:
rules: rules:
- !reference [.main_rules, rules] - !reference [.main_rules, rules]
variables: variables:
SUFF_SCH: run_drc,run_erc print_sch step bom SUFF_SCH: run_drc sch
SUFF_PCB: all print_front gerbers drill position SUFF_PCB: run_erc,update_xml pcb
script: script:
- !reference [.commands, templates]
- SUFFIX=$SUFF_SCH - SUFFIX=$SUFF_SCH
- !reference [.commands, kibot] - !reference [.commands, kibot]
- cd $CI_PROJECT_DIR
- !reference [.commands, panel] - !reference [.commands, panel]
- SUFFIX=$SUFF_PCB - SUFFIX=$SUFF_PCB
- cd $CI_PROJECT_DIR
- !reference [.commands, kibot] - !reference [.commands, kibot]
- cd $CI_PROJECT_DIR
- !reference [.commands, neo] - !reference [.commands, neo]

30
.scripts/ki_plugin.py Normal file
View File

@@ -0,0 +1,30 @@
from kikit import panelize_ui_impl as ki
from kikit.panelize import Panel
from kikit.panelize_ui_impl import Substrate, readLength
from pcbnewTransition import pcbnew
from pcbnewTransition.pcbnew import LoadBoard, VECTOR2I
from kikit.plugin import LayoutPlugin
import json
from typing import Iterable
from kikit.common import fromDegrees
class ManualLayout(LayoutPlugin):
def buildLayout(self, panel: Panel, inputFile: str,
sourceArea: pcbnew.BOX2I) -> Iterable[Substrate]:
netRenamer = lambda x, y: self.netPattern.format(n=x, orig=y)
refRenamer = lambda x, y: self.refPattern.format(n=x, orig=y)
with open("boards.json") as json_file:
json_str = json_file.read()
boards = []
for d in json.loads(json_str):
source = {"type": "auto", "tolerance": readLength("5mm")}
board = LoadBoard(d["board"])
sourceArea = ki.readSourceArea(source, board)
drc_flag = False
if d["board"] == inputFile and not len(panel.sourcePaths):
drc_flag = True
panel.appendBoard(d["board"], VECTOR2I(*[readLength(p) for p in d["pos"]]),\
sourceArea, inheritDrc=drc_flag, rotationAngle=fromDegrees(d.get("rot", 0.0)),\
netRenamer=netRenamer, refRenamer=refRenamer)
return panel.substrates

11
.scripts/post_panel.py Normal file
View File

@@ -0,0 +1,11 @@
import json
import sys
proj = sys.argv[1]
json_file = open(proj)
json_str = json_file.read()
d = json.loads(json_str)
d["board"]["design_settings"]["rule_severities"]["lib_footprint_issues"] = "ignore"
d["board"]["design_settings"]["rule_severities"]["lib_footprint_mismatch"] = "ignore"
with open(proj, mode="w") as json_file:
json.dump(d, json_file, indent=2)

View File

@@ -1,15 +1,25 @@
# Example KiPlot config file # Example KiPlot config file
kibot: kibot:
version: 1 version: 1
import:
- file: JLCPCB
preflight: preflight:
run_erc: true run_erc: true
update_xml: true update_xml: true
run_drc: true run_drc: true
check_zone_fills: false set_text_variables:
- name: 'rev'
command: "if [ $(git describe --tags | wc -w) -gt 0 ]; then git describe --tags; else echo $CI_COMMIT_SHORT_SHA; fi"
- name: 'date'
expand_kibot_patterns: true
text: '%D'
fill_zones: true
ignore_unconnected: false ignore_unconnected: false
global: global:
environment: environment:
models_3d: "/models_3d" user_templates: "${CI_PROJECT_DIR}/.templates"
outputs: outputs:
- name: 'print_sch' - name: 'print_sch'
comment: "Print schematic (PDF)" comment: "Print schematic (PDF)"
@@ -25,7 +35,7 @@ outputs:
options: options:
output_name: PCB_Top.pdf output_name: PCB_Top.pdf
layers: layers:
- layer: B.Cu - 'copper'
- layer: F.SilkS - layer: F.SilkS
- name: 'bom' - name: 'bom'
@@ -39,6 +49,8 @@ outputs:
- field: Quantity Per PCB - field: Quantity Per PCB
name: Qty name: Qty
- Description - Description
- mpn
- manf
- field: References - field: References
name: Schematic Reference name: Schematic Reference
csv: csv:
@@ -57,10 +69,11 @@ outputs:
type: step type: step
dir: . dir: .
options: options:
download: true output: '%f_%r.%x'
kicad_3d_url: https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/ download: false
subst_models: true
- name: 'position' - name: 'neo_position'
comment: "Pick and place" comment: "Pick and place"
type: position type: position
options: options:
@@ -70,125 +83,13 @@ outputs:
separate_files_for_front_and_back: false separate_files_for_front_and_back: false
only_smd: true only_smd: true
- name: 'assembly'
comment: "Pick and place file, JLC style"
type: position
options:
output: '%f_cpl.%x'
format: CSV
units: millimeters
separate_files_for_front_and_back: false
only_smd: true
columns:
- id: Ref
name: Designator
- Val
- Package
- id: PosX
name: "Mid X"
- id: PosY
name: "Mid Y"
- id: Rot
name: Rotation
- id: Side
name: Layer
- name: 'gerbers'
comment: "Gerbers for the board house"
type: gerber
dir: Gerbers
options:
# generic layer options
exclude_edge_layer: true
exclude_pads_from_silkscreen: false
use_aux_axis_as_origin: false
plot_sheet_reference: false
plot_footprint_refs: true
plot_footprint_values: true
force_plot_invisible_refs_vals: false
tent_vias: true
# gerber options
line_width: 0.1
subtract_mask_from_silk: false
use_protel_extensions: false
gerber_precision: 4.6
create_gerber_job_file: true
use_gerber_x2_attributes: true
use_gerber_net_attributes: true
layers:
- 'copper'
- 'technical'
- layer: Edge.Cuts
suffix: Edge_Cuts
- name: JLCPCB_gerbers
comment: Gerbers compatible with JLCPCB
type: gerber
dir: JLCPCB
options:
exclude_edge_layer: true
exclude_pads_from_silkscreen: true
plot_sheet_reference: false
plot_footprint_refs: true
plot_footprint_values: false
force_plot_invisible_refs_vals: false
tent_vias: true
use_protel_extensions: true
create_gerber_job_file: false
disable_aperture_macros: true
gerber_precision: 4.6
use_gerber_x2_attributes: false
use_gerber_net_attributes: false
line_width: 0.1
subtract_mask_from_silk: true
inner_extension_pattern: '.g%n'
layers:
# Note: a more generic approach is to use 'copper' but then the filenames
# are slightly different.
- F.Cu
- B.Cu
- In1.Cu
- In2.Cu
- In3.Cu
- In4.Cu
- In5.Cu
- In6.Cu
- F.SilkS
- B.SilkS
- F.Mask
- B.Mask
- Edge.Cuts
- name: JLCPCB_drill
comment: Drill files compatible with JLCPCB
type: excellon
dir: JLCPCB
options:
pth_and_npth_single_file: false
pth_id: '-PTH'
npth_id: '-NPTH'
metric_units: true
map: gerber
route_mode_for_oval_holes: false
output: "%f%i.%x"
- name: JLCPCB_fab
comment: ZIP file for JLCPCB
type: compress
dir: JLCPCB
options:
files:
- from_output: JLCPCB_gerbers
dest: /
- from_output: JLCPCB_drill
dest: /
- name: 'diff_pcb' - name: 'diff_pcb'
comment: "Diff for visual comparison" comment: "Diff for visual comparison"
type: diff type: diff
dir: . dir: .
options: options:
only_different: true only_different: true
old: KIBOT_TAG-0
- name: 'diff_sch' - name: 'diff_sch'
comment: "Diff for visual comparison" comment: "Diff for visual comparison"
@@ -197,4 +98,17 @@ outputs:
options: options:
only_different: true only_different: true
pcb: false pcb: false
old: KIBOT_TAG-0
groups:
- name: pcb
outputs:
- _JLCPCB_fab
- neo_position
- print_front
- name: sch
outputs:
- bom
- print_sch