$fn=100;

wall = 3;
width = 70;

top_box_height = 59+6;
servo_hole = 2.5+0.5;

screw_cutout_width = 8;
screw_cutout_cc = 45;

button_diameter = 12.5;

button_left_x = -2.54*1.5-2.54*3;
button_left_y = 2.54*0.5+2.54;
button_right_x = -2.54*1.5+2.54*3;
button_right_y = 2.54*0.5+2.54;

led_left_x = -2.54*1.5-2.54*3;
led_left_y = 2.54*0.5+2.54*6.5;
led_right_x = -2.54*1.5+2.54*3;
led_right_y = 2.54*0.5+2.54*6.5;

led_diameter = 2.5;

tolerance = 0.3;

module cover (){
	// Main mounting plate
	difference(){	
		union(){
			cube([width-wall*2-tolerance,top_box_height-wall*2-tolerance,wall], center = true);
			translate([screw_cutout_cc/2,0,0])cube([screw_cutout_width-tolerance, top_box_height, wall], center=true);
			translate([-screw_cutout_cc/2,0,0])cube([screw_cutout_width-tolerance, top_box_height, wall], center=true);
			#translate([-1.3,14,wall/2])rotate([0, 0, 0])linear_extrude(height = 1.5)import("padlock.dxf");
			#translate([-16.5,14,wall/2])rotate([0, 0, 0])linear_extrude(height = 1.5)import("padlock-unlock.dxf");
		}
		// Motor box screw cutout
		translate([-screw_cutout_cc/2,top_box_height/2-wall,0])cylinder(r=servo_hole/2, h = wall, center=true);
		translate([screw_cutout_cc/2,top_box_height/2-wall,0])cylinder(r=servo_hole/2, h = wall, center=true);
		translate([-screw_cutout_cc/2,-top_box_height/2+wall,0])cylinder(r=servo_hole/2, h = wall, center=true);
		translate([screw_cutout_cc/2,-top_box_height/2+wall,0])cylinder(r=servo_hole/2, h = wall, center=true);
		// Button cutout
		translate([button_left_x,button_left_y,0])cylinder(r=button_diameter/2, h = wall, center=true);
		translate([button_right_x,button_right_y,0])cylinder(r=button_diameter/2, h = wall, center=true);
		// Led cutout
		translate([led_left_x,led_left_y,0])cylinder(r=led_diameter/2, h = wall*3, center=true);
		translate([led_right_x,led_right_y,0])cylinder(r=led_diameter/2, h = wall*3, center=true);
	}
	#translate([-30,-24,wall/2])rotate([0, 0, 0])linear_extrude(height = 1.5)text("CMTEC", size = 5);
	#translate([-2.5,-24,wall/2])rotate([0, 0, 0])linear_extrude(height = 1.5)text("Z-DRL", size = 8);
}

cover();
