pixalynx/edge-connector

Configures USB-A, Micro-USB, and USB-C PCB-edge connectors with exposed copper contacts and automatically shaped, positioned board tongues.

Version
1.0.0
License
GPL-3.0-only
Stars
0

MicroUsbEdgeConnector.tsx

// Adapted from vasya-zh/PCB-Edge-USB-connector-KiCad-library; see NOTICE.md.
import type { ChipProps } from "tscircuit"
import { EdgeContactFootprint } from "./EdgeContactFootprint"
import { microUsbEdgePads, microUsbEdgeProfile } from "./microUsbGeometry"

export const microUsbEdgeConnectorPinLabels = {
  pin1: ["VBUS"],
  pin2: ["DM", "D_MINUS"],
  pin3: ["DP", "D_PLUS"],
  pin4: ["ID"],
  pin5: ["GND"],
} as const

export const microUsbEdgeConnectorGeometry = {
  boardThickness: 0.6,
  tipY: 1.58,
  edgeProfile: microUsbEdgeProfile,
} as const

export type MicroUsbEdgeConnectorProps = Omit<
  ChipProps<typeof microUsbEdgeConnectorPinLabels>,
  "footprint" | "pinLabels" | "layer" | "cadModel" | "children"
>

/** Five-contact Micro-B receptacle tongue, top copper, mating toward +Y. */
export function MicroUsbEdgeConnector(props: MicroUsbEdgeConnectorProps) {
  return (
    <connector
      schWidth={2.2}
      schHeight={1.2}
      schPinArrangement={{ rightSide: { pins: [1, 2, 3, 4, 5], direction: "top-to-bottom" } }}
      showPinAliases
      {...props}
      layer="top"
      doNotPlace
      pinLabels={microUsbEdgeConnectorPinLabels}
      footprint={<EdgeContactFootprint pads={microUsbEdgePads} />}
    />
  )
}

export default MicroUsbEdgeConnector