From 122148f8e554f52be7a942945d913d4cd9806a69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gy=C3=B6rgy=20Kurucz?= <kuruczgyurci@hotmail.com>
Date: Sun, 1 Apr 2018 16:13:19 +0200
Subject: [PATCH] Added tobacco pusher model. Added rotary encoder knob model.

---
 src/pcb_box/pcb_box.scad                      | 98 +++++++++++++++++--
 .../rotary_encoder_knob.scad                  | 30 ++++++
 src/tobacco_pusher/tobacco_pusher.scad        | 16 +++
 3 files changed, 136 insertions(+), 8 deletions(-)
 create mode 100644 src/rotary_encoder_knob/rotary_encoder_knob.scad
 create mode 100644 src/tobacco_pusher/tobacco_pusher.scad

diff --git a/src/pcb_box/pcb_box.scad b/src/pcb_box/pcb_box.scad
index da02b64..01a0c2a 100644
--- a/src/pcb_box/pcb_box.scad
+++ b/src/pcb_box/pcb_box.scad
@@ -1,16 +1,98 @@
 
-s = [55, 63];
+/* config 1
+pcb = [55, 63, 1.65];
 margin = 0.5;
 lip = 1;
 height = 12;
 corner_r = 2;
 bottom_wall = 1;
+top_height = 6.5;
+top_part_thickness = 2;
+*/
 
-difference() {
-    translate([0, 0, -height/2]) linear_extrude(height) minkowski() {
-        square([s.x, s.y], center=true);
-        circle(r=corner_r, $fn=50);
+pcb = [45.02, 44.8, 1.75];
+margin = 0.7;
+extend = [0, 8];
+lip = [1, 1];
+height = 15;
+corner_r = 2;
+bottom_wall = 1;
+top_height = 20 - 5;
+top_part_thickness = 2;
+top_part_margin = 0.4;
+
+module txt(t, s=4) {
+    text(t, font="DejaVu Sans Mono", size=s);
+}
+
+module outline() {
+    minkowski() {
+            square([pcb.x+extend.x, pcb.y+extend.y], center=true);
+            circle(r=corner_r, $fn=50);
     }
-    translate([0, 0, height/2]) cube([s.x + margin, s.y + margin, height], center=true);
-    translate([0, 0, bottom_wall]) cube([s.x - lip*2, s.y - lip*2, height], center=true);
-}
\ No newline at end of file
+}
+
+module bottom_part() {
+    translate([0, 0, height/2]) difference() {
+        translate([0, 0, -height/2]) linear_extrude(height) outline();
+        translate([0, 0, height/2]) cube([pcb.x + margin, pcb.y + margin, height], center=true);
+        translate([0, 0, bottom_wall]) cube([pcb.x - lip.x*2, pcb.y - lip.y*2, height], center=true);
+    }
+}
+
+module connectors() {
+    translate([-pcb.x/2, -pcb.y/2]) {
+        /* config1
+        translate([15, 1.5]) square([20, 25.5-1.5]); //inputs
+        translate([38, 1.5]) square([16, 25.5-1.5]); //dimmers
+        translate([35, 31-5/2]) square([8, 20]); //isp
+        translate([33, 31+15/2-5/2]) square([5, 5]); //isp notch
+        translate([16+3-0.6, 56]) square([18, 6]); //rpi
+        translate([8+1, 43]) square([9, 7]); //switches
+        translate([4+1-0.5, 28+2.5]) square([7, 10]);
+        */
+        translate([14.02+18.4858/2, 12.95+16.4/2]) circle(r=7, $fn=30); //sw1
+        translate([31.895+10.75/2, 15.925+9.95/2]) circle(r=4, $fn=30);
+    }
+}
+
+module markings() {
+    translate([-pcb.x/2, -pcb.y/2]) {
+        /* config1
+        translate([pcb.x-3, pcb.y-36.5]) rotate(90) txt("Controller", 4.6);
+        //translate([13.5, 5.5]) rotate(90) txt("buses");
+        //translate([pcb.x+1.5, 4]) rotate(90) txt("dimmers", 3);
+        translate([21.5, pcb.y-14]) rotate(0) txt("rPi", 5);
+        //translate([31, 33]) rotate(90) txt("ISP");
+        translate([13, 30]) rotate(0) txt("+12V");
+        translate([13, 36]) rotate(0) txt("+5V");
+        translate([-1.5, 35]) rotate(0) txt("-", 7);
+        translate([-1.5, 29]) rotate(0) txt("-", 7);
+        */
+    }
+}
+
+module top_part() {
+    difference() {
+        union() {
+            translate([0, 0, height]) linear_extrude(top_height) outline();
+            z = height/2 - pcb.z;
+            f = top_part_thickness/2;
+            translate([0, 0, height-z]) linear_extrude(z+f)
+            square([pcb.x+margin-top_part_margin, pcb.y+margin-top_part_margin], center=true);
+        }
+        linear_extrude(height+top_height-top_part_thickness) square([pcb.x - lip.x*2, pcb.y - lip.y*2], center=true);
+        linear_extrude(50) connectors();
+        t = top_part_thickness;
+        translate([0, 0, height+top_height-t/2]) linear_extrude(t) markings();
+    }
+}
+
+//difference() {
+//    bottom_part();
+//    translate([0, 0, 50+bottom_wall]) cube([20, pcb.y+extend.y, 100], center=true);
+//    cylinder(d=8, center=true, h=5, $fn=30);
+//}
+rotate([180, 0, 0]) 
+//translate([0, 0, 3])
+top_part();
\ No newline at end of file
diff --git a/src/rotary_encoder_knob/rotary_encoder_knob.scad b/src/rotary_encoder_knob/rotary_encoder_knob.scad
new file mode 100644
index 0000000..9a21aad
--- /dev/null
+++ b/src/rotary_encoder_knob/rotary_encoder_knob.scad
@@ -0,0 +1,30 @@
+
+interface_height = 5;
+interface_margin = 0.25;
+rod_height = 5.5;
+outside_diameter = 11;
+knob_height = 7;
+knob_diameter = 25;
+knob_corner_r = 2;
+
+module outline() {
+    difference() {
+        circle(d=6, $fn=50);
+        translate([-5, 4.5-6/2]) square([10, 10]);
+    }
+}
+
+rotate([180, 0, 0]) difference() {
+    union() {
+        cylinder(d=outside_diameter, h = interface_height + rod_height + knob_height/2, $fn=60);
+        translate([0, 0, interface_height + rod_height]) {
+            cylinder(d=knob_diameter, h=knob_height/2, $fn=50);
+            minkowski() {
+                translate([0, 0, knob_corner_r]) cylinder(r=knob_diameter/2-knob_corner_r, h=knob_height-knob_corner_r*2, $fn=50);
+                sphere(r=knob_corner_r, $fn=50);
+            }
+        }
+    }
+    translate([0, 0, -1]) linear_extrude(interface_height+1) offset(interface_margin) outline();
+}
+
diff --git a/src/tobacco_pusher/tobacco_pusher.scad b/src/tobacco_pusher/tobacco_pusher.scad
new file mode 100644
index 0000000..6db28d3
--- /dev/null
+++ b/src/tobacco_pusher/tobacco_pusher.scad
@@ -0,0 +1,16 @@
+base = [67, 5.5, 5.5];
+shoulder = 6;
+tab_height = 28;
+tab_width = 20;
+tab_thickness = 2;
+module tab() {
+    t = (base.x - tab_width)/2;
+    m = -base.z/2;
+    polygon(points=[
+        [0, m], [base.x, m], [base.x, shoulder], [base.x-t, tab_height],
+        [t, tab_height], [0, shoulder]
+    ]);
+}
+
+translate([0, base.y/2 + tab_thickness/2, base.z]) rotate([90, 0, 0]) linear_extrude(tab_thickness) tab();
+cube(base);
\ No newline at end of file
-- 
GitLab