-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpchepa.scad
3351 lines (2756 loc) · 94.2 KB
/
pchepa.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
include <BOSL2/std.scad>
include <BOSL2/joiners.scad>
include <BOSL2/screws.scad>
include <BOSL2/walls.scad>
include <scadqr/qr.scad>
// original inspiration <https://www.cleanairkits.com/products/exhalaron>
// cites <https://www.mdpi.com/2075-5309/11/8/329>
// looks similar to <https://www.printables.com/model/386124> -- minimal single
// barrel filter
/// user/customizer parameters
/* [Global] */
// Enables display of meeting-part ghosts ; e.g. adjoining base/cover plate counterpart.
buddy = true;
// Enables preview cutaway for some parts.
cutaway = false;
// Assembly explosion distance.
explode = 50;
// How big is your printer's printable area?
build_plate_size = [250, 250];
/* [Part Selection] */
//@make -o duo/render.png --colorscheme='Tomorrow Night' -D mode=0 -D filter_count=2 -D base_embed_battery_holder=true --imgsize=1024,768 --camera=-48.4318,49.2886,16.9119,81.6,0,39.2,1279.49
//@make -o duo/as_explode.png --colorscheme='Tomorrow Night' -D mode=0 -D filter_count=2 -D base_embed_battery_holder=true --imgsize=1024,768 --animate=40 -D explode='50*$t' --camera=-48.4318,49.2886,16.9119,81.6,0,39.2,1279.49
//@make -o duo/base_a.stl -D mode=10 -D filter_count=2 -D base_embed_power_port=true
//@make -o duo/base_b.stl -D mode=11 -D filter_count=2 -D base_embed_power_port=true
//@make -o duo/base_bank_a.stl -D mode=10 -D filter_count=2 -D base_embed_power_bank=true
//@make -o duo/base_bank_b.stl -D mode=11 -D filter_count=2 -D base_embed_power_bank=true
//@make -o duo/base_batt_a.stl -D mode=10 -D filter_count=2 -D base_embed_battery_holder=true
//@make -o duo/base_batt_b.stl -D mode=11 -D filter_count=2 -D base_embed_battery_holder=true
//@make -o duo/batt_house.stl -D mode=70
//@make -o duo/batt_house_lid.stl -D mode=71
//@make -o duo/batt_house_exit.stl -D mode=72
//@make -o duo/base_label_a.stl -D mode=40 -D label_bottom=true -D filter_count=2
//@make -o duo/base_label_b.stl -D mode=41 -D label_bottom=true -D filter_count=2
//@make -o duo/cover_a.stl -D mode=20 -D filter_count=2
//@make -o duo/cover_b.stl -D mode=21 -D filter_count=2
//@make -o duo/cover_grommet.stl -D mode=29 -D filter_count=2
//@make -o duo/grill_box_basic.stl -D mode=30 -D filter_count=2 -D grill_ear=[0,0] -D grill_window=[24,46] -D pwm_ctl_pcb_size=[0,0,0]
//@make -o duo/grill_box_a.stl -D mode=30 -D filter_count=2
//@make -o duo/grill_box_b.stl -D mode=31 -D filter_count=2
//@make -o duo/wall_0.stl -D mode=50 -D filter_count=2
//@make -o duo/wall_1.stl -D mode=51 -D filter_count=2
//@make -o duo/wall_2.stl -D mode=52 -D filter_count=2
//@make -o duo/wall_3.stl -D mode=53 -D filter_count=2
//@make -o duo/wall_noft_0.stl -D mode=50 -D filter_count=2 -D wrapwall_foot_size=[0,0]
//@make -o duo/wall_noft_1.stl -D mode=51 -D filter_count=2 -D wrapwall_foot_size=[0,0]
//@make -o duo/wall_noft_2.stl -D mode=52 -D filter_count=2 -D wrapwall_foot_size=[0,0]
//@make -o duo/wall_noft_3.stl -D mode=53 -D filter_count=2 -D wrapwall_foot_size=[0,0]
//@make -o test/power_module.stl -D mode=101 -D filter_count=2
//@make -o test/wallslot.stl -D mode=102 -D filter_count=2
//@make -o test/wall.stl -D mode=50 -D filter_count=2 -D wrapwall_length=50
//@make -o test/cover_hole.stl -D mode=103 -D filter_count=2
//@make -o test/joiner_clip.stl -D mode=104
//@make -o test/power_bank_tunnel.stl -D mode=105 -D base_embed_power_bank=true
//@make -o test/batt_house_tunnel.stl -D mode=105 -D base_embed_battery_holder=true
//@make -o test/grill_ear.stl -D mode=107
//@make -o test/pwm_ctl_mount.stl -D mode=108
//@make -o test/label_a.stl -D mode=40 -D filter_count=2
//@make -o test/label_b.stl -D mode=41 -D filter_count=2
//@make -o test/label_plate_a.stl -D mode=42 -D filter_count=2
//@make -o test/label_plate_b.stl -D mode=43 -D filter_count=2
//@make -o parts/clip.stl -D mode=90
//@make -o parts/base_channel_plug.stl -D mode=91
//@make -o parts/base_bank_channel_plug.stl -D mode=91 -D base_embed_power_bank=true
//@make -o parts/pwm_knob.stl -D mode=93
//@make -o parts/wall_bender.stl -D mode=94
//@make -o parts/wall_bender_brace.stl -D mode=95
// Which part to model: base / cover / grill / wall / etc...
mode = 0; // [0:Full Assembly, 1:Assembly A, 2:Assembly B, 10:Base Plate A, 11:Base Plate B, 20:Cover Plate A, 21:Cover Plate B, 29:Cover Port Grommet, 30:Grill Box A, 31:Grill Box B, 40:Label A, 41:Label B, 42:Label Plate A, 43:Label Plate B, 50:Wall 0, 51:Wall 1, 52:Wall 2, 53:Wall 3, 70:Battery Housing, 71:Battery Housing Lid, 72:Battery Wire Guard, 90:Rabbit Clip, 91:Base Channel Plug, 93:PWM Knob, 94:Wall Bender, 95:Wall Bender Brace, 100:Dev, 101:Power Module Fit Test, 102:Wallslot Test, 103:Cover Hole Test, 104:Clip Tolerance Test, 105:Power Bank Tunnel, 106:Power Bank, 107:Grill Ear Test, 108:PWM Controller Test]
// How many filter/fan pairs to use ; NOTE currently 2 is the only value that has been tested to work well ; TODO support 1 and 3
filter_count = 2; // [1, 2]
/* [HEPA Filter Metrics] */
// Height of the HEPA filter cylinder.
filter_height = 5.9 * 25.4;
// Outer diameter of the HEPA filter cylinder.
filter_od = 180;
// Nyemo supposedly has a 7inch spec, so 177.8 = 7*25.4, but in reality it measured more like 180mm.
// Inner diameter of the HEPA filter cylinder cavity.
filter_id = 114;
// Size of the filter lip: X value is the radial wall thickness, Y value is the height.
filter_lip_size = [2, 8];
// Thickness of the teardrop grips that hold the filter inside the base and cover plates. You could set this to zero to disable, but then vertical integrity of the assembly is lost, as no other part is currently designed to hold everything together, instead relying on gripping the filter's plastic ledge.
filter_grip = 1;
// Additional space to leave radially between the filter and mesh wrap wall.
filter_extra_space = 0;
// Additional fit tolerance for the cover/base plate filter recess.
filter_tolerance = 0.1;
/* [Designed Supports] */
// Interface gap between support and supported part.
support_gap = 0.2;
// Bridging gap between supports.
support_every = 15;
// Thickness of support walls and internal struts.
support_width = 0.8;
// Thickness of footer support walls that run parallel to and underneath floating external walls.
support_wall_width = 2.4;
// Enable to show support walls in preview, otherwise only active in production renders.
$support_preview = false;
/* [Joiner Clip Parameters] */
// Preview color for joiner clips.
clip_color = "#eeeeee";
// Size of the joiner BOSL2 rabbit clips used to join base and cover plate pairs: [width, length, depth]
clip_size = [14, 14, 3];
// Minimum amout of vertical padding to leave above/below clip sockets.
clip_pad = 1;
// The snap parameter gives the depth of the clip sides, which controls how easy the clip is to insert and remove.
clip_snap = 0.75;
// Thickness of the curved line that forms the clip.
clip_thick = 1.6;
// The clip "ears" are made over-wide by the compression value. A nonzero compression helps make the clip secure in its socket.
clip_compress = 1.0;
// Extra space in the socket for easier insertion.
clip_tolerance = 0.35;
// Clip fit test tolerance range: [start, step, end]
clip_fit_test = [0.2, 0.05, 0.6];
/* [Wraparound Wall Metrics] */
// Mesh wrap wall preview color.
wrapwall_color = "#bb2424";
// Thickness of the mesh wrap wall, radially away from filter center; set to zero to disable mesh wall.
wrapwall_thickness = 1.6;
// Mesh wrap wall slot depth cut into the base/cover plates.
wrapwall_slot_depth = 5;
// Mesh wrap wall triangular wedge at top/bottom edge.
wrapwall_foot_size = [1.6, 3.2]; // 1x2 wrapwall_thickness
// Mesh wrap wall slot fit tolerance for the channel cut into the base/cover plates.
wrapwall_tolerance = 0.2;
// Additional tolerance at the open end of the base/cover plate mesh wall slot.
wrapwall_draft = 0.4;
// Auotmatic determination of mesh wall section length, by dividing the total perimeter evenly.
wrapwall_section_limit = build_plate_size.x - 10;
// Manual setting for how many sections the mesh wrap wall will be split into; overrides automatic division based on build_plate_size.
wrapwall_sections = 0;
// Manual setting for mesh wrap wall section length; overrides perimeter division logic.
wrapwall_length = 0;
// Manual setting for mesh wrap wall section height; overrides default derived from filter_height.
wrapwall_height = 0;
// Mesh wrap wall sections will use dovetail joiners of this dimension; [w, h, spacing] vector, set either w or h to 0 to disable dovetails.
wrapwall_dovetail = [5, 3, 15];
// Additional tolerance added to mesh wrap wall dovetail receptacles.
wrapwall_dovetail_tolerance = 0.1;
/* [PC Fan Metrics] */
// Fan body preview color.
fan_color = "#666666";
// Basic dimensions of the fan, default is for a standard 120mm fan.
fan_size = [ 120, 120, 25 ];
// Corner rounding of the fan, cosmetically used for the development ghost, has no effect on produced geometry.
fan_rounding = 7;
// Inner diameter of the fan housing, used to size the cover bore hole, and the grill perforation area.
fan_id = 116.4;
// Screw size of the fan itself, cosmetically used for the development ghost, has no effect on produced geometry.
fan_screw = "#4";
// <https://superuser.com/questions/225882/what-type-of-screws-are-used-for-computer-fans>
// Apparently they're 7/32" /5.5mm self tapping screws, though some places say
// they're 3/8". I'd note given their design, you should have some leeway since
// the screws cut into the plastic, to use different threads or slightly larger
// screws.
// Spacing between fan screw hole centers.
fan_screw_spacing = 105;
/* [Fan Grill Metrics] */
// Fan grill box preview color.
grill_color = "#24705b";
// Amount of padding to add around each side of the fan within the grill box; should be at least enough to allow routing of fan cables.
grill_padding = 5;
// Thickness of grill box walls.
grill_thickness = 3;
// Corner and edge chamfering of the grill box.
grill_chamfer = 5;
// Optional side anchor/handle ear on the fan grill gox; diameter/height vector, set either to 0 to disable.
grill_ear = [15, 4];
// Optional hole in any side anchor ear for a carrying strap attachment; set to 0 to disable.
grill_ear_hole = 10;
// Grill perforation hole size.
grill_hole_size = 4;
// Grill perforation hole spacing.
grill_hole_spacing = 1;
// Grill perforation hole polygon degree (default: hexagon).
grill_hole_degree = 6;
// Grill box mounting screw size, need to be compatible with the fan_screw size; will bolt through grill, fan, and into cover plate.
grill_screw = "M3";
// Screw preview color for grill assembly.
grill_screw_color = "#333333";
// Head type for the grill box mounting screw, default is flush/countersunk heads.
grill_screw_head = "flat";
// Preview screw head drive type.
grill_screw_drive = "hex";
// Cutout window size in the extra space area of the grill box between filters. Set either dimension to 0 to disable.
grill_window = [ 0, 0 ];
/* [Filter Cover Parameters] */
// Cover plate preview color.
cover_color = "#4390e0";
// Overall Z thickness of the cover plate between the filter and fan.
cover_height = 20;
// Upper chamfer size of the cover plate, additional radial space as needed.
cover_overhang = 4;
// Lower chamfer size of the cover plate, additional radial space as needed.
cover_underhang = 0.8;
// How many joiner clips to use in the cover plate.
cover_clips = 4;
// Size of the cover heatset inserts in [diameter, height]; set either to zero to instead use a screw-into-plastic hole.
cover_heatset_hole = [4.4, 5.3];
// Access notch cutout around the filter recess of cover plate.
cover_notch = [20, 20, 30];
// Rounding radius for any cover notch cutout.
cover_notch_rounding = 5;
// Which cover notch cuboid edges should be rounded; default is only Z-aligned edges; NOTE notch cube is oriented so that it's local Z is along the cover_notch_side vector.
cover_notch_rounding_edges = [
[0, 0, 0, 0], // yz -- +- -+ ++
[0, 0, 0, 0], // xz
[1, 1, 1, 1], // xy
];
// Placement vector for cover notch; unit is outer wallslot radius.
cover_notch_side = RIGHT;
/* [Cover Plate Wire Ports] */
// Size of wiring pass through hole(s) in the cover plate; set either dimension to zero to disable.
cover_port = [40, 20];
// Placement, along the Y axis of the inner cover plate edge, of any wire pass through holes
cover_port_at = [-48, 48];
// Reduce size of grommet part by this much from the cover plate hole.
cover_port_grommet_tolerance = 0.2;
// Thickness of grommet tube walls and height of the upper lip.
cover_port_grommet_wall = 1;
// Width of grommet lips and height of the lower lip.
cover_port_grommet_lip = 3;
/* [Filter Base Parameters] */
// Base plate preview color.
base_color = "#4390e0";
// Base label cut/color depth.
base_label_depth = 0.5;
// Base label preview color.
base_label_color = "white";
// Overall Z thickness of the base plate under the filter. When embedding a battery solution, this is merely a minimum constraint.
base_height = 20;
// Chamfer size of the base plate, additional radial space as needed.
base_overhang = 8;
// How many joiner clips to use in the base plate.
base_clips = 4;
// Enable a cavity and access tunnel for a power bank inside/between a pair of base plates.
base_embed_power_bank = false;
// Enable a cavity to install a usb pd trigger into, with cable ascent channel.
base_embed_power_port = false;
// Enable a cavity to install our desigend battery holder housing with cable ascent channel aligned with its exit.
base_embed_battery_holder = false;
// Height under the power bank from base plate bottom; needs to be able to accomodate a row of joiner clips.
base_power_bank_lift = 2*clip_pad + clip_size.z;
// Tunnel shrink radius in front of the power bank main cavity.
base_power_bank_tunnel_inset = 1;
// Corner and mouth flare chamfering on the power bank access tunnel.
base_power_bank_tunnel_chamfer = 4;
// Access notch cutout around the filter recess of base plate.
base_notch = [20, 20, 30];
// Rounding radius for any base notch cutout.
base_notch_rounding = 5;
// Which base notch cuboid edges should be rounded; default is only Z-aligned edges; NOTE notch cube is oriented so that it's local Z is along the base_notch_side vector.
base_notch_rounding_edges = [
[0, 0, 0, 0], // yz -- +- -+ ++
[0, 0, 0, 0], // xz
[1, 1, 1, 1], // xy
];
// Placement vector for the base notch; unit is outer wallslot radius.
base_notch_side = RIGHT;
/* [Base Label Parameters] */
// URL text for the base plate label
label_project_url = "https://github.com/jcorbin/pchepa";
// QR Code URL for the base plate label.
label_qr_url = "https://is.gd/izikah"; // shortened "https://github.com/jcorbin/pchepa/blob/main/user_guide/v1.md"
// Replacement filter description for the base plate label.
label_filter_name = "Nyemo H12 / TT-AP006";
// Option to attach label to bottom face rather than top face.
label_bottom = false;
/* [Power Module] */
// Preview color; TODO would be nice to color the pcb separate from socket.
power_module_color = "silver";
// Measured size of the USB-C power module PCB.
power_pcb_size = [10.8, 16.25, 1.5];
// Measured size of the power module USB-C female socket itself.
power_socket_size = [9, 6.8, 3.2];
// Edge rounding of the power module USB-C female socket.
power_socket_rounding = 1;
// How far the USB-C socket hangs out past the power module PCB edge.
power_socket_overhang = 1.6;
// How much of solder pad / wiring "porch" to allow at the back of the USB-C power module.
power_module_porch = 14;
// Diagonal cutting factor behind the USB-C power module to allow easy installation.
power_module_cut = 3;
// Fit tolerance for the USB-C power module.
power_module_tolerance = 0.2;
// Edge chamfering for the power module wiring channel.
power_channel_chamfer = 1;
// Fit tolerance for the fixation plug that will fill the power module wiring channel after installation.
power_channel_plug_tolerance = 0.1;
// Offset power channel from back of power module PCB; this helps the channel to miss the wrap wall channel, but needs to be low enough to still keep the USB-C socket pressed forward vs insertion.
power_channel_backset = 0.4;
// Notch in the back of the channel plug, allowing it to flex and be removed by a tool (like pliers).
channel_plug_notch_size = [ 5, 3 ];
/* [Power Bank] */
power_bank_color = "#333333";
power_bank_size = [ 62, 90.2, 22.5 ];
power_bank_rounding = 9;
power_bank_rounding_edges = "Y";
power_bank_sockets = [
struct_set(socket_spec("usb-c"), [
"name", "USB-C",
"offset", [15.5, 0]
]),
struct_set(socket_spec("usb-a-micro"), [
"name", "Micro USB-A",
"offset", [0, 0]
]),
struct_set(socket_spec("usb-a"), [
"name", "USB-A",
"offset", [-15.5, 0, 2]
]),
// led window
[
["name", "LED Indicator"],
["size", [11, 1.5, 1]],
["offset", [0, 0, -2.8]]
],
// button window
[
["size", [10, 5, 1]],
["rounding", 1],
["anchor", LEFT+FRONT],
["attach", BOTTOM],
["rotate", [0, -45, 0]],
["offset", [0, 10, 0]]
]
];
/* [PWM Controller] */
pwm_ctl_tolerance = 0.2;
pwm_ctl_inset = 5;
pwm_ctl_pcb_size = [20, 26, 1.2];
pwm_ctl_pot_size = [9.6, 12.2, 11.5];
pwm_ctl_pot_shaft = [6.8, 15];
pwm_ctl_pot_key = [2, 1, 0.9];
pwm_ctl_pot_offset = 0.6;
pwm_ctl_led_win = [4, 1, 1];
/* [Battery Housing] */
// TODO cite part
batt_housing_tolerance = 0.5;
batt_housing_wall = 1;
batt_housing_clearance = 10;
batt_pcb_size = [ 42.4, 88.6, 1.2 ];
batt_holder_size = [ 42.4, 78.2, 21.5 ];
batt_holder_setback = 5.5;
batt_pcb_mount_hole_d = 3.5;
batt_housing_mount_hole_d = 3;
batt_usb_socket_size = [ 9, 6.8, 3.3 ];
batt_usb_socket_clearance = [18, 2];
batt_usb_socket_rounding = 1;
batt_housing_color = "grey";
// NOTE offsets from pcb edge
batt_holder_mount_at = [
[-1.1, -1.1], // front left
[ 1.1, -1.1], // front right
[-1.1, 1.5], // back left
[ 1.1, 1.5], // back right
];
batt_window_size = 2;
batt_windows_at = [
[-13, -4],
[ 13, -4]
];
batt_side_size = [70, 32];
batt_exit_size = 6;
batt_slot_size = 2;
batt_slot_lift = 6;
/* [Geometry Detail] */
// Fragment minimum angle.
$fa = 4; // 1
// Fragment minimum size.
$fs = 0.2; // 0.05
// Nudging value used when cutting out (differencing) solids, to avoid coincident face flicker.
$eps = 0.01;
/// dispatch / integration
module __customizer_limit__() {}
pchepa_version = ""; // $gitvar$describe$
filter_recess = filter_lip_size.y + 2*filter_grip;
slot_inner_wall = 1.5*wrapwall_thickness; // extra before slot_id
slot_outer_wall = wrapwall_thickness; // extra after slot_od
slot_width = wrapwall_thickness > 0 ? wrapwall_thickness + 2*wrapwall_tolerance : 0;
slot_id = filter_od + filter_extra_space + 2*slot_inner_wall;
slot_od = slot_id + 2*slot_width;
wall_d = slot_id/2 + slot_od/2;
common_od = slot_od + 2*slot_outer_wall;
cover_od = common_od + 2*max(cover_overhang, cover_underhang);
base_od = common_od + 2*base_overhang;
cover_extra = filter_count < 2 ? 0 : base_od - cover_od;
wall_extra = filter_count < 2 ? 0 : base_od - wall_d;
cover_hole = cover_heatset_hole.x * cover_heatset_hole.y > 0
? cover_heatset_hole
: [struct_val(screw_info(grill_screw), "diameter") + 0.2, 8];
power_channel_size = [
power_pcb_size[0] + 2*power_channel_chamfer,
sqrt(power_pcb_size[1]^2/2) +
sqrt(power_pcb_size[2]^2/2) +
2*power_channel_chamfer,
];
wall_height = filter_height - 2*filter_recess + 2*wrapwall_slot_depth;
// TODO pockets in the base for weights or battery bank
/// mode[0-9] -- assemblies
if (mode == 0) {
echo(camera_arg());
echo(str("anim@", $t, " explode=", explode));
if (filter_count == 1) {
assembly();
}
else if (filter_count == 2) {
left(base_od/2)
left(explode/2)
assembly($idx = 0)
right(explode)
attach(RIGHT, LEFT) assembly($idx = 1);
}
else {
assert(false, "base unsupported filter_count");
}
}
else if (mode >= 1 && mode < 10) {
assembly($idx = mode - 1);
}
/// mode[10-19] -- bases
else if (mode >= 10 && mode < 20) {
base_i = mode - 10;
by = base_i % 2 == 0 ? RIGHT : LEFT;
bb = base_i % 2 == 0 ? LEFT : RIGHT;
translate($preview ? bb*base_od/2 : [0, 0, 0])
preview_cutaway(dir=by)
recolor(base_color) base($idx = base_i, label = true, anchor=BOTTOM) recolor(undef) {
%if (buddy) {
attach([
for (i = [ base_i % 2 : 2 : len(base_clip_sockets())-1 ])
str("clip_socket_", i)
], BOTTOM, overlap=clip_size.y - explode/4) clip(spin=90);
if (base_i == 0) {
if (base_embed_power_port) {
fwd(explode)
position("power_module")
recolor(power_module_color) power_module();
up(explode)
position("power_channel")
recolor(base_color) channel_plug(anchor=BOTTOM);
}
if (base_embed_power_bank) {
translate(by * explode)
position("power_bank")
recolor(power_bank_color) power_bank();
}
if (base_embed_battery_holder)
attach("battery_cavity_bottom", BOTTOM)
translate(by * min(batt_holder_size.x*2, 2*explode))
battery_housing() {
back(max(0, explode - $parent_size.x/2))
up(2*max(0, explode - $parent_size.x/2))
attach(TOP, "under")
battery_housing_lid();
up(max(0, explode - $parent_size.x/2))
attach("mount", "mount")
battery_holder_mockup()
up(max(0, explode - $parent_size.x/2)/2)
position(["batt1", "batt2"])
recolor("orange")
cyl(d=18, h=65, rounding=1, orient=FRONT);
back(min(batt_exit_size*2, max(0, explode - batt_exit_size/2)))
position(BACK)
battery_exit_channel(anchor=FRONT, orient=DOWN);
}
}
up(explode) attach("filter", BOTTOM) hepa_filter();
}
}
}
/// mode[20-29] -- tops (i.e. filter/fan integration cover)
else if (mode >= 20 && mode < 29) {
cover_i = mode - 20;
preview_cutaway(dir=FRONT)
recolor(cover_color)
cover($idx = cover_i, anchor = "filter", orient = $preview ? UP : DOWN) recolor(undef) {
%if (buddy) {
away = $idx % 2 == 0 ? RIGHT : LEFT;
down(explode) attach("filter", TOP) hepa_filter();
up(explode/4)
down(cover_heatset_hole.y)
up($eps)
attach(["screw_hole_0", "screw_hole_1", "screw_hole_2", "screw_hole_3"], BOTTOM)
heatset_insert();
attach([
for (i = [ cover_i % 2 : 2 : cover_clips-1 ])
str("clip_socket_", i)
], BOTTOM, overlap=clip_size.y - explode/4) clip(spin=90);
translate(away*(explode/4))
position(["port1", "port2"])
cover_port_grommet(orient=DOWN);
up(explode)
attach(TOP, "vent_bottom")
recolor(grill_color) grill($idx=cover_i) recolor(undef) {
down(explode/2)
attach("vent_interior", TOP) recolor(fan_color) pc_fan();
screw_length = grill_size().z + 5;
up(explode/2)
attach(["screw_hole_0", "screw_hole_1", "screw_hole_2", "screw_hole_3"], BOTTOM, overlap=screw_length)
recolor(grill_screw_color) screw(
spec = grill_screw,
head = grill_screw_head,
drive = grill_screw_drive,
thread = false, length = screw_length);
grill_controller(cover_i);
}
}
}
}
else if (mode == 29) {
cover_port_grommet();
}
/// mode[30-39] -- fan grills
else if (mode >= 30 && mode < 40) {
grill_i = mode - 30;
preview_cutaway(dir=FRONT)
recolor(grill_color)
grill($idx = grill_i, orient=$preview ? UP : DOWN) recolor(undef) {
%if (buddy) {
attach("vent_interior", TOP) pc_fan();
attach("vent_bottom", TOP) render() cover($idx = grill_i);
}
}
}
/// mode[40-49] -- base labels
else if (mode >= 40 && mode < 50) {
base_label_demo(mode - 40);
}
/// mode[50-59] -- wall sections
else if (mode >= 50 && mode < 59) {
wall_i = mode - 50;
wall_section(
w = wrapwall_length == 0 ? undef : wrapwall_length,
h = wrapwall_height == 0 ? undef : wrapwall_height,
left_dovetail = is_bit_set(wall_i, 0),
right_dovetail = is_bit_set(wall_i, 1)
);
}
/// mode[70-79] -- battery pack parts
else if (mode == 70) {
preview_cutaway(LEFT)
battery_housing()
if ($preview)
attach("mount", "mount")
battery_holder_mockup();
}
else if (mode == 71) {
preview_cutaway(FRONT)
battery_housing_lid(orient=$preview ? UP : DOWN)
if ($preview)
attach("under", TOP)
battery_housing();
}
else if (mode == 72) {
battery_exit_channel();
}
/// mode[90-99] -- spare parts
else if (mode == 90) {
clip(orient=FWD);
}
else if (mode == 91) {
channel_plug();
}
else if (mode == 93) {
pwm_pot_knob();
}
else if (mode == 94 || mode == 95) {
preview_cutaway(dir=BACK)
let (
is_brace = mode == 95,
od = slot_id - 4*wrapwall_draft,
id = filter_od,
md = id/2 + od/2,
w = od - id,
h = is_brace ? 20 : filter_height - 2*filter_recess,
outline = wallarc(d=md, adj=2.5), // TODO why adj tho
foot_w = 25,
foot_c = 5
)
recolor("yellow")
path_sweep(
shape = square([w, h], center=true),
path = is_brace ? outline : wallarc_add_feet(outline, foot_w, foot_c),
anchor = BOTTOM);
}
/// mode[100...] -- development aids and tests
else if (mode == 100) {
pwm_controller()
{
// show_anchors();
// #cube($parent_size, center=true);
}
}
else if (mode == 101) {
preview_cut(RIGHT, t=power_channel_size.x*7/8)
power_module_fit_test() {
if (!$preview) {
fwd(power_channel_chamfer)
back(power_channel_size.y / 2)
left(power_channel_size.x)
up(base_size().z - power_module_size().z/2)
attach(LEFT+BOTTOM, RIGHT+TOP)
channel_plug();
}
}
}
else if (mode == 102) {
wallslot_test() {
if ($preview) {
up(1)
back(
$idx == 0 ? cover_overhang + 2*wrapwall_thickness :
$idx == 1 ? base_overhang + 2*wrapwall_thickness :
0)
position(FRONT+TOP)
wall_section(w=50, h=50, anchor=TOP+BACK, orient=BACK);
}
}
}
else if (mode == 103) {
cover_hole_test(orient=$preview ? UP : DOWN);
}
else if (mode == 104) {
zrot($preview ? 0 : 180)
preview_cut(FRONT) clip_socket_tolerance_test(
tolerances=[ for (tol = [ clip_fit_test.x : clip_fit_test.y : clip_fit_test.z ]) tol ],
orient=$preview ? UP : BACK);
}
else if (mode == 105) {
pad = 5;
x_cut = base_od/2 - power_bank_size.x/2 - pad;
y_cut = power_bank_size.y/2 + pad;
xcopies(n = 2, spacing = x_cut) {
plate_xcut_idx(x_cut)
preview_cutaway(dir=BOTTOM)
back(y_cut/2)
front_half(s=base_od*2.1, y=y_cut)
base(label = false);
}
}
else if (mode == 106) {
echo(camera_arg());
power_bank() {
// mahths adatped form bosl2 show_anchors, dont worry 'bout it
label_size = 1.5;
%for (anchor = ["USB-A", "Micro USB-A", "USB-C"]) {
attach(anchor)
up(4*label_size)
fwd(2*label_size)
recolor([1, 1, 1, 1])
cube([label_size*4/4.5*len(anchor), label_size*4/3, $eps], center=true)
attach(TOP, BOTTOM)
recolor("black")
text3d(anchor, size=label_size, h=$eps, atype="ycenter", center=true);
}
}
}
else if (mode == 107) {
sz = grill_size();
y_cut = sz.y/4;
left_cut = -sz.x/2 + grill_thickness;
yrot($preview ? 0 : 180)
back_half(y=-y_cut, s=2.1*base_od)
front_half(y=y_cut, s=2.1*base_od)
left(left_cut) left_half(x=left_cut, s=2.1*base_od)
grill();
}
else if (mode == 108) {
w = pwm_ctl_pcb_size.x + 2*pwm_ctl_inset;
l = pwm_ctl_pcb_size.y + grill_thickness + pwm_ctl_inset;
x_cut = grill_size().x/2 - w;
y_cut = grill_size().y/2 - l;
yrot($preview ? 0 : 180)
left(w/2) left(x_cut)
back(l/2) back(y_cut)
right_half(s=2.1*base_od, x=x_cut)
front_half(s=2.1*base_od, y=-y_cut)
grill($idx = 0);
}
/// implementation
function is_bit_set(val, idx) =
let(pow2 = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768])
floor(val / pow2[idx%8]) % 2 == 1;
function camera_arg() = str( "--camera=",
$vpt.x, ",", $vpt.y, ",", $vpt.z, ",",
$vpr.x, ",", $vpr.y, ",", $vpr.z, ",",
$vpd);
module build_plate(size=build_plate_size, anchor = CENTER, spin = 0, orient = UP) {
size = scalar_vec3(size, 1);
down(size.z)
attachable(anchor, spin, orient, size=size) {
%cube(size=size, center=true);
children();
}
}
// Development cutaway aid
module preview_cut(v=UP, s=max(build_plate_size), t=0) {
if ($preview && cutaway) {
half_of(v, s=s)
translate(scalar_vec3(t))
children();
} else {
children();
}
}
module base_label_demo(i = 0) {
mode = floor(i / filter_count);
j = i % filter_count;
od = filter_od + 2*filter_lip_size.x;
id = filter_id;
module neg(anchor = CENTER, spin = 0, orient = UP) {
attachable(anchor, spin, orient, d=od, h=4*base_label_depth) {
recolor(base_color)
cyl(d = od, h=2*base_label_depth, anchor=TOP)
attach(TOP, BOTTOM, overlap=$eps)
diff()
cyl(d = id, h=2*base_label_depth+$eps, anchor=TOP)
tag("remove")
attach(TOP, BOTTOM, overlap=base_label_depth)
base_label(i = j, h = base_label_depth + $eps);
children();
}
}
module pos(anchor = CENTER, spin = 0, orient = UP) {
attachable(anchor, spin, orient, d=id, h=base_label_depth) {
recolor(base_label_color)
base_label(i = j, positive = true);
children();
}
}
module maybe_flip() {
if (label_bottom) {
xflip() children();
} else {
children();