chiark / gitweb /
adafruit-powerboost: wip fix led mixup
[reprap-play.git] / adafruit-powerboost-1000.scad
1 // -*- C -*-
2
3 psu_sz_nom = [ 11.43*2, 36.20 ];
4
5 //// toplevels-from:
6 include <adafruit-powerboost-common.scad>
7
8 psu_hole_pos = [ 2.05, // from back edge of psu_sz[0]
9                  0.55 * 0.5 * 25.4, // from centreline
10                  ];
11
12 psu_led_low_x = 4;
13
14 psu_led_usbend_y_min = 4.5;
15 psu_led_chrg_min_x = -1.0;
16 psu_led_chrg_max_x = 3.0;
17 psu_led_chrg_both_sz_y = 9.4;
18
19 psu_led_low_sz_x = 4.5;
20 psu_led_low_min_y = -1.5;
21 psu_led_low_max_y = 2.5;
22
23 psu_led_baffle_th = 0.8;
24 psu_led_baffle_ends = 1.5;
25
26 psu_baffle_th = [ 0.8, 3.5 ];
27 psu_innerend_led_depth = 7;
28
29 psu_led_legend_line = 0.75;
30
31 psu_led_legend_battery_l = 6.0;
32 psu_led_legend_battery_w = 4.0;
33 psu_led_legend_battery_nub_l = 0.75;
34 psu_led_legend_battery_nub_w = 1.5;
35
36 psu_led_legend_power_dia = 5.0;
37
38 psu_led_legend_gap = 1.25;
39
40 // ----- calculated -----
41
42 psu_led_legend_battery_edge = psu_led_legend_line;
43
44 psu_led_legend_power_tick_l =
45   psu_led_legend_power_dia * 0.65;
46 psu_led_legend_power_tick_dy = psu_led_legend_line;
47
48 psu_led_legend_power_sz_y =
49   psu_led_legend_power_dia/2 + psu_led_legend_power_tick_l/2
50   - psu_led_legend_power_tick_dy;
51
52 psu_innerend_led_x_midder =  - psu_hole_pos[1] - psu_hole_dia/2;
53
54 module PsuLedBafflePlan(){
55   AtPsuMountCorner(0,0) {
56     translate([ (psu_led_chrg_min_x + psu_led_chrg_max_x)/2,
57                psu_led_usbend_y_min + psu_led_chrg_both_sz_y/2 ])
58       square(center=true,
59              [ psu_led_chrg_max_x - psu_led_chrg_min_x
60                + psu_led_baffle_ends*2,
61                psu_led_baffle_th ]);
62   }
63 }
64
65 module PsuLedWindowsPlanCore(){
66   difference(){
67     union(){
68       // Two LEDs one side of inlet connector
69       // "Full" (near edge) and "Chrg" (inner)
70       AtPsuMountCorner(0,0) {
71         translate([0, psu_led_usbend_y_min ])
72           rectfromto([ psu_led_chrg_min_x, 0 ],
73                      [ psu_led_chrg_max_x,
74                        psu_led_chrg_both_sz_y ]);
75       }
76
77       // One LED, "Low", other side of inlet connector
78       AtPsuMountCorner(1,0) {
79         translate([0, psu_led_usbend_y_min ])
80           rectfromto([ 0,
81                        psu_led_low_min_y ],
82                      [ psu_led_low_sz_x,
83                        psu_led_low_max_y ]);
84       }
85
86       // One LED, PWR, near outlet USB pads
87       AtPsuMountCorner(0,1){
88         rectfromto([0,0],
89                    [psu_sz[0]/2 + psu_innerend_led_x_midder,
90                     psu_innerend_led_depth]);
91       }
92     }
93   }
94 }
95
96 module PsuLedLegendBattery(percent=50){
97   e = psu_led_legend_battery_edge;
98   empty_l = (100-percent)/100 * (psu_led_legend_battery_l - e*2);
99   difference(){
100     union(){
101       square([psu_led_legend_battery_l,
102               psu_led_legend_battery_w], center=true);
103       translate([psu_led_legend_battery_l/2, 0])
104         square([psu_led_legend_battery_nub_l*2,
105                 psu_led_legend_battery_nub_w], center=true);
106     }
107     if (empty_l > 0)
108       translate([-(psu_led_legend_battery_l/2-e),
109                  -(psu_led_legend_battery_w/2-e)])
110         square([empty_l, psu_led_legend_battery_w - e*2]);
111   }
112 }  
113
114 module PsuLedLegendPowerSymbol(){
115   $fn=30;
116   tick_mid = [0, psu_led_legend_power_dia/2 - psu_led_legend_power_tick_dy];
117
118   cut_slope = ( psu_led_legend_gap + psu_led_legend_line/2 ) / tick_mid[1];
119   cut_y = psu_led_legend_power_dia + 1;
120
121   translate(tick_mid)
122     square([psu_led_legend_line, psu_led_legend_power_tick_l], center=true);
123   
124   difference(){
125     circle(r= psu_led_legend_power_dia/2);
126     circle(r= psu_led_legend_power_dia/2 - psu_led_legend_line);
127
128     polygon([[0, 0],
129              [-cut_y * cut_slope, cut_y],
130              [ cut_y * cut_slope, cut_y]]);
131
132     if(0) translate(tick_mid)
133       square([psu_led_legend_line, psu_led_legend_power_tick_l]
134              + [psu_led_legend_gap*2, 0.1],
135              center=true);
136   }
137 }
138
139 module PsuLedLegendsPlan(){
140   translate([psu_led_legend_battery_l/2
141              + psu_innerend_led_x_midder
142              + psu_led_legend_gap,
143              psu_sz[1]/2
144              - psu_innerend_led_depth/2
145              ])
146     PsuLedLegendBattery(0);
147
148   for (full=[0,1]) {
149     translate([-psu_sz[0]/2
150                + psu_led_legend_battery_l/2
151                + psu_led_chrg_max_x
152                + psu_led_legend_gap,
153                -psu_sz[1]/2
154                + psu_led_usbend_y_min
155                + psu_led_chrg_both_sz_y * (1-full)
156                ])
157       PsuLedLegendBattery(full ? 100 : 50);
158   }
159
160   translate([psu_sz[0]/2
161              - psu_led_legend_power_dia/2,
162              -psu_sz[1]/2
163              + psu_led_legend_gap
164              + psu_led_usbend_y_min
165              + psu_led_low_max_y
166              + psu_led_legend_power_sz_y
167              ])
168     rotate([0,0,180])
169     PsuLedLegendPowerSymbol();
170 }