No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

trackball.scad 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. /*
  2. * Trackball
  3. * Copyright 2022 Thomas Buck - thomas@xythobuz.de
  4. *
  5. * Required parts:
  6. * - 1x Raspberry Pi Pico
  7. * - 4x Cherry MX compatible switches and keycaps
  8. * - 1x Billard ball, diameter 38mm
  9. * - 3x Si3N4 static bearing balls, diameter 3mm
  10. * - 1x PMW3360 sensor with breakout board
  11. * - 8x M2 screw, length 5mm
  12. * - 8x M2 heat melt insert, length 4mm
  13. *
  14. * For the PMW3360 breakout board get this:
  15. * https://github.com/jfedor2/pmw3360-breakout
  16. *
  17. * This program is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU General Public License as published by
  19. * the Free Software Foundation, either version 3 of the License, or
  20. * (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * See <http://www.gnu.org/licenses/>.
  28. */
  29. // https://www.thingiverse.com/thing:421524
  30. use <external/cherry_mx.scad>
  31. // https://www.printables.com/model/210898-raspberry-pi-pico-case
  32. use <external/pico_case.scad>
  33. // ######################
  34. // ## Rendering Select ##
  35. // ######################
  36. //ball_and_roller();
  37. //pico_wrap();
  38. //sensor();
  39. //mx_switch_cutout(wall);
  40. //mx_switch_test();
  41. //roller_mount_test();
  42. //roller_holder();
  43. //roller_mount_tri();
  44. //trackball_top();
  45. //trackball_bottom();
  46. assembly();
  47. //print();
  48. // #######################
  49. // #### Configuration ####
  50. // #######################
  51. $fn = 200;//42;
  52. ball_dia = 38.0;
  53. roller_dia = 3.0;
  54. roller_ball_h = ball_dia / 2 - 5;
  55. roller_count = 3;
  56. wall = 3.0;
  57. $c = 0.1;
  58. $e = 0.01;
  59. left_hand_version = false;
  60. cut_roller_holder = false;
  61. draw_supports = false;
  62. draw_ball_roller = true;
  63. draw_switches = true;
  64. draw_sensor = true;
  65. use_external_pico_model = true;
  66. // #######################
  67. // ## Raspberry Pi Pico ##
  68. // #######################
  69. pico_w = 21;
  70. pico_l = 51;
  71. pico_d = 1.0;
  72. pico_hole_d = 2.1;
  73. pico_hole_x = 4.8;
  74. pico_hole_y = 2.0;
  75. pico_hole_d_x = 11.4;
  76. pico_hole_d_y = pico_l - 2 * pico_hole_y;
  77. pico_usb_w = 8.0;
  78. pico_usb_h = 2.8;
  79. pico_usb_d = 6.0;
  80. pico_usb_off = 1.3;
  81. // ######################
  82. // ### PMW3360 Sensor ###
  83. // ######################
  84. // https://github.com/jfedor2/pmw3360-breakout
  85. sensor_w = 22;
  86. sensor_l = 34;
  87. sensor_pcb_h = 1.6;
  88. sensor_hole_dia = 2.2;
  89. sensor_hole_off_x = 3.0;
  90. sensor_hole_off_y = 3.0;
  91. sensor_hole_dist_x = 16.0;
  92. sensor_hole_dist_y = 24.5;
  93. sensor_cut_w = 8.0 + 0.5;
  94. sensor_cut_h = 17.26;
  95. sensor_cut_off_x = 7.0 - 0.25;
  96. sensor_cut_off_y = 5.27;
  97. sensor_cut_edge_to_pin1 = 2.75;
  98. sensor_edge_to_pin1 = 1.52;
  99. sensor_ball_to_lens_top = 2.4;
  100. sensor_ball_to_chip_bottom = 9.81;
  101. sensor_chip_w = 9.1;
  102. sensor_chip_l = 16.2;
  103. sensor_chip_h = 2.21;
  104. sensor_pin_w = 0.5;
  105. sensor_pin_h = 4.51;
  106. sensor_pin_d = 0.2;
  107. sensor_pin_dist = 10.7;
  108. sensor_pin_off_top = 0.5;
  109. sensor_pin_pitch = 0.89;
  110. sensor_pin1_to_optical_center = 5.66;
  111. sensor_lens_cutout_r = 2.0;
  112. sensor_lens_cutout_w = 4.0;
  113. sensor_lens_cutout_growth = 0.25;
  114. sensor_lens_cutout_to_chip = 6.71 - 1.60;
  115. sensor_lens_baseplate_h = 2.40;
  116. sensor_lens_d = 19.0 + 1.0;
  117. sensor_lens_w = 21.35 + 0.2;
  118. sensor_lens_off = 10.97;
  119. // ######################
  120. // ## MX Switch Cutout ##
  121. // ######################
  122. // https://geekhack.org/index.php?topic=70654.0
  123. mx_co_w = 14.0;
  124. mx_co_w_add = 0.8;
  125. mx_co_h = 14.0;
  126. mx_co_h_off_1 = 1.0;
  127. mx_co_h_off_2 = 3.5;
  128. mx_co_h_off_3 = mx_co_h - 2 * (mx_co_h_off_1 + mx_co_h_off_2);
  129. mx_co_r = 0.4;
  130. // https://geekhack.org/index.php?topic=71550.0
  131. mx_co_th = 1.5 - 0.1;
  132. mx_co_b_add = 1.0;
  133. mx_co_b_w = mx_co_w + mx_co_b_add;
  134. mx_co_b_h = mx_co_h + mx_co_b_add;
  135. mx_travel = 3.9;
  136. // ######################
  137. // ### Implementation ###
  138. // ######################
  139. base_dia = 62;
  140. grub_screw_dia = 2.8;
  141. grub_channel_dia = 4.0;
  142. roller_thread_dia = roller_dia + 5.0;
  143. roller_h = roller_dia + 7.0;
  144. roller_ball_h_off = 0.4;
  145. roller_ball_hold_off = 0.5;
  146. roller_thread_hole = roller_dia - 1;
  147. roller_small_hole = sphere_r_at_h(roller_ball_hold_off, roller_dia / 2) * 2;
  148. roller_ridge_h = 1.5;
  149. roller_mount_angle_off = 90;
  150. roller_mount_dia = roller_thread_dia + 2.0;
  151. ball_h = 15; // todo
  152. switch_test_w = 25;
  153. roller_mount_holder_gap = 0.8;
  154. sensor_pcb_mount_gap = 2.0;
  155. sensor_pcb_support_h = 1.6 + 3.4;
  156. // rotate translate
  157. sw = [
  158. [ [-5,0, -30 * (left_hand_version ? -1 : 1)], [0,-base_dia / 2 - 0,-17]],
  159. [ [-5,0, 15 * (left_hand_version ? -1 : 1)], [0,-base_dia / 2 - 0,-17]],
  160. [ [-5,0, 125 * (left_hand_version ? -1 : 1)], [0,-base_dia / 2 - 0,-17]],
  161. [ [-5,0,-125 * (left_hand_version ? -1 : 1)], [0,-base_dia / 2 - 0,-17]],
  162. ];
  163. sw_mount_w = mx_co_w + 7;
  164. sw_mount_co_l = 10;
  165. bottom_base_wall = wall + 0.5;
  166. bottom_base_below_zero = bottom_base_wall + 4.5;
  167. pico_co_w = pico_w + 1;
  168. pico_co_l = pico_l + 1;
  169. reset_button_dia = 4.0;
  170. reset_button_off_x = 7;
  171. reset_button_off_y = 12.15;
  172. pico_support_w = 6.5;
  173. pico_support_l = 5;
  174. pico_screw_depth = 6;
  175. pico_screw_d = 1.8;
  176. usb_cutout_grow_l = 10;
  177. usb_cutout_grow_x = 20;
  178. usb_cutout_grow_y = 40;
  179. usb_cutout_w_add = 1;
  180. usb_cutout_h_add = 0.6;
  181. assembly_dist = 20;
  182. roller_holder_sider_cut = 1.5;
  183. roller_holder_h_compensation = -0.1;
  184. bottom_add_wall = 4;
  185. screw_dia = 3.2;
  186. screw_off = base_dia / 2 - 10;
  187. screw_head_d = 6.0;
  188. screw_head_h = 3.5;
  189. screw_angles = [ 15, -15, 180 + 15, 180 - 15 ];
  190. screw_insert_dia = 4.8;
  191. screw_insert_h = 6.0;
  192. function sphere_r_at_h(h, r) = r * sin(acos(h / r));
  193. function sphere_angle_at_rh(h, r) = acos(h / r);
  194. module mx_switch_cutout(h) {
  195. translate([-mx_co_w / 2 - mx_co_w_add, -mx_co_h / 2, 0]) {
  196. linear_extrude(h + 1) {
  197. translate([mx_co_w_add, 0]) {
  198. square([mx_co_w, mx_co_h]);
  199. for (x = [mx_co_r / 2, mx_co_w - mx_co_r / 2])
  200. for (y = [mx_co_r / 2, mx_co_h - mx_co_r / 2])
  201. translate([x, y])
  202. circle(r = mx_co_r);
  203. }
  204. for (x = [0, mx_co_w + mx_co_w_add])
  205. for (y = [0, mx_co_h_off_2 + mx_co_h_off_3])
  206. translate([x, mx_co_h_off_1 + y, 0])
  207. square([mx_co_w_add, mx_co_h_off_2]);
  208. }
  209. translate([mx_co_w_add - mx_co_b_add / 2, -mx_co_b_add / 2, -1])
  210. cube([mx_co_b_w, mx_co_b_h, h - mx_co_th + 1]);
  211. }
  212. }
  213. module mx_switch_test() {
  214. difference() {
  215. translate([-switch_test_w / 2, -switch_test_w / 2, 0])
  216. cube([switch_test_w, switch_test_w, wall]);
  217. mx_switch_cutout(wall);
  218. translate([0, -switch_test_w / 2 + 1, wall - 1.0])
  219. linear_extrude(1.1)
  220. text("switch test", size = 3, halign = "center");
  221. }
  222. %translate([0, 0, wall])
  223. rotate([0, 0, 180])
  224. mx_switch($t);
  225. }
  226. module pico_own() {
  227. translate([-pico_w / 2, -pico_l / 2, 0])
  228. difference() {
  229. union() {
  230. color("green")
  231. cube([pico_w, pico_l, pico_d]);
  232. translate([(pico_w - pico_usb_w) / 2, pico_l - pico_usb_d + pico_usb_off, pico_d])
  233. cube([pico_usb_w, pico_usb_d, pico_usb_h]);
  234. }
  235. for (x = [0, pico_hole_d_x])
  236. for (y = [0, pico_hole_d_y])
  237. translate([pico_hole_x + x, pico_hole_y + y, -1])
  238. cylinder(d = pico_hole_d, h = pico_d + 2);
  239. }
  240. }
  241. module pico_wrap() {
  242. //if (use_external_pico_model)
  243. translate([-pico_w / 2, -pico_l / 2, 0])
  244. pico();
  245. //else
  246. pico_own();
  247. }
  248. module sensor_lens_cutout_intern() {
  249. cylinder(d = sensor_lens_cutout_r * 2, h = $e);
  250. translate([-sensor_lens_cutout_r, 0, 0])
  251. cube([sensor_lens_cutout_r * 2, sensor_lens_cutout_w, $e]);
  252. }
  253. module rounded_cube(x, y, z, r) {
  254. hull()
  255. for (tx = [r, x - r])
  256. for (ty = [r, y - r])
  257. translate([tx, ty, 0])
  258. cylinder(d = r * 2, h = z);
  259. }
  260. module sensor_lens_cutout() {
  261. translate([0, 0, sensor_lens_cutout_to_chip])
  262. hull() {
  263. translate([0, 0, sensor_lens_baseplate_h - $e])
  264. sensor_lens_cutout_intern();
  265. scale(1 + sensor_lens_cutout_growth * sensor_lens_baseplate_h)
  266. sensor_lens_cutout_intern();
  267. }
  268. translate([-sensor_lens_d / 2, -sensor_lens_w + sensor_lens_off, 0])
  269. rounded_cube(sensor_lens_d, sensor_lens_w, sensor_lens_cutout_to_chip, 6);
  270. translate([-3 / 2, -sensor_lens_w + sensor_lens_off - 0.5, 0])
  271. cube([3, 0.5, sensor_lens_cutout_to_chip]);
  272. }
  273. module sensor() {
  274. translate([-sensor_w / 2, -sensor_l / 2, 0])
  275. difference() {
  276. color("green")
  277. cube([sensor_w, sensor_l, sensor_pcb_h]);
  278. translate([sensor_cut_off_x, sensor_cut_off_y, -1])
  279. cube([sensor_cut_w, sensor_cut_h, sensor_pcb_h + 2]);
  280. for (x = [0, sensor_hole_dist_x])
  281. for (y = [0, sensor_hole_dist_y])
  282. translate([sensor_hole_off_x + x, sensor_hole_off_y + y, -1])
  283. cylinder(d = sensor_hole_dia, h = sensor_pcb_h + 2);
  284. }
  285. color("#303030")
  286. translate([-sensor_chip_w / 2, -sensor_l / 2 - sensor_chip_l + sensor_edge_to_pin1 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1, -sensor_chip_h])
  287. cube([sensor_chip_w, sensor_chip_l, sensor_chip_h]);
  288. translate([0, -sensor_l / 2 - 15 * sensor_pin_pitch + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1, 0])
  289. for (p = [0 : 15])
  290. translate([0, p * sensor_pin_pitch, 0])
  291. for (x = [-sensor_pin_dist / 2, sensor_pin_dist / 2])
  292. if (((p % 2 == 0) && (x < 0))
  293. || ((p % 2 == 1) && (x > 0)))
  294. translate([-sensor_pin_d / 2 + x, -sensor_pin_w / 2, -sensor_chip_h + sensor_pin_off_top])
  295. cube([sensor_pin_d, sensor_pin_w, sensor_pin_h]);
  296. translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0]) {
  297. color("cyan")
  298. translate([0, 0, -sensor_chip_h + 1])
  299. cylinder(d = 0.2, h = sensor_ball_to_chip_bottom - 1);
  300. %color("blue")
  301. sensor_lens_cutout();
  302. }
  303. }
  304. module ball_and_roller() {
  305. color("red")
  306. sphere(d = ball_dia, $fn = $fn * 2);
  307. for (r = [0 : roller_count - 1])
  308. rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r])
  309. translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h])
  310. rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0])
  311. translate([0, 0, -roller_dia / 2])
  312. roller_holder();
  313. }
  314. module roller_holder() {
  315. translate([0, 0, -roller_h + roller_dia / 2])
  316. difference() {
  317. color("magenta")
  318. union() {
  319. translate([0, 0, roller_h-roller_dia/2 + roller_ball_h_off-3])
  320. cylinder(d1 = roller_mount_dia, d2=roller_dia+1, h = 3);
  321. cylinder(d = roller_mount_dia, h = roller_h-roller_dia/2 + roller_ball_h_off-3);
  322. }
  323. translate([-roller_mount_dia / 2 - 1, roller_mount_dia / 2 - roller_holder_sider_cut, -1])
  324. cube([roller_mount_dia + 2, roller_mount_dia / 2 + 1, roller_h + 2]);
  325. translate([0, 0, -$e])
  326. cylinder(d = roller_thread_hole, h = $e+ roller_h - roller_dia / 2 + roller_ball_h_off + roller_ball_hold_off);
  327. translate([0, 0, roller_h - roller_dia / 2 + roller_holder_h_compensation])
  328. sphere(d = roller_dia, $fn = $fn * 2);
  329. if (cut_roller_holder)
  330. translate([-roller_thread_dia / 2 - 1, -roller_thread_dia, -1])
  331. cube([roller_thread_dia + 2, roller_thread_dia, roller_h + 2]);
  332. }
  333. %color("blue")
  334. sphere(d = roller_dia, $fn = $fn * 2);
  335. }
  336. module roller_mount() {
  337. translate([0, 0, -1-roller_h + roller_dia / 2]) {
  338. difference() {
  339. cylinder(d=roller_mount_dia+wall,h=roller_h/2);
  340. translate([0, 0, 1])
  341. cylinder(d=roller_mount_dia+$c*2,h=roller_h/2+$e);
  342. if (cut_roller_holder)
  343. translate([-roller_thread_dia / 2 - 1, -roller_thread_dia, -1])
  344. cube([roller_thread_dia + 2, roller_thread_dia, roller_h + 2]);
  345. }
  346. }
  347. }
  348. module roller_mount_test() {
  349. roller_holder();
  350. roller_mount();
  351. }
  352. module roller_mount_tri_hull() {
  353. for (r = [0 : roller_count - 1])
  354. rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r])
  355. translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h])
  356. rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0])
  357. translate([0, 0, -roller_h])
  358. cylinder(d = roller_mount_dia + wall + 1, h = roller_h - 3);
  359. translate([0, 0, -ball_dia / 2 - 11])
  360. cylinder(d = base_dia, h = $e);
  361. }
  362. module roller_mount_tri_body() {
  363. // space for roller holder
  364. for (r = [0 : roller_count - 1])
  365. rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r])
  366. translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h])
  367. rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0])
  368. translate([0, 0, -roller_h])
  369. cylinder(d = roller_mount_dia + roller_mount_holder_gap, h = ball_dia / 2 + roller_h);
  370. // room for ball itself
  371. sphere($fn = $fn * 2, d = ball_dia + $c * 2 + 4);
  372. // grub screws
  373. for (r = [0 : roller_count - 1])
  374. rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r])
  375. translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h])
  376. rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0])
  377. translate([0, 0, -roller_h/2])
  378. rotate([0,-90,0])
  379. translate([-2, 0, 2]) {
  380. cylinder(d = grub_screw_dia, h = ball_dia);
  381. translate([0, 0, roller_mount_dia / 4 + wall])
  382. cylinder(d = grub_channel_dia, h = ball_dia);
  383. }
  384. // sensor lens
  385. translate([0, 0, -ball_dia / 2 - ball_h])
  386. translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, ball_h + sensor_chip_h - sensor_ball_to_chip_bottom])
  387. translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0])
  388. sensor_lens_cutout();
  389. // sensor pcb
  390. translate([-1, -1, -ball_dia / 2 - ball_h])
  391. translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, ball_h + sensor_chip_h - sensor_ball_to_chip_bottom])
  392. translate([-sensor_w / 2, -sensor_l / 2, -10])
  393. cube([sensor_w + 2, sensor_l + 2, sensor_pcb_h + 10 + sensor_pcb_mount_gap]);
  394. }
  395. module roller_mount_sensor_pcb_support() {
  396. translate([-sensor_w / 2, -sensor_l / 2, sensor_pcb_h])
  397. translate([0, 0, -ball_dia / 2 - ball_h])
  398. translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, ball_h + sensor_chip_h - sensor_ball_to_chip_bottom])
  399. for (x = [0, sensor_hole_dist_x])
  400. for (y = [0, sensor_hole_dist_y])
  401. translate([sensor_hole_off_x + x, sensor_hole_off_y + y, 0])
  402. difference() {
  403. union() {
  404. color("magenta")
  405. cylinder(d = sensor_hole_dia + 1.5, h = sensor_pcb_mount_gap);
  406. if (draw_supports)
  407. color("black")
  408. translate([0, 0, -sensor_pcb_support_h])
  409. cylinder(d = sensor_hole_dia + 0.5, h = sensor_pcb_support_h);
  410. }
  411. cylinder(d = sensor_hole_dia - 0.2, h = sensor_pcb_mount_gap + 1);
  412. }
  413. if (draw_supports)
  414. color("black")
  415. for (x = [-5, 0, 5])
  416. for (y = [-8, 0, 6.5])
  417. if (((x == 0) && (y != 0)) || ((x != 0) && (y == 0)))
  418. translate([x, y + 2, -30])
  419. cylinder(d = sensor_hole_dia + 0.5, h = 8.5);
  420. if (draw_sensor)
  421. %translate([0, 0, -ball_dia / 2 - ball_h])
  422. translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, ball_h + sensor_chip_h - sensor_ball_to_chip_bottom])
  423. sensor();
  424. }
  425. // TODO holes for pcb screws not going into body!!
  426. module roller_mount_tri() {
  427. if (draw_ball_roller)
  428. %ball_and_roller();
  429. difference() {
  430. hull()
  431. roller_mount_tri_hull();
  432. roller_mount_tri_body();
  433. // TODO test cable cutout
  434. translate([-6, 0, -30.1])
  435. cube([12, 50, 2]);
  436. if (cut_roller_holder)
  437. translate([0, -base_dia / 2 - 1, -40])
  438. cube([base_dia / 2 + 1, base_dia + 2, 40]);
  439. }
  440. roller_mount_sensor_pcb_support();
  441. }
  442. module trackball_top() {
  443. translate([0, 0, ball_dia / 2 + ball_h]) {
  444. if (draw_ball_roller)
  445. %ball_and_roller();
  446. difference() {
  447. color("orange")
  448. hull() {
  449. roller_mount_tri_hull();
  450. for ( i = [0:len(sw)-1] ){
  451. rotate([0,sw[i][0][1],sw[i][0][2]])
  452. translate(sw[i][1])
  453. rotate([90+sw[i][0][0],0,0])
  454. translate([0, 0, -0.5])
  455. cube([sw_mount_w, sw_mount_w, 1], center = true);
  456. }
  457. }
  458. roller_mount_tri_body();
  459. if (cut_roller_holder)
  460. translate([0, -base_dia / 2 - 1, -40])
  461. cube([base_dia / 2 + 1, base_dia + 2, 40]);
  462. for ( i = [0:len(sw)-1] ){
  463. rotate([0,sw[i][0][1],sw[i][0][2]])
  464. translate(sw[i][1])
  465. rotate([90+sw[i][0][0],0,0])
  466. translate([0, 0, -sw_mount_co_l]) {
  467. mx_switch_cutout(sw_mount_co_l + 1);
  468. translate([0, 0, 2])
  469. rotate([90, 0, 0])
  470. cylinder(d = 4, h = 20);
  471. }
  472. }
  473. for (r = screw_angles)
  474. rotate([0, 0, r])
  475. translate([screw_off, 0, -ball_dia / 2 - 11 -1]) {
  476. cylinder(d = screw_insert_dia, h = screw_insert_h + 1);
  477. }
  478. }
  479. roller_mount_sensor_pcb_support();
  480. if (draw_switches)
  481. for ( i = [0:len(sw)-1] ){
  482. rotate([0,sw[i][0][1],sw[i][0][2]])
  483. translate(sw[i][1])
  484. rotate([90+sw[i][0][0],0,0])
  485. translate([0, 0, 1.])
  486. mx_switch($t);
  487. }
  488. }
  489. }
  490. module trackball_bottom_wrap() {
  491. %rotate([0, 180, 0])
  492. pico_wrap();
  493. color("magenta")
  494. translate([0, 0, -bottom_base_below_zero])
  495. difference() {
  496. cylinder(d = base_dia, h = bottom_base_below_zero + ball_h - 11);
  497. translate([0, 0, bottom_base_wall])
  498. cylinder(d = base_dia - bottom_base_wall * 2 - bottom_add_wall, h = bottom_base_below_zero + ball_h - 11);
  499. translate([-pico_co_w / 2, -pico_co_l / 2, bottom_base_wall])
  500. cube([pico_co_w, pico_co_l, bottom_base_below_zero + ball_h - 11]);
  501. translate([pico_w / 2 - reset_button_off_x, pico_l / 2 - reset_button_off_y, -1])
  502. cylinder(d = reset_button_dia, h = bottom_base_wall + 2);
  503. if (cut_roller_holder)
  504. translate([-base_dia / 2 - 1, -base_dia / 2 - 1, -10])
  505. cube([base_dia / 2 + 1, base_dia + 2, 40]);
  506. }
  507. color("cyan")
  508. for (x = [-1, 1])
  509. for (y = [-1, 1])
  510. translate([x * (pico_co_w - pico_support_w) / 2, y * (pico_co_l - pico_support_l) / 2, 0])
  511. translate([-pico_support_w / 2, -pico_support_l / 2, -bottom_base_below_zero + bottom_base_wall])
  512. cube([pico_support_w, pico_support_l, bottom_base_below_zero - bottom_base_wall - pico_d]);
  513. color("cyan")
  514. for (r = screw_angles)
  515. rotate([0, 0, r])
  516. translate([screw_off, 0, -bottom_base_below_zero + bottom_base_wall])
  517. cylinder(d = screw_head_d + 4, h = bottom_base_below_zero + ball_h - 11 - bottom_base_wall);
  518. }
  519. module usb_cutout() {
  520. hull() {
  521. translate([-usb_cutout_w_add / 2, 0, -usb_cutout_h_add / 2])
  522. cube([pico_usb_w + usb_cutout_w_add, 1, pico_usb_h + usb_cutout_h_add]);
  523. translate([-usb_cutout_grow_x / 2, usb_cutout_grow_l, -usb_cutout_grow_y / 2])
  524. cube([pico_usb_w + usb_cutout_grow_x, 1, pico_usb_h + usb_cutout_grow_y]);
  525. }
  526. }
  527. module trackball_bottom() {
  528. difference() {
  529. trackball_bottom_wrap();
  530. for (x = [0, pico_hole_d_x])
  531. for (y = [0, pico_hole_d_y])
  532. translate([-pico_w / 2, -pico_l / 2, 0])
  533. translate([pico_hole_x + x, pico_hole_y + y, -pico_d - pico_screw_depth])
  534. cylinder(d = pico_screw_d, h = pico_d + pico_screw_depth + 1);
  535. rotate([0, 180, 0])
  536. translate([-pico_w / 2, -pico_l / 2, 0])
  537. translate([(pico_w - pico_usb_w) / 2, pico_l - 1 + pico_usb_off, pico_d])
  538. usb_cutout();
  539. for (r = screw_angles)
  540. rotate([0, 0, r])
  541. translate([screw_off, 0, -bottom_base_below_zero - 1]) {
  542. cylinder(d = screw_dia, h = bottom_base_below_zero + 30);
  543. cylinder(d = screw_head_d, h = screw_head_h + 1);
  544. }
  545. }
  546. }
  547. module assembly() {
  548. translate([0, 0, assembly_dist / 2])
  549. trackball_top();
  550. translate([0, 0, -assembly_dist / 2])
  551. trackball_bottom();
  552. }
  553. module print() {
  554. translate([-40, 0, -4])
  555. trackball_top();
  556. translate([40, 0, bottom_base_below_zero])
  557. trackball_bottom();
  558. for (y = [-20, 0, 20])
  559. translate([0, y, 8.5])
  560. roller_holder();
  561. }