summaryrefslogtreecommitdiff
path: root/test.rb
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-05-11 19:35:03 -0700
committerJulian Blake Kongslie2022-05-11 19:35:03 -0700
commit0e8096b0663b793a30973d5904e1f02f083436a2 (patch)
treeba360687ba559ddfad809933b029416755efe813 /test.rb
downloadlace-0e8096b0663b793a30973d5904e1f02f083436a2.tar.xz
Initial commit.
Diffstat (limited to 'test.rb')
-rwxr-xr-xtest.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test.rb b/test.rb
new file mode 100755
index 0000000..86d1415
--- /dev/null
+++ b/test.rb
@@ -0,0 +1,33 @@
1#!/usr/bin/ruby
2
3require "./lace"
4
5def r(size, suffix="ohm")
6 comp("R", "0805", "resistor", "#{Lace::e12(size)}#{suffix}")
7end
8
9def c(size, suffix="nF")
10 comp("C", "0805", "capacitor", "#{Lace::e12(size)}#{suffix}")
11end
12
13def led(color="red")
14 comp("D", "0805", "LED", "1.5V 10mA #{color}")
15end
16
17nl = 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
23end
24
25nl.kicad
26$stdout.write("\n")
27nl.summary
28
29$stdout.write("\nBOM:\n")
30bom = nl.bom
31bom.keys.sort.each do | item |
32 $stdout.write(" #{bom[item]}\t#{item}\n")
33end