// License: CC0
//
// To the extent possible under law, Clementine Computing LLC has waived
// all copyright and related or neighboring rights to this file.
//
// This work is published from: United States.
//

include <PopufareHousingCommon.scad>

module PopufareHousingBackPlate_hinge1() {
  w = POPUFARE_HOUSING_WIDTH;
  h = POPUFARE_HOUSING_HEIGHT;

  fixture_dx = POPUFARE_FIXTURE_DX;
  fixture_dy = POPUFARE_FIXTURE_DY;
  fixture_bolt = 5.0/2.0;

  bx = POPUFARE_BRACKET_CX;
  br = POPUFARE_BRACKET_D/2.0;

  gland_cx = 0;
  gland_cy = -(h/2 - 1.5*POPUFARE_GLAND_DIAMETER);
  
  gdx = 1*POPUFARE_GLAND_DIAMETER/2;
  gdy = 1*POPUFARE_GLAND_DIAMETER/2;
  
  hinge_de = POPUFARE_HINGE1_DE;
  hinge_dh = POPUFARE_HINGE1_DH;
  hinge_dw = POPUFARE_HINGE1_DW;
  hinge_r = POPUFARE_HINGE1_R;

  lip = _MATERIAL_THICKNESS;

  difference() {
    union() {
      square([w,h], center=true);
      translate([0,-h/2-lip/2]) square([w,lip], center=true);
    }

    // gland cable assembly access
    //
    translate([gland_cx, gland_cy]) circle(POPUFARE_GLAND_DIAMETER/2.0);
    
    
    // optional plate fixture points (in case we need to close off or alter
    // the gland assembly diameter
    //
    translate([gland_cx + gdx, gland_cy + gdy]) circle(_M3r);
    translate([gland_cx - gdx, gland_cy + gdy]) circle(_M3r);
    translate([gland_cx - gdx, gland_cy - gdy]) circle(_M3r);
    translate([gland_cx + gdx, gland_cy - gdy]) circle(_M3r);


    // hinge attachment
    //
    translate([ -hinge_dw/2, h/2 - hinge_de ]) circle(hinge_r);
    translate([  hinge_dw/2, h/2 - hinge_de ]) circle(hinge_r);
    
    translate([ -hinge_dw/2, h/2 - (hinge_de + hinge_dh) ]) circle(hinge_r);
    translate([  hinge_dw/2, h/2 - (hinge_de + hinge_dh) ]) circle(hinge_r);

  }
}



module PopufareHousingBackPlate_hinge0() {
  w = POPUFARE_HOUSING_WIDTH;
  h = POPUFARE_HOUSING_HEIGHT;

  fixture_dx = POPUFARE_FIXTURE_DX;
  fixture_dy = POPUFARE_FIXTURE_DY;
  fixture_bolt = 5.0/2.0;

  bx = POPUFARE_BRACKET_CX;
  br = POPUFARE_BRACKET_D/2.0;

  gland_cx = 0;
  gland_cy = -(h/2 - 1.5*POPUFARE_GLAND_DIAMETER);
  
  gdx = 1*POPUFARE_GLAND_DIAMETER/2;
  gdy = 1*POPUFARE_GLAND_DIAMETER/2;
  
  hinge_w = POPUFARE_HINGE_BACK_HOLE_WIDTH;
  hinge_de = POPUFARE_HINGE_BACK_HOLE_DE;
  hinge_r = POPUFARE_HINGE_D/2;

  lip = _MATERIAL_THICKNESS;

  difference() {
    union() {
      square([w,h], center=true);
      translate([0,-h/2-lip/2]) square([w,lip], center=true);
    }

    // gland cable assembly access
    //
    translate([gland_cx, gland_cy]) circle(POPUFARE_GLAND_DIAMETER/2.0);
    
    
    // optional plate fixture points (in case we need to close off or alter
    // the gland assembly diameter
    //
    translate([gland_cx + gdx, gland_cy + gdy]) circle(_M3r);
    translate([gland_cx - gdx, gland_cy + gdy]) circle(_M3r);
    translate([gland_cx - gdx, gland_cy - gdy]) circle(_M3r);
    translate([gland_cx + gdx, gland_cy - gdy]) circle(_M3r);

    // hinge attachment
    //
    translate([ -hinge_w/2, h/2 - hinge_de ]) circle(hinge_r);
    translate([  hinge_w/2, h/2 - hinge_de ]) circle(hinge_r);

    // bottom bracket attachments
    //
    //translate([ (w/2 - POPUFARE_BRACKET_DE), -(h/2 - bx)]) circle(br);
    //translate([-(w/2 - POPUFARE_BRACKET_DE), -(h/2 - bx)]) circle(br);

    // hinge assembly attachment
    //


  }
}
module PopufareHousingBackPlate() {
  PopufareHousingBackPlate_hinge1();
}

//PopufareHousingBackPlate();
