Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
karmanyaahm authored Mar 29, 2024
2 parents 0b7c7fa + b32609f commit 65783b7
Show file tree
Hide file tree
Showing 61 changed files with 51,202 additions and 78 deletions.
149 changes: 72 additions & 77 deletions .github/workflows/gerbview.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,14 @@ Required files
||||
|---|---|---|
|✅| README.md | A description of your project |
|${(await hasCart(readme)) ? "✅" : "❌"} | cart.png | ${
(await hasCart(readme))
|${(await hasCart(readme)) ? "✅" : "❌"} | cart.png | ${(await hasCart(readme))
? "![cart.png](<https://raw.githubusercontent.com/hackclub/OnBoard/" +
(await currentCommitHash()) +
"/" +
path.dirname(readme) +
"/cart.png>)"
(await currentCommitHash()) +
"/" +
path.dirname(readme) +
"/cart.png>)"
: "You need to include a screenshot of your JLCPCB. Check out [these instructions](https://github.com/hackclub/OnBoard/blob/main/docs/ordering_from_JLCPCB.md#pcb-review). If you already have one, make sure it's a PNG file named exactly \"cart.png\"."
} |`; // TODO: can we handle both png and jpg/jpeg??
} |`; // TODO: can we handle both png and jpg/jpeg??

let gerbers = await gerbersInDir(path.dirname(readme));

Expand All @@ -151,10 +150,10 @@ Required files
}

async function gerbersInDir(readmepath) {
//console.error(readmepath);
//console.error(await fs.readdir(readmepath, {recursive: true}));
// INFO: ALLEGEDLY NEEDS NODE 20
return (await fs.readdir(readmepath, {recursive: true})).filter((f) => f.endsWith("gerber.zip")).map((f) => readmepath + "/" + f);
//console.error(readmepath);
//console.error(await fs.readdir(readmepath, {recursive: true}));
// INFO: ALLEGEDLY NEEDS NODE 20
return (await fs.readdir(readmepath, { recursive: true })).filter((f) => f.endsWith("gerber.zip")).map((f) => readmepath + "/" + f);
}

async function eachGerber(gerber) {
Expand All @@ -170,98 +169,94 @@ async function eachGerber(gerber) {
"/" +
gerber;
let [srcstatus, srcsw, srcmessage] = await analyzeSourceFiles(gerber);
let rawPdfUrl = `https://raw.githubusercontent.com/hackclub/OnBoard/${await currentCommitHash()}/${path.dirname(gerber)}/schematic.pdf`
return `
|${(await isValidGerber(gerber)) ? "✅" : "❌"}| gerber.zip | ${
(await isValidGerber(gerber))
|${(await isValidGerber(gerber)) ? "✅" : "❌"}| gerber.zip | ${(await isValidGerber(gerber))
? ""
: 'This gerber file is invalid. Please export a gerber from your PCB Design software (the same file you will submit to JLCPCB) and name it exactly "gerber.zip".'
}|
|${(await hasSchematic(gerber)) ? "🟨" : "❌"} | schematic.pdf | ${(await hasSchematic(gerber)) ? "Manually check ![schematic.pdf](<https://raw.githubusercontent.com/hackclub/OnBoard/" +
(await currentCommitHash()) +
"/" +
path.dirname(gerber) +
"/schematic.pdf>)" : "You must export your schematic file as schematic.pdf"} |
}|
|${(await hasSchematic(gerber)) ? "✅" : "❌"} | [schematic.pdf](${rawPdfUrl}) | ${(await hasSchematic(gerber)) ? `Manually check ![schematic.pdf](${rawPdfUrl})` : "You must export your schematic file as schematic.pdf"} |
|${srcstatus}| Source files - ${srcsw} | ${srcmessage} |
You can view a render of your board over on [gerber.zip/2d](<${URL}>)!
`;
}

async function analyzeSourceFiles(gerber) {
const isEasyEDASch = (f) => {
const isEasyEDASch = (f) => {
try {
let a = fss.readFileSync(f, { encoding: "utf-8", start: 0, end: 300 })
return a.includes("schematics") && a.includes(`docType": "5`);
let a = fss.readFileSync(f, { encoding: "utf-8", start: 0, end: 300 })
return a.includes("schematics") && a.includes(`docType": "5`);
} catch (error) {
return false;
return false;
}
};
};

const isEasyEDAPCB = (f) => {
const isEasyEDAPCB = (f) => {
try {
let a = fss.readFileSync(f, { encoding: "utf-8", start: 0, end: 300 })
return a.includes("canvas") && a.includes(`docType": "3`);
let a = fss.readFileSync(f, { encoding: "utf-8", start: 0, end: 300 })
return a.includes("canvas") && a.includes(`docType": "3`);
} catch (error) {
return false;
return false;
}
};
};

const isKiCADSch = (f) => {
const isKiCADSch = (f) => {
try {
return fss.readFileSync(f, { encoding: "utf-8", start: 0, end: 15 }).includes("kicad_sch");
return fss.readFileSync(f, { encoding: "utf-8", start: 0, end: 15 }).includes("kicad_sch");
} catch (error) {
return false;
return false;
}
};
};

const isKiCADPCB = (f) => {
const isKiCADPCB = (f) => {
try {
return fss.readFileSync(f, { encoding: "utf-8", start: 0, end: 15 }).includes("kicad_pcb");
return fss.readFileSync(f, { encoding: "utf-8", start: 0, end: 15 }).includes("kicad_pcb");
} catch (error) {
return false;
return false;
}
};
};

let d = path.dirname(gerber) + "/src/";
var ret = ["❌","Unknown","No source files found. Please make a directory called 'src' and put your gerbers and upload your source files there. There must be two files, one for the schematic and one for the PCB. ."];;// TODO: See instructions for [EasyEDA]() and [KiCAD]()
var ret = ["❌", "Unknown", "No source files found. Please make a directory called 'src' and put your gerbers and upload your source files there. There must be two files, one for the schematic and one for the PCB. ."];;// TODO: See instructions for [EasyEDA]() and [KiCAD]()
var files;
try{
files = (await fs.readdir(d)).map((f) => d + f);
}
catch {
return ret;
}

if (files.length === 0) {
return ret;
}

// heuristics, not super super accurate
let atLeastOneKicadSch = files.some((f) => isKiCADSch(f))
let atLeastOneKicadPCB = files.some((f) => isKiCADPCB(f))
let atLeastOneEasyEDASch = files.some((f) => isEasyEDASch(f))
let atLeastOneEasyEDAPCB = files.some((f) => isEasyEDAPCB(f))

if (atLeastOneKicadSch && atLeastOneKicadPCB) { // at least one file includes kicad
ret = ["✅", "KiCAD", "Found both PCB and SCH files"];
if (files.some((f) => (f.includes("backups") && fss.statSync(f).isDirectory()) || f.includes("cache"))) {
ret[0] = "❌";
ret[2] = "Please remove backups, cache and any other unneccessary files";
}
} else if (atLeastOneKicadSch || atLeastOneKicadPCB) { // here we are assuming all jsons are easyeda?????
ret[1] = "KiCAD";
ret[2] = "Please upload both your PCB and Schematic KiCAD files";
} else if (atLeastOneEasyEDASch && atLeastOneEasyEDAPCB) {
ret = ["✅", "EasyEDA", " Found both PCB and SCH files"];
} else if (atLeastOneEasyEDASch || atLeastOneEasyEDAPCB) {
ret[1] = "EasyEDA";
ret[2] = "Please upload both your PCB and Schematic EasyEDA files. ";//Instructions available [here]() TODO: add instructions
}
//console.error(files);
return ret;

try {
files = (await fs.readdir(d)).map((f) => d + f);
}
catch {
return ret;
}

if (files.length === 0) {
return ret;
}

// heuristics, not super super accurate
let atLeastOneKicadSch = files.some((f) => isKiCADSch(f))
let atLeastOneKicadPCB = files.some((f) => isKiCADPCB(f))
let atLeastOneEasyEDASch = files.some((f) => isEasyEDASch(f))
let atLeastOneEasyEDAPCB = files.some((f) => isEasyEDAPCB(f))

if (atLeastOneKicadSch && atLeastOneKicadPCB) { // at least one file includes kicad
ret = ["✅", "KiCAD", "Found both PCB and SCH files"];
if (files.some((f) => (f.includes("backups") && fss.statSync(f).isDirectory()) || f.includes("cache"))) {
ret[0] = "❌";
ret[2] = "Please remove backups, cache and any other unneccessary files";
}
} else if (atLeastOneKicadSch || atLeastOneKicadPCB) { // here we are assuming all jsons are easyeda?????
ret[1] = "KiCAD";
ret[2] = "Please upload both your PCB and Schematic KiCAD files";
} else if (atLeastOneEasyEDASch && atLeastOneEasyEDAPCB) {
ret = ["✅", "EasyEDA", " Found both PCB and SCH files"];
} else if (atLeastOneEasyEDASch || atLeastOneEasyEDAPCB) {
ret[1] = "EasyEDA";
ret[2] = "Please upload both your PCB and Schematic EasyEDA files. ";//Instructions available [here]() TODO: add instructions
}
//console.error(files);


return ret;
}

function hasCart(readme) {
Expand All @@ -282,15 +277,15 @@ function hasSchematic(gerber) {
.readFile(d + "/schematic.pdf", { encoding: "utf-8", start: 0, end: 4 })
.then((fileContent) => fileContent.startsWith("%PDF-"))
.catch((error) => {
//console.error("Error occurred:", error);
//console.error("Error occurred:", error);
return false;
});
}

function isValidGerber(gerber) {
var s = null;
if (path.basename(gerber) !== "gerber.zip") {
return false;
return false;
}
try {
s = execSync(`unzip -l "${gerber}"`, {
Expand Down
Binary file added Gerber.zip
Binary file not shown.
Binary file added Schematic.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/VENDORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is the list of approved vendors that the HCB grant cards can be used on. To
- [PCBgogo](https://www.pcbgogo.com): Cheaper shipping for UK via Hong Kong post + $50 coupon for first time users.
- [Aisler](https://aisler.net): A EU-based vendor with green PCBs. Pricing per square centimeter. Similar price as other vendors, but faster shipping to EU countries.

> Keep in mind that some international vendors will place an additional customs surcharge after purchasing. JLCPCB generally covers this in their additional fees breakdown (they don't cover customs in India). It's on you to check before ordering because the grant can't cover additional merchants like customs.
> Keep in mind that some international vendors will place an additional customs surcharge after purchasing. JLCPCB generally covers this in their additional fees breakdown (they don't cover customs in India). It's on you to check before ordering because the grant can't cover additional charges like customs.
## Adding to the list

Expand Down
28 changes: 28 additions & 0 deletions projects/Cai' PCB NFC CARD/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: "Jickle/Cai Ong"
slack_handle: "Cai"
github_handle: "Cai0n_29"
tutorial: https://jams.hackclub.com/jam/hacker-card
---

# YOUR PROJECT NAME

<!-- Describe your board in 2-3 sentences.
What are you making?
I made a hacker card! I learned to make it on the jams tutorial in Hackclub Website.
What will it do? -->
The hacker card can bring you to the website or the links you want to open. It uses the NFC chip.

<!-- How much is it going to cost? -->
All together with the board and shipping fee would be $19.90
The board costs $3.10
The shipping fee costs $16.80
![Screenshot 2024-03-15 220059](https://github.com/Cai0n29/OnBoard/assets/131544283/8bebf162-2d10-41d5-8296-91911a2ef7aa)

<!-- Tell us a little bit about your design process.
What were some challenges?
Well there are challenges when I checked the drc checking and there's a lot of errors.
What helped?
Onboard on Slack and One HackClubber clarifies that the errors are coming from the antenna. I'm really grateful tho
***Totally optional*** -->
Binary file added projects/Cai' PCB NFC CARD/cart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/Cai' PCB NFC CARD/gerber.zip
Binary file not shown.
Binary file added projects/Cai' PCB NFC CARD/pickandplace.csv
Binary file not shown.
Binary file added projects/Cai' PCB NFC CARD/schematic.pdf
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 65783b7

Please sign in to comment.