from jitx import PadMapping
from jitx.anchor import Anchor
from jitx.component import Component as JITXComponent
from jitx.circuit import Circuit
from jitx.landpattern import Landpattern, Pad
from jitx.net import Port
from jitx.shapes.composites import rectangle
from jitx.shapes.primitive import Arc, ArcPolyline, Polyline, Text, Circle
from jitx.feature import Custom, Paste, Silkscreen, Soldermask, Courtyard
from jitx.symbol import Direction, Pin, Symbol, SymbolMapping
from jitx.transform import Transform
[docs]
class RectangleSmdPad(Pad):
shape = rectangle(0.9, 1.7)
solder_mask = [Soldermask(rectangle(1.002, 1.802))]
paste = [Paste(rectangle(1.002, 1.802))]
[docs]
class RectangleSmdPad1(Pad):
shape = rectangle(0.8, 3)
solder_mask = [Soldermask(rectangle(0.902, 3.102))]
paste = [Paste(rectangle(0.902, 3.102))]
[docs]
class LandpatternCONN_SMD_2P_P2_00_PH2_0_SPWB(Landpattern):
name = "CONN-SMD_2P-P2.00_PH2.0-SPWB"
p = {
1: RectangleSmdPad().at((1.0005, -3.5)),
2: RectangleSmdPad().at((-0.9995, -3.5)),
3: RectangleSmdPad1().at((-3.2495, 2.85)),
4: RectangleSmdPad1().at((3.2505, 2.85)),
}
pcb_layer_reference = Silkscreen(Text(">REF", 0.5, Anchor.W).at((-0.75, 6.1066)))
pcb_layer_value = Custom(
Text(">VALUE", 0.5, Anchor.W).at((-0.75, 5.1066)), name="Fab"
)
custom_layer = [
Custom(Polyline(0.254, [(-3.2005, -1.85), (-3.2005, -3.451)]), name="Fab"),
Custom(Polyline(0.254, [(3.2005, -3.45), (3.2005, -1.85)]), name="Fab"),
Custom(Polyline(0.254, [(3.2005, -1.85), (-3.2005, -1.85)]), name="Fab"),
Custom(Polyline(0.254, [(-3.9995, 4.15), (4.0005, 4.15)]), name="Fab"),
Custom(Polyline(0.254, [(4.0005, 4.15), (4.0005, -3.45)]), name="Fab"),
Custom(Polyline(0.254, [(-3.9995, -3.45), (-3.9995, 4.15)]), name="Fab"),
Custom(Polyline(0.254, [(-3.2005, -3.45), (-4.0005, -3.45)]), name="Fab"),
Custom(Polyline(0.254, [(4.0005, -3.45), (3.2005, -3.45)]), name="Fab"),
Custom(ArcPolyline(0.06, [Arc((4.0005, -3.925), 0.03, 0, -360)]), name="Fab"),
]
silkscreen = [
Silkscreen(Polyline(0.254, [(-3.2005, -1.85), (-3.2005, -3.45)])),
Silkscreen(Polyline(0.254, [(3.2005, -3.45), (3.2005, -1.85)])),
Silkscreen(Polyline(0.254, [(3.2005, -1.85), (-3.1995, -1.85)])),
Silkscreen(Polyline(0.254, [(4.0005, 4.15), (4.0005, -3.45)])),
Silkscreen(Polyline(0.254, [(-2.4995, 4.15), (2.5005, 4.15)])),
Silkscreen(Polyline(0.254, [(-3.9995, -3.45), (-3.9995, 4.15)])),
Silkscreen(Polyline(0.254, [(-3.2005, -3.45), (-4.0005, -3.45)])),
Silkscreen(Polyline(0.254, [(4.0005, -3.45), (3.2005, -3.45)])),
]
courtyard = [Courtyard(rectangle(8.255, 8.802))]
# model3ds = [
# Model3D(
# "jitx-64d1abccb789d8dc4b86a79c.stp",
# position=(0.0, 0.0, 0.0),
# scale=(1.0, 1.0, 1.0),
# rotation=(0.0, 0.0, 0.0),
# )
# ]
[docs]
class SymbolPH2_0_2PWB(Symbol):
pin_name_size = 0.7874
pad_name_size = 0.7874
p = {
1: Pin((-1, 1), 2, Direction.Left),
2: Pin((-1, -1), 2, Direction.Left),
3: Pin((2, -3), 2, Direction.Down),
4: Pin((2, 3), 2, Direction.Up),
}
layer_reference = Text(">REF", 0.55559, Anchor.C).at((0, 4.57481))
layer_value = Text(">VALUE", 0.55559, Anchor.C).at((0, 3.78741))
draws = [
Transform((1, 0), 0) * rectangle(4.00001, 6.00001),
Circle(radius=0.3).at((0, 2)),
]
[docs]
class Component(JITXComponent):
description = "Battery connector module for 2.0mm pitch battery connection"
manufacturer = "BOOMELE"
mpn = "C47647"
reference_designator_prefix = "J"
datasheet = "https://datasheet.lcsc.com/lcsc/1912111436_BOOMELE-Boom-Precision-Elec-C47647_C47647.pdf"
p = {1: Port(), 2: Port(), 3: Port(), 4: Port()}
landpattern = LandpatternCONN_SMD_2P_P2_00_PH2_0_SPWB()
symbol = SymbolPH2_0_2PWB()
cmappings = [
SymbolMapping(
{p[1]: symbol.p[1], p[2]: symbol.p[2], p[3]: symbol.p[3], p[4]: symbol.p[4]}
),
PadMapping(
{
p[1]: landpattern.p[1],
p[2]: landpattern.p[2],
p[3]: landpattern.p[3],
p[4]: landpattern.p[4],
}
),
]
[docs]
class PH2_0_2PWB(Circuit):
"""
PH2-0-2PWB Module
Battery connector module for 2.0mm pitch battery connection
"""
power = Port() # Power/positive terminal
ground = Port() # Ground/negative terminal
# Battery connector from LCSC database
battery = Component()
# Circuit connections
nets = [
# Battery connector connections
ground + battery.p[1], # Ground to battery pin 1
power + battery.p[2], # Power to battery pin 2
]
Device: type[PH2_0_2PWB] = PH2_0_2PWB