// 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 PopufareHousingInnerTopPlate() {
  _r = 3;
  _outr = 18;

  idx = POPUFARE_SCREEN_WIDTH_CAPACITIVE;
  idy = POPUFARE_SCREEN_HEIGHT_CAPACITIVE;

  hole_width  = POPUFARE_INNER_PLATE_HOLE_WIDTH;
  hole_height = POPUFARE_INNER_PLATE_HOLE_HEIGHT;

  w2 = hole_width/2;
  h2 = hole_height/2;
  //x = hole_width + _outr;
  //y = hole_height + _outr;
  
  x = POPUFARE_INNER_PLATE_HOLE_WIDTH + _outr;
  y = POPUFARE_INNER_PLATE_HOLE_HEIGHT + _outr;

  w2 = hole_width/2;
  h2 = hole_height/2;
  
  tab_w = 10;
  tab_h = 30;
  
  band_w = 10;
  band_p = 2.5;
  
  top_dh = (y - idy)/2;
  
  open_dw = 85;
  
  union() {
    difference() {
      rounded_rect(x,y, _r);
      

      // straps across middle to support
      //
      rounded_rect(idx - band_w*4 + 2*_r, idy, _r);
      
      translate([-idx/2 + band_w/2,  idy/2 - idy/(2*band_p)]) rounded_rect(band_w, idy/band_p, _r);
      translate([-idx/2 + band_w/2, -idy/2 + idy/(2*band_p)]) rounded_rect(band_w, idy/band_p, _r);
      
      translate([ idx/2 - band_w/2,  idy/2 - idy/(2*band_p)]) rounded_rect(band_w, idy/band_p, _r);
      translate([ idx/2 - band_w/2, -idy/2 + idy/(2*band_p)]) rounded_rect(band_w, idy/band_p, _r);
      
      // joining screw holes
      //
      translate([-hole_width/2, -hole_height/2]) circle(_M3r);
      translate([ hole_width/2, -hole_height/2]) circle(_M3r);
      translate([ hole_width/2,  hole_height/2]) circle(_M3r);
      translate([-hole_width/2,  hole_height/2]) circle(_M3r);
      
      // hdmi and usb access
      //
      translate([0, y/2]) square([open_dw,30], center=true);
   
    }
    
    // round the over hang tabs at top
    //
    translate([-open_dw/2,idy/2+top_dh/2]) rounded_rect(10, top_dh, _r);
    translate([ open_dw/2,idy/2+top_dh/2]) rounded_rect(10, top_dh, _r);

  }
}

//PopufareHousingInnerTopPlate();
