5 Commits

Author SHA1 Message Date
62907b10c7 get removed egg 2026-01-23 14:42:26 +13:00
903b09e8ca updated readme slightly it still needs work 2026-01-23 14:42:11 +13:00
91e6ed00c2 added a temp dir 2026-01-23 14:41:48 +13:00
56c30b7241 hooks setup script 2026-01-23 14:41:24 +13:00
c4010680b8 kicad cli hook 2026-01-23 14:41:04 +13:00
21 changed files with 2073 additions and 19313 deletions

41
.github/rename.py vendored
View File

@@ -1,41 +0,0 @@
from pathlib import Path
import os
import sys
from ruamel.yaml import YAML
# renames the main project in the template dir and in the project settings
def rename_project(project_name, new_name = "template"):
"""renames the kicad project"""
project_path = str(Path(f"Hardware/{project_name}_PROJECT"))
files = os.listdir(project_path)
for index, file in enumerate(files):
print(file)
os.rename(os.path.join(project_path, file), os.path.join(project_path, file.replace(project_name, new_name)))
os.rename(project_path, project_path.replace(project_name, new_name))
pcb_path = str(Path(f"Hardware/{project_name}_PCB"))
os.rename(pcb_path, pcb_path.replace(project_name, new_name))
doc_path = str(Path(f"Hardware/{project_name}_DOCS"))
os.rename(doc_path, doc_path.replace(project_name, new_name))
def main():
yaml : YAML = YAML()
with open(Path("project_settings.yaml"), "r") as yaml_file:
settings = yaml.load(yaml_file)
print(f"{settings['project_name']=}")
print(f"{settings=}")
rename_project(settings["project_name"], sys.argv[1])
settings["project_name"] = sys.argv[1]
settings["needs_setup"] = False
# have to just print it out a rewrite over .project_settings because this guy
# is dumb and doesnt just let you write these out to string
with open(Path("project_settings.yaml"), "w", encoding=("utf-8")) as file:
yaml.dump(settings, file)
if __name__ == "__main__":
main()

View File

@@ -1,46 +0,0 @@
# look it would be piss easy to just keep it as a CSV but we can post process to add cool things like cost to each of the parts
import csv
import sys
import chevron
import datetime
from pprint import pprint
file_path_delimter = "\\" if sys.platform == "win32" else "/"
def load_bom(filename : str) -> dict:
out_dict = {
"parts" : [],
"time" : str(datetime.datetime.now().time()),
"date" : str(datetime.datetime.now().date().strftime("%d-%m-%Y")),
"total_cost" : 0,
"total_parts" : 0,
"project_name" : filename.strip(".csv").strip("bom").split(file_path_delimter)[-1]
}
with open(filename, "r") as csv_file:
for row in csv.DictReader(csv_file):
part_cost = 0
out_dict["total_parts"] += 1
out_dict["parts"].append(
{
"Reference" : row["Refs"],
"Value" : row["Value"],
"Quantity" : row["Qty"],
"part_number" : row["Footprint"],
"cost" : part_cost, # add some API call somewhere here
}
)
return out_dict
def main():
report_hash = load_bom(sys.argv[1])
# pprint(report_hash)
with open(sys.argv[2], "r") as txt:
out = chevron.render(txt.read(), report_hash)
with open(sys.argv[3], "w") as md:
md.write(out)
if __name__ == "__main__":
main()

View File

@@ -1,57 +0,0 @@
from violation import Violation
import datetime
import json
from pprint import pprint
def process_violation_list(drc_json : dict, list_name : str) -> None:
if list_name in drc_json.keys():
unconnected_items_errors = []
unconnected_items_warns = []
number_of_errors = 0
number_of_warns = 0
for violation in drc_json[list_name]:
v = Violation(violation, "drc")
if (v.violation_type == "error"):
unconnected_items_errors.append(v)
number_of_errors += 1
if (v.violation_type == "warn"):
unconnected_items_warns.append(v)
number_of_warns += 1
drc_json[list_name] = {
"errors" : unconnected_items_errors,
"warns" : unconnected_items_warns,
"number_of_errors" : number_of_errors,
"number_of_warns" : number_of_warns,
}
else:
drc_json.setdefault(list_name, {})
drc_json[list_name].setdefault("number_of_errors", 0)
drc_json[list_name].setdefault("number_of_warns", 0)
def process_report(report : str) -> dict:
out_dict : dict = json.loads(report)
number_of_errors = 0;
number_of_errors = 0;
process_violation_list(out_dict, "unconnected_items")
process_violation_list(out_dict, "violations")
process_violation_list(out_dict, "schematic_parity")
out_dict.setdefault(
"total_errors",
out_dict["unconnected_items"]["number_of_errors"] +
out_dict["violations"]["number_of_errors"] +
out_dict["schematic_parity"]["number_of_errors"]
)
out_dict.setdefault(
"total_warns",
out_dict["unconnected_items"]["number_of_warns"] +
out_dict["violations"]["number_of_warns"] +
out_dict["schematic_parity"]["number_of_warns"]
)
return out_dict

View File

@@ -1,53 +0,0 @@
from violation import Violation
import datetime
import json
class Sheet:
def __init__(self, json_obj : dict) -> None:
self.name : str = json_obj["path"]
self.name_md : str = self.name.replace(" ", "-")
self.number_of_errors : int = 0
self.number_of_warns : int = 0
self.errors : list[Violation] = list()
self.warns : list[Violation] = list()
for violation in json_obj["violations"]:
v = Violation(violation, "erc")
if (v.violation_type == "error"):
self.errors.append(v)
self.number_of_errors += 1
if (v.violation_type == "warn"):
self.warns.append(v)
self.number_of_warns += 1
def to_dict(self) -> dict:
out_dict = self.__dict__
errors_strings = []
warns_strings = []
for error in out_dict["errors"]:
errors_strings.append(error.__dict__)
out_dict["errors"] = errors_strings
for warn in out_dict["warns"]:
warns_strings.append(warn.__dict__)
out_dict["warns"] = warns_strings
return out_dict
def process_report(report : str) -> dict:
out_dict : dict = json.loads(report)
sheets = [Sheet(sheet) for sheet in out_dict["sheets"]]
out_dict["sheets"] = [sheet.to_dict() for sheet in sheets]
out_dict.setdefault(
"total_errors",
sum(sheet.number_of_errors for sheet in sheets)
)
out_dict.setdefault(
"total_warns",
sum(sheet.number_of_warns for sheet in sheets)
)
return out_dict

View File

@@ -1,50 +0,0 @@
# usage: python process_json_reports.py report.json template.mustache outfile.md project_name
import chevron
import sys
import datetime
import json
import process_erc_json
import process_drc_json
from pprint import pprint
def load_report(filename : str, project_name : str) -> dict:
out_dict : dict = {}
with open(filename, "r") as js:
if ("erc" in filename.lower()):
out_dict = process_erc_json.process_report(js.read())
if ("drc" in filename.lower()):
out_dict = process_drc_json.process_report(js.read())
out_dict.setdefault(
"time",
str(datetime.datetime.now().time())
)
out_dict.setdefault(
"date",
str(datetime.datetime.now().date().strftime("%d-%m-%Y"))
)
out_dict.setdefault(
"project_name",
project_name
)
out_dict.setdefault(
"has_violations",
True if out_dict["total_warns"] + out_dict["total_errors"] else None
)
return out_dict
def main():
report_hash = load_report(sys.argv[1], sys.argv[4])
# pprint(report_hash)
with open(sys.argv[2], "r") as txt:
out = chevron.render(txt.read(), report_hash)
with open(sys.argv[3], "w") as md:
md.write(out)
if __name__ == "__main__":
main()

View File

@@ -1,94 +0,0 @@
import chevron
import sys
import datetime
import json
import glob
from pathlib import Path
from pprint import pprint
# erc
# {
# "project_name" : "string",
# "passing_erc" : "bool",
# "erc_summary_link" : "link",
# }
# drc
# {
# "project_name" : "string",
# "passing_drc" : "bool",
# "drc_summary_link" : "link",
# }
# project
# {
# "project_name" : "string",
# "project_link" : "link",
# "schematic_link" : "link",
# "gerber_link" : "link",
# "bom_report_link" : "link",
# "bom_csv_link" : "link"
# }
EXTRAS_FILENAME = "readme_extras.json"
def load_json_file(filename : str) -> dict:
with open(Path(f"{filename}/{filename}"), "r") as js:
return json.loads(js.read())
def create_hash(filenames : list[str]) -> dict:
report_outs = filenames
report_outs.remove("readme_extras.json")
extras = {}
with open("readme_extras.json", "r") as js:
extras = json.loads(js.read())
reports_dicts : list[dict] = []
for report_name in report_outs:
reports_dicts.append(load_json_file(report_name))
readme_hash = {
**extras,
"projects" : [],
"did_error" : False,
"multiple_projects" : None
}
for report in reports_dicts:
for project in readme_hash["projects"]:
if project["project_name"] == report["project_name"]:
for key in report.keys():
project.setdefault(key, report[key])
break
else:
readme_hash["projects"].append(report)
pprint(readme_hash)
for project in readme_hash["projects"]:
readme_hash["did_error"] |= not project["passing_erc"]
readme_hash["did_error"] |= not project["passing_drc"]
project.setdefault("passing_erc_emoji", "" if project["passing_erc"] == "true" else "")
project.setdefault("passing_drc_emoji", "" if project["passing_drc"] == "true" else "")
readme_hash["multiple_projects"] = True if len(readme_hash["projects"]) > 1 else None
pprint(readme_hash)
return readme_hash
def main():
print(sys.argv)
readme_template, *args = sys.argv[1:]
report_hash = create_hash(args)
with open(readme_template, "r") as txt:
out = chevron.render(txt.read(), report_hash)
with open("README.md", "w") as md:
md.write(out)
if __name__ == "__main__":
main()

View File

@@ -1,3 +0,0 @@
chevron
pathlib
ruamel.yaml

View File

@@ -1,18 +0,0 @@
class Violation:
def __init__(self, violation : dict, violation_report_type : str = ["erc", "drc"]) -> None:
self.violation_type : str = \
"warn" if violation["severity"] == "warning" else "error"
self.name : str = violation["description"]
self.content : str = ""
# this violation_report_type purely exists because of a bug
# in kicads json output format where json output on erc reports
# the position in decimeters
for item in violation["items"]:
item_string = item["description"]
x : float = float(item["pos"]["x"]) * (100.0 if (violation_report_type == "erc") else 1.0)
y : float = float(item["pos"]["y"]) * (100.0 if (violation_report_type == "erc") else 1.0)
# print(f"{x=}")
item_string += f" at [x = {x:.4}mm, y = {y:.4}mm]\n"
self.content += item_string

View File

@@ -1,29 +0,0 @@
{{! hash schema }}
{{! {
"project_name" : "the name of the project",
"time" : "the name of the project",
"date" : "the name of the project",
"total_parts" : "number",
"total_cost" : "number",
"parts" : [
{
"Reference" : "part_reference" ,
"Value" : "the value of the part" ,
"Quantity" : "number" ,
"part_number" : "the part number" ,
"cost" : "number"
}
]
} }}
# 📄 BOM for {{project_name}} 📄
report created at {{time}} on {{date}}.
{{project_name}} has a total of {{total_parts}} parts with a cost of ${{total_cost}}.
| Reference | Value | Quantity | part number | cost |
| --------- | ----- | -------- | ----------- | ---- |
{{#parts}}
| {{Reference}} | {{Value}} | {{Quantity}} | {{part_number}} | ${{cost}} |
{{/parts}}
| | total | {{total_parts}} | total | ${{total_cost}} |

View File

@@ -1,133 +0,0 @@
{{! hash schema }}
{{! {
"date" : "the date of creation",
"time" : "the time of creation",
"total_warns" : "number",
"total_errors" : "number",
"has_violations" : "flag to say if the project has a violation",
"violations" : {
"number_of_errors" : "number",
"number_of_warns" : "number",
"warns" : [
{
"name" : "string",
"content" : "string"
}
],
"errors" : [
{
"name" : "string",
"content" : "string"
}
]
},
"unconnected_items" : {
"number_of_errors" : "number",
"number_of_warns" : "number",
"warns" : [
{
"name" : "string",
"content" : "string"
}
],
"errors" : [
{
"name" : "string",
"content" : "string"
}
]
},
"schematic_parity" :{
"number_of_errors" : "number",
"number_of_warns" : "number",
"warns" : [
{
"name" : "string",
"content" : "string"
}
],
"errors" : [
{
"name" : "string",
"content" : "string"
}
]
}
} }}
# 📟 {{project_name}} DRC report 📟
report created at {{time}} 🕧 on {{date}} 🗓️.
the design rule check found:
- {{total_errors}} errors in your design 😱
- {{total_warns}} warns in your design 🫨
{{#has_violations}}
number of errors and warns breakdown per sheet:
| error type | number of errors 🔴 | number of warns 🟠 |
| ----------------------------------------- | -------------------------------------- | ------------------------------------- |
| [violations](#violations) ❌ | {{violations.number_of_errors}} | {{violations.number_of_warns}} |
| [unconnected items](#unconnected-items) ⛓️‍💥| {{unconnected_items.number_of_errors}} | {{unconnected_items.number_of_warns}} |
| [schematic parity](#schematic-parity) 🔗 | {{schematic_parity.number_of_errors}} | {{schematic_parity.number_of_warns}} |
| total | {{total_errors}} | {{total_warns}} |
below is a more in-depth breakdown of the errors and warns per error type.
note you should only use this for quickly checking that the project
you uploaded has no error or warn. YOU SHOULD *NOT* use this to actually
run the drc in kicad so you can see where is erroring.
# violations
## errors : {{violations.number_of_errors}}
{{#violations.errors}}
### {{name}}
{{content}}
{{loction}}
{{/violations.errors}}
## warns : {{violations.number_of_warns}}
{{#violations.warns}}
### {{name}}
{{content}}
{{loction}}
{{/violations.warns}}
# unconnected items
## errors : {{unconnected_items.number_of_errors}}
{{#unconnected_items.errors}}
### {{name}}
{{content}}
{{loction}}
{{/unconnected_items.errors}}
## warns : {{unconnected_items.number_of_warns}}
{{#unconnected_items.warns}}
### {{name}}
{{content}}
{{loction}}
{{/unconnected_items.warns}}
# schematic parity
## errors : {{schematic_parity.number_of_errors}}
{{#schematic_parity.errors}}
### {{name}}
{{content}}
{{loction}}
{{/schematic_parity.errors}}
## warns : {{schematic_parity.number_of_warns}}
{{#schematic_parity.warns}}
### {{name}}
{{content}}
{{loction}}
{{/schematic_parity.warns}}
{{/has_violations}}
{{^has_violations}}
the design had no errors or warns, good job. ✅✅
{{/has_violations}}

View File

@@ -1,73 +0,0 @@
{{! hash schema }}
{{! {
"date" : "the date of creation",
"time" : "the time of creation",
"total_warns" : "number",
"total_errors" : "number",
"has_violations" : "flag to say if the project has a violation",
"sheets" : [
{
"name" : "string",
"name_md" : "just name but i replaced the spaces with hyphens",
"number_of_errors" : "number",
"number_of_warns" : "number",
"warns" : [
{
"name" : "string",
"content" : "string"
}
],
"errors" : [
{
"name" : "string",
"content" : "string"
}
]
}
]
} }}
# ⚡{{project_name}} ERC report ⚡
report created at {{time}} 🕧 on {{date}} 🗓️.
the electronic rules check found:
- {{total_errors}} errors in your design 😱
- {{total_warns}} warns in your design 🫨
{{#has_violations}}
number of errors and warns breakdown per sheet:
| sheet name 📄| number of errors 🔴 | number of warns 🟠 |
| ---------- | ---------------- | --------------- |
{{#sheets}}
| [{{name}}](#{{name_md}}) | {{number_of_errors}} | {{number_of_warns}} |
{{/sheets}}
| total | {{total_errors}}| {{total_warns}}|
below is a more in-depth breakdown of the errors and warn per sheets.
note you should only use this for quickly checking that the project
you uploaded has no error or warn. YOU SHOULD *NOT* use this to actually
run your ERC in kicad so you can see where is erroring.
{{#sheets}}
# {{name}}
## errors : {{number_of_errors}}
{{#errors}}
### {{name}}
{{content}}
{{/errors}}
## warns : {{number_of_warns}}
{{#warns}}
### {{name}}
{{content}}
{{/warns}}
{{/sheets}}
{{/has_violations}}
{{^has_violations}}
the design had no errors or warns, good job. ✅✅
{{/has_violations}}

View File

@@ -1,5 +0,0 @@
# how the templates work
templates work by using a json file to fill in the templating spots. for more information on the templates checkout [mustache templates](https://mustache.github.io/). these templates use a json file format as what they call a "hash" to fill out the templates. the hashs for each of these templates are layout at the top of each of the `.mustache` files in a comment. These are also the hashes outputted by the processing scripts. usages for these scripts are at the top of the file.
if any schema says bool this actually means the value is either something or either doesnt exist/null.

View File

@@ -1,153 +0,0 @@
{{! hash schema }}
{{! {
"badge" : "the ci badge",
"lastest_action_run_link" : "link to the lastest action",
"did_error" : "to check if errors occured in the pipeline",
"title" : "the tiltle of the project, can be set in project_settings or it will use the repo name",
"multiple_projects" : "bool",
"projects" : [
{
"project_name" : "string",
"project_link" : "link",
"passing_erc" : "bool",
"passing_erc_emoji" : "string",
"erc_summary_link" : "link",
"passing_drc" : "bool",
"passing_drc_emoji" : "string",
"drc_summary_link" : "link",
"gerber_link" : "link",
"schematic_link" : "link",
"bom_report_link" : "link",
"bom_csv_link" : "link"
}
]
} }}
# kicad project {{title}}
{{badge}}
{{! [![.github/workflows/main.yaml](https://github.com/sirlilpanda/kicad-project-template/actions/workflows/main.yaml/badge.svg)](https://github.com/sirlilpanda/kicad-project-template/actions/workflows/main.yaml) }}
a cool table showing the workflow of all the kicad projects.
| project_name | DRC | ERC |
| ------------ | --- | --- |
{{#projects}}
| {{project_name}} | [{{passing_erc_emoji}}]({{erc_summary_link}})| [{{passing_drc_emoji}}]({{drc_summary_link}}) |
{{/projects}}
for a quick guide check [project setup](#project-setup)
This is a simple project template for new kicad projects. This template has some basic setup already completed such as workflows for auto creating all the things you forget when creating a kicad project such as:
{{^multiple_projects}}
{{#projects}}
- [gerbers]({{gerber_link}})
- [bom]({{bom_report_link}})
- [schematic pdf]({{schematic_link}})
{{/projects}}
{{/multiple_projects}}
{{#multiple_projects}}
| project_name | schematic | bom | bom report | gerbers |
| ------------ | --------- | --- | ---------- | ------- |
{{#projects}}
| [{{project_name}}]({{project_link}}) | [{{project_name}}_schematic.pdf]({{schematic_link}}) | [{{project_name}}_bill_of_materials.csv]({{bom_csv_link}}) | [{{project_name}}_bom_report.md]({{bom_report_link}}) | [{{project_name}}_grbr.zip]({{gerber_link}}) |
{{/projects}}
{{/multiple_projects}}
This workflow will also run the design rules check on the PCB and schematic to ensure that you upload a working PCB. These reports are uploaded as summaries within the github [actions tab]({{lastest_action_run_link}}). This template has a simple schematic PCB in it (because DRC fails on an empty PCB). Shown below is the example PCB.
![example pcb with battery diode and resistor](res/image.png)
besides from that the project also has:
- common predefined trace widths
- smallest vias size [JLCPBC allows](https://jlcpcb.com/capabilities/Capabilities#Drilling)
- custom net colours in the schematic editor
- `red` for +V
- `blue` for -V
- `grey` for ground
to create a repo from this template follow this [guide](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)
contained in this template are:
---
- `.github/` : all files relating to github actions and other admin see [here](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions) for more example of what can be placed in it
- `report_processing` : where the python scripts are stored for processing the json report data from kicad
- `report_templates` : where the template for said reports are stored
- `workflows/` : this is where the github actions are kept
- `main.yaml` : the main github action that will auto generate all files required and run DRC and ERC
- `rename.py` : the script for renaming the project
- `hardware/` : this is where the kicad projects live note this can be changed
- `docs/` : this is where the generate docs are placed by default
- `BOM/` : where the bill of materials and price breakdown are kept
- `bill_of_materials.csv`: the auto generated bom for the kicad project
- `bom_report.md` : a report for the bill of materials
- `template_schematic.pdf` : the schematic for the kicad project, auto generated by the github action
- `pcbs/` : this is where the auto generated gerbers for the kicad project are stored
- `res/` : where resources are stored for the README
- `.gitignore`: a slightly modified gitignore from the [standard one](https://github.com/github/gitignore/blob/main/KiCad.gitignore)
- `project_settings.yaml` : where the settings for this project is stored
- `README.md` : this file, suggest you change this one creating your project
## project settings
there are currently very few project settings that can be changed (will will be change in the future) these are:
| setting | description |
| --------------------------- | ----------------------------------------------------------------- |
| has_been_set_up | a flag to tell the setup action if the project has been set up |
| project_name | the name of the project, this will be set to the name of the repo |
| production_formats | the output production format for the PCBs |
| dynamic_read_me | allow the readme to be updated using the given template |
| bom_template_path | the template used to write the bom report files |
| erc_report_template_path | the template used to write the erc report files |
| drc_report_template_path | the template used to write the drc report files |
| readme_template_path | the template used to write projects readme |
| schematic_output_name | the name suffix of the generated schematics |
| bom_csv_output_name | the name suffix of the generated bom csv file |
| bom_report_output_name | the name suffix of the generated bom report |
| production_file_output_name | the name suffix of the generated production file |
| schematic_output_path | the output path of the generated schematics files |
| bom_csv_output_path | the output path of the generated bom csv file |
| bom_report_output_path | the output path of the generated bom report |
| production_file_output_path | the output path of the generated production file |
## project setup
### creating a new repo with the template
creating a new template from a repo is simple:
1. click on the button in the top right hand corner called `use this template`
![alt text](res/image-5.png)
2. when the drop down menu appears click on `create a new repository`
![alt text](res/image-6.png)
3. once you click you will be brought to this page, note that the repo name you choose here will be the name that you kicad project is called.
![alt text](res/image-7.png)
after these steps you then need to configure the repo settings to do their magic see [configuring repo settings](#configuring-repo-settings) for what to do next.
### configuring repo settings
once you have created a new repo with the template, you ill have to configure the github action settings. this is because you will get an error that looks something along these lines:
![alt text](res/image-4.png)
where the action can not commit the changes due to not having permissions follow these steps:
1. open the repo setting
![alt text](res/image-1.png)
2. then head in to actions : General
![alt text](res/image-2.png)
3. then scroll down to workflow permissions and ensure that both
`Read and write permissions` and `Allow GitHub Actions to create and approve pull requests` are ticked as seen below
![alt text](res/image-3.png)
this should fix the problem if not, go harass stack overflow they need it
Once all of these steps have been followed the workflow should be passing, however the `README.md` will only update on the next push request.
## editing the readme
As this repo can and will automatically update the repo corresponding to the given readme template. If you dont want to use this you can always disable this by setting the `dynamic_read_me` to `false`. but if you want some very cool features like auto updating tables to show what projects are passing the rules check or simple links to parts of your directory. then have a look at the template readme and learn [mustache](https://mustache.github.io/)
## improvements

View File

@@ -1,539 +0,0 @@
on:
push:
branches: [main, master, workflow_testing]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
ERC_JOB_NAME : "⚡ERC report⚡"
DRC_JOB_NAME : "📟 DRC report 📟"
jobs:
setup_new_project: # this job only exists for project creation
runs-on: ubuntu-latest
name: set up project
steps:
- name: Checkout
uses: actions/checkout@v4
# reads the project_setting.yaml file allowing you to access it with steps.id.outputs.[key]
- name: read yaml file
uses: juliojimenez/yamler@v1.1.0
id: yaml
with:
yaml-file: ${{ github.workspace }}/project_settings.yaml
- name: check setup
run: |
echo ${{steps.yaml.outputs.needs_setup}}
- name: Setting up Python and chevron to processes failed reports
# workflows really need some more work done on them
if: ${{ !cancelled() && steps.yaml.outputs.needs_setup == 'true' && github.repository != 'sirlilpanda/kicad-project-template'}}
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: installing requirements
if: ${{ !cancelled() && steps.yaml.outputs.needs_setup == 'true' && github.repository != 'sirlilpanda/kicad-project-template'}}
run: pip install -r ${{ github.workspace }}/.github/report_processing/requirements.txt
- name: rename project if setup has not been completed
if: ${{ !cancelled() && steps.yaml.outputs.needs_setup == 'true' && github.repository != 'sirlilpanda/kicad-project-template'}}
run: python ${{ github.workspace }}/.github/rename.py ${{github.event.repository.name}}
- name: commit production files
if: ${{ !cancelled() && steps.yaml.outputs.needs_setup == 'true' && github.repository != 'sirlilpanda/kicad-project-template'}}
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'setup project'
push: true
add: "."
setup_matrixs:
outputs:
projects: ${{ steps.projects.outputs.projects }}
runs-on: ubuntu-latest
name: matrix setup 🗓️
needs: setup_new_project
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setting up Python
# workflows really need some more work done on them
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: installing requirements
run: pip install pyyaml
- name: creating list start
run:
echo -n "projects=[" >> temp.txt
# this find commad outputs path1,path2,path3 with out the .kicad_pro ext
# .kicad_pro ext is removed because the erc and drc steps want either a
# .kicad_sch or .kicad_pcb file it also makes it easier to name files
# with the project name
# this output will look like
# projects=["path/projet_name", "path/projet_name2", ...]
- name: get kicad project names
run:
find . -type f -name "*.kicad_pro" -exec sh -c 'echo -n "\"${0%.kicad_pro}\","' {} \; | sed 's/.\{1\}$//' >> temp.txt
- name: creating list end
run:
echo "]" >> temp.txt
- name: list output
run:
cat temp.txt
- name: creating list end
id: projects
run:
cat temp.txt >> "$GITHUB_OUTPUT"
# basename is used here to remove the rest of the path from the find
#
DRC:
runs-on: ubuntu-latest
name: "📟 DRC report 📟"
needs: setup_matrixs
strategy:
matrix:
project_path: ${{ fromJSON(needs.setup_matrixs.outputs.projects) }}
steps:
- name: check matrix
run: basename ${{ matrix.project_path }}
- name: setting env
run:
echo "PROJECT_NAME=$(basename ${{ matrix.project_path }})" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: read-yaml-file
uses: juliojimenez/yamler@v1.1.0
id: yaml
with:
yaml-file: ${{ github.workspace }}/project_settings.yaml
- name: Setting up Python and chevron to processes reports
# workflows really need some more work done on them
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: installing requirements
run: pip install -r ${{ github.workspace }}/.github/report_processing/requirements.txt
- name: Run KiCad DRC
id: drc
uses: sparkengineering/kicad-action@v4
with:
kicad_pcb: ${{ matrix.project_path }}.kicad_pcb
pcb_drc: true
report_format: json
pcb_drc_file: drc.json
- name: checking files were created
run:
ls -R
- name: creating DRC report in markdown
if: ${{ always() }}
run: python
${{ github.workspace }}/.github/report_processing/process_json_reports.py
${{ github.workspace }}/$(dirname ${{matrix.project_path}})/drc.json
${{ github.workspace }}/${{steps.yaml.outputs.drc_report_template_path}}
${{ github.workspace }}/${{ env.PROJECT_NAME }}_drc.md
${{ env.PROJECT_NAME }}
- name: upload report summary
if: ${{ always() }}
run: cat ${{ github.workspace }}/${{ env.PROJECT_NAME }}_drc.md >> $GITHUB_STEP_SUMMARY
- name: get summary url
if: ${{always()}}
id: exp
uses: pl-strflt/job-summary-url-action@v1
with:
job: "${{env.DRC_JOB_NAME}} (${{matrix.project_path}})"
- name: create files to upload
if: ${{always()}}
run: |
echo "{\"passing_drc\":\"${{steps.drc.conclusion != 'failure'}}\",\"project_name\":\"${{env.PROJECT_NAME}}\", \"drc_summary_link\":\"${{ steps.exp.outputs.job_summary_url }}\"}" >> ${{env.PROJECT_NAME}}_drc.json
- name: upload data for readme updating
if: ${{always()}}
uses: actions/upload-artifact@v4
with:
name: ${{env.PROJECT_NAME}}_drc.json
path: ${{env.PROJECT_NAME}}_drc.json
ERC:
runs-on: ubuntu-latest
name: "⚡ERC report⚡"
needs: setup_matrixs
strategy:
matrix:
project_path: ${{ fromJSON(needs.setup_matrixs.outputs.projects) }}
steps:
- name: check matrix
run: basename ${{ matrix.project_path }}
- name: setting env
run:
echo "PROJECT_NAME=$(basename ${{ matrix.project_path }})" >> $GITHUB_ENV
- name: setting env
run:
echo "PROJECT_NAME=$(basename ${{ matrix.project_path }})" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: read-yaml-file
uses: juliojimenez/yamler@v1.1.0
id: yaml
with:
yaml-file: ${{ github.workspace }}/project_settings.yaml
- name: Setting up Python and chevron to processes reports
# workflows really need some more work done on them
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: installing requirements
run: pip install -r ${{ github.workspace }}/.github/report_processing/requirements.txt
- name: Run KiCad ERC
id: erc
uses: sparkengineering/kicad-action@v4
with:
kicad_sch: ${{ matrix.project_path }}.kicad_sch
sch_erc: true
report_format: json
sch_erc_file: erc.json
- name: checking files were created
run:
ls -R
- name: creating ERC report in markdown
if: ${{ always() }}
run: python
${{ github.workspace }}/.github/report_processing/process_json_reports.py
${{ github.workspace }}/$(dirname ${{matrix.project_path}})/erc.json
${{ github.workspace }}/${{steps.yaml.outputs.erc_report_template_path}}
${{ github.workspace }}/${{ env.PROJECT_NAME }}_erc.md
${{ env.PROJECT_NAME }}
- name: upload report summary
if: ${{ always() }}
run: cat ${{ github.workspace }}/${{ env.PROJECT_NAME }}_erc.md >> $GITHUB_STEP_SUMMARY
- name: get summary url
if: ${{always()}}
id: exp
uses: pl-strflt/job-summary-url-action@v1
with:
job: "${{env.ERC_JOB_NAME}} (${{matrix.project_path}})"
- name: print summary url
if: ${{always()}}
run: echo '${{ steps.exp.outputs.job_summary_url }}'
shell: bash
- name: create files to upload
if: ${{always()}}
run: |
echo "{\"passing_erc\":\"${{steps.erc.conclusion != 'failure'}}\",\"project_name\":\"${{env.PROJECT_NAME}}\", \"erc_summary_link\":\"${{ steps.exp.outputs.job_summary_url }}\"}" >> ${{env.PROJECT_NAME}}_erc.json
- name: upload data for readme updating
if: ${{always()}}
uses: actions/upload-artifact@v4
with:
name: ${{env.PROJECT_NAME}}_erc.json
path: ${{env.PROJECT_NAME}}_erc.json
production_job:
runs-on: ubuntu-latest
name: creating production files bom sch gerbers 📂
needs: setup_matrixs
strategy:
matrix:
project_path: ${{ fromJSON(needs.setup_matrixs.outputs.projects) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: read-yaml-file
uses: juliojimenez/yamler@v1.1.0
id: yaml
with:
yaml-file: ${{ github.workspace }}/project_settings.yaml
- name: setting env
run:
echo "PROJECT_NAME=$(basename ${{ matrix.project_path }})" >> $GITHUB_ENV
- name: setting env
run: | # | the / here is defined in the project settings
echo "schematic_file=${{env.PROJECT_NAME}}${{steps.yaml.outputs.schematic_output_name}}.pdf" >> $GITHUB_ENV
echo "bill_of_materials_file=${{env.PROJECT_NAME}}${{steps.yaml.outputs.bom_csv_output_name}}.csv" >> $GITHUB_ENV
echo "production_format_file=${{env.PROJECT_NAME}}${{steps.yaml.outputs.production_file_output_name}}.zip" >> $GITHUB_ENV
echo "bom_report_file=${{env.PROJECT_NAME}}${{steps.yaml.outputs.bom_report_output_name}}.md" >> $GITHUB_ENV
- name: checking envs
run:
echo "${{env.schematic_file}}"
echo "${{env.bill_of_materials_file}}"
echo "${{env.production_format_file}}"
echo "${{env.bom_report_file}}"
- name: setting env
run:
echo "PROJECT_NAME=$(basename ${{ matrix.project_path }})" >> $GITHUB_ENV
- name: setting env
run: | # | the / here is defined in the project settings
echo "schematic_file=${{env.PROJECT_NAME}}${{steps.yaml.outputs.schematic_output_name}}.pdf" >> $GITHUB_ENV
echo "bill_of_materials_file=${{env.PROJECT_NAME}}${{steps.yaml.outputs.bom_csv_output_name}}.csv" >> $GITHUB_ENV
echo "production_format_file=${{env.PROJECT_NAME}}${{steps.yaml.outputs.production_file_output_name}}.zip" >> $GITHUB_ENV
echo "bom_report_file=${{env.PROJECT_NAME}}${{steps.yaml.outputs.bom_report_output_name}}.md" >> $GITHUB_ENV
- name: checking envs
run:
echo "${{env.schematic_file}}"
echo "${{env.bill_of_materials_file}}"
echo "${{env.production_format_file}}"
echo "${{env.bom_report_file}}"
- name: Setting up Python and chevron to processes reports
# workflows really need some more work done on them
if: ${{ !cancelled() }}
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: installing requirements
if: ${{ !cancelled() }}
run: pip install -r ${{ github.workspace }}/.github/report_processing/requirements.txt
- name: Export production files
id: production
uses: sparkengineering/kicad-action@v4
if: '!cancelled()'
with:
kicad_sch: ${{ matrix.project_path }}.kicad_sch
sch_pdf: true # Generate PDF
sch_bom: true # Generate BOM
kicad_pcb: ${{ matrix.project_path }}.kicad_pcb
pcb_gerbers: true # Generate Gerbers
- name: Moving production files to correct location
if: ${{ !cancelled() && steps.production.conclusion == 'success' }}
run: |
mv ${{ github.workspace }}/$(dirname ${{matrix.project_path}})/sch.pdf ${{ github.workspace }}/${{env.schematic_file}}
mv ${{ github.workspace }}/$(dirname ${{matrix.project_path}})/bom.csv ${{ github.workspace }}/${{env.bill_of_materials_file}}
mv ${{ github.workspace }}/$(dirname ${{matrix.project_path}})/gbr.zip ${{ github.workspace }}/${{env.production_format_file}}
- name: creating BOM report in markdown
if: ${{ !cancelled() }}
run: python
${{ github.workspace }}/.github/report_processing/process_bom_files.py
${{ github.workspace }}/${{env.bill_of_materials_file}}
${{ github.workspace }}/${{steps.yaml.outputs.bom_template_path}}
${{ github.workspace }}/${{env.bom_report_file}}
- name: upload report'
uses: actions/upload-artifact@v4
with:
name: production-files-${{env.PROJECT_NAME}}.zip
path: |
${{ github.workspace }}/${{env.schematic_file}}
${{ github.workspace }}/${{env.bill_of_materials_file}}
${{ github.workspace }}/${{env.production_format_file}}
${{ github.workspace }}/${{env.bom_report_file}}
- name: data for readme updating
if: ${{always()}}
run: |
echo "{" >> ${{env.PROJECT_NAME}}_project.json
echo "\"schematic_link\":\"https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/${{env.schematic_file}}\"," >> ${{env.PROJECT_NAME}}_project.json
echo "\"bom_csv_link\":\"https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/${{env.bill_of_materials_file}}\"," >> ${{env.PROJECT_NAME}}_project.json
echo "\"bom_report_link\":\"https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/${{env.bom_report_file}}\"," >> ${{env.PROJECT_NAME}}_project.json
echo "\"gerber_link\":\"https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/${{env.production_format_file}}\"," >> ${{env.PROJECT_NAME}}_project.json
echo "\"project_link\":\"https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}/$(dirname ${{matrix.project_path}})\"," >> ${{env.PROJECT_NAME}}_project.json
echo "\"project_name\":\"${{env.PROJECT_NAME}}\"" >> ${{env.PROJECT_NAME}}_project.json
echo "}" >> ${{env.PROJECT_NAME}}_project.json
- name: upload report
if: ${{always()}}
uses: actions/upload-artifact@v4
with:
name: ${{env.PROJECT_NAME}}_project.json
path: ${{env.PROJECT_NAME}}_project.json
readme_job:
runs-on: ubuntu-latest
name: update readme
if: ${{ always() }}
needs: [DRC, ERC, production_job]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: read-yaml-file
uses: juliojimenez/yamler@v1.1.0
id: yaml
with:
yaml-file: ${{ github.workspace }}/project_settings.yaml
- name: download ercs files
if: ${{ steps.yaml.outputs.dynamic_read_me == 'true' }}
uses: actions/download-artifact@v4
with:
pattern: "*_erc.json"
path: ${{ github.workspace }}
- name: download drcs files
if: ${{ steps.yaml.outputs.dynamic_read_me == 'true' }}
uses: actions/download-artifact@v4
with:
pattern: "*_drc.json"
path: ${{ github.workspace }}
- name: download production json files
if: ${{ steps.yaml.outputs.dynamic_read_me == 'true' }}
uses: actions/download-artifact@v4
with:
pattern: "*_project.json"
path: ${{ github.workspace }}
- name: Setting up Python
if: ${{ steps.yaml.outputs.dynamic_read_me == 'true' }}
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: installing requirements
if: ${{ !cancelled() && steps.yaml.outputs.dynamic_read_me == 'true' }}
run: pip install -r ${{ github.workspace }}/.github/report_processing/requirements.txt
- name: create extra info for readme hash
if: ${{ steps.yaml.outputs.dynamic_read_me == 'true' }}
run: |
echo "{" >> readme_extras.json
echo "\"badge\" : \"[![.github/workflows/main.yaml](https://github.com/${{github.repository}}/actions/workflows/main.yaml/badge.svg?branch=${{github.ref_name}})](https://github.com/${{github.repository}}/actions/workflows/main.yaml)\"," >> readme_extras.json
echo "\"lastest_action_run_link\" : \"https://github.com/${{github.repository}}/actions/runs/${{ github.run_id }}\"," >> readme_extras.json
echo "\"title\" : \"${{steps.yaml.outputs.project_name}}\"" >> readme_extras.json
echo "}" >> readme_extras.json
- name: show extras
run:
cat readme_extras.json
- name: create new readme
if: ${{ steps.yaml.outputs.dynamic_read_me == 'true' }}
run:
python
${{ github.workspace }}/.github/report_processing/process_output_files.py
${{ github.workspace }}/${{steps.yaml.outputs.readme_template_path}} *.json
- name: upload data for readme updating
if: ${{ steps.yaml.outputs.dynamic_read_me == 'true' }}
uses: actions/upload-artifact@v4
with:
name: README.md
path: README.md
- name: list everything
if: ${{always()}}
run: ls -R
upload_job:
runs-on: ubuntu-latest
name: commit production files
if: ${{ always() }}
needs: [readme_job]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: read-yaml-file
uses: juliojimenez/yamler@v1.1.0
id: yaml
with:
yaml-file: ${{ github.workspace }}/project_settings.yaml
- name: download production files
uses: actions/download-artifact@v4
with:
pattern: production-files-*
path: ${{ github.workspace }}
- name: download readme
uses: actions/download-artifact@v4
with:
name: README.md
path: ${{ github.workspace }}
- name: check downloads
run: ls -R
- name: Moving files to correct location
run: |
mv ${{ github.workspace }}/production-files-*/*${{steps.yaml.outputs.schematic_output_name}}.pdf ${{ github.workspace }}/${{steps.yaml.outputs.schematic_output_path}}
mv ${{ github.workspace }}/production-files-*/*${{steps.yaml.outputs.bom_csv_output_name}}.csv ${{ github.workspace }}/${{steps.yaml.outputs.bom_csv_output_path}}
mv ${{ github.workspace }}/production-files-*/*${{steps.yaml.outputs.bom_report_output_name}}.md ${{ github.workspace }}/${{steps.yaml.outputs.bom_report_output_path}}
mv ${{ github.workspace }}/production-files-*/*${{steps.yaml.outputs.production_file_output_name}}.zip ${{ github.workspace }}/${{steps.yaml.outputs.production_file_output_path}}
- name: commit production files
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'production files'
push: true
pull: '--rebase --autostash'
tag_push: '--force' # just makes life easier
tag: 'v1.0.0 --force'
add: |
${{ github.workspace }}/*${{steps.yaml.outputs.schematic_output_name}}.pdf
${{ github.workspace }}/*${{steps.yaml.outputs.bom_csv_output_name}}.csv
${{ github.workspace }}/*${{steps.yaml.outputs.bom_report_output_name}}.md
${{ github.workspace }}/*${{steps.yaml.outputs.production_file_output_name}}.zip
${{ github.workspace }}/README.md
- name: list everything
if: ${{always()}}
run: ls -R

2
.gitignore vendored
View File

@@ -29,3 +29,5 @@ Hardware/*/*.xml
Hardware/*/*.csv Hardware/*/*.csv
__pycache__/ __pycache__/
temp/

216
.hooks/kicad_cli_tools.py Normal file
View File

@@ -0,0 +1,216 @@
# yes we are using json because
# i dont want to install a yaml
# parser on the users computer
import json
import os
import subprocess
import csv
from enum import Enum
from pathlib import Path
from os import listdir
from os.path import isfile, join
KICAD_CLI_PATH = "kicad-cli"
TEMP_FILE_PATH = "docs/"
PCB_IMAGE_OUTPUT_PATH = "res/"
PCB_PDF_OUTPUT_PATH = "docs/"
PCB_PDF_FILE_SUFFIX = "_pcb"
SCHEMATIC_OUTPUT_PATH = "docs/"
SCHEMATIC_FILE_SUFFIX = "_schematic"
BOM_OUTPUT_PATH = "docs/"
BOM_REPORT_NAME = "_bom"
TEMP_DRC_REPORT_NAME = "_drc"
TEMP_ERC_REPORT_NAME = "_erc"
# quiet
KICAD_CLI_STDOUT=subprocess.DEVNULL
# verbose
# KICAD_CLI_STDOUT=subprocess.STDOUT
class OutputReportType(Enum):
JSON = 1
REPORT = 2
def get_file_extension(self) -> str:
if (self == OutputReportType.JSON):
return "json"
if (self == OutputReportType.REPORT):
return "rpt"
return "txt"
# this is a thin vale on the kicad cli tool
class KicadProject:
def __init__(self, path : Path) -> None:
self.project_path = path.parent
self.project_name = path.name.removesuffix(".kicad_pro")
self.created_files : list[Path] = []
print(f"{self.project_path=}")
print(f"{self.project_name=}")
def erc_check(
self,
report_format : OutputReportType = OutputReportType.JSON,
return_report : bool = False
) -> None | dict | str:
format_type = report_format.name.lower()
pcb_file_path = self.project_path / f"{self.project_name}.kicad_sch"
erc_report_path = Path(TEMP_FILE_PATH) / f"{self.project_name}{TEMP_ERC_REPORT_NAME}.{report_format.get_file_extension()}"
retcode = subprocess.call(
f'{KICAD_CLI_PATH} sch erc {pcb_file_path} --output {erc_report_path} --format {format_type}',
shell=True,
stdout=KICAD_CLI_STDOUT
)
if (retcode != 0):
print(f"erc check failed return code {retcode}")
exit(1)
self.created_files.append(erc_report_path)
if (return_report):
with open(erc_report_path, "r") as txt:
if format_type == OutputReportType.JSON:
return json.loads(txt.read())
if format_type == OutputReportType.RPT:
return txt.read()
def drc_check(
self,
report_format : OutputReportType = OutputReportType.JSON,
return_report : bool = False
) -> None | dict | str:
format_type = report_format.name.lower()
pcb_file_path = self.project_path / f"{self.project_name}.kicad_pcb"
drc_report_path = Path(TEMP_FILE_PATH) / f"{self.project_name}{TEMP_DRC_REPORT_NAME}.{report_format.get_file_extension()}"
print(f"{format_type=}, {drc_report_path=}")
retcode = subprocess.call(
f'{KICAD_CLI_PATH} pcb drc {pcb_file_path} --output {drc_report_path} --format {format_type}',
shell=True,
stdout=KICAD_CLI_STDOUT
)
print(f"{retcode=}")
if (retcode != 0):
print(f"drc check failed return code {retcode}")
exit(1)
self.created_files.append(drc_report_path)
if (return_report):
with open(drc_report_path, "r") as txt:
if format_type == OutputReportType.JSON:
return json.loads(txt.read())
if format_type == OutputReportType.RPT:
return txt.read()
def process_bom(
self,
return_csv : bool = False
) -> None | list[list[str]]:
sch_file_path = self.project_path / f"{self.project_name}.kicad_sch"
bom_output_path = Path(BOM_OUTPUT_PATH) / f"{self.project_name}{BOM_REPORT_NAME}.csv"
retcode = subprocess.call(
f'{KICAD_CLI_PATH} sch export bom {sch_file_path} --output {bom_output_path}',
shell=True,
stdout=KICAD_CLI_STDOUT
)
if (retcode != 0):
print(f"process_bom failed return code {retcode}")
exit(1)
self.created_files.append(bom_output_path)
if (return_csv):
with open(bom_output_path, "r") as csvfile:
bom_csv = csv.reader(csvfile, delimiter=',', quotechar='"')
return [row for row in bom_csv]
def get_image(self,
image_type : str = "png",
height : int = 900,
width : int = 1600,
side : str = "top",
background : str = "default",
preset : str = "follow_pcb_editor",
zoom : int = 2,
) -> None:
"""
image_typ = "png" | "jpg"
side = "top" | "bottom" | "left" | "right" | "front" | "back"
background = "default" | "transparent" | "opaque"
"""
pcb_file_path = self.project_path / f"{self.project_name}.kicad_pcb"
render_output_path = Path(PCB_IMAGE_OUTPUT_PATH) / f"{self.project_name}_render.{image_type}"
retcode = subprocess.call(
f'{KICAD_CLI_PATH} pcb render {pcb_file_path} --output {render_output_path} --preset {preset} --zoom {zoom} ',
shell=True,
stdout=KICAD_CLI_STDOUT
)
if (retcode != 0):
print(f"get_image failed return code {retcode}")
exit(1)
self.created_files.append(render_output_path)
# i am not giving you the pdf to output if you want to do that yourself go ahead
def create_schmatic_pdf(self) -> None:
sch_file_path = self.project_path / f"{self.project_name}.kicad_sch"
sch_report_path = Path(SCHEMATIC_OUTPUT_PATH) / f"{self.project_name}{SCHEMATIC_FILE_SUFFIX}.pdf"
retcode = subprocess.call(
f'{KICAD_CLI_PATH} sch export pdf {sch_file_path} --output {sch_report_path}',
shell=True,
stdout=KICAD_CLI_STDOUT
)
if (retcode != 0):
print(f"create_schmatic_pdf failed return code {retcode}")
exit(1)
self.created_files.append(sch_report_path)
def create_pcb_pdf(self, layers : list[str] = ["F.Cu", "B.Cu"]) -> None:
pcb_file_path = self.project_path / f"{self.project_name}.kicad_pcb"
pcb_report_path = Path(PCB_PDF_OUTPUT_PATH) / f"{self.project_name}{PCB_PDF_FILE_SUFFIX}.pdf"
retcode = subprocess.call(
f'{KICAD_CLI_PATH} pcb export pdf {pcb_file_path} --output {pcb_report_path} --layers {",".join(layers)}',
shell=True,
stdout=KICAD_CLI_STDOUT
)
if (retcode != 0):
print(f"create_pcb_pdf failed return code {retcode}")
exit(1)
self.created_files.append(pcb_report_path)
def commit_files(files: list[Path], commit_message : str) -> None:
for file in files:
# add & commit, could use the return code however these should never fail
print(f"adding and commiting {file}")
ret_add = subprocess.call(f"git add {file}", shell=True)
ret_commit = subprocess.call(f"git commit -m \"{commit_message}\"", shell=True)
def main() -> None:
# find all kicad project files to operate on
for path in Path(".").rglob('*.kicad_pro'):
k = KicadProject(path)
k.drc_check(report_format= OutputReportType.REPORT)
k.erc_check(report_format= OutputReportType.REPORT)
k.process_bom()
k.create_schmatic_pdf()
k.get_image()
commit_files(k.created_files, "auto commited")
if __name__ == "__main__":
try:
main()
exit(0)
except Exception as e:
exit(1)

File diff suppressed because it is too large Load Diff

View File

@@ -131,23 +131,6 @@
(embedded_fonts no) (embedded_fonts no)
) )
) )
(text "NOTES:\n\nperipherals share an i2c bus with the usb hub and pd controller since\nsharing the I2C directly with the keyboard could create an security\nproblem with peripherals directly snooping on the keyboard presses"
(exclude_from_sim no)
(at 177.546 171.704 0)
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
(uuid "d3f32ef9-7845-471f-9a2d-347129dd0ced")
)
(junction
(at 119.38 87.63)
(diameter 0)
(color 0 0 0 0)
(uuid "0d62faf3-7ac5-4aa0-a42b-5105bac463e3")
)
(junction (junction
(at 121.92 43.18) (at 121.92 43.18)
(diameter 0) (diameter 0)
@@ -160,12 +143,6 @@
(color 0 0 0 0) (color 0 0 0 0)
(uuid "b5bb2435-e65f-48e0-968d-ab8aaa4b12c3") (uuid "b5bb2435-e65f-48e0-968d-ab8aaa4b12c3")
) )
(junction
(at 121.92 85.09)
(diameter 0)
(color 0 0 0 0)
(uuid "f394cf1f-1263-412d-a551-a6bb389d818f")
)
(wire (wire
(pts (pts
(xy 116.84 90.17) (xy 124.46 90.17) (xy 116.84 90.17) (xy 124.46 90.17)
@@ -178,27 +155,7 @@
) )
(wire (wire
(pts (pts
(xy 156.21 72.39) (xy 156.21 81.28) (xy 158.75 30.48) (xy 171.45 30.48)
)
(stroke
(width 0)
(type default)
)
(uuid "0d4e4247-2d6c-49a1-aa03-b837619937ff")
)
(wire
(pts
(xy 189.23 72.39) (xy 189.23 95.25)
)
(stroke
(width 0)
(type default)
)
(uuid "0eb7122d-5ebb-4a84-9623-2e2f43e86430")
)
(wire
(pts
(xy 160.02 30.48) (xy 186.69 30.48)
) )
(stroke (stroke
(width 0) (width 0)
@@ -206,16 +163,6 @@
) )
(uuid "12dfe020-b936-465c-883a-ec0410085d39") (uuid "12dfe020-b936-465c-883a-ec0410085d39")
) )
(wire
(pts
(xy 152.4 128.27) (xy 152.4 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "210e8cb2-2d78-4c1b-a19f-13b359de2a8a")
)
(wire (wire
(pts (pts
(xy 124.46 30.48) (xy 120.65 30.48) (xy 124.46 30.48) (xy 120.65 30.48)
@@ -238,7 +185,7 @@
) )
(wire (wire
(pts (pts
(xy 160.02 40.64) (xy 186.69 40.64) (xy 158.75 40.64) (xy 171.45 40.64)
) )
(stroke (stroke
(width 0) (width 0)
@@ -258,7 +205,7 @@
) )
(wire (wire
(pts (pts
(xy 160.02 43.18) (xy 186.69 43.18) (xy 158.75 43.18) (xy 171.45 43.18)
) )
(stroke (stroke
(width 0) (width 0)
@@ -268,7 +215,7 @@
) )
(wire (wire
(pts (pts
(xy 160.02 53.34) (xy 186.69 53.34) (xy 158.75 53.34) (xy 171.45 53.34)
) )
(stroke (stroke
(width 0) (width 0)
@@ -286,86 +233,6 @@
) )
(uuid "42478fb0-d963-4a32-9a84-cb8efe8bfe2e") (uuid "42478fb0-d963-4a32-9a84-cb8efe8bfe2e")
) )
(wire
(pts
(xy 157.48 128.27) (xy 157.48 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "4b951d1a-bcdc-4c98-af00-cd1a7e1c678d")
)
(wire
(pts
(xy 134.62 128.27) (xy 134.62 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "54e60b55-b905-48d7-b9d9-f6391da4de8e")
)
(wire
(pts
(xy 175.26 100.33) (xy 194.31 100.33)
)
(stroke
(width 0)
(type default)
)
(uuid "5ce14ed7-0ef0-460d-b339-edbfd7544eb9")
)
(wire
(pts
(xy 137.16 128.27) (xy 137.16 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "60d3ab8a-95df-46f3-bec6-2dc3a187f51f")
)
(wire
(pts
(xy 165.1 128.27) (xy 165.1 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "66deb91d-1258-4901-9787-79d919147d24")
)
(wire
(pts
(xy 124.46 162.56) (xy 119.38 162.56)
)
(stroke
(width 0)
(type default)
)
(uuid "709dbd2e-c9e0-4c1a-a827-db18ba893b19")
)
(wire
(pts
(xy 162.56 128.27) (xy 162.56 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "72d53f33-0421-48ef-a656-5b17938fc538")
)
(wire
(pts
(xy 175.26 97.79) (xy 191.77 97.79)
)
(stroke
(width 0)
(type default)
)
(uuid "74d167ef-beb2-4ab2-b313-7d4f5666b6c9")
)
(wire (wire
(pts (pts
(xy 113.03 33.02) (xy 124.46 33.02) (xy 113.03 33.02) (xy 124.46 33.02)
@@ -386,26 +253,6 @@
) )
(uuid "84d5d859-0e0a-41c9-8fe7-670235a0baa5") (uuid "84d5d859-0e0a-41c9-8fe7-670235a0baa5")
) )
(wire
(pts
(xy 194.31 72.39) (xy 194.31 100.33)
)
(stroke
(width 0)
(type default)
)
(uuid "89507da5-c109-419e-b04c-867ecec5f8f2")
)
(wire
(pts
(xy 119.38 162.56) (xy 119.38 87.63)
)
(stroke
(width 0)
(type default)
)
(uuid "8f7b1c9c-5456-4f3f-82de-e97ddf30dec7")
)
(wire (wire
(pts (pts
(xy 121.92 43.18) (xy 124.46 43.18) (xy 121.92 43.18) (xy 124.46 43.18)
@@ -418,37 +265,7 @@
) )
(wire (wire
(pts (pts
(xy 175.26 95.25) (xy 189.23 95.25) (xy 158.75 35.56) (xy 171.45 35.56)
)
(stroke
(width 0)
(type default)
)
(uuid "93f472b4-2e62-46ef-9668-d05e2d49379b")
)
(wire
(pts
(xy 132.08 128.27) (xy 132.08 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "968c2893-9090-463d-a070-dfaaf9a11cbd")
)
(wire
(pts
(xy 121.92 160.02) (xy 124.46 160.02)
)
(stroke
(width 0)
(type default)
)
(uuid "a04c42e6-a89f-4a72-a1cb-e147d35f3486")
)
(wire
(pts
(xy 160.02 35.56) (xy 186.69 35.56)
) )
(stroke (stroke
(width 0) (width 0)
@@ -456,26 +273,6 @@
) )
(uuid "a082fd9a-da7a-4f37-a009-8d0c237d3f93") (uuid "a082fd9a-da7a-4f37-a009-8d0c237d3f93")
) )
(wire
(pts
(xy 139.7 128.27) (xy 139.7 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "a144d56c-4cb7-4bc7-a782-fcf21e0ebd15")
)
(wire
(pts
(xy 121.92 85.09) (xy 121.92 160.02)
)
(stroke
(width 0)
(type default)
)
(uuid "a2ca66cc-afa5-4acd-96ec-321755f5bbc1")
)
(wire (wire
(pts (pts
(xy 113.03 40.64) (xy 119.38 40.64) (xy 113.03 40.64) (xy 119.38 40.64)
@@ -496,26 +293,6 @@
) )
(uuid "a471c19c-9031-47cd-966d-454a9e2d7e07") (uuid "a471c19c-9031-47cd-966d-454a9e2d7e07")
) )
(wire
(pts
(xy 167.64 128.27) (xy 167.64 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "b7cb2597-c851-431e-aabe-b90623270d1a")
)
(wire
(pts
(xy 154.94 128.27) (xy 154.94 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "b850a76c-dee8-4b43-a05a-77e64f535b96")
)
(wire (wire
(pts (pts
(xy 113.03 43.18) (xy 121.92 43.18) (xy 113.03 43.18) (xy 121.92 43.18)
@@ -536,16 +313,6 @@
) )
(uuid "c4d4554a-6bbb-4d39-813f-db4960d1911a") (uuid "c4d4554a-6bbb-4d39-813f-db4960d1911a")
) )
(wire
(pts
(xy 129.54 128.27) (xy 129.54 139.7)
)
(stroke
(width 0)
(type default)
)
(uuid "c569b18e-08b0-4bbc-bdf2-46a3091e5bbc")
)
(wire (wire
(pts (pts
(xy 119.38 40.64) (xy 124.46 40.64) (xy 119.38 40.64) (xy 124.46 40.64)
@@ -558,7 +325,7 @@
) )
(wire (wire
(pts (pts
(xy 160.02 33.02) (xy 186.69 33.02) (xy 158.75 33.02) (xy 171.45 33.02)
) )
(stroke (stroke
(width 0) (width 0)
@@ -566,16 +333,6 @@
) )
(uuid "cca17029-29df-41e8-b8b6-a75c2d3d8dd9") (uuid "cca17029-29df-41e8-b8b6-a75c2d3d8dd9")
) )
(wire
(pts
(xy 175.26 102.87) (xy 196.85 102.87)
)
(stroke
(width 0)
(type default)
)
(uuid "d2787657-63d6-443c-9b88-bc71feb3e3d7")
)
(wire (wire
(pts (pts
(xy 121.92 43.18) (xy 121.92 85.09) (xy 121.92 43.18) (xy 121.92 85.09)
@@ -588,17 +345,7 @@
) )
(wire (wire
(pts (pts
(xy 153.67 72.39) (xy 153.67 81.28) (xy 158.75 46.99) (xy 171.45 46.99)
)
(stroke
(width 0)
(type default)
)
(uuid "d38ff251-5c54-4427-a365-9edb69009a67")
)
(wire
(pts
(xy 160.02 46.99) (xy 186.69 46.99)
) )
(stroke (stroke
(width 0) (width 0)
@@ -608,7 +355,7 @@
) )
(wire (wire
(pts (pts
(xy 160.02 49.53) (xy 186.69 49.53) (xy 158.75 49.53) (xy 171.45 49.53)
) )
(stroke (stroke
(width 0) (width 0)
@@ -618,7 +365,7 @@
) )
(wire (wire
(pts (pts
(xy 160.02 55.88) (xy 186.69 55.88) (xy 158.75 55.88) (xy 171.45 55.88)
) )
(stroke (stroke
(width 0) (width 0)
@@ -626,26 +373,6 @@
) )
(uuid "dbcd2f88-a6e4-43c3-99ba-2e7915809ced") (uuid "dbcd2f88-a6e4-43c3-99ba-2e7915809ced")
) )
(wire
(pts
(xy 196.85 72.39) (xy 196.85 102.87)
)
(stroke
(width 0)
(type default)
)
(uuid "dbe8b97f-069e-4fd8-a462-005d764e5cd6")
)
(wire
(pts
(xy 191.77 72.39) (xy 191.77 97.79)
)
(stroke
(width 0)
(type default)
)
(uuid "decfcf39-ca20-48cc-b1df-fafbcc7b0af6")
)
(wire (wire
(pts (pts
(xy 113.03 45.72) (xy 116.84 45.72) (xy 113.03 45.72) (xy 116.84 45.72)
@@ -724,7 +451,7 @@
) )
(sheet (sheet
(at 124.46 27.94) (at 124.46 27.94)
(size 35.56 44.45) (size 34.29 44.45)
(exclude_from_sim no) (exclude_from_sim no)
(in_bom yes) (in_bom yes)
(on_board yes) (on_board yes)
@@ -847,7 +574,7 @@
) )
) )
(pin "PWR_USBD2" output (pin "PWR_USBD2" output
(at 160.02 30.48 0) (at 158.75 30.48 0)
(uuid "022ee30e-d7a7-4e0d-9525-243861daec14") (uuid "022ee30e-d7a7-4e0d-9525-243861daec14")
(effects (effects
(font (font
@@ -857,7 +584,7 @@
) )
) )
(pin "PWR_USBD3" output (pin "PWR_USBD3" output
(at 160.02 33.02 0) (at 158.75 33.02 0)
(uuid "e0c59a43-4738-4f58-b8fc-a3d415fa2325") (uuid "e0c59a43-4738-4f58-b8fc-a3d415fa2325")
(effects (effects
(font (font
@@ -867,7 +594,7 @@
) )
) )
(pin "PWR_USBD4" output (pin "PWR_USBD4" output
(at 160.02 35.56 0) (at 158.75 35.56 0)
(uuid "88f9270b-7fa1-46d2-afae-16d86b89617e") (uuid "88f9270b-7fa1-46d2-afae-16d86b89617e")
(effects (effects
(font (font
@@ -877,7 +604,7 @@
) )
) )
(pin "USBD2_N" input (pin "USBD2_N" input
(at 160.02 43.18 0) (at 158.75 43.18 0)
(uuid "26cb3814-1921-46cf-8844-12b04cb3c3a6") (uuid "26cb3814-1921-46cf-8844-12b04cb3c3a6")
(effects (effects
(font (font
@@ -887,7 +614,7 @@
) )
) )
(pin "USBD2_P" input (pin "USBD2_P" input
(at 160.02 40.64 0) (at 158.75 40.64 0)
(uuid "e7d772c5-dc0f-491d-bbe4-b88081353547") (uuid "e7d772c5-dc0f-491d-bbe4-b88081353547")
(effects (effects
(font (font
@@ -897,7 +624,7 @@
) )
) )
(pin "USBD3_N" input (pin "USBD3_N" input
(at 160.02 49.53 0) (at 158.75 49.53 0)
(uuid "fc187a48-f260-492a-aa8d-4a05dd5d92c3") (uuid "fc187a48-f260-492a-aa8d-4a05dd5d92c3")
(effects (effects
(font (font
@@ -907,7 +634,7 @@
) )
) )
(pin "USBD3_P" input (pin "USBD3_P" input
(at 160.02 46.99 0) (at 158.75 46.99 0)
(uuid "b122bf8c-a643-45fe-a07c-05de668c6f1d") (uuid "b122bf8c-a643-45fe-a07c-05de668c6f1d")
(effects (effects
(font (font
@@ -917,7 +644,7 @@
) )
) )
(pin "USBD4_N" input (pin "USBD4_N" input
(at 160.02 55.88 0) (at 158.75 55.88 0)
(uuid "3be6f3e5-0fac-48a6-a8d2-edecabee3143") (uuid "3be6f3e5-0fac-48a6-a8d2-edecabee3143")
(effects (effects
(font (font
@@ -927,7 +654,7 @@
) )
) )
(pin "USBD4_P" input (pin "USBD4_P" input
(at 160.02 53.34 0) (at 158.75 53.34 0)
(uuid "b9d029e2-85c1-4f99-b445-115221ce0e26") (uuid "b9d029e2-85c1-4f99-b445-115221ce0e26")
(effects (effects
(font (font
@@ -946,7 +673,7 @@
) )
(sheet (sheet
(at 124.46 81.28) (at 124.46 81.28)
(size 50.8 46.99) (size 34.29 25.4)
(exclude_from_sim no) (exclude_from_sim no)
(in_bom yes) (in_bom yes)
(on_board yes) (on_board yes)
@@ -970,7 +697,7 @@
) )
) )
(property "Sheetfile" "MCU.kicad_sch" (property "Sheetfile" "MCU.kicad_sch"
(at 124.46 128.8546 0) (at 124.46 107.2646 0)
(effects (effects
(font (font
(size 1.27 1.27) (size 1.27 1.27)
@@ -986,206 +713,6 @@
) )
) )
) )
(pin "BOOT" input
(at 175.26 95.25 0)
(uuid "5350e495-4d5c-4bbd-a668-6baa0038a59c")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "EN" input
(at 175.26 97.79 0)
(uuid "01a73818-18a9-45f4-91fb-54ffb37f210e")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "PROG_RXD" input
(at 175.26 102.87 0)
(uuid "93795dd2-4ad6-4e2b-9d1c-87b07db7516b")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "PROG_TXD" input
(at 175.26 100.33 0)
(uuid "ceb74c69-2d1c-4ccb-a98b-7013d7afe921")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "SCL" input
(at 124.46 85.09 180)
(uuid "6b26697c-6991-421d-9cc6-83e1160b8536")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "SDA" input
(at 124.46 87.63 180)
(uuid "c22bfbe3-dbdb-4fd6-8da5-6abeda230da1")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "USB_D+" input
(at 156.21 81.28 90)
(uuid "a64b796e-58d3-4d10-8b3b-ea873abd0e09")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "USB_D-" input
(at 153.67 81.28 90)
(uuid "8cc3d7da-f9fc-44d3-9f6e-56554249f4d0")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "USB_PD_ALERT" input
(at 124.46 90.17 180)
(uuid "9d3df001-0d47-4cf9-9c86-771119f74161")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "!INT_L" input
(at 129.54 128.27 270)
(uuid "92002c5d-8457-45b8-8a70-066b0942bd0d")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "!INT_R" input
(at 132.08 128.27 270)
(uuid "0fb336ad-0201-4fa3-84fc-31b75f995dab")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "!RESET" input
(at 134.62 128.27 270)
(uuid "f9edb144-f2c8-4f88-bc9d-f6cc4fb6c219")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "KEYBOARD_EN" input
(at 137.16 128.27 270)
(uuid "7a7ecabe-be46-4135-8bc2-eecbf70df888")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "LED_DIN" input
(at 139.7 128.27 270)
(uuid "25d5c932-899b-4610-b493-334c0187c483")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "PERIPHERAL_EN" input
(at 152.4 128.27 270)
(uuid "54309a34-9b5f-462e-a15c-ad27feabbbac")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "DISPLAY_RX" input
(at 162.56 128.27 270)
(uuid "438a60d7-5143-48eb-8b17-338fce15561b")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "DISPLAY_TX" input
(at 165.1 128.27 270)
(uuid "6b2c6e9f-4857-4fa1-97cd-4164cba66cfa")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "PERIPHERAL_SCL" input
(at 154.94 128.27 270)
(uuid "d54b8353-2b82-41cc-847a-a9021734c3f1")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "PERIPHERAL_SDA" input
(at 157.48 128.27 270)
(uuid "2495c05e-2d4a-415c-9325-1bbca6e908fa")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "DISPLAY_EN" input
(at 167.64 128.27 270)
(uuid "329e846c-b37e-43b5-80bd-bc9f7a2f9d96")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(instances (instances
(project "keyboard_controller" (project "keyboard_controller"
(path "/b230ff6d-d62b-4e9b-b4a9-a03792e35fdd" (path "/b230ff6d-d62b-4e9b-b4a9-a03792e35fdd"
@@ -1237,8 +764,8 @@
) )
) )
(sheet (sheet
(at 124.46 139.7) (at 124.46 114.3)
(size 50.8 35.56) (size 34.29 17.78)
(exclude_from_sim no) (exclude_from_sim no)
(in_bom yes) (in_bom yes)
(on_board yes) (on_board yes)
@@ -1253,7 +780,7 @@
) )
(uuid "597f86ca-912d-4f96-a6ed-f7d99a92319e") (uuid "597f86ca-912d-4f96-a6ed-f7d99a92319e")
(property "Sheetname" "keyboard_interface" (property "Sheetname" "keyboard_interface"
(at 124.46 138.9884 0) (at 124.46 113.5884 0)
(effects (effects
(font (font
(size 1.27 1.27) (size 1.27 1.27)
@@ -1262,7 +789,7 @@
) )
) )
(property "Sheetfile" "keyboard_interface.kicad_sch" (property "Sheetfile" "keyboard_interface.kicad_sch"
(at 124.46 175.8446 0) (at 124.46 132.6646 0)
(effects (effects
(font (font
(size 1.27 1.27) (size 1.27 1.27)
@@ -1270,136 +797,6 @@
(justify left top) (justify left top)
) )
) )
(pin "!INT_L" input
(at 129.54 139.7 90)
(uuid "dfddb606-9130-42e7-b976-59022accd5d9")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "!INT_R" input
(at 132.08 139.7 90)
(uuid "abcaa1e1-6b58-4908-bf10-d555ab18a420")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "!RESET" input
(at 134.62 139.7 90)
(uuid "7c1e12b8-76c5-44c7-97bb-c4d427c02483")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "KEYBOARD_EN" input
(at 137.16 139.7 90)
(uuid "2785fa47-f574-4b33-94e9-9073391710de")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "KEYBOARD_SCL" input
(at 124.46 160.02 180)
(uuid "2747bc29-a3eb-44ec-ab9e-6e941b763207")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "KEYBOARD_SDA" input
(at 124.46 162.56 180)
(uuid "45851f95-7b92-4d86-9e28-4909e5ae17a1")
(effects
(font
(size 1.27 1.27)
)
(justify left)
)
)
(pin "LED_DIN" input
(at 139.7 139.7 90)
(uuid "4dd614b7-1b13-4ca2-a794-19d36140e307")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "PERIPHERAL_EN" input
(at 152.4 139.7 90)
(uuid "560cc74d-33bf-414b-a6dc-29a53a2ac606")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "DISPLAY_EN" input
(at 167.64 139.7 90)
(uuid "16b394d0-a316-4cfd-99ba-588a9be642d4")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "DISPLAY_RX" input
(at 162.56 139.7 90)
(uuid "7ef42b38-f742-4e5a-b170-3f4713bdf2e7")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "DISPLAY_TX" input
(at 165.1 139.7 90)
(uuid "1b464f6d-e04c-4a04-9d5c-3d6f6ff8d901")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "PERIPHERAL_SCL" input
(at 154.94 139.7 90)
(uuid "35391ca1-0923-4799-b45e-2b0af2c4490a")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(pin "PERIPHERAL_SDA" input
(at 157.48 139.7 90)
(uuid "24ec76d0-0377-4197-af8f-c10c5641e5d8")
(effects
(font
(size 1.27 1.27)
)
(justify right)
)
)
(instances (instances
(project "keyboard_controller" (project "keyboard_controller"
(path "/b230ff6d-d62b-4e9b-b4a9-a03792e35fdd" (path "/b230ff6d-d62b-4e9b-b4a9-a03792e35fdd"
@@ -1501,7 +898,7 @@
) )
) )
(sheet (sheet
(at 186.69 27.94) (at 171.45 27.94)
(size 26.67 44.45) (size 26.67 44.45)
(exclude_from_sim no) (exclude_from_sim no)
(in_bom yes) (in_bom yes)
@@ -1517,7 +914,7 @@
) )
(uuid "f949d847-95e8-43ae-a947-73b7c5fb08a2") (uuid "f949d847-95e8-43ae-a947-73b7c5fb08a2")
(property "Sheetname" "USB_output_n_prog" (property "Sheetname" "USB_output_n_prog"
(at 186.69 27.2284 0) (at 171.45 27.2284 0)
(effects (effects
(font (font
(size 1.27 1.27) (size 1.27 1.27)
@@ -1526,7 +923,7 @@
) )
) )
(property "Sheetfile" "programming_interface.kicad_sch" (property "Sheetfile" "programming_interface.kicad_sch"
(at 186.69 72.9746 0) (at 171.45 72.9746 0)
(effects (effects
(font (font
(size 1.27 1.27) (size 1.27 1.27)
@@ -1535,7 +932,7 @@
) )
) )
(pin "PROG_BOOT" input (pin "PROG_BOOT" input
(at 189.23 72.39 270) (at 173.99 72.39 270)
(uuid "9839852c-0bd9-42f0-9cfb-ef0fca8c4d1e") (uuid "9839852c-0bd9-42f0-9cfb-ef0fca8c4d1e")
(effects (effects
(font (font
@@ -1545,7 +942,7 @@
) )
) )
(pin "PROG_EN" input (pin "PROG_EN" input
(at 191.77 72.39 270) (at 176.53 72.39 270)
(uuid "0bbb709f-867a-4ad9-b27d-c9dd80af824f") (uuid "0bbb709f-867a-4ad9-b27d-c9dd80af824f")
(effects (effects
(font (font
@@ -1555,7 +952,7 @@
) )
) )
(pin "PROG_TXD" input (pin "PROG_TXD" input
(at 194.31 72.39 270) (at 179.07 72.39 270)
(uuid "3a0c9a5e-ff7b-4915-93b6-fbc60fed8e8e") (uuid "3a0c9a5e-ff7b-4915-93b6-fbc60fed8e8e")
(effects (effects
(font (font
@@ -1565,7 +962,7 @@
) )
) )
(pin "USB_1_PWR" input (pin "USB_1_PWR" input
(at 186.69 30.48 180) (at 171.45 30.48 180)
(uuid "37260822-24a5-4f7f-840e-b8175a827ddb") (uuid "37260822-24a5-4f7f-840e-b8175a827ddb")
(effects (effects
(font (font
@@ -1575,7 +972,7 @@
) )
) )
(pin "USB_2_PWR" input (pin "USB_2_PWR" input
(at 186.69 33.02 180) (at 171.45 33.02 180)
(uuid "1ea4aeb2-8f1a-4107-8ac8-3e2f94d5b674") (uuid "1ea4aeb2-8f1a-4107-8ac8-3e2f94d5b674")
(effects (effects
(font (font
@@ -1585,7 +982,7 @@
) )
) )
(pin "USB_3_PWR" input (pin "USB_3_PWR" input
(at 186.69 35.56 180) (at 171.45 35.56 180)
(uuid "6d12db6b-1cef-4759-aa5f-83d5ecdf30d6") (uuid "6d12db6b-1cef-4759-aa5f-83d5ecdf30d6")
(effects (effects
(font (font
@@ -1595,7 +992,7 @@
) )
) )
(pin "USB_OUT_1_DN" input (pin "USB_OUT_1_DN" input
(at 186.69 43.18 180) (at 171.45 43.18 180)
(uuid "e8294594-e1c3-4bb6-9df9-e265f76f73a3") (uuid "e8294594-e1c3-4bb6-9df9-e265f76f73a3")
(effects (effects
(font (font
@@ -1605,7 +1002,7 @@
) )
) )
(pin "USB_OUT_1_DP" input (pin "USB_OUT_1_DP" input
(at 186.69 40.64 180) (at 171.45 40.64 180)
(uuid "9ff0a255-e00b-485a-a4ca-65a4386bc7a2") (uuid "9ff0a255-e00b-485a-a4ca-65a4386bc7a2")
(effects (effects
(font (font
@@ -1615,7 +1012,7 @@
) )
) )
(pin "USB_OUT_2_DN" input (pin "USB_OUT_2_DN" input
(at 186.69 49.53 180) (at 171.45 49.53 180)
(uuid "22bdd00b-ea14-40b2-8286-6008c82f8c40") (uuid "22bdd00b-ea14-40b2-8286-6008c82f8c40")
(effects (effects
(font (font
@@ -1625,7 +1022,7 @@
) )
) )
(pin "USB_OUT_2_DP" input (pin "USB_OUT_2_DP" input
(at 186.69 46.99 180) (at 171.45 46.99 180)
(uuid "88a71857-176c-48a2-9da4-7b200715ed3a") (uuid "88a71857-176c-48a2-9da4-7b200715ed3a")
(effects (effects
(font (font
@@ -1635,7 +1032,7 @@
) )
) )
(pin "USB_OUT_3_DN" input (pin "USB_OUT_3_DN" input
(at 186.69 55.88 180) (at 171.45 55.88 180)
(uuid "75c6d7e3-fd78-4dc9-8845-0a67e7528ffb") (uuid "75c6d7e3-fd78-4dc9-8845-0a67e7528ffb")
(effects (effects
(font (font
@@ -1645,7 +1042,7 @@
) )
) )
(pin "USB_OUT_3_DP" input (pin "USB_OUT_3_DP" input
(at 186.69 53.34 180) (at 171.45 53.34 180)
(uuid "f353501a-b5e8-4cc1-ad49-92f908e35673") (uuid "f353501a-b5e8-4cc1-ad49-92f908e35673")
(effects (effects
(font (font
@@ -1655,7 +1052,7 @@
) )
) )
(pin "PROG_RXD" input (pin "PROG_RXD" input
(at 196.85 72.39 270) (at 181.61 72.39 270)
(uuid "2c32949d-ae8f-49d0-8906-eb61485bf0b0") (uuid "2c32949d-ae8f-49d0-8906-eb61485bf0b0")
(effects (effects
(font (font

File diff suppressed because it is too large Load Diff

123
README.md
View File

@@ -1,115 +1,18 @@
# kicad project template # How to use this template
[![.github/workflows/main.yaml](https://github.com/sirlilpanda/kicad-project-template/actions/workflows/main.yaml/badge.svg?branch=main)](https://github.com/sirlilpanda/kicad-project-template/actions/workflows/main.yaml)
a cool table showing the workflow of all the kicad projects. custom keyboard
| project_name | DRC | ERC |
| ------------ | --- | --- |
| template | [](https://github.com/sirlilpanda/kicad-project-template/actions/runs/14507154830/attempts/1#summary-40698563204)| [](https://github.com/sirlilpanda/kicad-project-template/actions/runs/14507154830/attempts/1#summary-40698563199) |
for a quick guide check [project setup](#project-setup) ![rendered pcb](res/keyboard_render.png)
This is a simple project template for new kicad projects. This template has some basic setup already completed such as workflows for auto creating all the things you forget when creating a kicad project such as: the code for creating all of this lives in `.hooks/`
- [gerbers](https://github.com/sirlilpanda/kicad-project-template/tree/main/template_gerber.zip) ## setup
- [bom](https://github.com/sirlilpanda/kicad-project-template/tree/main/template_bom_report.md) dependencies:
- [schematic pdf](https://github.com/sirlilpanda/kicad-project-template/tree/main/template_schematic.pdf) - python3.9+ (used for crossplatfrom scripting)
- kicad-cli
to set up the hooks just run
This workflow will also run the design rules check on the PCB and schematic to ensure that you upload a working PCB. These reports are uploaded as summaries within the github [actions tab](https://github.com/sirlilpanda/kicad-project-template/actions/runs/14507154830). This template has a simple schematic PCB in it (because DRC fails on an empty PCB). Shown below is the example PCB. ```
python setup.py
![example pcb with battery diode and resistor](res/image.png) ```
This script will add a line in the `.git/hooks/pre-push` to auto run `.hooks/kicad_cli_tools.py`
besides from that the project also has:
- common predefined trace widths
- smallest vias size [JLCPBC allows](https://jlcpcb.com/capabilities/Capabilities#Drilling)
- custom net colours in the schematic editor
- `red` for +V
- `blue` for -V
- `grey` for ground
to create a repo from this template follow this [guide](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)
contained in this template are:
---
- `.github/` : all files relating to github actions and other admin see [here](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions) for more example of what can be placed in it
- `report_processing` : where the python scripts are stored for processing the json report data from kicad
- `report_templates` : where the template for said reports are stored
- `workflows/` : this is where the github actions are kept
- `main.yaml` : the main github action that will auto generate all files required and run DRC and ERC
- `rename.py` : the script for renaming the project
- `hardware/` : this is where the kicad projects live note this can be changed
- `docs/` : this is where the generate docs are placed by default
- `BOM/` : where the bill of materials and price breakdown are kept
- `bill_of_materials.csv`: the auto generated bom for the kicad project
- `bom_report.md` : a report for the bill of materials
- `template_schematic.pdf` : the schematic for the kicad project, auto generated by the github action
- `pcbs/` : this is where the auto generated gerbers for the kicad project are stored
- `res/` : where resources are stored for the README
- `.gitignore`: a slightly modified gitignore from the [standard one](https://github.com/github/gitignore/blob/main/KiCad.gitignore)
- `project_settings.yaml` : where the settings for this project is stored
- `README.md` : this file, suggest you change this one creating your project
## project settings
there are currently very few project settings that can be changed (will will be change in the future) these are:
| setting | description |
| --------------------------- | ----------------------------------------------------------------- |
| has_been_set_up | a flag to tell the setup action if the project has been set up |
| project_name | the name of the project, this will be set to the name of the repo |
| production_formats | the output production format for the PCBs |
| dynamic_read_me | allow the readme to be updated using the given template |
| bom_template_path | the template used to write the bom report files |
| erc_report_template_path | the template used to write the erc report files |
| drc_report_template_path | the template used to write the drc report files |
| readme_template_path | the template used to write projects readme |
| schematic_output_name | the name suffix of the generated schematics |
| bom_csv_output_name | the name suffix of the generated bom csv file |
| bom_report_output_name | the name suffix of the generated bom report |
| production_file_output_name | the name suffix of the generated production file |
| schematic_output_path | the output path of the generated schematics files |
| bom_csv_output_path | the output path of the generated bom csv file |
| bom_report_output_path | the output path of the generated bom report |
| production_file_output_path | the output path of the generated production file |
## project setup
### creating a new repo with the template
creating a new template from a repo is simple:
1. click on the button in the top right hand corner called `use this template`
![alt text](res/image-5.png)
2. when the drop down menu appears click on `create a new repository`
![alt text](res/image-6.png)
3. once you click you will be brought to this page, note that the repo name you choose here will be the name that you kicad project is called.
![alt text](res/image-7.png)
after these steps you then need to configure the repo settings to do their magic see [configuring repo settings](#configuring-repo-settings) for what to do next.
### configuring repo settings
once you have created a new repo with the template, you ill have to configure the github action settings. this is because you will get an error that looks something along these lines:
![alt text](res/image-4.png)
where the action can not commit the changes due to not having permissions follow these steps:
1. open the repo setting
![alt text](res/image-1.png)
2. then head in to actions : General
![alt text](res/image-2.png)
3. then scroll down to workflow permissions and ensure that both
`Read and write permissions` and `Allow GitHub Actions to create and approve pull requests` are ticked as seen below
![alt text](res/image-3.png)
this should fix the problem if not, go harass stack overflow they need it
Once all of these steps have been followed the workflow should be passing, however the `README.md` will only update on the next push request.
## editing the readme
As this repo can and will automatically update the repo corresponding to the given readme template. If you dont want to use this you can always disable this by setting the `dynamic_read_me` to `false`. but if you want some very cool features like auto updating tables to show what projects are passing the rules check or simple links to parts of your directory. then have a look at the template readme and learn [mustache](https://mustache.github.io/)
## improvements

28
setup.py Normal file
View File

@@ -0,0 +1,28 @@
import sys
import os
import stat
from pathlib import Path
PYTHON_BIN = sys.executable
HOOK_SCRIPT_PATH = Path(".hooks/kicad_cli_tools.py")
HOOK_TYPE = "pre-push"
HOOK_PATH = Path(f".git/hooks/{HOOK_TYPE}")
# used if the hook path already exists we dont want to over write anything you have in there
# we would append however all of the default hooks have and `exit 0` which means it wont run
OLD_HOOK_PATH = Path(f".git/hooks/{HOOK_TYPE}-old")
if (os.path.exists(HOOK_PATH)):
os.rename(HOOK_PATH, OLD_HOOK_PATH)
with open(HOOK_PATH, "w") as txt:
txt.writelines([
"#!/bin/sh\n", #shebang
f"{PYTHON_BIN} {HOOK_SCRIPT_PATH}\n"
"exit 0\n" #make sure she closes
])
# make sure its executable
st = os.stat(HOOK_PATH)
os.chmod(HOOK_PATH, st.st_mode | stat.S_IEXEC)