meta:
  engine: 4.0.5
  author: zoriya
  name: abyss
units:
  kx: cx
  ky: cy
  px: 4
  py: 4
  mc_width: 18+2

  # dont forget that choc v2 is essentially mx
  plate_thickness: 1.2 # choc: 1.2, mx: 1.5
  kcox: 13.8 # key cutout (choc: 13.8, mx: 14)
  kcoy: 13.8 # key cutout (choc: 13.8, mx: 14)
points:
  zones:
    matrix:
      # Fix placement on KiCAD sheet.
      anchor:
        shift: [100, -100]
      key:
        padding: 1ky
        spread: 1kx
      columns:
        pinky:
          key.column_net: C0
          rows:
            top:
              skip: true
        ring:
          key.column_net: C1
          key.stagger: ky/2
        middle:
          key.column_net: C2
          key.stagger: ky/4
        index:
          key.column_net: C3
          key.stagger: -ky/2
        inner:
          key.column_net: C4
          key.stagger: ky/2
          rows:
            top:
              skip: true
      rows:
        bottom:
          row_net: R2
        home:
          row_net: R1
        top:
          row_net: R0
    thumb:
      key:
        padding: 1ky
        spread: 1kx
      anchor:
        ref: matrix_index_bottom
        shift: [-kx/2, -ky * 1.5]
      columns:
        left:
          key.column_net: C3
        home:
          key.column_net: C4
          key.spread: kx+2
          key.splay: -15
          key.origin: [-0.5kx, -0.5ky]
        right:
          key.column_net: C5
          key.spread: kx+2
          key.splay: -15
          key.origin: [-0.5kx, -0.5ky]
          key.width: 1.5kx
          key.rotate: 90
      rows:
        cluster:
          row_net: R3
outlines:
  raw:
    - what: rectangle
      where: true
      bound: false
      size: [kx + px, ky + py]
    - what: rectangle
      where: thumb_right_cluster
      bound: false
      size: [1.5kx + px, ky + py]
  keys:
    - what: rectangle
      where: true
      bound: false
      size: [kx - 0.5, ky - 0.5]
    - what: rectangle
      where: thumb_right_cluster
      bound: false
      size: [1.5kx - 0.5, ky - 0.5]
  board_raw:
    - what: polygon
      operation: stack
      points:
        - ref: matrix_middle_top
          shift: [-2.5kx - px, 0.5ky + py]
        - ref: matrix_middle_top
          shift: [0.5kx + px, 0.5ky + py]
        - ref: matrix_middle_top
          shift: [2.5kx + mc_width, 0.5ky + py]
        - ref: matrix_middle_top
          shift: [2.5kx + mc_width, -3.5ky + py]
        - ref: thumb_right_cluster
          shift: [0.5kx + 2px, -0.5ky - py]
        - ref: thumb_right_cluster
          shift: [-0.5kx - 2px, -0.5ky - py]
        - ref: thumb_left_cluster
          shift: [-0.5kx - px, -0.5ky - py]
        - ref: matrix_pinky_bottom
          shift: [1.5kx, -0.5ky - py]
        - ref: matrix_pinky_bottom
          shift: [-0.5kx - px, -0.5ky - py]
  board:
    - name: board_raw
      fillet: 4
  plate_keys:
    - what: rectangle
      where: true
      bound: false
      size: [kcox, kcoy]
  plate:
    - name: board
    - operation: subtract
      name: plate_keys
  case:
    - name: board_raw
    - operation: subtract
      name: plate_keys
  combo:
    - name: case
    - operation: stack
      name: raw
pcbs:
  abyss:
    outlines:
      main:
        outline: board
    footprints:
      choc_hotswap:
        what: choc
        where: true
        params:
          keycaps: true
          reverse: true
          hotswap: true
          from: "{{column_net}}"
          to: "{{colrow}}"
      diode:
        what: diode
        where: true
        params:
          from: "{{colrow}}"
          to: "{{row_net}}"
        adjust:
          shift: [0, -5]

      promicro:
        what: infused-kim/nice_nano_pretty
        params:
          traces: true

          # all pins in up-down order (first left side then right side)
          # GND (fake pin)
          P0: 'DPD'   # Display Data (unused)
          P1: 'DPC'   # Display Clock (unused)
          # GND
          # GND
          P2: 'F0'    # Free
          P3: 'F1'    # Free
          P4: 'R0'    # Row Top
          P5: 'R1'    # Row Home
          P6: 'R2'    # Row Bottom
          P7: 'R3'    # Row Thumb
          P8: 'F8'    # Free
          P9: 'DPE'   # Display CS (nice!view only) (unused)

          # Left Side
          # RAW       # Battery Pos
          # GND       # Ground / Battery Neg
          # RST       # Reset pin
          # VCC       # External Power
          P21: 'C0'   # Column Pinky
          P20: 'C1'   # Column Ring
          P19: 'C2'   # Column Middle
          P18: 'C3'   # Column Index
          P15: 'C4'   # Column Inner
          P14: 'C5'   # Column Thumb
          P16: 'F16'  # Free, but could be Encoder 1
          P10: 'F10'  # Free, but could be Encoder 2
        where:
          ref: matrix_inner_bottom
          shift: [1kx+1, 0.5ky]

      reset_switch:
        what: infused-kim/switch_reset
        params:
          reverse: true
          from: GND
          to: RST
        where:
          ref: matrix_inner_home
          shift: [-0.25kx, 1.25ky]
          rotate: 90
      power_switch:
        what: infused-kim/switch_power
        params:
          reverse: true
          from: BAT_P
          to: RAW
        where:
          ref: matrix_inner_home
          shift: [0.25kx, 1.25ky]
          rotate: 90

      battery_connector:
        what: ceoloide/battery_connector_jst_ph_2
        params:
          BAT_P: BAT_P
          BAT_N: GND
          reversible: true
          include_courtyard: false
        where:
          ref: matrix_inner_home
          shift: [0, 0.75ky]
          rotate: 90

      mounts_top_left:
        what: infused-kim/mounting_hole
        params:
          drill: 2.9 #m3
        where:
          ref: matrix_middle_top
          shift: [-2.5kx, 0.5ky]
      mounts_top_right:
        what: infused-kim/mounting_hole
        params:
          drill: 2.9 #m3
        where:
          ref: matrix_middle_top
          shift: [2.5kx + mc_width - px, 0.5ky]
      mounts_middle_right:
        what: infused-kim/mounting_hole
        params:
          drill: 2.9 #m3
        where:
          ref: matrix_middle_bottom
          shift: [2.5kx + mc_width - px, -1.25ky]
      mounts_bottom_left:
        what: infused-kim/mounting_hole
        params:
          drill: 2.9 #m3
        where:
          ref: matrix_middle_bottom
          shift: [-2.5kx, -1.25ky]
      mounts_thumb_left:
        what: infused-kim/mounting_hole
        params:
          drill: 2.9 #m3
        where:
          ref: thumb_left_cluster
          shift: [-0.5kx - 0.25px, -0.5ky - 0.25py]
      mounts_thumb_right:
        what: infused-kim/mounting_hole
        params:
          drill: 2.9 #m3
        where:
          ref: thumb_right_cluster
          shift: [-0.5kx - 1.25px, -0.5ky]

      mounts_plate_left:
        what: infused-kim/mounting_hole
        where:
          ref: matrix_ring_home
          shift: [-0.5kx, -0.5ky]
      mounts_plate_right:
        what: infused-kim/mounting_hole
        where:
          ref: matrix_index_top
          shift: [0.5kx, -0.5ky]
      mounts_plate_thumb:
        what: infused-kim/mounting_hole
        where:
          ref: thumb_home_cluster
          shift: [0.5kx + 0.75px, 0.5ky - 0.75py]
