$fn=30;
top_r = 5;

wall = 3;
bottom = 5;

height = 111;
width = 70;

lock_box_height = 29+wall*2;
lock_box_depth = 13+wall;
lock_box_width = 27+wall*2;
lock_box_position = 60;

key_inner_diameter = 40;
key_outer_diameter = 57;
key_depth = 2;
key_position = 111;

handle_inner_diameter = 40;
handle_outer_diameter = 52;
handle_depth = 2;
handle_position = 0;

cable_lock_cutout_diameter = 13;
cable_lock_width = 4;
cable_lock_heigh = 2;
cable_lock_pos_1 = handle_position;
cable_lock_pos_2 = lock_box_position;

m3_nut_hole_height = 3.2;
m3_nut_hole_width = 5.8;

light_guide_diameter = 2.5+0.2;

pcb_distance_width = 5;
pcb_distance_z = 4;
pcb_distance_hole = 2;

servo_width = 40;
servo_height = 20;
servo_depth = 10;
servo_wall = 2;
servo_hole = 2.5;
servo_hole_cc_x = 47.26;
servo_hole_cc_y = 10.17;

screw_cutout_width = 8;
screw_cutout_cc = 45;

module cover (){
	// Main mounting plate
	difference(){	
		union(){
			// Lock/Motor box
			translate([0,lock_box_position,lock_box_depth/2])minkowski(){
				cube([lock_box_width-top_r*2, lock_box_height-top_r*2, lock_box_depth-1], center=true);
				cylinder(r=top_r, h=1, center=true);
			}
			// Bottom plate
			translate([0,height/2,bottom/2])cube([width, height, bottom], center = true);
			translate([0,0,bottom/2])cylinder(r = width/2, h = bottom, center = true, $fn=100);
			translate([0,key_position,bottom/2])cylinder(r = width/2, h = bottom, center = true, $fn=100);

		}
		// Handle cutout
		translate([0,handle_position,bottom/2])cylinder(r = handle_inner_diameter/2, h = bottom, center = true, $fn=100);
		translate([0,handle_position,bottom/2+bottom/2-handle_depth/2])cylinder(r = handle_outer_diameter/2, h = handle_depth, center = true, $fn=100);
		// Key cutout	
		translate([0,key_position,bottom/2])cylinder(r = key_inner_diameter/2, h = bottom, center = true, $fn=100);
		translate([0,key_position,bottom/2+bottom/2-key_depth/2])cylinder(r = key_outer_diameter/2, h = key_depth, center = true, $fn=100);
		// Sensor cable cutout	
		translate([0,cable_lock_pos_1+(cable_lock_pos_2-cable_lock_pos_1)/2,cable_lock_heigh/2])cube([cable_lock_width,cable_lock_pos_2-cable_lock_pos_1,cable_lock_heigh], center = true);
		// Motor cutout	
		translate([0,lock_box_position,(lock_box_depth-wall)/2])cube([lock_box_width-wall*2,lock_box_height-wall*2,lock_box_depth-wall], center = true);
	}
}

cover();
