kibot:
  version: 1

global:
  filters:
  #- number: 1007
  #- number: 1015
  #- number: 58  # KiAuto
  # small OAR, limits are hardcoded and don't match JLC's capabilities
  - number: 87
  # more than one schematic file but KiBot chooses the right one (based on config name or name of Kicad project)
  - number: 44
  field_lcsc_part: LCSC
  out_dir: generated
  # use GUI for DRC because we have DRC exclusions
  drc_exclusions_workaround: true
  units: millimeters   # also used for dimensions

import:
- file: JLCPCB

preflight:
  run_erc: true
  update_xml: true
  #run_drc: true  # doesn't work (timeout)
  erc_warnings: true
  check_zone_fills: true
  ignore_unconnected: false

filters:
  - name: only_pcba
    comment: 'Only parts that do not have a DNP field and do not have a copper-only footprint'
    type: generic
    exclude_any:
      - column: DNP
        regex: '^1|PCBA$'
      - column: Part
        regex: '^SolderJumper_'
      - column: Part
        regex: '^NetTie_'
      - column: Part
        regex: '^MountingHole_'
      # Testpoints can be copper-only or an actual part to be placed
      # so we better handle this with "in_bom no" or DNP to avoid
      # future surprises.
      #- column: Part
      #  regex: '^TestPoint_'
  - name: non_pcba
    comment: 'Parts that are not placed in PCBA, i.e. maybe order separately'
    type: generic
    include_only:
      - column: DNP
        # We also match DNP=1 here because we may want to order them anyway just in case.
        # (There was some reason to include the footprint, after all.)
        regex: '^1|PCBA$'
  - name: fix_rotation_jlc
    comment: 'Adjust rotation for JLC'
    type: rot_footprint
    extend: true
    rotations:
      - [ "^D_SOD-123", 180 ]
      - [ "^SOT-563", 180 ]
      - [ "^PinHeader_", 270 ]
      - [ "^IDC-Header_", 270 ]

outputs:
- name: ibom
  comment: Generate Bill of Materials in interactive HTML format
  type: ibom
  dir: ./
  options:
    extra_fields: LCSC
# Nice idea but this is resetting my git to a previous state temporarily. What could possibly go wrong?!
# Well, at least that this is annoying when I edit stuff at the same time but really that's not something
# that such a tool should do!
#- name: basic_diff_pcb
#  comment: PCB diff between the last two changes
#  type: diff
#  dir: diff
#  layers:
#  - layer: F.Cu
#    suffix: F_Cu
#    description: Front copper
#  - layer: B.Cu
#    suffix: B_Cu
#    description: Bottom copper
#  - layer: F.Paste
#    suffix: F_Paste
#    description: Front solder paste
#  - layer: B.Silkscreen
#    suffix: B_Silkscreen
#    description: Bottom silkscreen (artwork)
#  - layer: F.Silkscreen
#    suffix: F_Silkscreen
#    description: Front silkscreen (artwork)
#  - layer: B.Mask
#    suffix: B_Mask
#    description: Bottom soldermask (negative)
#  - layer: F.Mask
#    suffix: F_Mask
#    description: Front soldermask (negative)
#  - layer: User.Drawings
#    suffix: User_Drawings
#    description: User drawings
#  - layer: User.Comments
#    suffix: User_Comments
#    description: User comments
#  - layer: Edge.Cuts
#    suffix: Edge_Cuts
#    description: Board shape
#  - layer: F.Courtyard
#    suffix: F_Courtyard
#    description: Front courtyard area
#  - layer: B.Fab
#    suffix: B_Fab
#    description: Bottom documentation
#  - layer: F.Fab
#    suffix: F_Fab
#    description: Front documentation
#  - layer: User.2
#    suffix: User_2
#    description: User layer 2
#  options:
#    old: KIBOT_LAST-1
#    old_type: git
#    new: HEAD
#    new_type: git
#    cache_dir: generated/.cache
#    add_link_id: true
#- name: basic_diff_sch
#  comment: Schematic diff between the last two changes
#  type: diff
#  dir: diff
#  options:
#    old: KIBOT_LAST-1
#    old_type: git
#    new: HEAD
#    new_type: git
#    cache_dir: generated/.cache
#    add_link_id: true
#    pcb: false
- name: JLCPCB_gerbers
  comment: Gerbers compatible with JLCPCB
  type: gerber
  dir: Manufacturers/JLCPCB
  extends: _JLCPCB_gerbers
  disable_run_by_default: true
  layers: &id002
  - layer: F.Cu
    suffix: F_Cu
    description: Front copper
  - layer: B.Cu
    suffix: B_Cu
    description: Bottom copper
  - layer: F.Paste
    suffix: F_Paste
    description: Front solder paste
  - layer: B.Silkscreen
    suffix: B_Silkscreen
    description: Bottom silkscreen (artwork)
  - layer: F.Silkscreen
    suffix: F_Silkscreen
    description: Front silkscreen (artwork)
  - layer: B.Mask
    suffix: B_Mask
    description: Bottom soldermask (negative)
  - layer: F.Mask
    suffix: F_Mask
    description: Front soldermask (negative)
  - layer: Edge.Cuts
    suffix: Edge_Cuts
    description: Board shape
- name: JLCPCB_drill
  comment: Drill files compatible with JLCPCB
  type: excellon
  dir: Manufacturers/JLCPCB
  extends: _JLCPCB_drill
  disable_run_by_default: true
- name: JLCPCB_position
  comment: Pick and place file, JLCPCB style
  type: position
  dir: Manufacturers/JLCPCB
  extends: _JLCPCB_position
  disable_run_by_default: true
  options:
    pre_transform:
    - _kicost_rename
    - fix_rotation_jlc
    only_smd: false
- name: JLCPCB_bom
  comment: BoM for JLCPCB
  type: bom
  dir: Manufacturers/JLCPCB
  extends: _JLCPCB_bom
  disable_run_by_default: true
  options:
    exclude_filter: 'only_pcba'
- name: LCSC_bom
  comment: BoM for LCSC, i.e. no PCBA parts
  type: bom
  dir: Manufacturers/JLCPCB
  extends: _JLCPCB_bom
  disable_run_by_default: true
  options:
    output: '%f_%i_lcsc_non_pcba.%x'
    exclude_filter: 'non_pcba'
    columns:
      - field: Value
        name: Comment
      - field: References
        name: Designator
      - Footprint
      - field: _field_lcsc_part
        name: 'LCSC Part #'
      - field: DNP
        name: "DNP reason"
- name: JLCPCB
  comment: ZIP file for JLCPCB
  type: compress
  dir: Manufacturers
  extends: ''
  disable_run_by_default: _JLCPCB_compress
  options:
    files:
    - from_output: JLCPCB_gerbers
      dest: /
    - from_output: JLCPCB_drill
      dest: /
    - from_output: JLCPCB_position
      dest: /
    - from_output: JLCPCB_bom
      dest: /
- name: basic_info
  comment: Information about the run
  type: info
  dir: .
- name: basic_pcb_print_pdf
  comment: PCB
  type: pcb_print
  dir: PCB/PDF
  options:
    format: PDF
    pages:
    - layers:
      - layer: F.Cu
      - layer: F.Mask
        color: '#14332440'
      - layer: F.Paste
      - layer: F.Silkscreen
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      sheet: Front copper
    - layers:
      - layer: B.Cu
      - layer: B.Mask
        color: '#14332440'
      - layer: B.Silkscreen
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      mirror: true
      sheet: Bottom copper
    - layers:
      - layer: F.Courtyard
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      sheet: Front courtyard area
    - layers:
      - layer: B.Fab
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      mirror: true
      sheet: Bottom documentation
    - layers:
      - layer: F.Fab
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      sheet: Front documentation
    keep_temporal_files: true
- name: basic_pcb_print_svg
  comment: PCB
  type: pcb_print
  dir: PCB/SVG
  options:
    format: SVG
    pages:
    - layers:
      - layer: F.Cu
      - layer: F.Mask
        color: '#14332440'
      - layer: F.Paste
      - layer: F.Silkscreen
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      sheet: Front copper
    - layers:
      - layer: B.Cu
      - layer: B.Mask
        color: '#14332440'
      - layer: B.Silkscreen
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      mirror: true
      sheet: Bottom copper
    - layers:
      - layer: F.Courtyard
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      sheet: Front courtyard area
    - layers:
      - layer: B.Fab
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      mirror: true
      sheet: Bottom documentation
    - layers:
      - layer: F.Fab
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      sheet: Front documentation
    keep_temporal_files: true
    add_background: true
- name: basic_pcb_print_png
  comment: PCB
  type: pcb_print
  dir: PCB/PNG
  options:
    format: PNG
    pages:
    - layers:
      - layer: F.Cu
      - layer: F.Mask
        color: '#14332440'
      - layer: F.Paste
      - layer: F.Silkscreen
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      sheet: Front copper
    - layers:
      - layer: B.Cu
      - layer: B.Mask
        color: '#14332440'
      - layer: B.Silkscreen
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      mirror: true
      sheet: Bottom copper
    - layers:
      - layer: F.Courtyard
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      sheet: Front courtyard area
    - layers:
      - layer: B.Fab
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      mirror: true
      sheet: Bottom documentation
    - layers:
      - layer: F.Fab
      - layer: Edge.Cuts
      - layer: User.Drawings
      - layer: User.Comments
      - layer: User.2
      sheet: Front documentation
    keep_temporal_files: true
    add_background: true
- name: basic_pdf
  comment: Individual layers in PDF format
  type: pdf
  dir: Individual_Layers/PDF
  run_by_default: false
  layers:
  - layer: F.Cu
    suffix: F_Cu
    description: Front copper
  - layer: B.Cu
    suffix: B_Cu
    description: Bottom copper
  - layer: F.Paste
    suffix: F_Paste
    description: Front solder paste
  - layer: B.Silkscreen
    suffix: B_Silkscreen
    description: Bottom silkscreen (artwork)
  - layer: F.Silkscreen
    suffix: F_Silkscreen
    description: Front silkscreen (artwork)
  - layer: B.Mask
    suffix: B_Mask
    description: Bottom soldermask (negative)
  - layer: F.Mask
    suffix: F_Mask
    description: Front soldermask (negative)
  - layer: User.Drawings
    suffix: User_Drawings
    description: User drawings
  - layer: User.Comments
    suffix: User_Comments
    description: User comments
  - layer: Edge.Cuts
    suffix: Edge_Cuts
    description: Board shape
  - layer: F.Courtyard
    suffix: F_Courtyard
    description: Front courtyard area
  - layer: B.Fab
    suffix: B_Fab
    description: Bottom documentation
  - layer: F.Fab
    suffix: F_Fab
    description: Front documentation
  - layer: User.2
    suffix: User_2
    description: User layer 2
- name: basic_pdf_sch_print
  comment: Schematic in PDF format
  type: pdf_sch_print
  dir: Schematic
  run_by_default: false
  options:
    # This does not work!
    all_pages: true
- name: basic_svg_sch_print
  comment: Schematic in SVG format
  type: svg_sch_print
  dir: Schematic
  run_by_default: false
  options:
    # This does not work!
    all_pages: true
- name: basic_render_3d_top
  comment: 3D view from top
  type: render_3d
  dir: 3D
  options:
    ray_tracing: true
    orthographic: true
    download: true
- name: basic_render_3d_30deg
  comment: 3D view from 30 degrees
  type: render_3d
  dir: 3D
  output_id: 30deg
  options:
    ray_tracing: true
    rotate_x: 3
    rotate_z: -2
    download: true
- name: basic_render_3d_bottom
  comment: 3D view from bottom
  type: render_3d
  dir: 3D
  options:
    ray_tracing: true
    orthographic: true
    view: bottom
    download: true
#- name: report_simple
#  comment: Simple design report
#  type: report
#  output_id: _simple
#  run_by_default: false
#  options:
#    template: simple_ASCII
#    do_convert: true
- name: report_full
  comment: Full design report
  type: report
  options:
    template: full_SVG
    do_convert: true
- name: basic_svg
  comment: Individual layers in SVG format
  type: svg
  dir: Individual_Layers/SVG
  run_by_default: false
  layers:
  - layer: F.Cu
    suffix: F_Cu
    description: Front copper
  - layer: B.Cu
    suffix: B_Cu
    description: Bottom copper
  - layer: F.Paste
    suffix: F_Paste
    description: Front solder paste
  - layer: B.Silkscreen
    suffix: B_Silkscreen
    description: Bottom silkscreen (artwork)
  - layer: F.Silkscreen
    suffix: F_Silkscreen
    description: Front silkscreen (artwork)
  - layer: B.Mask
    suffix: B_Mask
    description: Bottom soldermask (negative)
  - layer: F.Mask
    suffix: F_Mask
    description: Front soldermask (negative)
  - layer: User.Drawings
    suffix: User_Drawings
    description: User drawings
  - layer: User.Comments
    suffix: User_Comments
    description: User comments
  - layer: Edge.Cuts
    suffix: Edge_Cuts
    description: Board shape
  - layer: F.Courtyard
    suffix: F_Courtyard
    description: Front courtyard area
  - layer: B.Fab
    suffix: B_Fab
    description: Bottom documentation
  - layer: F.Fab
    suffix: F_Fab
    description: Front documentation
  - layer: User.2
    suffix: User_2
    description: User layer 2