landpattern module#

LCSCLandpattern: the landpattern of the catalogue part being ordered.

A component that names an LCSC part has already said which footprint it wants, and LCSC publishes that footprint. This builds it, so that a part whose package no generator draws does not have to be traced by hand, and so that the landpattern and the part ordered against it cannot drift apart.

Put one in a component that carries an LCSCPart:

>>> class Sensor(jitx.Component):
...     lcsc = LCSCPart("C2874116")
...     SDA = Port()
...     SCL = Port()
...     landpattern = LCSCLandpattern(ports={"1": SDA, "2": SCL})

Which part’s footprint that is comes off the component’s own LCSCPart, which may be assigned below the landpattern, so the constructor only registers a post-processing step and JITX runs it once the component is otherwise complete. Naming the part instead builds it there and then, and is what a parts provider does when it attaches a catalogue footprint in materialize:

>>> component.landpattern = LCSCLandpattern(partnumber="C2874116")

It is recorded in lcsc.lock.json next to the orientation, and read from there on every later build. A design whose parts are all in the lock file never reaches the network, and the footprint it builds is reviewable in a diff rather than fetched afresh and silently different. An orientation of zero is recorded with it: a landpattern built from the catalogue footprint is already in the frame JLCPCB places the part in, so there is no correction to measure. As everywhere in that file, a value already present wins.

ARC_SEGMENTS = 32#

How finely an elliptical arc is approximated, in segments per full turn.

Only true ellipses need it. A circular arc, which is all a footprint normally draws, becomes a JITX Arc and is exact.

exception LandpatternError[source]#

Bases: Exception

A catalogue footprint that cannot be turned into a landpattern.

class LockFile(path)[source]#

Bases: Context

Where the lcsc.lock.json to read and write lives.

Set it when the file does not belong at the project root, which is where it is looked for otherwise.

>>> class MyDesign(jitx.Design):
...     lockfile = LockFile(Path("vendor/lcsc.lock.json"))
Parameters:

path (Path)

path: Path#
class LCSCLandpattern(ports=None, *, partnumber=None)[source]#

Bases: Container

The landpattern of the component’s LCSC part, from LCSC’s own data.

Holds a Landpattern built from the catalogue footprint and, when the ports are given, the PadMapping that binds them to it. Being a container, both are members of the component, exactly as if they had been written there.

Parameters:
  • ports (Mapping[str | int, Port] | None) –

    pad name to port. LCSC pad names are strings, and a name may appear on more than one pad; every pad with that name goes to the port named here. Giving the same port for more than one name works too and has the same effect, which is how a part with several pads on one pin is described.

    When it is omitted, no PadMapping is made and JITX’s default in-order mapping binds the component’s ports to the pads. That is only right when the pads are in pin order and there is exactly one of each, which is the common case; the exception is a footprint with repeated pad names, where the pads are grouped by name and mapped in order of first appearance.

  • partnumber (str | None) – the LCSC C-number to fetch, when the component’s own LCSCPart is not the part whose footprint is wanted.

Not memoized: what it builds depends on the component it is in rather than on its arguments, so two components must not share one.

package: str = ''#

EasyEDA’s name for the package, once the footprint has been read.

The exporter reads it for the BOM’s package column, which is otherwise the landpattern’s class name and would say nothing.

resolve(partnumber, file)[source]#

The part’s catalogue footprint, from the lock file or from LCSC.

The lock file is the authority. A part that is not in it is fetched and recorded, with an orientation of zero, so that the next build of the same design is offline and builds the same landpattern.

Parameters:
  • partnumber (str) – the LCSC C-number.

  • file (Path) – the lcsc.lock.json to read, and to extend on a miss.

Return type:

Footprint

typename(component)[source]#

A component’s class name, for a message a user has to act on.

Return type:

str

Parameters:

component (Any)