diff --git a/kibot/globals.py b/kibot/globals.py index 4e0aad7e..b9dd6f92 100644 --- a/kibot/globals.py +++ b/kibot/globals.py @@ -45,10 +45,23 @@ class Globals(FiltersOptions): Currently known are FR1 to FR5 """ self.solder_mask_color = 'green' """ Color for the solder mask. Currently used for documentation and to choose default colors. + KiCad 6: you should set this in the Board Setup -> Physical Stackup. Currently known are green, black, white, yellow, purple, blue and red """ + self.solder_mask_color_top = '' + """ Color for the top solder mask. When not defined `solder_mask_color` is used. + Read `solder_mask_color` help """ + self.solder_mask_color_bottom = '' + """ Color for the bottom solder mask. When not defined `solder_mask_color` is used. + Read `solder_mask_color` help """ self.silk_screen_color = 'white' """ Color for the markings. Currently used for documentation and to choose default colors. Currently known are black and white """ + self.silk_screen_color_top = '' + """ Color for the top silk screen. When not defined `silk_screen_color` is used. + Read `silk_screen_color` help """ + self.silk_screen_color_bottom = '' + """ Color for the bottom silk screen. When not defined `silk_screen_color` is used. + Read `silk_screen_color` help """ self.pcb_finish = 'HAL' """ Finishing used to protect pads. Currently used for documentation and to choose default colors. KiCad 6: you should set this in the Board Setup -> Board Finish -> Copper Finish option. @@ -135,6 +148,23 @@ class Globals(FiltersOptions): if GS.global_kiauto_wait_start and int(GS.global_kiauto_wait_start) != GS.global_kiauto_wait_start: GS.global_kiauto_wait_start = int(GS.global_kiauto_wait_start) logger.warning(W_MUSTBEINT+'kiauto_wait_start must be integer, truncating to '+str(GS.global_kiauto_wait_start)) + # - Solder mask + if GS.global_solder_mask_color_top and GS.global_solder_mask_color_bottom: + # Top and bottom defined, use the top as general + GS.global_solder_mask_color = GS.global_solder_mask_color_top + else: + if not GS.global_solder_mask_color_top: + GS.global_solder_mask_color_top = GS.global_solder_mask_color + if not GS.global_solder_mask_color_bottom: + GS.global_solder_mask_color_bottom = GS.global_solder_mask_color + # - Silk screen + if GS.global_silk_screen_color_top and GS.global_silk_screen_color_bottom: + GS.global_silk_screen_color = GS.global_silk_screen_color_top + else: + if not GS.global_silk_screen_color_top: + GS.global_silk_screen_color_top = GS.global_silk_screen_color + if not GS.global_silk_screen_color_bottom: + GS.global_silk_screen_color_bottom = GS.global_silk_screen_color set_filters(self.unparsed) diff --git a/kibot/gs.py b/kibot/gs.py index c92a0fa8..77d73bc8 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -88,7 +88,11 @@ class GS(object): global_time_reformat = None global_pcb_material = None global_solder_mask_color = None + global_solder_mask_color_top = None + global_solder_mask_color_bottom = None global_silk_screen_color = None + global_silk_screen_color_top = None + global_silk_screen_color_bottom = None global_pcb_finish = None global_edge_connector = None global_castellated_pads = None diff --git a/kibot/out_pcbdraw.py b/kibot/out_pcbdraw.py index 9cd5baf4..64fceeb4 100644 --- a/kibot/out_pcbdraw.py +++ b/kibot/out_pcbdraw.py @@ -49,20 +49,28 @@ class PcbDrawStyle(Optionable): def config(self, parent): # Apply global defaults + # PCB Material if GS.global_pcb_material is not None: material = GS.global_pcb_material.lower() for mat, color in PCB_MAT_COLORS.items(): if mat in material: self.clad = "#"+color break - if GS.global_solder_mask_color is not None: - name = GS.global_solder_mask_color.lower() - if name in SOLDER_COLORS: - (self.copper, self.board) = SOLDER_COLORS[name] - if GS.global_silk_screen_color is not None: - name = GS.global_silk_screen_color.lower() - if name in SILK_COLORS: - self.silk = "#"+SILK_COLORS[name] + # Solder mask + if parent.bottom: + name = GS.global_solder_mask_color_bottom or GS.global_solder_mask_color + else: + name = GS.global_solder_mask_color_top or GS.global_solder_mask_color + if name and name.lower() in SOLDER_COLORS: + (self.copper, self.board) = SOLDER_COLORS[name.lower()] + # Silk screen + if parent.bottom: + name = GS.global_silk_screen_color_bottom or GS.global_silk_screen_color + else: + name = GS.global_silk_screen_color_top or GS.global_silk_screen_color + if name and name.lower() in SILK_COLORS: + self.silk = "#"+SILK_COLORS[name.lower()] + # PCB Finish if GS.global_pcb_finish is not None: name = GS.global_pcb_finish.lower() for nm, color in PCB_FINISH_COLORS.items(): @@ -146,6 +154,11 @@ class PcbDrawOptions(VariantOptions): super().__init__() def config(self, parent): + # Pre-parse the bottom option + if 'bottom' in self._tree: + bot = self._tree['bottom'] + if isinstance(bot, bool): + self.bottom = bot super().config(parent) # Libs if isinstance(self.libs, type): diff --git a/kibot/out_render_3d.py b/kibot/out_render_3d.py index 73008662..630c2fde 100644 --- a/kibot/out_render_3d.py +++ b/kibot/out_render_3d.py @@ -85,14 +85,26 @@ class Render3DOptions(Base3DOptions): if mat in material: self.board = "#"+color break - if GS.global_solder_mask_color is not None: - name = GS.global_solder_mask_color.lower() - if name in SOLDER_COLORS: - (_, self.solder_mask) = SOLDER_COLORS[name] - if GS.global_silk_screen_color is not None: - name = GS.global_silk_screen_color.lower() - if name in SILK_COLORS: - self.silk = "#"+SILK_COLORS[name] + # Pre parse the view option + bottom = False + if 'view' in self._tree: + v = self._tree['view'] + bottom = isinstance(v, str) and v == 'bottom' + # Solder mask + if bottom: + name = GS.global_solder_mask_color_bottom or GS.global_solder_mask_color + else: + name = GS.global_solder_mask_color_top or GS.global_solder_mask_color + if name and name.lower() in SOLDER_COLORS: + (_, self.solder_mask) = SOLDER_COLORS[name.lower()] + # Silk screen + if bottom: + name = GS.global_silk_screen_color_bottom or GS.global_silk_screen_color + else: + name = GS.global_silk_screen_color_top or GS.global_silk_screen_color + if name and name.lower() in SILK_COLORS: + self.silk = "#"+SILK_COLORS[name.lower()] + # PCB finish if GS.global_pcb_finish is not None: name = GS.global_pcb_finish.lower() for nm, color in PCB_FINISH_COLORS.items(): diff --git a/kibot/out_report.py b/kibot/out_report.py index ba1834a3..2af2c2a8 100644 --- a/kibot/out_report.py +++ b/kibot/out_report.py @@ -89,6 +89,15 @@ def to_smd_tht(smd, tht): return "NONE" +def to_top_bottom_color(front, bottom): + """ Returns a text indicating the top/bottom colors """ + f = front.strip().lower() + b = bottom.strip().lower() + if f == b: + return front.capitalize() + return "Top: "+front.capitalize()+" / Bottom: "+bottom.capitalize() + + def solve_edge_connector(val): if val == 'no': return '' @@ -475,7 +484,13 @@ class ReportOptions(BaseOptions): def run(self, fname): self.pcb_material = GS.global_pcb_material self.solder_mask_color = GS.global_solder_mask_color + self.solder_mask_color_top = GS.global_solder_mask_color_top + self.solder_mask_color_bottom = GS.global_solder_mask_color_bottom + self.solder_mask_color_text = to_top_bottom_color(GS.global_solder_mask_color_top, GS.global_solder_mask_color_bottom) self.silk_screen_color = GS.global_silk_screen_color + self.silk_screen_color_top = GS.global_silk_screen_color_top + self.silk_screen_color_bottom = GS.global_silk_screen_color_bottom + self.silk_screen_color_text = to_top_bottom_color(GS.global_silk_screen_color_top, GS.global_silk_screen_color_bottom) self.pcb_finish = GS.global_pcb_finish self.edge_connector = solve_edge_connector(GS.global_edge_connector) self.castellated_pads = GS.global_castellated_pads diff --git a/kibot/report_templates/report_full.txt b/kibot/report_templates/report_full.txt index 34951b83..5141eb4c 100644 --- a/kibot/report_templates/report_full.txt +++ b/kibot/report_templates/report_full.txt @@ -7,9 +7,9 @@ Board size: ${bb_w_mm}x${bb_h_mm} mm (${bb_w_in}x${bb_h_in} inches) - Finish: ${pcb_finish} - Layers: ${layers} Solder mask: ${solder_mask} -- Color: ${solder_mask_color} +- Color: ${solder_mask_color_text} Silk screen: ${silk_screen} -- Color: ${silk_screen_color} +- Color: ${silk_screen_color_text} #?edge_connector or castellated_pads or edge_plating Special features: diff --git a/kibot/report_templates/report_simple.txt b/kibot/report_templates/report_simple.txt index 4f2df453..b9354c20 100644 --- a/kibot/report_templates/report_simple.txt +++ b/kibot/report_templates/report_simple.txt @@ -26,11 +26,11 @@ Materials: Solder mask: - ${solder_mask} -- ${solder_mask_color} +- ${solder_mask_color_text} Marking: - ${silk_screen} screen printing -- Silk: ${silk_screen_color} +- Silk: ${silk_screen_color_text} Other markings: - ROHS / UL / Date - Yes if available diff --git a/tests/reference/5_1_6/light_control-report.txt b/tests/reference/5_1_6/light_control-report.txt index 01f61266..a19dbf65 100644 --- a/tests/reference/5_1_6/light_control-report.txt +++ b/tests/reference/5_1_6/light_control-report.txt @@ -7,9 +7,9 @@ Board size: 59.69x48.26 mm (2.35x1.9 inches) - Finish: ENIG - Layers: 4 Solder mask: TOP / BOTTOM -- Color: blue +- Color: Top: Blue / Bottom: Red Silk screen: TOP / BOTTOM -- Color: white +- Color: White # Important sizes diff --git a/tests/reference/5_1_6/light_control-report_simple.txt b/tests/reference/5_1_6/light_control-report_simple.txt index 09c3c177..32cc7c5a 100644 --- a/tests/reference/5_1_6/light_control-report_simple.txt +++ b/tests/reference/5_1_6/light_control-report_simple.txt @@ -18,11 +18,11 @@ Materials: Solder mask: - TOP / BOTTOM -- blue +- Top: Blue / Bottom: Red Marking: - TOP / BOTTOM screen printing -- Silk: white +- Silk: White Other markings: - ROHS / UL / Date - Yes if available diff --git a/tests/reference/6_0_0/light_control-report.txt b/tests/reference/6_0_0/light_control-report.txt index 77aad17a..b0349c24 100644 --- a/tests/reference/6_0_0/light_control-report.txt +++ b/tests/reference/6_0_0/light_control-report.txt @@ -7,9 +7,9 @@ Board size: 59.69x48.26 mm (2.35x1.9 inches) - Finish: ENIG - Layers: 4 Solder mask: TOP / BOTTOM -- Color: blue +- Color: Top: Blue / Bottom: Red Silk screen: TOP / BOTTOM -- Color: white +- Color: White Special features: - Edge connector: yes, bevelled diff --git a/tests/reference/6_0_0/light_control-report_simple.txt b/tests/reference/6_0_0/light_control-report_simple.txt index 151744d5..b294cd1a 100644 --- a/tests/reference/6_0_0/light_control-report_simple.txt +++ b/tests/reference/6_0_0/light_control-report_simple.txt @@ -22,11 +22,11 @@ Materials: Solder mask: - TOP / BOTTOM -- blue +- Top: Blue / Bottom: Red Marking: - TOP / BOTTOM screen printing -- Silk: white +- Silk: White Other markings: - ROHS / UL / Date - Yes if available diff --git a/tests/yaml_samples/report_simple_1.kibot.yaml b/tests/yaml_samples/report_simple_1.kibot.yaml index eb45736c..6d4a8995 100644 --- a/tests/yaml_samples/report_simple_1.kibot.yaml +++ b/tests/yaml_samples/report_simple_1.kibot.yaml @@ -3,7 +3,8 @@ kibot: version: 1 global: - solder_mask_color: blue + solder_mask_color_top: blue + solder_mask_color_bottom: red pcb_finish: ENIG outputs: