[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add LED footprints for MX #40

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ __pycache__/
*-backups
fp-info-cache
*.kicad_prl
scripts/output
32 changes: 31 additions & 1 deletion scripts/keyswitch_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from switch import StabilizerCherryMX, SwitchAlpsMatias, SwitchCherryMX, \
SwitchHybridCherryMxAlps, SwitchKailhChoc, \
SwitchHotswapKailh, SwitchKailhKH, \
SwitchKailhNB, SwitchKailhChocMini
SwitchKailhNB, SwitchKailhChocMini, \
LEDTHTCherryMX

path3d = '${KICAD6_3RD_PARTY}/3dmodels/' \
'com_github_perigoso_keyswitch-kicad-library/' \
Expand Down Expand Up @@ -111,6 +112,34 @@ def generate_switch_cherry_mx(output_path):
file_handler.writeFile(os.path.join(out_path, f'{switch.name}.kicad_mod'), timestamp=0)


def generate_led_tht_cherry_mx(output_path):
spacing = 19.05
group = 'LED_THT_Keyboard_Cherry_MX'

out_path = os.path.join(output_path, f'{group}.pretty')
if not os.path.isdir(out_path):
os.mkdir(out_path)
keys = ['1u', '1.25u', '1.25u90', '1.5u', '1.5u90', '1.75u', '1.75u90',
'2u', '2u90', '2.25u', '2.25u90', '2.5u', '2.5u90', '2.75u',
'2.75u90', '3u', '3u90', '4u', '4.5u', '5.5u', '6u', '6uOffset',
'6.25u', '6.5u', '7u', 'ISOEnter', 'ISOEnter90', 'ISOEnter180',
'ISOEnter270']

leds = []

leds.append(LEDTHTCherryMX(path3d=path3d))

for key in keys:
leds.append(LEDTHTCherryMX(path3d=path3d,
keycap=Keycap(spacing=spacing,
**keycaps[key])))

for led in leds:
file_handler = KicadFileHandler(led)
file_handler.writeFile(os.path.join(out_path, f'{led.name}.kicad_mod'), timestamp=0)



def generate_switch_hybrid_cherry_mx_alps(output_path):
spacing = 19.05
group = 'Switch_Keyboard_Hybrid'
Expand Down Expand Up @@ -325,6 +354,7 @@ def generate_switch_hotswap_kailh_choc(output_path):
generate_stabilizer_cherry_mx(args.output)
generate_switch_alps_matias(args.output)
generate_switch_cherry_mx(args.output)
generate_led_tht_cherry_mx(args.output)
generate_switch_hybrid_cherry_mx_alps(args.output)
generate_switch_kailh_choc(args.output)
generate_switch_hotswap_kailh_choc(args.output)
Expand Down
88 changes: 88 additions & 0 deletions scripts/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,94 @@ def _init_cutout_relief(self):
self.append(PolygoneLine(polygone=polyline,
layer='Eco1.User', width=0.1))

class LEDTHTCherryMX(Switch):

cherry_w = 14
cherry_h = 14

def __init__(self,
name: str = 'LED_THT_Cherry_MX',
description: str = 'THT LED for Cherry MX keyswitch',
tags: str = 'Cherry MX Keyboard Keyswitch Switch LED',
cutout: str = 'simple', keycap: Keycap = None,
path3d: str = None, model3d: str = None):

if cutout not in ['simple', 'relief', None]:
raise ValueError(f'Cutout type {cutout} not supported.')

self.cutout = cutout

Switch.__init__(self,
name=name,
description=description,
tags=tags,
cutout=True if cutout is not None else False,
keycap=keycap,
path3d=path3d,
model3d=model3d if model3d is not None
else f'{name}.wrl')

self._init_switch()

if cutout is not None:
if cutout == 'simple':
self._init_cutout_simple()
elif cutout == 'relief':
self._init_cutout_relief()

if keycap is not None:
self.append(keycap)

def _init_switch(self):

# create fab outline
self.append(RectLine(start=[-self.cherry_w/2, -self.cherry_h/2],
end=[self.cherry_w/2, self.cherry_h/2],
layer='F.Fab', width=0.1))

# create pads
self.append(Pad(number=1, type=Pad.TYPE_THT, shape=Pad.SHAPE_CIRCLE,
at=[-1.27, 5.08], size=[1.905, 1.905], drill=1.04,
layers=['*.Cu', 'B.Mask']))
self.append(Pad(number=2, type=Pad.TYPE_THT, shape=Pad.SHAPE_CIRCLE,
at=[1.27, 5.08], size=[1.905, 1.905], drill=1.04,
layers=['*.Cu', 'B.Mask']))
Comment on lines +375 to +380
Copy link
Author
@Gigahawk Gigahawk Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dimensions based on MX_Alps_Hybrid, I've had success with these dimensions in the past:
https://github.com/ai03-2725/MX_Alps_Hybrid/blob/master/MX_Only.pretty/MXOnly-1.25U.kicad_mod#L23-L24


def _init_cutout_simple(self):

# create cutout
self.append(RectLine(start=[-self.cherry_w/2, -self.cherry_h/2],
end=[self.cherry_w/2, self.cherry_h/2],
layer='Eco1.User', width=0.1))

def _init_cutout_relief(self):

# create cutout
polyline = [[7, -7],
[7, -6],
[7.8, -6],
[7.8, -2.9],
[7, -2.9],
[7, 2.9],
[7.8, 2.9],
[7.8, 6],
[7, 6],
[7, 7],
[-7, 7],
[-7, 6],
[-7.8, 6],
[-7.8, 2.9],
[-7, 2.9],
[-7, -2.9],
[-7.8, -2.9],
[-7.8, -6],
[-7, -6],
[-7, -7],
[7, -7]]

self.append(PolygoneLine(polygone=polyline,
layer='Eco1.User', width=0.1))


# https://www.cherrymx.de/en/dev.html
# https://github.com/keyboardio/keyswitch_documentation/blob/master/datasheets/ALPS/SKCL.pdf
Expand Down