gokul/macro-six-usbc

A six-key macro keyboard PCB paired with a separate physical enclosure.

Version
0.1.16
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone gokul/macro-six-usbc  # download the package files into ./macro-six-usbc
tsci add gokul/macro-six-usbc    # add it to your project as @tsci/gokul.macro-six-usbc

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

scripts/assert-geometry-equal.ts

import { deepStrictEqual, ok } from 'node:assert'

// Allow only floating-point noise between JS runtimes, not layout changes.
// Coordinates are in mm; 1e-9 mm is far below Gerber output precision.
export function assertGeometryEqual(actual: unknown, expected: unknown, path = 'geometry'): void {
  if (typeof actual === 'number' && typeof expected === 'number') {
    ok(Number.isFinite(actual) && Number.isFinite(expected) && Math.abs(actual - expected) <= 1e-9,
      `${path}: ${actual} differs from ${expected}`)
    return
  }
  if (Array.isArray(actual) && Array.isArray(expected)) {
    deepStrictEqual(actual.length, expected.length, `${path}: array length changed`)
    actual.forEach((value, index) => assertGeometryEqual(value, expected[index], `${path}[${index}]`))
    return
  }
  if (actual && expected && typeof actual === 'object' && typeof expected === 'object') {
    const a = actual as Record<string, unknown>
    const b = expected as Record<string, unknown>
    deepStrictEqual(Object.keys(a).sort(), Object.keys(b).sort(), `${path}: fields changed`)
    for (const key of Object.keys(a)) assertGeometryEqual(a[key], b[key], `${path}.${key}`)
    return
  }
  deepStrictEqual(actual, expected, path)
}