echo(version=version());
 
module stand() {
color([0.4,0.9,1.0,1.0])
difference() {
    difference() {
        union(){
            translate([-10, 0, 35]) import("pistand.stl", convexity=3);
            translate([10, 0, 35]) import("pistand.stl", convexity=3);
            rotate([65,0,0])
                translate([0, 56, 1]) linear_extrude(height = 2.3)
                square([90,40], center = true);
        }
	
        rotate([65,0,0])
            translate([0, 56, 0]) linear_extrude(height = 4)
            square([66,35], center = true);
    }
    rotate([0,0,0])
        translate([0, 25, -1]) linear_extrude(height = 4)
        square([52,36], center = true);
}};


module backing(){
    translate([0, 0, 3])
    difference() {
    translate([0, 23.7, -2.7])
        linear_extrude(height = 34.9)
        square([89.9,60], center = true);

    translate([-43.25, 52.25, -3])
    linear_extrude(height = 36)
        difference(){
            square([6,6], center = true);
            translate([2.75,-2.75,0])circle(4.5);
        }
        
    translate([43.25, 52.25, -3])
    linear_extrude(height = 36)
        difference(){
            square([6,6], center = true);
            translate([-2.75,-2.75,0])circle(4.5);
        }
 
    translate([0, 0, -3])
    linear_extrude(height = 200)
         square([84,100], center = true);

    rotate([65,0,0])
        translate([0, 0, -1]) linear_extrude(height = 100)
        square([200,200], center = true);

}};


module board_holder(){

translate([0, -0.5,0])
difference(){
    linear_extrude(height = 2)
         square([63,29], center = true);
   
    translate([32-7, 14.5-7, -4])
    linear_extrude(height = 6)
    intersection(){
            translate([3.5,3.5,0])
            square([7.1,7.1], center = true);
        difference(){
            square([15,15], center = true);
            translate([0,0,0])circle(7);
        }
    }
    
    translate([-32+7, 14.5-7, -4])
    linear_extrude(height = 6)
    intersection(){
            translate([-3.5,3.5,0])
            square([7.1,7.1], center = true);
        difference(){
            square([15,15], center = true);
            translate([0,0,0])circle(7);
        }
    }
    
    translate([32-7, -14.5+7, -4])
    linear_extrude(height = 6)
    intersection(){
            translate([3.5,-3.5,0])
            square([7.1,7.1], center = true);
        difference(){
            square([15,15], center = true);
            translate([0,0,0])circle(7);
        }
    }
    
    translate([-32+7, -14.5+7, -4])
    linear_extrude(height = 6)
    intersection(){
            translate([-3.5,-3.5,0])
            square([7.1,7.1], center = true);
        difference(){
            square([15,15], center = true);
            translate([0,0,0])circle(7);
        }
    }
}

}



module board(){
 difference(){
    linear_extrude(height = 2.2)
         square([66,31], center = true);
    
    translate([33-7, 15-7, -4])
    linear_extrude(height = 8)
    intersection(){
            translate([3.5,3.5,0])
            square([7.1,7.1], center = true);
        difference(){
            square([15,15], center = true);
            translate([0,0,0])circle(8.5);
        }
    }
    
    translate([-33+7, 15-7, -4])
    linear_extrude(height = 8)
    intersection(){
            translate([-3.5,3.5,0])
            square([7.1,7.1], center = true);
        difference(){
            square([15,15], center = true);
            translate([0,0,0])circle(8.5);
        }
    }
    
        translate([33-7, -15+6.5, -4])
    linear_extrude(height = 8)
    intersection(){
            translate([3.5,-3.5,0])
            square([7.1,7.1], center = true);
        difference(){
            square([15,15], center = true);
            translate([0,0,0])circle(8.5);
        }
    }
    
    translate([-33+7, -15+6.5, -4])
    linear_extrude(height = 8)
    intersection(){
            translate([-3.5,-3.5,0])
            square([7.1,7.1], center = true);
        difference(){
            square([15,15], center = true);
            translate([0,0,0])circle(8.5);
        }
    }
}

}



module pms_cutout(){
            translate([0, 46.8, 0.5]) linear_extrude(height = 13)
        square([56,14], center = true);
}

module pms_shroud(){
    union(){
    difference(){
        translate([0, 45.7, 0.5]) linear_extrude(height = 14)
        square([56,16], center = true);

        translate([0, 25,-1 ]) linear_extrude(height = 12)
        square([52,36+24], center = true);
        
        translate([7, 26, -1]) linear_extrude(height = 14)
        square([38,34], center = true);
    }
    
    translate([-19, 43.6, 0.5]) linear_extrude(height = 12)
        square([14,1], center = true);
    
    translate([6, 48.3, 0.5]) linear_extrude(height = 13)
        square([1.5,10.5], center = true);
    translate([-6, 48.3, 0.5]) linear_extrude(height = 13)
        square([1.5,10.5], center = true);
    
    translate([0, 52.6, 0.5])linear_extrude(height = 1)
        square([52,2], center = true);
    for(i = [0:1]){
        translate([0, 48.5, 3.3+i*4]) 
        rotate([8,0,0])linear_extrude(height = 1)
        square([52,10.5], center = true);
    }
    }
}

module backplate(){
difference(){
union(){
pms_shroud();
difference(){    
        translate([0, 33, 32.2])
        linear_extrude(height = 3)
        square([88,35], center = true);
translate([-2,35,32.1]) //TODO FIX EXACT POS
union(){
    translate([0,0,1]) board();
    board_holder();
}
stand();
}

difference(){    
        translate([0, 30, 20.2])
        linear_extrude(height = 3)
        square([88,40], center = true);
translate([-2,35,20.1]) //TODO FIX EXACT POS
union(){
    translate([0,0,1]) board();
    board_holder();
}

stand();

}


difference() {
  backing();
  stand();
  pms_cutout();
}
}
translate([-13, 52, 20.5]) color([1,0,0,1]) linear_extrude(height = 7) square([12,10], center = true);

translate([-3, 52, 23.5]) color([1,0,0,1]) linear_extrude(height = 2.0) square([3.5,10], center = true);

translate([-3, 50, 22]) color([1,0,0,1]) linear_extrude(height = 5.0) square([4.5,2], center = true);

translate([-24, 52, 23]) color([1,0,0,1]) linear_extrude(height = 6.0) square([6,10], center = true);
translate([-2, 18, 0]) color([1,0,0,1]) linear_extrude(height = 40.0) square([60,16], center = true);    
    
}
}
stand();
    