# Slice board formats: every slice fact drawn in the board frame, in one place.
# Explained in formats.md. Read by scripts/validate_board.py (the format check), and from phase 3 by
# bread-mechanical slice-case/design/synth/tools/resolve.py at a pinned bread-infra tag.
#
# Board frame (Slice Interface 1, "Slice board formats"; bread-mechanical formats.yaml): mm, x from the
# bus edge toward the front edge, y up from the bottom (-A, MCU USB) edge. Part positions are footprint
# origins; rot is KiCad's footprint rotation in degrees; side is F or B.
# A rect is [x0, y0, x1, y1]; a circle is [x, y, r].
#
# Sources named below:
#   SI1         spec/slice/slice-interface-1.md, "Slice board formats"
#   MEC-n       rfcs/0001-slice-interface-2/07-mechanical.md (proposed for SI2)
#   slot-if     bread-mechanical slice-case/design/synth/slot-interface-v1.1.json
#   case.scad   bread-mechanical slice-case/design/synth/case.scad (spec.py mirrors it)
#   templates   hardware/BREAD_Slice.kicad_pcb at the last commit that touched it on origin/main:
#                 Slice_TEMP_NANO_S2L 83e0926, Slice_TEMP_NUCL_S4L d613b24, Slice_TEMP_PICO_S2L 2e9a303,
#                 Slice_TEMP_NUCL_L4L 006e3f7, Slice_TEMP_PICO_L4L d735160

version: 0 # v0 is the SI1 boards as built today. A changed core or outline is a new pattern (slice-S-v1).

formats:
  slice-S-v0:
    board: [70.0, 100.0] # SI1 format S; MEC-1
    corner_r: 5.0 # SI1 "Slice board corners are R5"
    thickness: [1.4, 1.8] # slot-if slice_side_datums.board_thickness_range (not checked here)
    tolerance: 0.05 # mm on the outline, corner radius, holes and bus row. SI1: boards that meet a format match it to 0.02
    bus:
      footprint: PinSocket_1x10_P2.54mm_Horizontal # SI1 "Slot connector"; the reference varies (J1, J2, J4, J12)
      row: [3.6, 50.0] # pin-row centre. SI1 x 3.60; y 50.0 is MEC-3 and slot-if (templates: 50.02)
    holes: {inset: 5.0, d: 5.0, keepout_r: 5.0} # SI1 (4 x d5.0 NPTH, 5 from each edge); keepout_r MEC-2
    height: {top: 21.57, bottom: 3.23} # case.scad: roof_in 20.3 and floor_in -6.1 against board_top_N -1.27 and a 1.6 board (MEC-5: 21.6 / 3.2); not checked here
    zones:
      # side: F (top), B (bottom) or both (default). A footprint occupies its own side, and both if it has
      # plated through-hole pads. allow: [bus] lets the bus socket in.
      bus_edge_strip: # a margin against the case bus-end wall and the backplane guide
        rect: [0.0, 0.0, 1.0, 100.0]
        allow: [bus]
      bus_edge_overhang: # nothing but the bus socket crosses the bus edge
        beyond: bus_edge
        allow: [bus]
      bus_window: # slot-if bus_edge_zone.case_bus_window: "within 6.4 of the bus edge and |A| <= 15.4, only the bus socket"
        rect: [0.0, 34.6, 6.4, 65.4]
        side: F
        allow: [bus]
      boss_keepout: # case.scad boss_d 9.0: tray and lid bosses at the two bus-side holes
        circles: [[5.0, 5.0, 4.5], [5.0, 95.0, 4.5]]
      corner_towers: # case.scad: far-corner panel towers, from tower_gap 0.3 above the board; x from front_inset 11.1
        rects: [[58.9, 0.0, 70.0, 9.8], [58.9, 90.2, 70.0, 100.0]]
        side: F
      front_io: # case.scad / spec.py front opening under the removable panel: x from W - front_inset 11.1,
        # y between the far bosses' faces + open_clear 0.3 (5 + 4.5 + 0.3 = 9.8). Connectors leave here.
        rect: [58.9, 9.8, 70.0, 90.2]
        holds: "^J[0-9]+$" # connectors, by reference, the bus socket excepted; judged on the board, so one may cross the front edge
        enforced: false # v0: reported, never a failure
    cores:
      # Keyed by slice.yaml hardware.mcu.form_factor. footprint: the footprint name contains this.
      # ref: the expected reference, or a list of accepted ones.
      nano: # Slice_TEMP_NANO_S2L
        tolerance: {pos: 0.05, rot: 0.1}
        parts:
          mcu: {ref: A1, footprint: Arduino_Nano, at: [20.010, 42.360, 0], side: F}
          led: {ref: [D1, D2], footprint: WS2812, at: [50.500, 4.067, 0], side: F}
          buck_u: {ref: U1, footprint: SOIC_05WU-7_DIO, at: [6.150, 17.045, 0], side: B} # fleet standard
          buck_l: {ref: L1, footprint: L_1210, at: [11.250, 17.045, 0], side: B}
          buck_cin: {ref: C1, footprint: C_1206, at: [6.200, 20.300, 180], side: B}
          buck_cbs: {ref: C2, footprint: C_1206, at: [8.550, 13.545, 180], side: B}
          buck_co1: {ref: C3, footprint: C_1206, at: [11.250, 20.345, 0], side: B}
          buck_co2: {ref: C4, footprint: C_1206, at: [11.250, 23.400, 0], side: B}
          buck_pad: {ref: HS1, footprint: Thermal_Pad, at: [9.200, 18.350, 0], side: F}
          net_tie: {ref: NT1, footprint: NetTie-2, at: [6.100, 24.600, 90], side: B}
      nucleo32: # Slice_TEMP_NUCL_S4L; buck block as nano. U1 is TSOT-23-6 there: drift from the fleet standard
        tolerance: {pos: 0.05, rot: 0.1}
        parts:
          mcu: {ref: U2, footprint: MODULE_NUCLEO-L432KC, at: [27.674, 26.199, 0], side: F}
          led: {ref: [D1, D2], footprint: WS2812, at: [50.500, 4.067, 0], side: F}
          buck_u: {ref: U1, footprint: SOIC_05WU-7_DIO, at: [6.150, 17.045, 0], side: B}
          buck_l: {ref: L1, footprint: L_1210, at: [11.250, 17.045, 0], side: B}
          buck_cin: {ref: C1, footprint: C_1206, at: [6.200, 20.300, 180], side: B}
          buck_cbs: {ref: C2, footprint: C_1206, at: [8.550, 13.545, 180], side: B}
          buck_co1: {ref: C3, footprint: C_1206, at: [11.250, 20.345, 0], side: B}
          buck_co2: {ref: C4, footprint: C_1206, at: [11.250, 23.400, 0], side: B}
          buck_pad: {ref: HS1, footprint: Thermal_Pad, at: [9.200, 18.350, 0], side: F}
          net_tie: {ref: NT1, footprint: NetTie-2, at: [6.100, 24.600, 90], side: B}
      pico: # Slice_TEMP_PICO_S2L; its buck block, HS1 and NT1 sit 6.45..6.76 higher than nano's (its own core)
        tolerance: {pos: 0.05, rot: 0.1}
        parts:
          mcu: {ref: A2, footprint: RaspberryPi_Pico, at: [40.290, 5.863, 180], side: F}
          led: {ref: [D1, D2], footprint: WS2812, at: [50.500, 4.067, 0], side: F}
          buck_u: {ref: U1, footprint: SOIC_05WU-7_DIO, at: [6.150, 23.800, 0], side: B}
          buck_l: {ref: L1, footprint: L_1210, at: [11.250, 23.800, 0], side: B}
          buck_cin: {ref: C1, footprint: C_1206, at: [6.200, 27.055, 180], side: B}
          buck_cbs: {ref: C2, footprint: C_1206, at: [8.550, 20.300, 180], side: B}
          buck_co1: {ref: C3, footprint: C_1206, at: [11.250, 27.100, 0], side: B}
          buck_co2: {ref: C4, footprint: C_1206, at: [11.250, 30.155, 0], side: B}
          buck_pad: {ref: HS1, footprint: Thermal_Pad, at: [9.200, 24.800, 0], side: F}
          net_tie: {ref: NT1, footprint: NetTie-2, at: [6.100, 31.355, 90], side: B}

  slice-L-v0:
    board: [100.0, 145.0] # SI1 format L; MEC-1
    corner_r: 5.0 # SI1
    thickness: [1.4, 1.8] # slot-if (not checked here)
    tolerance: 0.05 # as slice-S-v0
    bus:
      footprint: PinSocket_1x10_P2.54mm_Horizontal # SI1
      row: [3.6, 50.0] # SI1, MEC-3, slot-if: the same distance from the bottom edge as S
    holes: {inset: 5.0, d: 5.0, keepout_r: 5.0} # SI1; keepout_r MEC-2
    height: {top: 21.57, bottom: 3.23} # case.scad, as slice-S-v0; not checked here
    zones:
      bus_edge_strip: # as slice-S-v0, full height
        rect: [0.0, 0.0, 1.0, 145.0]
        allow: [bus]
      bus_edge_overhang: # as slice-S-v0
        beyond: bus_edge
        allow: [bus]
      bus_window: # slot-if case_bus_window, as slice-S-v0 (the bus row is 50.0 up on both formats)
        rect: [0.0, 34.6, 6.4, 65.4]
        side: F
        allow: [bus]
      boss_keepout: # case.scad boss_d 9.0 at the two bus-side holes
        circles: [[5.0, 5.0, 4.5], [5.0, 140.0, 4.5]]
      corner_towers: # case.scad, as slice-S-v0: x from W - 11.1
        rects: [[88.9, 0.0, 100.0, 9.8], [88.9, 135.2, 100.0, 145.0]]
        side: F
      front_io: # case.scad / spec.py front opening, as slice-S-v0: y 9.8 .. H - 9.8
        rect: [88.9, 9.8, 100.0, 135.2]
        holds: "^J[0-9]+$"
        enforced: false
    cores:
      # No public nano L template: an L board with a nano has no core entry yet.
      nucleo32: # Slice_TEMP_NUCL_L4L, from its own bottom edge (its outline is 100.12 x 144.89). U1 is TSOT-23-6 there
        tolerance: {pos: 0.05, rot: 0.1}
        parts:
          mcu: {ref: U2, footprint: MODULE_NUCLEO-L432KC, at: [27.516, 25.699, 0], side: F}
          led: {ref: [D1, D2], footprint: WS2812, at: [50.500, 4.067, 0], side: F}
          buck_u: {ref: U1, footprint: SOIC_05WU-7_DIO, at: [6.150, 17.045, 0], side: B}
          buck_l: {ref: L1, footprint: L_1210, at: [11.250, 17.045, 0], side: B}
          buck_cin: {ref: C1, footprint: C_1206, at: [6.200, 20.300, 180], side: B}
          buck_cbs: {ref: C2, footprint: C_1206, at: [8.550, 13.545, 180], side: B}
          buck_co1: {ref: C3, footprint: C_1206, at: [11.250, 20.345, 0], side: B}
          buck_co2: {ref: C4, footprint: C_1206, at: [11.250, 23.400, 0], side: B}
          buck_pad: {ref: HS1, footprint: Thermal_Pad, at: [9.200, 18.350, 0], side: F}
          net_tie: {ref: NT1, footprint: NetTie-2, at: [6.100, 24.600, 90], side: B}
      pico: # Slice_TEMP_PICO_L4L; buck block moved with J1 on 2026-11-27 (d735160)
        tolerance: {pos: 0.05, rot: 0.1}
        parts:
          mcu: {ref: A2, footprint: RaspberryPi_Pico, at: [40.290, 5.863, 180], side: F}
          led: {ref: [D1, D2], footprint: WS2812, at: [50.500, 4.067, 0], side: F}
          buck_u: {ref: U1, footprint: SOIC_05WU-7_DIO, at: [6.400, 18.645, 0], side: B}
          buck_l: {ref: L1, footprint: L_1210, at: [11.575, 18.645, 0], side: B}
          buck_cin: {ref: C1, footprint: C_1206, at: [6.573, 21.945, 180], side: B}
          buck_cbs: {ref: C2, footprint: C_1206, at: [8.700, 15.145, 180], side: B}
          buck_co1: {ref: C3, footprint: C_1206, at: [11.500, 21.945, 0], side: B}
          buck_co2: {ref: C4, footprint: C_1206, at: [11.500, 25.000, 0], side: B}
          buck_pad: {ref: HS1, footprint: Thermal_Pad, at: [9.450, 19.645, 0], side: F}
          net_tie: {ref: NT1, footprint: NetTie-2, at: [6.350, 26.200, 90], side: B}
