diff options
| author | Julian Blake Kongslie | 2022-05-11 19:35:03 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-05-11 19:35:03 -0700 |
| commit | 0e8096b0663b793a30973d5904e1f02f083436a2 (patch) | |
| tree | ba360687ba559ddfad809933b029416755efe813 /test.rb | |
| download | lace-0e8096b0663b793a30973d5904e1f02f083436a2.tar.xz | |
Initial commit.
Diffstat (limited to '')
| -rwxr-xr-x | test.rb | 33 |
1 files changed, 33 insertions, 0 deletions
| @@ -0,0 +1,33 @@ | |||
| 1 | #!/usr/bin/ruby | ||
| 2 | |||
| 3 | require "./lace" | ||
| 4 | |||
| 5 | def r(size, suffix="ohm") | ||
| 6 | comp("R", "0805", "resistor", "#{Lace::e12(size)}#{suffix}") | ||
| 7 | end | ||
| 8 | |||
| 9 | def c(size, suffix="nF") | ||
| 10 | comp("C", "0805", "capacitor", "#{Lace::e12(size)}#{suffix}") | ||
| 11 | end | ||
| 12 | |||
| 13 | def led(color="red") | ||
| 14 | comp("D", "0805", "LED", "1.5V 10mA #{color}") | ||
| 15 | end | ||
| 16 | |||
| 17 | nl = Lace::Netlist.new do | ||
| 18 | vcc = net("vcc") | ||
| 19 | gnd = net("gnd") | ||
| 20 | |||
| 21 | vcc - r((5 - 1.5)/0.010) - led - gnd | ||
| 22 | vcc - c(100) - gnd | ||
| 23 | end | ||
| 24 | |||
| 25 | nl.kicad | ||
| 26 | $stdout.write("\n") | ||
| 27 | nl.summary | ||
| 28 | |||
| 29 | $stdout.write("\nBOM:\n") | ||
| 30 | bom = nl.bom | ||
| 31 | bom.keys.sort.each do | item | | ||
| 32 | $stdout.write(" #{bom[item]}\t#{item}\n") | ||
| 33 | end | ||
