-
Notifications
You must be signed in to change notification settings - Fork 2
/
phone_case.scad
2140 lines (1909 loc) · 77.7 KB
/
phone_case.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
/* Phone case generator.
* Supports phone case, Joycon rails, Junglecat rails, and Cuttlephone gamepad
* Designed to 3d print with PLA+, 0.4mm nozzle, 0.2mm layer height.
* Author: Maave
*/
use <fonts/orbitron/orbitron-light.otf>
use <fonts/Baloo_2/Baloo2-VariableFont_wght.ttf>
use <fonts/Audiowide/Audiowide-Regular.ttf>
// The Belfry OpenScad Library, v2
// These have to be imported using an "include" statement because several variables for things like anchors are defined in here.
include <libraries/BOSL2_submodule/std.scad>
include <libraries/BOSL2_submodule/geometry.scad>
include <libraries/BOSL2_submodule/rounding.scad>
include <libraries/BOSL2_submodule/shapes3d.scad>
/* measurements from the phone
* all values are in mm
* Customizer's UI precision (0.1, 0.01, etc) depends on the precision of the variable.
*/
/* [shell] */
case_material = "hard"; // [hard, soft]
case_type = "phone case"; // [phone case, gamepad, joycon, junglecat]
case_thickness = 1.6; // 0.1
//if the screen is curved and the case cutaway, you might want some extra grip
shell_side_stickout = 0; // 0.1
// Thin the shell lips around the screen bezels, keeping full case thickness at the top and bottom
shell_enable_angled_screen_bezels = false;
// Thickest the lip should be on the outer edges (in practice - a little under that due to curves used)
shell_screen_max_lip_outer = 2; // 0.1
// Thinnest the lip should be on the inner edges
shell_screen_min_lip_inner = 1; // 0.1
/* [emboss] */
phone_model = "Sample case";
emboss_size = "large"; // [logo, large, small, very_small, none]
//Check font names in OpenSCAD > Help > Font List. Simple sans-serif fonts will print better
emboss_font = "Audiowide";
font_size = 7.1; // 0.1
emboss_small_font = "Audiowide";
small_font_size = 6.1; // 0.1
emboss_logo = "logos/dude.svg";
logo_x = 0.0; // 0.1
logo_y = 0.0; // 0.1
/* [3D print] */
//this will support the rail and some overhangs during a horizontal print, and support the Joycon lock notch on a vertical print
manual_supports = true;
support_thickness = 0.4;
//This will make a gap in between the supports and the object. Set this to approx your layer height.
support_airgap = 0.20;
//test cuts. Print part of the case to see how it fits
test_mode = "none"; //[none, corners, right_edge, right_buttons, left_edge, bottom_edge, top_edge, left_button, top_half_pla, telescopic]
//NOT WORKING. A plastic guide to help you cut the support out of the Joycon or Junglecat rails
rail_cut_tools = false;
render_quality="quick"; // [quick, export]
/* [body] */
//rounding of the corners when viewed screen-up.
body_radius = 5.25; // 0.01
//replaces the round radius with a 45-degree cut
body_chamfer = false;
body_length = 140.0; // 0.1
body_width = 50.0; // 0.1
body_thickness = 8.1; // 0.1
body_radius_top = 2.1; // 0.01
body_radius_bottom = 3.1; // 0.01
//for phones with different rounding on the sides, like Galaxy S9
body_bottom_side_radius = 0.1; // 0.01
//decrease for shallow shallow curves like the S9
body_bottom_side_angle = 90; // 0.1
/* [screen] */
screen_radius = 8.01; // 0.01
screen_lip_length = 3.1; // 0.1
screen_length = body_length - screen_lip_length;
screen_lip_width = 3.1; // 0.1
screen_width = body_width - screen_lip_width;
//left/right curved screen radius
screen_curve_radius = 0.1; // 0.1
//decrease for shallow shallow curves like the S9
screen_curve_angle = 90; // 0.1
//cuts away the side of the case for curved screens
screen_undercut = 0.1; //default is 0.01 because of Openscad precision bug
//sticks up so the screen is recessed
extra_lip = false;
//NOT WORKING: if the corners are sharp, add some "ramp" to the sides
extra_sides = false;
//use these if one of the corners is particularly loose and you've already tuned the body tight
screen_extra_top_left = 0; // 0.1
screen_extra_top_right = 0; // 0.1
screen_extra_bottom_left = 0; // 0.1
screen_extra_bottom_right = 0; // 0.1
/* [buttons - on the phone's body] */
right_power_button = false;
right_power_from_top = 31.1; // 0.1
right_power_length = 10.1; // 0.1
right_volume_buttons = false;
right_volume_from_top = 50.1; // 0.1
right_volume_length = 20.1; // 0.1
left_power_button = false;
left_power_from_top = 30.1; // 0.1
left_power_length = 10.1; // 0.1
left_volume_from_top = 50.1; // 0.1
left_volume_buttons = false;
left_volume_length = 20.1; // 0.1
//moves the buttons toward the screen (positive) or toward the back panel (negative). Buttons are centered by default
buttons_vertical_fudge = 0.1; // 0.1
// how much to the buttons protrude from the device body's edge in the X or Y axis
button_body_protrusion = 0.5; // 0.01
// how thick are the buttons in the Z axis?
button_case_thickness = 2; // 0.1
/* [buttons - on the case] */
// how much should the buttons protrude out of the case in the X or Y axis
button_shell_protrusion = 0.8; // 0.1
// Button and wall position in the shell, 0 being right on the phone, 100 on the outer edge of the case. (Values further away from center may or may not work well depending on the case thickness and shape of the device.)
button_wall_offset_percentage = 50; // [10.0:0.1:90.0]
// wall thickness, impacts how stiff are the buttons going to be
button_wall_thickness = 0.8; // 0.1
right_power_button_texture = "serrated"; //[none,serrated]
left_power_button_texture = "serrated"; //[none,serrated]
// To allow error in measuring length
button_padding = 2; // 0.1
// Button clearance on hard cases
buttons_clearance_hard_case = 5; // 0.1
// Button clearance on soft cases
buttons_clearance_soft_case = 3; // 0.1
// How thick should the button face be (zero uses hardcoded body_thickness ratios)
buttons_outer_thickness = 0; // 0.1
// Button prismoid angle
buttons_overhang_angle = 60; // 0.1
// Include a notch in the volume rocker
button_volume_rocker_notch = false;
rocker_notch_length = 1; // 0.1
/* [more buttons] */
right_button_1 = false;
right_button_1_from_top = 111.1; // 0.1
right_button_1_length = 10.1; // 0.1
left_button_1 = false;
left_button_1_from_top = 111.1; // 0.1
left_button_1_length = 10.1; // 0.1
right_button_2 = false;
right_button_2_from_top = 131.1; // 0.1
right_button_2_length = 10.1; // 0.1
left_button_2 = false;
left_button_2_from_top = 131.1; // 0.1
left_button_2_length = 10.1; // 0.1
/* [more holes] */
right_hole_1 = false;
right_hole_1_from_top = 89.1; // 0.1
right_hole_1_length = 10.1; // 0.1
right_hole_2 = false;
right_hole_2_from_top = 89.1; // 0.1
right_hole_2_length = 10.1; // 0.1
left_hole_1 = false;
left_hole_1_from_top = 89.1; // 0.1
left_hole_1_length = 10.1; // 0.1
left_hole_2 = false;
left_hole_2_from_top = 89.1; // 0.1
left_hole_2_length = 10.1; // 0.1
/* [camera / fingerprint] */
//camera cutout is a rectangle with rounded corners
camera = true;
camera_width = 20.5; // 0.1
camera_height = 9.1; // 0.1
//get a circle by setting camera_radius to half of height and width
camera_radius = 4.5; // 0.1
camera_from_side = 8.5; // 0.1
camera_from_top = 8.7; // 0.1
// extra gap around camera. 0.5 - 1.0 recommended.
camera_clearance = 1.1; // 0.1
// how much does the camera protrude from the body
camera_protrusion = 0.0; // 0.1
// Does the camera block interact with the edges of the phone - e.g. "island" does not: Pixel 1 to 5, all iPhones so far; "bar" protrudes from the phone back and joins on both sides: Pixel 6, 7; (unsupported) "right_corner" Galaxy S21
camera_block_style = "island"; //[island,bar,right_corner]
camera_block_fillet_radius = 0.5; // 0.1
camera_cutout_chamfer_angle = 45.0; // [0.0:0.1:89.9]
//for irregular shapes like Galaxy S9+
camera_cut_2 = false;
camera_width_2 = 20.5; // 0.1
camera_height_2 = 9.1; // 0.1
camera_from_side_2 = 8.5; // 0.1
camera_from_top_2 = 8.7; // 0.1
fingerprint = false;
fingerprint_center_from_top = 36.5; // 0.1
fingerprint_diam = 13.1; // 0.1
fingerprint_cutout_chamfer_angle = 45.0; // [0.0:0.1:89.9]
// Combines the fingerprint sensor and camera opening into a single larger one. One example where this works well is a thicker soft case on the Pixel 5. (Using OpenSCAD hull() to be specific.)
fingerprint_combine_with_camera = false;
/* [charge, headphone, and mic] */
mic_on_top = false;
mic_on_bottom = false;
top_mic_from_right_edge = 14.1; // 0.1
bottom_mic_from_right_edge = 14.1; // 0.1
top_mic_offset_up = 0.1; // 0.1
bottom_mic_offset_up = 0.1; // 0.1
headphone_from_left_edge = 14.1; // 0.1
headphone_on_top = false;
headphone_on_bottom = false;
charge_on_bottom = true;
charge_cutout_bevel_angle_y = 10;
charge_cutout_bevel_angle_z = 10;
bottom_speakers_right = false;
bottom_speakers_left = false;
bottom_speaker_inner_edge_from_center = 11.6; // 0.1
bottom_speaker_vertical_offset_from_center = 0.0; // 0.1
bottom_speaker_width = 10.5; // 0.1
bottom_speaker_height = 1.2; // 0.1
/* [universal phone adapters] */
split_in_half = false;
telescopic_pocket = false;
body_seam_width = 0.1; // 0.1
body_seam_offset = 0.1; // 0.1
open_top = false;
open_top_backchop = false;
open_top_chop_ratio = 0.51; // 0.01
speaker_holes_bottom = false;
clamp_top = false;
rotate_upright = false;
upright_angle = rotate_upright ? -90 : 0;
telescopic = false;
telescopic_clearance_thickness = 0.5; // 0.1
//the body_width direction of the slider, This often needs sanding
telescopic_clearance_width = 0.8; // 0.1
/* [build vars] */
//will this version be posted on the website?
build_phone=true;
build_junglecat=true;
build_joycon=true;
build_hard=true;
build_soft=true;
in_development=false;
//end customizer variables
module end_customizer_variables(){}
//alternate Fn values to speed up OpenSCAD. Turn this up during build
lowFn = render_quality == "export" ? 100 : 10;
highFn = render_quality == "export" ? 150 : 25;
$fn=highFn;
/* I cannot override some variables via command line. Why? This works. */
case_type_override="stupid_hack";
case_type2 = (case_type_override!=undef && case_type_override!="stupid_hack") ? case_type_override : case_type;
case_material_override="stupid_hack";
case_material2 = (case_material_override!=undef && case_material_override!="stupid_hack") ? case_material_override : case_material;
case_thickness2_override="stupid_hack";
case_thickness2 = (case_thickness2_override!=undef && case_thickness2_override!="stupid_hack") ? case_thickness2_override : case_thickness;
//the base near the phone
soft_button_thickness1 = abs(buttons_outer_thickness) < 0.1 ? body_thickness*0.55 : buttons_outer_thickness;
button_cut_rounding = body_thickness*0.15;
button_rounding=body_thickness*0.1;
//peak of the button - ignored if using buttons_outer_thickness
soft_button_thickness2 = body_thickness*0.22;
soft_cut_height1=body_thickness*0.6;
extra_lip_bonus = extra_lip ? 1 : 0;
anti_snag_radius = 3.8;
upright_translate = rotate_upright ? body_width/2 + case_thickness2 : 0;
// gamepad variables
gamepad_wing_length = 35; //max that will fit on my printer
gamepad_body_radius = 10;
gamepad_shell_radius = 2;
gamepad_peg_y_distance = 14;
// joycon and junglecat shared variables
max_rail_shell_radius = 2.5; //if too high it'll intersect with the rail
max_rail_body_radius = 3.9; //if too high it'll intersect with the stop notch
rail_shell_radius_top = (body_radius_top<max_rail_shell_radius) ? body_radius_top : max_rail_shell_radius; //TODO: tweak this, make is softer to hold, ensure it doesn't conflict with body
rail_shell_radius_bottom = (body_radius_bottom<max_rail_shell_radius) ? body_radius_bottom : max_rail_shell_radius; //TODO: tweak this, make is softer to hold, ensure it doesn't conflict with body
rail_body_radius = (body_radius<max_rail_body_radius) ? body_radius : max_rail_body_radius;
// joycon variables
joycon_inner_width = 10.2;
joycon_lip_width = 7.3;
joycon_lip_thickness = 0.7;
joycon_depth = 2.34;
//this will bottom-out the rail if the body is wide enough
joycon_length = 91.5;
// shell is thickened to fit the joycon
joycon_min_thickness = joycon_inner_width + 2*case_thickness2;
joycon_thickness = (body_thickness < joycon_min_thickness) ? joycon_min_thickness:body_thickness;
joycon_z_shift = body_thickness-joycon_thickness+case_thickness2;
lock_notch_width = 3.8;
lock_notch_offset = 9.8; //how far from the top
lock_notch_depth = (joycon_inner_width-joycon_lip_width)/2;
//junglecat variables
junglecat_rail_length = 61.0;
junglecat_dimple_from_top = 63.5;
junglecat_inner_width = 3.5;
junglecat_lip_width = 2.0;
junglecat_lip_thickness = 0.4;
junglecat_depth = 3.3;
//max joycon thickness. If the entire case is thicker than this, we must make stick-out junglecat rails
junglecat_wing_thickness = 11.7;
junglecat_wing_radius = 1.3;
junglecat_wings = body_thickness+case_thickness2*2 >= junglecat_wing_thickness;
junglecat_stickout = 4.2;
//embossment text
name = "Cuttlephone";
author = "Maave";
version = "v 0.4";
//unsupported features
lanyard_loop = false;
//colors are only visual, and only in OpenSCAD
//use hex values or https://en.wikipedia.org/wiki/Web_colors#X11_color_names
bodyColor="SeaGreen";
translate([0,0,upright_translate])
rotate([0,upright_angle, 0])
main();
module main() {
difference(){
if(case_type2=="phone case") {
phone_case();
}
else if(case_type2=="gamepad") {
gamepad();
}
else if(case_type2=="joycon") {
joycon_rails();
}
else if(case_type2=="junglecat") {
junglecat_rails();
}
test_cuts();
}
if(rail_cut_tools) {
if(case_type2=="joycon") {
joycon_cut_guide();
}
else if(case_type2=="junglecat") {
junglecat_cut_guide();
}
}
}
module phone_case(){
difference(){
color(bodyColor)
phone_shell();
body();
shell_cuts();
}
if (case_material2 == "soft") {
soft_buttons();
}
manual_supports_();
universal_clamp();
telescopic_clamp();
}
module gamepad(){
difference(){
color(bodyColor)
gamepad_shell();
body();
shell_cuts();
gamepad_cuts();
}
gamepad_trigger();
copy_mirror() gamepad_trigger();
//gamepad_faceplates();
universal_clamp();
telescopic_clamp();
}
module shell_cuts(){
usb_cut();
button_cuts();
if (fingerprint_combine_with_camera) {
hull() {
camera_cut();
extra_camera_cut();
fingerprint_cut();
}
} else {
camera_cut();
extra_camera_cut();
fingerprint_cut();
}
mic_cuts();
top_headphone_cut();
screen_cut();
lanyard_cut();
universal_cuts();
version_info_emboss();
}
module joycon_rails(){
difference(){
color(bodyColor)
joycon_shell();
body();
shell_cuts();
joycon_cuts();
}
if (case_material2 == "soft") {
soft_buttons();
}
manual_supports_();
universal_clamp();
telescopic_clamp();
}
module junglecat_rails(){
difference(){
color(bodyColor)
junglecat_shell();
body();
shell_cuts();
junglecat_cuts();
}
if (case_material2 == "soft") {
soft_buttons();
}
manual_supports_();
universal_clamp();
telescopic_clamp();
}
*body();
module body(disable_curved_screen=false, include_camera_block=true){
color("orange", 0.6)
union() {
difference() {
minkowski() {
cube([ body_width - 2*body_radius,
body_length - 2*body_radius,
0.01 ],
center=true
);
//edge profile
//this pill shape will spin around the cube
if(body_chamfer) {
cyl(
l=body_thickness,
r=body_radius,
chamfer1=body_radius_bottom,
chamfer2=body_radius_top,
$fn=lowFn
);
} else {
cyl(
l=body_thickness,
r=body_radius,
rounding1=body_radius_bottom,
rounding2=body_radius_top,
$fn=lowFn
);
}
}
//for curved screens and irregular shapes like Galaxy S9+
//only for the phone shape, not the outside of the case. It causes a snag at the corner
if(!disable_curved_screen){
body_extra_radius();
}
}
if (camera_block_style == "bar" && include_camera_block) {
translate([0,body_length/2-camera_from_top-camera_height/2,-body_thickness/2]) body_camera_bar();
}
}
}
*body_extra_radius();
module body_extra_radius(){
debug = 1; //1.2;
if(body_bottom_side_radius>0.1){ //customizer precision workaround
//bottom curve right
color("Crimson", 0.4)
translate([body_width/2,0,-body_thickness/2])
rotate([90,0,180])
shallow_fillet(l=body_length*debug-body_radius, r=body_bottom_side_radius, ang=body_bottom_side_angle);
//bottom curve left
color("red", 0.4)
translate([-body_width/2,0,-body_thickness/2])
rotate([90,0,0])
shallow_fillet(l=body_length*debug-body_radius, r=body_bottom_side_radius, ang=body_bottom_side_angle);
}
if(screen_curve_radius>0.1){
//curved screen right
color("red", 0.4)
translate([body_width/2,0,body_thickness/2])
rotate([-90,0,180])
shallow_fillet(l=body_length*debug-body_radius, r=screen_curve_radius, ang=screen_curve_angle);
//curved screen left
color("red", 0.4)
translate([-body_width/2,0,body_thickness/2])
rotate([-90,0,0])
shallow_fillet(l=body_length*debug-body_radius, r=screen_curve_radius, ang=screen_curve_angle);
}
}
*body_camera_bar();
module body_camera_bar(){
difference() {
intersection() {
translate([0,0,camera_block_fillet_radius-camera_protrusion]) cuboid([camera_width+camera_block_fillet_radius*2,camera_height,camera_block_fillet_radius*2], rounding = camera_block_fillet_radius, edges = [BOTTOM+LEFT,BOTTOM+RIGHT]);
translate([0,0,-camera_protrusion/2]) cube([body_width,camera_height,camera_protrusion*2], center = true);
}
translate([body_width/2-body_radius_bottom/2,0,camera_protrusion/2]) cube([body_radius_bottom/2,camera_height*2,camera_protrusion*2], center = true);
translate([-(body_width/2-body_radius_bottom/2),0,camera_protrusion/2]) cube([body_radius_bottom/2,camera_height*2,camera_protrusion*2], center = true);
}
}
//manual supports, and stick-out buttons for soft TPU prints
module manual_supports_(){
//support the lock notch on vertical Joycon prints
copy_mirror()
if(case_type2=="joycon" && rotate_upright==true && manual_supports==true){
tower_peak_w = 1;
tower_peak_l = 1;
//support tower
translate([
-body_width/2-case_thickness2,
-body_length/2-case_thickness2-joycon_depth-joycon_lip_thickness-support_airgap,
joycon_z_shift-joycon_lip_width/2
])
rotate([0,90,0])
prismoid(
//wide base, shifted peak
size1=[ tower_peak_l*8, tower_peak_w*8 ],
size2=[ tower_peak_l, tower_peak_w ],
shift=[ -tower_peak_l*3.25, tower_peak_w*3.5 ],
h=body_width+case_thickness2-lock_notch_width/2-lock_notch_depth/2-lock_notch_offset,
anchor=BOTTOM+BACK+LEFT
);
//lock notch support
translate([
body_width/2-lock_notch_depth/2-lock_notch_offset-support_airgap/2,
-body_length/2-case_thickness2-joycon_depth-joycon_lip_thickness,
joycon_z_shift-joycon_lip_width/2-lock_notch_depth/2
])
rotate([0,90,0])
prismoid(
size1=[ tower_peak_l, tower_peak_w ],
//wide enough to tuck under the rail
size2=[ lock_notch_depth-support_airgap, joycon_lip_thickness*2 ],
//shift over so the base meets the support tower
shift=[ 0, joycon_lip_thickness*2-tower_peak_w ],
h=lock_notch_width,
anchor=BACK
);
}
}
*phone_shell();
module phone_shell(){
translate([0,0,extra_lip_bonus/2])
union() {
difference() {
resize(newsize=[
body_width + 2*case_thickness2 + 2*shell_side_stickout,
body_length + 2*case_thickness2,
body_thickness + 2*case_thickness2 + extra_lip_bonus
])
body(disable_curved_screen=true, include_camera_block=false);
}
if (camera_block_style == "bar" && camera_protrusion > case_thickness2) {
translate([0,body_length/2-camera_from_top-camera_height/2,-body_thickness/2])
resize(newsize=[
body_width + 2*case_thickness2 + 2*shell_side_stickout - body_radius_bottom,
camera_height + 2*case_thickness2,
camera_protrusion + 2*case_thickness2
])
body_camera_bar();
}
}
}
module gamepad_shell(){
minkowski() {
//face shape
cube(
[ body_width - 2*gamepad_body_radius,
body_length + gamepad_wing_length*2 - 2*gamepad_body_radius,
0.01 ],
center=true);
//edge shape and thickness
translate([0,0,extra_lip_bonus/2])
cyl(
l=body_thickness + 2*case_thickness2 + extra_lip_bonus,
r=gamepad_body_radius+case_thickness2,
rounding1=gamepad_shell_radius,
rounding2=gamepad_shell_radius
);
}
}
module joycon_shell(){
translate([0,0,joycon_z_shift])
minkowski() {
//face shape
cube(
[ body_width - 2*rail_body_radius,
body_length + 2*joycon_depth + 2*joycon_lip_thickness - 2*rail_body_radius,
0.01 ],
center=true);
//edge shape and thickness
translate([0,0,extra_lip_bonus/2])
cyl(
l=joycon_thickness + 2*case_thickness2 + extra_lip_bonus,
r=rail_body_radius+case_thickness2,
rounding1=rail_shell_radius_bottom,
rounding2=rail_shell_radius_top
);
}
}
module junglecat_shell(){
minkowski() {
//face shape
cube(
[ body_width - 2*rail_body_radius,
body_length + 2*junglecat_depth + 2*junglecat_lip_thickness - 2*rail_body_radius,
0.01 ],
center=true
);
junglecat_edge_shape();
}
//the case is too thick. The junglecat rail needs to stick out
if(junglecat_wings) {
echo("case too thick. Extending for junglecat rails");
minkowski(){
wing_length_margin = 8;
translate([body_width/2-junglecat_dimple_from_top/2-wing_length_margin/2,0,0])
cuboid(
[ junglecat_dimple_from_top+wing_length_margin,
body_length + 2*junglecat_depth + 2*junglecat_lip_thickness+ junglecat_stickout*2+case_thickness2*2,
junglecat_wing_thickness ],
rounding=junglecat_wing_radius,
anchor=CENTER
);
//junglecat_edge_shape();
}
}
universal_clamp();
telescopic_clamp();
module junglecat_edge_shape(){
//edge shape and thickness
translate([0,0,extra_lip_bonus/2])
cyl(
l=body_thickness + 2*case_thickness2 + extra_lip_bonus,
r=rail_body_radius+case_thickness2,
rounding1=rail_shell_radius_bottom,
rounding2=rail_shell_radius_top
);
}
}
//junglecat_cut_guide();
module junglecat_cut_guide(){
finger_tab_l = 40;
finger_tab_h = 40;
copy_mirror() {
translate([0,-body_length*0.6,0]) {
difference() {
union(){
//tube to stick down the rail
scale([1.1,0.9,0.9]) //shrink for clearance and overhang droops
rotate([0,90,0])
prismoid(
size1=[junglecat_inner_width, junglecat_depth],
size2=[junglecat_inner_width, junglecat_depth],
h=junglecat_rail_length,
chamfer=[0,0,0,0],
rounding=[0,junglecat_depth/2,junglecat_depth/2,0],
anchor=CENTER
);
//something to hold onto so you don't cut yourself
rotate([0,0,0])
translate([junglecat_rail_length/2,0.4,-6])
cuboid( [ finger_tab_l, junglecat_inner_width, finger_tab_h],
rounding=1,
edges=[RIGHT,TOP,BOTTOM],
anchor=LEFT+CENTER
);
}
finger_r = 15;
//finger hole
translate([junglecat_rail_length/2+finger_tab_l-finger_r/2,0,-finger_tab_h/2])
rotate([90,0,0])
cyl(h=10, r=finger_r);
//cutout lines
translate([0,-junglecat_depth/2-junglecat_lip_thickness/2,0]) {
rotate([90,0,0])
rect_tube(
size=[ junglecat_rail_length*2+support_airgap*2, junglecat_lip_width+support_airgap*2],
isize=[junglecat_rail_length*2, junglecat_lip_width],
h=junglecat_depth,
anchor=CENTER
);
}
}
}
}
}
//junglecat_cuts();
module junglecat_cuts(universal_inside=false){
//adding the universal cut has janked this up
//TODO: make a single shape and then mirror/translate to desired position
junglecat_stickout_adjust = junglecat_wings && !universal_inside ? junglecat_stickout : 0;
universal_inside_negative = universal_inside ? -1 : 1;
universal_inside_off = universal_inside ? 0 : 1;
universal_inside_on = universal_inside ? 1 : 0;
universal_inside_length = junglecat_rail_length * 1.2;
copy_mirror() {
color("red", 0.4)
translate([0, -body_length/2-case_thickness2*universal_inside_off-junglecat_depth/2 - junglecat_stickout_adjust, 0]) {
//dimple
if(!universal_inside){
translate([body_width/2-junglecat_dimple_from_top,
-case_thickness2-junglecat_lip_thickness,
0])
sphere(d=2.0);}
//inside channels
translate([(body_width-junglecat_rail_length)/2+case_thickness2,-junglecat_lip_thickness*universal_inside_on,0])
rotate([0,90,0])
prismoid(
size1=[junglecat_inner_width, junglecat_depth],
size2=[junglecat_inner_width, junglecat_depth],
h=junglecat_rail_length*1.05,
chamfer=[0,0,0,0],
rounding=[0,junglecat_depth/2,junglecat_depth/2,0],
anchor=CENTER
);
//manual supports or just a cutout
translate([(body_width-junglecat_rail_length)/2+case_thickness2,
(-junglecat_depth/2-junglecat_lip_thickness/2)*universal_inside_negative, 0]) {
if(manual_supports==true && rotate_upright==false){
//this adds a gap to aide removal. It'll probably still require a razor blade
removal_aid = 4;
rotate([90,0,0])
rect_tube(
size=[ junglecat_rail_length + 0.5, junglecat_lip_width ],
isize=[junglecat_rail_length, junglecat_lip_width - support_airgap - 0.01 ],
h=junglecat_depth,
anchor=CENTER);
}
else {
//cut out the rail slot. Bring your own support
cube([junglecat_rail_length + 0.5, junglecat_depth, junglecat_lip_width ], center=true);
}
}
}
}
}
*joycon_cut_guide();
module joycon_cut_guide() {
translate([0,-body_length*0.6,0]) {
difference() {
//bar
cube([body_width*1.5,joycon_depth,joycon_inner_width],center=true);
//cut guides
translate([0,-joycon_depth/2-joycon_lip_thickness/2,0]) {
rotate([90,0,0])
rect_tube(
size=[body_width*2, joycon_lip_width+support_airgap],
isize=[body_width*2-support_airgap, joycon_lip_width],
h=joycon_depth,
anchor=CENTER
);
}
}
}
}
*joycon_cuts();
module joycon_cuts(){
copy_mirror() {
color("red", 0.2)
translate([0, -body_length/2-case_thickness2-joycon_depth/2, joycon_z_shift]) {
//inner cutout
translate([body_width/2+case_thickness2,0,0])
cuboid([joycon_length,joycon_depth,joycon_inner_width], anchor=RIGHT);
//lip cutout
translate([body_width/2+case_thickness2,-joycon_depth/2-joycon_lip_thickness/2,0]) {
if(manual_supports==true && rotate_upright==false){
//this adds a visible lip so you rip off the support and not the rail
removal_aid = 4;
rotate([90,0,0])
rect_tube(
size=[ body_width+5, joycon_lip_width+support_airgap],
isize=[body_width+case_thickness2-removal_aid, joycon_lip_width],
h=joycon_depth,
anchor=RIGHT);
} else { //bring your own support
cuboid([joycon_length, joycon_lip_thickness+2, joycon_lip_width], anchor=RIGHT);
}
}
//lock notch
translate([
body_width/2-lock_notch_depth/2-lock_notch_offset,
-joycon_depth/2-joycon_lip_thickness/2,
-joycon_lip_width/2-lock_notch_depth/2
])
cube([
lock_notch_width,
joycon_lip_thickness+0.5,
lock_notch_depth],
center=true
);
}
}
}
gamepad_cutout_translate = -body_length/2-gamepad_wing_length/2;
gamepad_length_buffer = 2;
gamepad_width_buffer = 2;
//gamepad_cuts();
//gamepad_hole();
module gamepad_hole(){
gamepad_cut_radius = gamepad_body_radius/1.3;
extra_height = 5;
translate([
0,
gamepad_cutout_translate,
extra_height/2
])
prismoid(
size1=[body_width-gamepad_width_buffer, gamepad_wing_length-gamepad_length_buffer],
size2=[body_width-gamepad_width_buffer, gamepad_wing_length-gamepad_length_buffer],
h=body_thickness+extra_height,
rounding=gamepad_cut_radius,
anchor=CENTER,
$fn=lowFn
);
}
trigger_debug = true;
trigger_rounding = 1;
trigger_rounding2 = 4; //this affects the "peg" separating the triggers
trigger_space = 2.5; //this affects the "peg" separating the triggers
trigger_width = 10;
trigger_height = 10;
trigger_clearance = 0.5;
trigger_rounding_profile = [trigger_rounding,0,0,trigger_rounding2];
trigger_inside_lip = 2;
min_trigger_inside_lip_thickness = 1.6; //should be multiple of layer height
//translate([0,0,10]) gamepad_trigger();
module gamepad_trigger(){
trigger_stickout = 2.5;
//TODO: changig the height affects other sizes. Huh?
translate([
body_width/2+case_thickness2,
gamepad_cutout_translate,
case_thickness2/2
])
rotate([0,90,0])
copy_mirror()
translate([0,trigger_width/2+trigger_space/2,case_thickness2]) {
prismoid(
size1=[body_thickness+case_thickness2, trigger_width],
size2=[body_thickness-3, trigger_width-3],
h=trigger_stickout,
rounding=trigger_rounding_profile,
anchor=BOTTOM+CENTER,
$fn=lowFn
);
translate([0,0,-case_thickness2-gamepad_width_buffer]){
prismoid(
size1=[body_thickness+case_thickness2, trigger_width],
size2=[body_thickness+case_thickness2, trigger_width],
h=case_thickness2+gamepad_width_buffer,
rounding=trigger_rounding_profile,
anchor=BOTTOM+CENTER,
$fn=lowFn
);
translate([0,0,-min_trigger_inside_lip_thickness])
prismoid(
size1=[body_thickness+case_thickness2, trigger_width+trigger_inside_lip],
size2=[body_thickness+case_thickness2, trigger_width+trigger_inside_lip],
h=min_trigger_inside_lip_thickness,
rounding=trigger_rounding_profile,
anchor=BOTTOM+CENTER,
$fn=lowFn
);
}
}
}
//gamepad_trigger_cut();
module gamepad_trigger_cut() {
gamepad_trigger(); //ensure it fits
//refactor this so the translations are easier to keep track of. Prob means changing anchor
color("red", 0.2)
translate([
body_width/2,
gamepad_cutout_translate,
0
])
rotate([0,90,0])
copy_mirror() translate([body_thickness/2,trigger_width/2+trigger_space/2,])
prismoid(
size1=[ body_thickness+case_thickness2+1, trigger_width+trigger_clearance],
size2=[ body_thickness+case_thickness2+1, trigger_width+trigger_clearance],
h=body_thickness*2,
rounding=trigger_rounding_profile,
anchor=RIGHT+CENTER,
$fn=lowFn
);
}
//gamepad_ffc_cut();
module gamepad_ffc_cut(){
//
ffc_radius = 3;
ffc_cut_length = 8;
ffc_off_center = -12;
translate([
ffc_off_center,
-body_length/2 ,
-body_thickness/2
])
rotate( [90, 0, 0] )
pie_slice(ang=180, l=ffc_cut_length, r=ffc_radius, center=true);
}
module gamepad_cuts(){
copy_mirror() {
gamepad_hole();
gamepad_trigger_cut();
gamepad_ffc_cut();
}
}
//gamepad_faceplates();
module gamepad_faceplates(){
//color("red", 0.2) peg_cuts();
module peg_cuts() {
translate([0,gamepad_cutout_translate,-body_thickness/2+case_thickness2 +2]) {