From 7873778e637aa1861e9706c5b3fc8c6c345adc25 Mon Sep 17 00:00:00 2001 From: Sergio Costas Date: Sun, 10 Jul 2022 16:42:14 +0200 Subject: [PATCH] Remove grid traces in switches 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. --- klepcbgen.py | 13 ++++++++- klepcbgenmod.py | 76 ++++++++++++++++++++++++++----------------------- 2 files changed, 53 insertions(+), 36 deletions(-) diff --git a/klepcbgen.py b/klepcbgen.py index 668a00d..9924021 100644 --- a/klepcbgen.py +++ b/klepcbgen.py @@ -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: @@ -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() \ No newline at end of file + kbpcbgen.keyboard.print_key_info() diff --git a/klepcbgenmod.py b/klepcbgenmod.py index 261edc4..12730d5 100644 --- a/klepcbgenmod.py +++ b/klepcbgenmod.py @@ -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) @@ -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(