chiark / gitweb /
scaffold-clamp-cleat: sort out toplevels
[reprap-play.git] / quacks-ingredients.scad
1 // -*- C -*-
2
3 //
4 // git clean -xdff
5 // ./quacks-ingredients-update-levels
6 // make autoincs
7 //
8 // make -j8 quacks-stls 2>&1 | tee log
9 // OR EG
10 // make -j8 quacks-ingredients-L{1,2,3,4,5},Base_Yellow.auto.stl
11 //
12 // ./quacks-ingredients-make-copy-gcodes Base_Yellow   etc.
13 //
14 //   Print Q-P-1 in spots, Q-P-2 in main colour, Q-P-3 in spots
15 //
16 // For colours which only have zero-spot counters, print only Q-P-2
17
18 token_dia = 20;
19 spot_dia = 4.3;
20 spot_gap = spot_dia / 3.0;
21
22 thick = 3.0;
23
24 multicolour_gap = 0.075; // each side
25 initial_layer_thick = 0.400;
26 initial_layer_width = 0.750;
27 final_layer_thick = 0.500;
28 multicolour_post = 4;
29
30 $fs=0.1;
31 $fa=1;
32
33 // calculated
34
35 token_pitch = token_dia + 3;
36
37 // autoadjusted
38
39 $spots_absent = false;
40 $spots_plusgap = false;
41
42 module Spots_Extrude_Lower(){
43   d = $spots_plusgap ? 1 : 0;
44   translate([0,0,-d])
45     linear_extrude(height= initial_layer_thick + d)
46     children(0);
47 }
48
49 module Spots_Extrude_Upper(){
50   d = $spots_plusgap ? 1 : 0;
51   translate([0,0, thick + d])
52     mirror([0,0, 1])
53     linear_extrude(height= final_layer_thick + d)
54     children(0);
55 }
56
57 module SpotAt(condition, xy) {
58   if (condition == !$spots_absent) {
59     translate(xy * (spot_gap + spot_dia) * sqrt(0.5))
60       circle(r= spot_dia/2 +
61              ($spots_plusgap ? multicolour_gap : 0));
62   }
63 }
64
65 module Token_Spots(){
66   SpotAt(($nspots % 2) > 0,  [0,0]);
67   SpotAt($nspots >= 2, [ 1, 1]);
68   SpotAt($nspots >= 2, [-1,-1]);
69   SpotAt($nspots >= 4, [ 1,-1]);
70   SpotAt($nspots >= 4, [-1, 1]);
71 }
72
73 module Token_Spots_All(){
74   $nspots = 5;
75   Token_Spots();
76 }
77
78 module Token_L1(){
79   Spots_Extrude_Lower()
80     Token_Spots();
81 }
82
83 module Token_L2(){
84   $spots_absent = true;
85   Spots_Extrude_Lower()
86     Token_Spots();
87 }
88
89 module Token_L3(){
90   $spots_plusgap = true;
91   difference(){
92     linear_extrude(height=thick)
93       circle(r=token_dia/2);
94     Spots_Extrude_Lower() Token_Spots_All();
95     Spots_Extrude_Upper() Token_Spots_All();
96   }
97 }
98
99 module Token_L4(){
100   $spots_absent = true;
101   Spots_Extrude_Upper()
102     Token_Spots();
103 }
104
105 module Token_L5(){
106   Spots_Extrude_Upper()
107     Token_Spots();
108 }
109
110 module Frame(phase, base_sz) {
111   zs = [ initial_layer_thick,
112          initial_layer_thick,
113          thick,
114          thick,
115          thick ];
116
117   sz = base_sz + phase * initial_layer_width * 2 * [1,1];
118   linear_extrude(height= initial_layer_thick) {
119     difference(){
120       square(center=true, sz + initial_layer_width * 2 * [1,1]);
121       square(center=true, sz);
122     }
123   }
124   // Priming tower
125   translate([-base_sz[0]/2, (2.8-phase)*(multicolour_post*1.7)])
126     linear_extrude(height= zs[phase-1])
127     square(multicolour_post);
128 }
129
130 module Tests(){
131   for ($nspots = [1,2,3,4]) {
132     translate(($nspots - 2) * token_pitch * [1,0])
133       children();
134   }
135 }
136
137 module Tests_L() { ////toplevel
138   Frame($phase, token_dia * [ 6, 1.5 ]);
139   Tests() Token_L();
140 }
141
142 //// toplevels-from:
143 include <quacks-ingredients-counts.scad>
144
145 //Demo();