gokul/macro-six-usbc

USB-powered ATmega32U4 controller board with protected/switched 5 V power, six tactile keys, rotary encoder, reset/boot/ISP interfaces, power LED, and six daisy-chained SK6812 RGB LEDs driven through MOSFETs.

Version
0.1.6
License
MIT
Stars
0

lib/controls.tsx

import { Fragment } from "react"
import { CPG151101D06 } from "../imports/CPG151101D06"
import { EC11E18244AU } from "../imports/EC11E18244AU"
import { SK6812MINI_HS } from "../imports/SK6812MINI_HS"
import { AO3401A } from "../imports/AO3401A"
import { C, R } from "./passives"

export const keyPositions = [
  { x: -28, y: 13, pin: "KEY1" }, { x: -5, y: 13, pin: "KEY2" },
  { x: 18, y: 13, pin: "KEY3" }, { x: -28, y: -13, pin: "KEY4" },
  { x: -5, y: -13, pin: "KEY5" }, { x: 18, y: -13, pin: "KEY6" },
] as const

export const Controls = () => (
  <group pcbRelative pcbX={0} pcbY={0} name="controls" schSheetName="Controls" schGrid gridCols={6} gridGap={3}>
      {keyPositions.map((key, i) => (
        <CPG151101D06 key={key.pin} name={`SW${i + 1}`} pcbX={key.x} pcbY={key.y}
          connections={{ pin1: `net.${key.pin}`, pin2: "net.GND" }} />
      ))}
      <EC11E18244AU pinAttributes={{pin6:{isPassive:true},pin7:{isPassive:true},pin8:{isPassive:true},pin9:{isPassive:true,requiresGround:true},pin10:{isPassive:true},pin11:{isPassive:true},pin12:{isPassive:true,requiresGround:true},A:{isPassive:true},B:{isPassive:true},C:{isPassive:true,requiresGround:true},D:{isPassive:true},E:{isPassive:true,requiresGround:true}}} name="ENC1" pcbX={43} pcbY={0}
        connections={{ A: "net.ENC_A", B: "net.ENC_B", C: "net.GND", D: "net.ENC_PUSH", E: "net.GND", pin6: "net.GND", pin7: "net.GND" }} />
      <R name="R_ENCA" resistance="10k" part="C98220" pcbX={39} pcbY={-11}
        connections={{ pin1: "net.VCC", pin2: "net.ENC_A" }} />
      <R name="R_ENCB" resistance="10k" part="C98220" pcbX={43} pcbY={-11}
        connections={{ pin1: "net.VCC", pin2: "net.ENC_B" }} />
      <AO3401A name="Q_RGB" pcbX={-42} pcbY={25} connections={{ pin1: "net.RGB_GATE", pin2: "net.VCC", pin3: "net.LED_5V" }} />
      <R name="R_RGB_PULL" resistance="100k" part="C25803" pcbX={-42} pcbY={29}
        connections={{ pin1: "net.VCC", pin2: "net.RGB_GATE" }} />
      <R name="R_RGB_DATA" resistance="330" part="C23138" pcbX={-36} pcbY={25}
        connections={{ pin1: "net.RGB_DATA", pin2: "net.LED_IN" }} />
      <R name="R_RGB_DOWN" resistance="100k" part="C25803" pcbX={-36} pcbY={29}
        connections={{ pin1: "net.LED_IN", pin2: "net.GND" }} />
      {keyPositions.map((key, i) => (
        <Fragment key={key.pin}>
          <SK6812MINI_HS name={`U_RGB${i + 1}`} pcbX={key.x + 10.5} pcbY={key.y + 5} pcbRotation={270}
            connections={{ VDD: "net.LED_5V", GND: "net.GND", DI: i === 0 ? "net.LED_IN" : `net.LED_LINK${i}`, ...(i < 5 ? { DO: `net.LED_LINK${i + 1}` } : {}) }} />
          <C name={`C_LED${i + 1}`} capacitance="100nF" pcbX={key.x + 10.5} pcbY={key.y + 1.5}
            connections={{ pin1: "net.LED_5V", pin2: "net.GND" }} />
        </Fragment>
      ))}
  </group>
)