Skip to content

Commit

Permalink
Remove grid traces in switches
Browse files Browse the repository at this point in the history
This patch adds two extra parameters that allow to remove the
traces in the fore and/or background in each switch. Alone is
 not very useful, but combined with the other patches makes
it more useful.
  • Loading branch information
rastersoft committed Jul 10, 2022
1 parent 93fa590 commit 7873778
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 36 deletions.
13 changes: 12 additions & 1 deletion klepcbgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def parse_command_line_arguments():
help='The base name of the output files (e.g. "id80" will result in "id80.sch" and \
"id80.pcb"',
)
parser.add_argument(
"--no-grid-background-tracks", action="store_true",
help="Don't add background-layer tracks to each button.",
default=False
)
parser.add_argument(
"--no-grid-foreground-tracks", action="store_true",
help="Don't add foreground-layer tracks to each button.",
default=False
)

args = parser.parse_args()

if not args.infile:
Expand All @@ -37,4 +48,4 @@ def parse_command_line_arguments():
arguments = parse_command_line_arguments()
kbpcbgen = KLEPCBGenerator()
kbpcbgen.generate_kicadproject(arguments)
kbpcbgen.keyboard.print_key_info()
kbpcbgen.keyboard.print_key_info()
76 changes: 41 additions & 35 deletions klepcbgenmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ def generate_kicadproject(self, arguments):
if not os.path.exists(arguments.outname):
os.mkdir(arguments.outname)

self._no_grid_background_tracks = arguments.no_grid_background_tracks
self._no_grid_foreground_tracks = arguments.no_grid_foreground_tracks
self.read_kle_json(arguments)
self.generate_rows_and_columns()
self.generate_schematic(arguments)
Expand Down Expand Up @@ -362,51 +364,55 @@ def place_layout_components(self):
)

# Place vias
for offset in col_via_offsets:
via_x = ref_x + offset[0]
via_y = ref_y + offset[1]
if not self._no_grid_foreground_tracks:
for offset in col_via_offsets:
via_x = ref_x + offset[0]
via_y = ref_y + offset[1]
components_section = (
components_section
+ viatpl.render(x=via_x, y=via_y, netnum=key.colnetnum)
+ "\n"
)

if not self._no_grid_background_tracks:
for offset in row_via_offsets:
via_x = ref_x + offset[0]
via_y = ref_y + offset[1]
components_section = (
components_section
+ viatpl.render(x=via_x, y=via_y, netnum=key.rownetnum)
+ "\n"
)

# Place traces
if not self._no_grid_background_tracks:
components_section = (
components_section
+ viatpl.render(x=via_x, y=via_y, netnum=key.colnetnum)
+ tracetpl.render(
x1=ref_x + row_via_offsets[0][0],
y1=ref_y + row_via_offsets[0][1],
x2=ref_x + row_via_offsets[1][0],
y2=ref_y + row_via_offsets[1][1],
layer="B.Cu",
netnum=key.rownetnum,
)
+ "\n"
)

for offset in row_via_offsets:
via_x = ref_x + offset[0]
via_y = ref_y + offset[1]
if not self._no_grid_foreground_tracks:
components_section = (
components_section
+ viatpl.render(x=via_x, y=via_y, netnum=key.rownetnum)
+ tracetpl.render(
x1=ref_x + col_via_offsets[0][0],
y1=ref_y + col_via_offsets[0][1],
x2=ref_x + col_via_offsets[1][0],
y2=ref_y + col_via_offsets[1][1],
layer="F.Cu",
netnum=key.colnetnum,
)
+ "\n"
)

# Place traces
components_section = (
components_section
+ tracetpl.render(
x1=ref_x + row_via_offsets[0][0],
y1=ref_y + row_via_offsets[0][1],
x2=ref_x + row_via_offsets[1][0],
y2=ref_y + row_via_offsets[1][1],
layer="B.Cu",
netnum=key.rownetnum,
)
+ "\n"
)

components_section = (
components_section
+ tracetpl.render(
x1=ref_x + col_via_offsets[0][0],
y1=ref_y + col_via_offsets[0][1],
x2=ref_x + col_via_offsets[1][0],
y2=ref_y + col_via_offsets[1][1],
layer="F.Cu",
netnum=key.colnetnum,
)
+ "\n"
)

components_section = (
components_section
+ tracetpl.render(
Expand Down

0 comments on commit 7873778

Please sign in to comment.