Ver código fonte

add for loop for sw position and orientation

phschoen 1 ano atrás
pai
commit
4c279668f9
1 arquivos alterados com 31 adições e 124 exclusões
  1. 31
    124
      hardware/trackball.scad

+ 31
- 124
hardware/trackball.scad Ver arquivo

@@ -190,30 +190,13 @@ roller_mount_holder_gap = 0.8;
190 190
 sensor_pcb_mount_gap = 2.0;
191 191
 
192 192
 sensor_pcb_support_h = 1.6 + 3.4;
193
-
194
-sw1_rot_x = -5;
195
-sw1_rot_z = -30 * (left_hand_version ? -1 : 1);
196
-sw1_trans_x = 0;
197
-sw1_trans_y = -base_dia / 2 - 0;
198
-sw1_trans_z = -17;
199
-
200
-sw2_rot_x = -5;
201
-sw2_rot_z = 15 * (left_hand_version ? -1 : 1);
202
-sw2_trans_x = 0;
203
-sw2_trans_y = -base_dia / 2 - 0;
204
-sw2_trans_z = -17;
205
-
206
-sw3_rot_x = -5;
207
-sw3_rot_z = 125 * (left_hand_version ? -1 : 1);
208
-sw3_trans_x = 0;
209
-sw3_trans_y = -base_dia / 2 - 0;
210
-sw3_trans_z = -17;
211
-
212
-sw4_rot_x = -5;
213
-sw4_rot_z = -125 * (left_hand_version ? -1 : 1);
214
-sw4_trans_x = 0;
215
-sw4_trans_y = -base_dia / 2 - 0;
216
-sw4_trans_z = -17;
193
+//         rotate                                     translate
194
+sw = [
195
+        [ [-5,0, -30 * (left_hand_version ? -1 : 1)], [0,-base_dia / 2 - 0,-17]],
196
+        [ [-5,0,  15 * (left_hand_version ? -1 : 1)], [0,-base_dia / 2 - 0,-17]],
197
+        [ [-5,0, 125 * (left_hand_version ? -1 : 1)], [0,-base_dia / 2 - 0,-17]],
198
+        [ [-5,0,-125 * (left_hand_version ? -1 : 1)], [0,-base_dia / 2 - 0,-17]],
199
+    ];
217 200
 
218 201
 sw_mount_w = mx_co_w + 7;
219 202
 sw_mount_co_l = 10;
@@ -574,30 +557,13 @@ module trackball_top() {
574 557
             color("orange")
575 558
             hull() {
576 559
                 roller_mount_tri_hull();
577
-                
578
-                rotate([0, 0, sw1_rot_z])
579
-                translate([sw1_trans_x, sw1_trans_y, sw1_trans_z])
580
-                rotate([90 + sw1_rot_x, 0, 0])
581
-                translate([0, 0, -0.5])
582
-                cube([sw_mount_w, sw_mount_w, 1], center = true);
583
-                
584
-                rotate([0, 0, sw2_rot_z])
585
-                translate([sw2_trans_x, sw2_trans_y, sw2_trans_z])
586
-                rotate([90 + sw2_rot_x, 0, 0])
587
-                translate([0, 0, -0.5])
588
-                cube([sw_mount_w, sw_mount_w, 1], center = true);
589
-                
590
-                rotate([0, 0, sw3_rot_z])
591
-                translate([sw3_trans_x, sw3_trans_y, sw3_trans_z])
592
-                rotate([90 + sw3_rot_x, 0, 0])
593
-                translate([0, 0, -0.5])
594
-                cube([sw_mount_w, sw_mount_w, 1], center = true);
595
-                
596
-                rotate([0, 0, sw4_rot_z])
597
-                translate([sw4_trans_x, sw4_trans_y, sw4_trans_z])
598
-                rotate([90 + sw4_rot_x, 0, 0])
599
-                translate([0, 0, -0.5])
600
-                cube([sw_mount_w, sw_mount_w, 1], center = true);
560
+                for ( i = [0:len(sw)-1] ){
561
+                    rotate([0,sw[i][0][1],sw[i][0][2]])
562
+                    translate(sw[i][1])
563
+                    rotate([90+sw[i][0][0],0,0])
564
+                    translate([0, 0, -0.5])
565
+                    cube([sw_mount_w, sw_mount_w, 1], center = true);
566
+                }
601 567
             }
602 568
             
603 569
             roller_mount_tri_body();
@@ -606,65 +572,19 @@ module trackball_top() {
606 572
             translate([0, -base_dia / 2 - 1, -40])
607 573
             cube([base_dia / 2 + 1, base_dia + 2, 40]);
608 574
             
609
-            rotate([0, 0, sw1_rot_z])
610
-            translate([sw1_trans_x, sw1_trans_y, sw1_trans_z])
611
-            rotate([90 + sw1_rot_x, 0, 0])
612
-            translate([0, 0, -sw_mount_co_l]) {
613
-                mx_switch_cutout(sw_mount_co_l + 1);
614
-                
615
-                translate([0, 0, 2])
616
-                rotate([90, 0, 0])
617
-                cylinder(d = 4, h = 20);
618
-            }
619
-            
620
-            rotate([0, 0, sw2_rot_z])
621
-            translate([sw2_trans_x, sw2_trans_y, sw2_trans_z])
622
-            rotate([90 + sw2_rot_x, 0, 0])
623
-            translate([0, 0, -sw_mount_co_l]) {
624
-                mx_switch_cutout(sw_mount_co_l + 1);
625
-                
626
-                translate([0, 0, 2])
627
-                rotate([90, 0, 0])
628
-                cylinder(d = 4, h = 20);
629
-            }
630
-            
631
-            rotate([0, 0, sw3_rot_z])
632
-            translate([sw3_trans_x, sw3_trans_y, sw3_trans_z])
633
-            rotate([90 + sw3_rot_x, 0, 0])
634
-            translate([0, 0, -sw_mount_co_l]) {
635
-                mx_switch_cutout(sw_mount_co_l + 1);
636
-                
637
-                translate([0, 0, 2])
638
-                rotate([90, 0, 0])
639
-                cylinder(d = 4, h = 20);
640
-            }
641
-            
642
-            rotate([0, 0, sw4_rot_z])
643
-            translate([sw4_trans_x, sw4_trans_y, sw4_trans_z])
644
-            rotate([90 + sw4_rot_x, 0, 0])
645
-            translate([0, 0, -sw_mount_co_l]) {
646
-                mx_switch_cutout(sw_mount_co_l + 1);
647
-                
648
-                translate([0, 0, 2])
649
-                rotate([90, 0, 0])
650
-                cylinder(d = 4, h = 20);
651
-            }
652 575
             
653
-            /*
654
-            hull() {
655
-                rotate([0, 0, sw1_rot_z])
656
-                translate([sw1_trans_x, sw1_trans_y, sw1_trans_z])
657
-                rotate([90 + sw1_rot_x, 0, 0])
658
-                translate([0, 0, -sw_mount_co_l + 5])
659
-                mx_switch_cutout(sw_mount_co_l - 10);
660
-                
661
-                rotate([0, 0, sw2_rot_z])
662
-                translate([sw2_trans_x, sw2_trans_y, sw2_trans_z])
663
-                rotate([90 + sw2_rot_x, 0, 0])
664
-                translate([0, 0, -sw_mount_co_l + 5])
665
-                mx_switch_cutout(sw_mount_co_l - 10);
576
+            for ( i = [0:len(sw)-1] ){
577
+                rotate([0,sw[i][0][1],sw[i][0][2]])
578
+                translate(sw[i][1])
579
+                rotate([90+sw[i][0][0],0,0])
580
+                translate([0, 0, -sw_mount_co_l]) {
581
+                    mx_switch_cutout(sw_mount_co_l + 1);
582
+                    
583
+                    translate([0, 0, 2])
584
+                    rotate([90, 0, 0])
585
+                    cylinder(d = 4, h = 20);
586
+                }
666 587
             }
667
-            */
668 588
             
669 589
         
670 590
             for (r = screw_angles)
@@ -676,25 +596,12 @@ module trackball_top() {
676 596
         
677 597
         roller_mount_sensor_pcb_support();
678 598
     
679
-        if (draw_switches) {
680
-            %rotate([0, 0, sw1_rot_z])
681
-            translate([sw1_trans_x, sw1_trans_y, sw1_trans_z])
682
-            rotate([90 + sw1_rot_x, 0, 0])
683
-            mx_switch($t);
684
-        
685
-            %rotate([0, 0, sw2_rot_z])
686
-            translate([sw2_trans_x, sw2_trans_y, sw2_trans_z])
687
-            rotate([90 + sw2_rot_x, 0, 0])
688
-            mx_switch($t);
689
-        
690
-            %rotate([0, 0, sw3_rot_z])
691
-            translate([sw3_trans_x, sw3_trans_y, sw3_trans_z])
692
-            rotate([90 + sw3_rot_x, 0, 0])
693
-            mx_switch($t);
694
-        
695
-            %rotate([0, 0, sw4_rot_z])
696
-            translate([sw4_trans_x, sw4_trans_y, sw4_trans_z])
697
-            rotate([90 + sw4_rot_x, 0, 0])
599
+        if (draw_switches)
600
+        for ( i = [0:len(sw)-1] ){
601
+            rotate([0,sw[i][0][1],sw[i][0][2]])
602
+            translate(sw[i][1])
603
+            rotate([90+sw[i][0][0],0,0])
604
+                translate([0, 0, 1.])
698 605
             mx_switch($t);
699 606
         }
700 607
     }

Carregando…
Cancelar
Salvar