summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-05-17 11:30:47 -0700
committerJulian Blake Kongslie2022-05-17 11:30:47 -0700
commita41bb0395b649808faf3b59c8c653ee1d23f9bfc (patch)
treecbf272514029a46f9840917885abf133ef8daf07
parentInitial generic part library (diff)
downloadlace-a41bb0395b649808faf3b59c8c653ee1d23f9bfc.tar.xz
Make limited use of the part library
-rwxr-xr-xtest.rb15
1 files changed, 4 insertions, 11 deletions
diff --git a/test.rb b/test.rb
index e8d2a6b..b524539 100755
--- a/test.rb
+++ b/test.rb
@@ -1,24 +1,17 @@
1#!/usr/bin/ruby 1#!/usr/bin/ruby
2 2
3require "./lace" 3require "./lace"
4 4require "./library"
5def r(size)
6 comp("R", "0805", "resistor", size)
7end
8
9def c(size)
10 comp("C", "0805", "capacitor", size)
11end
12 5
13def led(color="red") 6def led(color="red")
14 comp("D", "0805", "LED", "1.5V 10mA #{color}") - r("220Ω") 7 comp("D", "0805", "LED", "1.5V 10mA #{color}") - r(220)
15end 8end
16 9
17def inverter() 10def inverter()
18 $inverters ||= [] 11 $inverters ||= []
19 if $inverters.empty? 12 if $inverters.empty?
20 u = comp("U", "TSOP-14", "74HCT04", "hex inverter") 13 u = comp("U", "TSOP-14", "74HCT04", "hex inverter")
21 $vcc - u[14] - c("100nF") - u[7] - $gnd 14 $vcc - u[14] - c("100n") - u[7] - $gnd
22 $inverters += [ 15 $inverters += [
23 pair(u[1], u[2]), 16 pair(u[1], u[2]),
24 pair(u[3], u[4]), 17 pair(u[3], u[4]),
@@ -44,7 +37,7 @@ def probe(attenuation=20, impedance=50)
44 if attenuation == 1 37 if attenuation == 1
45 pair(jack[1], jack[2]) 38 pair(jack[1], jack[2])
46 else 39 else
47 pair(r("#{(attenuation-1)*impedance}Ω") - jack[1], jack[2]) 40 pair(r((attenuation-1)*impedance) - jack[1], jack[2])
48 end 41 end
49end 42end
50 43