//ipad 10,11 - Andnary - P2G

ev = (nc%2==0);
my_off = (ev) ? cw+vrw+vrw/2 : cw/2+vrw;

screen_openings=[
// *** the numbers in screen_openings are assumed to be in pixels or millimeters depending on the value of "unit of measure for screen" in "Free-form and Hybrid Keyguard Openings "***
//  ID,           x,       y,         width, height,   shape, top slope, bottom slope, left slope, right slope, corner radius,  other
[    1,           2,    lcbh, sw/2-my_off-2,   lmbh,    "rr",        90,           90,         90,          90,           bcr,       ],
[    1, sw/2+my_off,    lcbh, sw/2-my_off-2,   lmbh,    "rr",        90,           90,         90,          90,           bcr,       ],
];

rem = (coh-shm)/2+(lmbhm+lcbhm)+hrw/2+ch/2;
my_x = (cow+lp*mpp-rp*mpp)/2;

case_openings= (ev) ? 
[
//  ID,              x,      y,    width, height,  shape, top slope, bottom slope, left slope, right slope, corner radius,   other
[    1,  my_x-cw-vrw/2,    -ff, cw*2+vrw,   rem,     "r",        90,           90,         90,          90,             0,       ],
[    1,  my_x+cw+vrw/2,    -ff,        0,      0,  "oa3",        90,           90,         90,          90,             2,       ],
[    1,  my_x-cw-vrw/2,    -ff,        0,      0,  "oa2",        90,           90,         90,          90,             2,       ],
]:
[
//  ID,           x,      y,  width, height,  shape, top slope, bottom slope, left slope, right slope, corner radius,   other
[    1,   my_x-cw/2,    -ff,     cw,    rem,    "r",        90,           90,         90,          90,             0,       ],
[    1,   my_x-cw/2,    -ff,      0,      0,  "oa2",        90,           90,         90,          90,             2,       ],
[    1,   my_x+cw/2,    -ff,      0,      0,  "oa3",        90,           90,         90,          90,             2,       ],
];

case_additions=[
//  ID,       x,      y,  width, height,  shape, thickness,  trim above, trim below, trim to right, trim to left, corner radius
[    1,       0,      0,      0,      0,    "r",         0,        -999,       -999,          -999,         -999,             0],
];






/***********SCREEN VARIABLES
These special variables can be used to locate screen openings relative to the (0,0) location of the screen opening region
Unless otherwise specified, the units is determined by the setting of "unit of measure for screen" in "Free-form and Hybrid
Keyguard Openings".

** screen variables
	sh 	screen height (in millimeters or pixels)
	sw	screen width (in millimeters or pixels)
	sat	screen area thickkness (cannot exceed the keyguard thickness)

	mpp	millimeters per pixel	
	ppm	pixels per millimeter

	nr	number of rows in grid
	nc	number of columns in grid

** app variables (in millimeters or pixels)
	sbh	status bar height
	umbh	upper message bar height
	ucbh	upper command bar height
	lmbh	lower message bar height
	lcbh	lower command bar height

	sbb	status bar bottom
	umbb	upper message bar bottom
	ucbb	upper command bar bottom
	lmbt	lower message bar top
	lmbb	lower message bar bottom
	lcbb	lower command bar bottom
	
** grid variables (in millimeters or pixels)
	gw	grid width
	gh	grid height
	gt 	grid top
	gb	grid bottom

	tp	top padding
	bp	bottom padding
	lp	left padding
	rp	right padding
	
	gwm	grid width in millimeters
	ghm	grid height in millimeters

** cell variables (the value is in millimeters)
	cw	cell width (doesn't apply to cells that are affected by left/right compensation for tight cases)
	ch	cell height (doesn't apply to cells that are affected by top/bottom compensation for tight cases)
	ccr	cell corner radius

	hor	height of ridge
	tor	thickness of ridge


/***********CASE and KEYGUARD VARIABLES
These special variables can be used to locate openings and place additions relative to the (0,0) location of the case opening
[Note that the (0,0) location of the case opening is not absolute and can move if the screen doesn't sit in the middle of the opening.  These variables are independent of that movement. All variables are in millimeters]

	coh	case opening height
	cow 	case opening width
	cocr	case opening corner radius

	kt	keyguard thickness - specified in Keyguard Basics
	sat	screen area thickness of the grid and bar part of keyguard - specified in Keyguard Basics

	lcow	the default width of the left side of case opening when in landscape mode
	bcoh	the default height of the bottom side of case opening when in landscape mode


/***********KEYGUARD FRAME VARIABLES
Normally, the dimensions of the case opening determine the size of the keyguard.  If designing a keyguard that goes into a frame, the
dimensions of the case opening determine the size of the frame and the size of the keyguard is set separately in the "Keyguard Frame Info"
section.

	kh	keyguard height - specified in Keyguard Frame Info
	kw	keyguard width - specified in Keyguard Frame Info
	kcr	keyguard corner radius - specified in Keyguard Frame Info


/***********CAMERA and HOME BUTTON VARIABLES
The designer thinks of the camera and home button as positioned relative to the edge of the screen, not the edge of the tablet or the edget of the case opening so these variables will work best in the screen_openings set of instructions. Note that all the measurements in this set are in millimeters.  If you use these in a design that assumes all screen measurements are in pixels, multiply the variable times ppm (pixels per millimeter).

	hloc	home button location: 1,2,3,4 (adjusted for orientation)
	hbd	distance from screen to home button in millimeters
	hbh	home button height in millimeters
	hbw	home button width in millimeters
	cloc	camera location: 1,2,3,4 (adjusted for orientation)
	cmd	distance from screen to camera in millimeters
	cmh	camera height in millimeters
	cmw	camera width in millimeters

	r180	yes/no, has the tablet been rotated 180 degrees
	sxo	sign of x offset, relative to standard photos of the tablet
	syo	sign of y offset, relative to standard photos of the tablet
	
	xols	x location of the left side of the case opening adjusted for rotating the tablet 180 degrees
	xors	x location of the right side of the case opening adjusted for rotating the tablet 180 degrees
	yobs	y location of the bottom side of the case opening adjusted for rotating the tablet 180 degrees
	yots	y location of the top side of the case opening adjusted for rotating the tablet 180 degrees


/***********TABLET VARIABLES
	th     height of tablet in millimeters
	tw     width of tablet in millimeters - specified in internal designer data
	tcr    tablet corner radius in millimeters - specified in internal designer data


/************ DISPLAYING THE VALUE OF A VARIABLE
If you just want to see what the contents of a variable is you use the "echo" command and look for what is displayed in the console
pane.  For example, if you wanted to see what the designer thinks the height of the tablet is in millimeters, put this line at the
top of this file:

echo(th=th);

Don't forget the semicolon at the end of the line.  Save the file and look at the Console pane in OpenSCAD.  You should see a line that
looks something like this:

ECHO: th = 184

So the designer thinks that the height of the tablet is 184 millimeters.


/************ CREATING YOUR OWN VARIABLES
You may want to create your own variables and use them to place features of your keyguard.  For example, you may want to put a
bump between each column of cells to aid in navigation by a visually impaired individual. The distance from the left edge of the grid
to the middle of the rail between column 1 and column 2 is the width of the grid divided by the number of columns.  That looks like
this: gw/nc.  The distance to the center of the rail between column 2 and column 3 is (gw/nc)*2, and so on.  You may want a variable
that is shorter in length so that your instruction lines don't get too long.  Just create your own variables:
c1 = gw/nc;
c2 = (gw/nc)*2;
c3 = (gw/nc)*3;
c4 = (gw/nc)*4;
c5 = (gw/nc)*5;
...

Put these lines at the top of the openings_and_additions.txt file then use the variables in the "x" column.

Note: that you may create a variable that is already being used in the keyguard designer you will see a Warning message like this:

   "WARNING: c1 was assigned on line 1101 of "keyguard_v68.scad" but was overwritten in file openings_and_additions.txt, line 1"

with a yellow background. It's telling you that you are trying to define "c1" but the keyguard designer is also trying to define it.

You will need to change the name of your variable until it doesn't collide with the keyguard designer progrogram.


************************************************************************************************************************************/



