Example #1
0
def export_jlcpcb(pcb, schematic):
    pcb_file = os.path.abspath(pcb)

    output_dir = os.path.join(
        electronics_root, 'build',
        os.path.splitext(os.path.basename(pcb_file))[0] + '-jlc')
    file_util.mkdir_p(output_dir)

    with versioned_file(pcb_file):
        command = [
            'kikit',
            'fab',
            'jlcpcb',
        ]
        if schematic is not None:
            schematic_file = os.path.abspath(schematic)
            command += [
                '--assembly',
                '--schematic',
                schematic_file,
            ]
        command += [
            pcb_file,
            output_dir,
        ]
        subprocess.check_call(command)
Example #2
0
def export_schematic(schematic_file, kicad_4):
    # Use absolute path - eeschema handles libraries differently with full path vs filename
    schematic_file = os.path.abspath(schematic_file)
    filename, _ = os.path.splitext(os.path.basename(schematic_file))
    output_dir = os.path.join(electronics_root, 'build')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir, 'export_schematic_screencast.ogv')
    schematic_output_pdf_file = os.path.join(output_dir, filename + '.pdf')
    schematic_output_png_file = os.path.join(output_dir, filename + '.png')

    settings = {
        'PlotFormat': '4',  # PDF
    }
    with patch_config(os.path.expanduser('~/.config/kicad/eeschema'), settings):
        with versioned_file(schematic_file):
            with recorded_xvfb(screencast_output_file, width=WIDTH, height=HEIGHT, colordepth=24):
                with PopenContext(['eeschema', schematic_file], close_fds=True) as eeschema_proc:
                    eeschema_plot_schematic(output_dir, kicad_4)
                    eeschema_proc.terminate()

    logger.info('Rasterize')
    subprocess.check_call([
        'convert',
        '-density', '96',
        schematic_output_pdf_file,
       '-background', 'white',
       '-alpha', 'remove',
       schematic_output_png_file,
   ])
Example #3
0
def export_3d(filename):
    pcb_file = os.path.abspath(filename)
    output_dir = os.path.join(electronics_root, 'build')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir,
                                          'export_3d_screencast.ogv')

    name, _ = os.path.splitext(os.path.basename(pcb_file))
    output_file = os.path.join(output_dir, f'{name}-3d.png')

    settings = {
        'canvas_type': '1',
        'SMaskColor_Red': '0.1',
        'SMaskColor_Green': '0.1',
        'SMaskColor_Blue': '0.1',
        'RenderEngine': '1',
        'Render_RAY_ProceduralTextures': '0',
    }
    with patch_config(os.path.expanduser('~/.config/kicad/pcbnew'), settings):
        with versioned_file(pcb_file):
            with recorded_xvfb(screencast_output_file,
                               width=WIDTH,
                               height=HEIGHT,
                               colordepth=24):
                with PopenContext(['pcbnew', pcb_file],
                                  close_fds=True) as pcbnew_proc:
                    _pcbnew_export_3d(output_file)
                    pcbnew_proc.terminate()
Example #4
0
def export_jlcpcb(schematic, pcb):
    schematic_file = os.path.abspath(schematic)
    pcb_file = os.path.abspath(pcb)

    output_dir = os.path.join(electronics_root, 'build', 'jlc')
    file_util.mkdir_p(output_dir)

    with versioned_file(pcb_file):
        subprocess.check_call([
            'kikit',
            'fab',
            'jlcpcb',
            '--assembly',
            '--schematic',
            schematic_file,
            pcb_file,
            output_dir,
        ])