-
Notifications
You must be signed in to change notification settings - Fork 0
/
points gauge.scad
131 lines (112 loc) · 3.28 KB
/
points gauge.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
// Draw the plaque
// Draw the gauge with servo cuttouts
difference()
{
union()
{
difference()
{
color("blue")
translate([-52.8,-10,0]) cube([112,73,1.5]);
translate([-51.8,-9,00.5]) cube([110,71,2]);
}
rotate([0,0,240]) draw_gauge();
}
$fn = 15;
translate([0,0,-0.1]) cylinder(h=5, r=6);
translate([6.2,0,-0.1]) cylinder(h=5, r=2.5);
}
// Various modules
module draw_gauge()
{
// Draw the edges
mark(0,0.5,55,0);
mark(1,0.5,55,0);
// Draw the major lines and labels
for(i = [0 : 0.1 : 1])
{
mark(i,1,15,40);
label(i, i * 100);
}
// Draw the minor lines
for(i = [0 : 0.01 : 1])
{
mark(i,0.2,5,50);
}
}
module label(percent, value)
{
// 0% = 180
// 100% = 60
converted_angle = 177.5 - (120 * percent);
//text(text = str(text,"_",a[1]), font = font, size = 20, halign = a[1]);
//}
linear_extrude(height = 1.5)
{
// 180 is left extent, 60 is right extent
rotate([0,0,converted_angle])
translate([0, 55,0])
rotate([0,0,90]) text(text = str(value), size = 4.5);
}
}
// Percent is the relative angle on the dial where left is 0 and right is 1
// Thickness is how wide
// Length is length
// Margin is how far from the centre point
module mark(percent, thickness, length, margin)
{
// 0% = 180
// 100% = 60
converted_angle = 180 - (120 * percent);
offset = thickness / 2;
// 180 is left extent, 60 is right extent
rotate([0,0,converted_angle])
translate([-offset, margin,0])
cube([thickness,length,1.5]);
}
/*
* Excerpt from...
*
* Parametric Encoder Wheel
*
* by Alex Franke (codecreations), March 2012
* http://www.theFrankes.com
*
* Licenced under Creative Commons Attribution - Non-Commercial - Share Alike 3.0
*/
module arc(innerradius, radius, height, degrees )
{
$fn=60;
render()
{
if( degrees > 180 )
{
difference()
{
difference()
{
cylinder( r=radius, h=height );
cylinder( r=innerradius*1.0001, h=height );
}
rotate([0,0,-degrees]) arc( innerradius,radius*1.0001, height*1.0001, 360-degrees) ;
}
}
else
{
difference()
{
// Outer ring
rotate_extrude()
translate([innerradius, 0, 0])
square([radius - innerradius,height]);
// Cut half off
translate([0,-(radius+1),-.5])
cube ([radius+1,(radius+1)*2,height+1]);
// Cover the other half as necessary
rotate([0,0,180-degrees])
translate([0,-(radius+1),-.5])
cube ([radius+1,(radius+1)*2,height+1]);
}
}
}
}