{% extends "../base.html" %}
{% block content %}
{% macro gpio_select(name,default) %}
<select class="form-control" name="{{name}}" id="{{name}}">
	<option value="0" {% if default==0 %}selected{% endif %} translate>Disable</option>
	<option value="7" {% if default==7 %}selected{% endif %} translate>Physical 7, BCM 4</option>
	<option value="8" {% if default==8 %}selected{% endif %} translate>Physical 8, BCM 14</option>
	<option value="10" {% if default==10 %}selected{% endif %} translate>Physical 10, BCM 15</option>
	<option value="11" {% if default==11 %}selected{% endif %} translate>Physical 11, BCM 17</option>
	<option value="12" {% if default==12 %}selected{% endif %} translate>Physical 12, BCM 18</option>
	<option value="13" {% if default==13 %}selected{% endif %} translate>Physical 13, BCM 27</option>
	<option value="15" {% if default==15 %}selected{% endif %} translate>Physical 15, BCM 22</option>
	<option value="16" {% if default==16 %}selected{% endif %} translate>Physical 16, BCM 23</option>
	<option value="18" {% if default==18 %}selected{% endif %} translate>Physical 18, BCM 24</option>
	<option value="22" {% if default==22 %}selected{% endif %} translate>Physical 22, BCM 25</option>
	<option value="29" {% if default==29 %}selected{% endif %} translate>Physical 29, BCM 5</option>
	<option value="31" {% if default==31 %}selected{% endif %} translate>Physical 31, BCM 6</option>
	<option value="32" {% if default==32 %}selected{% endif %} translate>Physical 32, BCM 12</option>
	<option value="33" {% if default==33 %}selected{% endif %} translate>Physical 33, BCM 13</option>
	<option value="36" {% if default==36 %}selected{% endif %} translate>Physical 36, BCM 16</option>
	<option value="37" {% if default==37 %}selected{% endif %} translate>Physical 37, BCM 26</option>	
</select>
{% endmacro %}
{% macro speed_select(name,label,default) %}
<label for="{{name}}">{{label}}</label>
<select class="form-control" name="{{name}}" id="{{name}}">
	<option value="300" {% if default==300 %}selected{% endif %}>300</option>
	<option value="600" {% if default==600 %}selected{% endif %}>600</option>
	<option value="1200" {% if default==1200 %}selected{% endif %}>1200</option>
	<option value="2400" {% if default==2400 %}selected{% endif %}>2400</option>
	<option value="4800" {% if default==4800 %}selected{% endif %}>4800</option>
	<option value="9600" {% if default==9600 %}selected{% endif %}>9600</option>
	<option value="14400" {% if default==14400 %}selected{% endif %}>14400</option>
	<option value="19200" {% if default==19200 %}selected{% endif %}>19200</option>
	<option value="28800" {% if default==28800 %}selected{% endif %}>28800</option>
	<option value="38400" {% if default==38400 %}selected{% endif %}>38400</option>
	<option value="57600" {% if default==57600 %}selected{% endif %}>57600</option>
	<option value="115200" {% if default==115200 %}selected{% endif %}>115200</option>
</select>
{% endmacro %}
<div class="starter-template">
	<form action="" method="post" class="edit-page" id="setup">
		<input type="hidden" id="arch" value="{{arch}}">
		<legend translate>Printer Settings</legend>
		{% if printing %}
			<div class="alert alert-warning" role="alert" translate>Some critical settings such as type of the shield and etc, will not take effect in the middle of printing. To change those settings without restart, stop printing and submit this page again.</div>
		{% endif %}
		<div class="row flex-row">
			<div class="col-md-3">
				<label for="Name"> <translate>Printer Name</translate>{{helpModal("printer-name")}}</label>
				<input class="form-control" value="{{Name}}" name="Name" id="Name">
				<br>
			</div>
			<div class="col-md-3">
				<label><translate>Setup Mode</translate></label>
				<select class="form-control" name="SetupMode" id="SetupMode">
					<option value="0" {% if SetupMode==0 %}selected{% endif %} translate>Essential</option>
					<option value="1" {% if SetupMode==1 %}selected{% endif %} translate>Basic</option>
					<option value="2" {% if SetupMode==2 %}selected{% endif %} translate>Advanced</option>
				</select>				
				<br>
			</div>
			<div class="col-md-3">
				<label for="PrinterType"> <translate>Type</translate></label>
				<select class="form-control" name="PrinterType" id="PrinterType">
					<option value="0" {% if PrinterType==0 %}selected{% endif %} translate>Projector / LCD</option>
					<option value="1" {% if PrinterType==1 %}selected{% endif %} translate>Laser</option>
				</select>
				<br>
			</div>
			<div class="col-md-3">
				<label for="Lang"> <translate>Language</translate></label>
				<select class="form-control" name="Lang" id="Lang">
					<option value="" {% if Lang=="" %}selected{% endif %} translate>English</option>
					<option value="pt-br" {% if Lang=="pt-br" %}selected{% endif %} translate>Brazilian Portuguese</option>
					<option value="it" {% if Lang=="it" %}selected{% endif %} translate>Italian</option>
					<option value="sp" {% if Lang=="sp" %}selected{% endif %} translate>Spanish</option>
					<option value="chn" {% if Lang=="chn" %}selected{% endif %} translate>Chinese</option>
					<option value="tr" {% if Lang=="tr" %}selected{% endif %} translate>Turkish</option>
					<option value="ru" {% if Lang=="ru" %}selected{% endif %} translate>Russian</option>
				</select>
				<br>
			</div>
			<div class="col-md-3">
				<label for="Theme"> <translate>Theme</translate></label>
				<select class="form-control" name="Theme" id="Theme">
					<option value="0" {% if Theme==0 %}selected{% endif %} translate>Blue / Dark</option>
					<option value="1" {% if Theme==1 %}selected{% endif %} translate>Blue / Light</option>
					<option value="2" {% if Theme==2 %}selected{% endif %} translate>Black / Light</option>
					<option value="3" {% if Theme==3 %}selected{% endif %} translate>Brown / Light</option>
					<option value="4" {% if Theme==4 %}selected{% endif %} translate>Black / Dark</option>
				</select>
				<br>
			</div>
			<div class="col-md-3">
				<label for="ShieldType"><translate>Shield Use</translate>{{helpModal("shield-connection-type,shield")}}</label>
				<select class="form-control" name="ShieldType" id="ShieldType">
					<option value="0" {% if ShieldType==0 %}selected{% endif %} translate>Disabled</option>
					<option value="1" {% if ShieldType==1 %}selected{% endif %} translate>USB/Serial</option>
					<option value="2" {% if ShieldType==2 %}selected{% endif %} class="conditional" data-condition="#arch=='arm'" translate>i2c</option>
				</select>
				<br>
			</div>			
			<div class="col-md-3">
				<label for="ShutterMode"><translate>Shutter</translate></label>
				<select class="form-control" name="ShutterMode" id="ShutterMode">
					<option value="2" {% if ShutterMode==2 %}selected{% endif %} translate>Disable</option>
					<option value="1" {% if ShutterMode==1 %}selected{% endif %} translate>Open Before Each Layer</option>
					<option value="0" {% if ShutterMode==0 %}selected{% endif %} translate>Open Before Print</option>
				</select>
				<br>
			</div>
			<input value="{{SyscallStart}}" name="SyscallStart" type="hidden">
			<input value="{{SyscallFinish}}" name="SyscallFinish" type="hidden">
			<input value="{{ShieldPause}}" name="ShieldPause" type="hidden">
			<input value="{{ShieldUnpause}}" name="ShieldUnpause" type="hidden">
		</div>
		<div class="conditional" data-condition="#arch=='arm'">
		<h3 translate>Movement GPIOs</h3>
		<div class="row flex-row">
			<div class="col-md-3">			
				<label for="ZAxisPin"> <translate>Step GPIO for Z-Axis</translate>{{helpModal("z-axis-step-gpio,direct-control,gpio")}}</label>
				{{ gpio_select("ZAxisPin",ZAxisPin) }}
			</div>
			<div class="col-md-3 conditional" data-condition="#ZAxisPin > 0">
				<label for="DirectionPin"> <translate>Direction GPIO</translate>{{helpModal("z-axis-direction-gpio,direct-control,gpio")}}</label>
				{{ gpio_select("DirectionPin",DirectionPin) }}
				<br>
			</div>
			<div class="col-md-3 conditional" data-condition="#ZAxisPin > 0">			
				<label for="LimitPin"> <translate>Endstop Switch - Top Limit</translate>{{helpModal("z-axis-endstop-gpio,direct-control,gpio")}}</label>
				{{ gpio_select("LimitPin",LimitPin) }}
				<br>
			</div>
			<div class="col-md-3 conditional" data-condition="#ZAxisPin > 0">
				<label for="LimitPinB"> <translate>Endstop Switch - Bottom Limit</translate>{{helpModal("z-axis-endstop-gpio,direct-control,gpio")}}</label>
				{{ gpio_select("LimitPinB",LimitPinB) }}
			</div>
			<div class="col-md-3 conditional" data-condition="#ZAxisPin > 0 && (#LimitPinB>0||#LimitPin>0)">
				<label for="LimitPinMode"> <translate>Endstop Switch - Default State</translate>{{helpModal("z-axis-endstop-gpio,direct-control,gpio")}}</label>
				<select class="form-control" name="LimitPinMode" id="LimitPinMode">
					<option value="0" {% if LimitPinMode==0 %}selected{% endif %} translate>High</option>
					<option value="1" {% if LimitPinMode==1 %}selected{% endif %} translate>Low</option>
				</select>
			</div>
			<div class="col-md-3 conditional" data-condition="#ZAxisPin > 0 && (#LimitPinB>0||#LimitPin>0)">
				<label for="LimitPinReset"> <translate>Reset Position on Limit</translate>{{helpModal("z-axis-endstop-gpio,direct-control,gpio")}}</label>
				<select class="form-control" name="LimitPinReset" id="LimitPinReset">
					<option value="0" {% if LimitPinReset==0 %}selected{% endif %} translate>Yes</option>
					<option value="1" {% if LimitPinReset==1 %}selected{% endif %} translate>No</option>
				</select>
			</div>
			<div class="col-md-3 conditional" data-condition="#ZAxisPin > 0">
				<label for="EnablePin"> <translate>Driver Enable GPIO</translate>{{helpModal("z-axis-enable-gpio,direct-control,gpio")}}</label>
				{{ gpio_select("EnablePin",EnablePin) }}
				<br>
			</div>	
			<div class="col-md-3 conditional" data-condition="#ZAxisPin > 0 && #EnablePin > 0">
				<label for="EnablePinState"> <translate>Enable GPIO State</translate></label>
				<select class="form-control" name="EnablePinState" id="EnablePinState">
					<option value="0" {% if EnablePinState==0 %}selected{% endif %} translate>Low</option>
					<option value="1" {% if EnablePinState==1 %}selected{% endif %} translate>High</option>
				</select>
				<br>
			</div>
			<div class="col-md-3 conditional" data-condition="#ZAxisPin > 0 && #EnablePin > 0">
				<label for="EnablePinMode"> <translate>Enable GPIO Mode</translate></label>
				<select class="form-control" name="EnablePinMode" id="EnablePinMode">
					<option value="0" {% if EnablePinMode==0 %}selected{% endif %} translate>Enable on Boot</option>
					<option value="1" {% if EnablePinMode==1 %}selected{% endif %} translate>Enable Before Each Print</option>
				</select>
				<br>
			</div>
			<div class="col-md-12 conditional" data-condition="#ZAxisPin > 0 && #SetupMode==2">
				<label for="SpeedFormula"><translate>Custom Acceleration</translate>{{helpModal("speed-formula,vars,math,gcode")}} {{formulaModal()}}</label>
				<textarea class="form-control" name="SpeedFormula" id="SpeedFormula">{{SpeedFormula}}</textarea>
				<br>
			</div>
		</div>
		</div>
	
		<div class="conditional" data-condition="['1','2'].includes(#ShieldType)">
		<h3 translate>3D Printer Board</h3>
		<div class="note" translate>Not required, if you are using GPIOs to drive the 3d printer.</div>
		<div class="row flex-row">
			<div class="col-md-3">
				<label for="ShieldEncoding"><translate>Data Encoding</translate>{{helpModal("shield-data-encoding,shield")}}</label>
				<select class="form-control" name="ShieldEncoding" id="ShieldEncoding">
					<option value="0" {% if ShieldEncoding==0 %}selected{% endif %} translate>Ascii</option>
					<option value="1" {% if ShieldEncoding==1 %}selected{% endif %} translate>Binary</option>
				</select>
				<br>
			</div>
			<div class="col-md-3 conditional" data-condition="['1'].includes(#ShieldType)">
				<label for="ShieldUSBAddress"><translate>USB/Serial Port Address</translate>{{helpModal("shield-port-path,shield")}}</label>
				<input class="form-control" value="{{ShieldUSBAddress}}" name="ShieldUSBAddress" id="ShieldUSBAddress" list="devices">
				<datalist id="devices">
					{% for path in devices %}
						<option value="{{path}}">
					{% endfor %}
				</datalist>
				<br>
			</div>
			<div class="col-md-3 conditional" data-condition="['1'].includes(#ShieldType)">				
				{{ speed_select("ShieldSpeed","Baud Rate",ShieldSpeed) }}
				<br>
			</div>
			<div class="col-md-3">
				<label for="ShieldPositioning"><translate>Movement Positioning</translate></label>
				<select class="form-control" name="ShieldPositioning" id="ShieldPositioning">
					<option value="0" {% if ShieldPositioning==0 %}selected{% endif %} translate>Relative</option>
					<option value="1" {% if ShieldPositioning==1 %}selected{% endif %} translate>Absolute</option>
				</select>
				<br>
			</div>
			<div class="col-md-3">
				<label for="ShieldAxisMode"><translate>Shield Axis Direction</translate></label>
				<select class="form-control" name="ShieldAxisMode" id="ShieldAxisMode">
					<option value="0" {% if ShieldAxisMode==0 %}selected{% endif %} translate>Zero at Bottom</option>
					<option value="1" {% if ShieldAxisMode==1 %}selected{% endif %} translate>Zero at Top</option>
				</select>
			</div>
			<div class="col-md-3 conditional" data-condition="#arch=='arm'">				
				<label for="WaitPin"> <translate>Wait GPIO</translate>{{helpModal("shield-wait-pin,shield,gpio")}}</label>
				{{ gpio_select("WaitPin",WaitPin) }}			
			</div>
			<div class="col-md-3 conditional" data-condition="#arch=='arm' && ['2'].includes(#ShieldType)">
				<label for="ShieldI2CAddress"><translate>i2c Address</translate> <span class="label label-warning" translate>Restart Required</span></label>
				<input class="form-control" value="{{ShieldI2CAddress}}" name="ShieldI2CAddress" id="ShieldI2CAddress" type="number" min="0" max="127">
				<br>
			</div>
		</div>
		</div>
		<br>

		<h3 translate>Codes</h3>
		<div class="row flex-row">
			<div class="col-md-3">
				<label for="ShieldBootup">{{helpModal("gcode-bootup,vars,math,gcode,shield,exec")}} {{formulaModal()}}<translate>Bootup Code</translate></label>
				<textarea class="form-control" name="ShieldBootup" id="ShieldBootup">{{ShieldBootup}}</textarea>
				<br>
			</div>
			<div class="col-md-3">
				<label for="ShieldStart"><translate>Start of Print Code</translate>{{helpModal("gcode-start,vars,math,gcode,shield,exec")}} {{formulaModal()}}</label>
				<textarea class="form-control" name="ShieldStart" id="ShieldStart">{{ShieldStart}}</textarea>
			</div>
			<div class="col-md-3">
				<label for="ShieldResume"><translate>Resume Print Code</translate>{{helpModal("gcode-start,vars,math,gcode,shield,exec")}} {{formulaModal()}}</label>
				<textarea class="form-control" name="ShieldResume" id="ShieldResume">{{ShieldResume}}</textarea>
				<br>
			</div>
			<div class="col-md-3">
				<label for="ShieldFinish"><translate>Print Stop Code</translate> {{formulaModal()}}</label>
				<textarea class="form-control" name="ShieldFinish" id="ShieldFinish">{{ShieldFinish}}</textarea>
				<br>
			</div>
			<div class="col-md-3">
				<label for="ManualMoveGcode"><translate>Manual Movement Code Template</translate></label>
				<textarea class="form-control" name="ManualMoveGcode" id="ManualMoveGcode">{{ManualMoveGcode}}</textarea>
				<br>
			</div>
			<div class="col-md-3 conditional" data-condition="['1','0'].includes(#ShutterMode)">
				<label for="ShutterOpenGcode"><translate>Shutter Open Code</translate>{{helpModal("gcode-shutter-open,vars,math,gcode,shield,exec")}} {{formulaModal()}}</label>
				<textarea class="form-control" name="ShutterOpenGcode" id="ShutterOpenGcode">{{ShutterOpenGcode}}</textarea>
				<br>
			</div>
			<div class="col-md-3 conditional" data-condition="['1','0'].includes(#ShutterMode)">
				<label for="ShutterCloseGcode"><translate>Shutter Close Code</translate> {{formulaModal()}}</label>
				<textarea class="form-control" name="ShutterCloseGcode" id="ShutterCloseGcode">{{ShutterCloseGcode}}</textarea>
				<br>
			</div>		
	
		</div>
		<div class="conditional" data-condition="#arch=='arm' && ['1','0'].includes(#ShutterMode)">
			<h3 translate>Shutter</h3>
			<div class="row flex-row">
				<div class="col-md-6">
					<label for="ShutterType"><translate>Shutter Type</translate>{{helpModal("shutter-type,gpio")}}</label>
					<select class="form-control" name="ShutterType" id="ShutterType">
						<option value="0" {% if ShutterType==0 %}selected{% endif %} translate>Through Shield</option>
						<option value="1" {% if ShutterType==1 %}selected{% endif %} translate>Servo Motor</option>
						<option value="2" {% if ShutterType==2 %}selected{% endif %} translate>True/False Signal</option>
					</select>
					<br>
				</div>
				<div class="col-md-6 ShutterType_toggle">				
					<label for="ShutterPin"><translate>Shutter GPIO</translate>{{helpModal("gpio")}}</label>
					{{ gpio_select("ShutterPin",ShutterPin) }}
					<br>
				</div>	
				<div class="col-md-4 ShutterType_toggle">
					<label for="ShutterOpen"><translate>Servo Pulse Width - Open</translate> <span class="label label-default" translate>ms</span>{{helpModal("servo-shutter")}}</label>
					<input class="form-control" value="{{ShutterOpen}}" name="ShutterOpen" id="ShutterOpen" type="number" min="500" max="2500">
				</div>
				<div class="col-md-4 ShutterType_toggle">
					<label for="ShutterClose"><translate>Servo Pulse Width - Close</translate> <span class="label label-default" translate>ms</span>{{helpModal("servo-shutter")}}</label>
					<input class="form-control" value="{{ShutterClose}}" name="ShutterClose" id="ShutterClose" type="number" min="500" max="2500">
				</div>
				<div class="col-md-4 ShutterType_toggle">
					<label for="ShutterSignalLength"><translate>Servo Signal Length</translate> <span class="label label-default" translate>Millisecond</span>{{helpModal("servo-shutter")}}</label>
					<input class="form-control" value="{{ShutterSignalLength}}" name="ShutterSignalLength" id="ShutterSignalLength" type="number">
					<br>
				</div>
			</div>
		</div>
	
		<h3 translate>Display</h3>
		<div class="row flex-row">
			<div class="col-md-3">
				<label for="ProjectorWidth"><translate>Horizontal Resolution</translate>{{regenerateRequired()}}</label>
				<input class="form-control" value="{{ProjectorWidth}}" name="ProjectorWidth" id="ProjectorWidth" type="number" min="1" required>
			</div>
			<div class="col-md-3">
				<label for="ProjectorHeight"><translate>Vertical Resolution</translate>{{regenerateRequired()}}</label>
				<input class="form-control" value="{{ProjectorHeight}}" name="ProjectorHeight" id="ProjectorHeight" type="number" min="1" required>
				<br>
			</div>
			<div class="col-md-3">
				<label for="XYRes"><translate>X/Y Resolution</translate> <span class="label label-default" translate>μm</span>{{helpModal("xy-resolution")}}{{regenerateRequired()}}</label>
				<input class="form-control" value="{{XYRes}}" name="XYRes" id="XYRes" step="0.001" type="number" min="1" required>
			</div>
			<div class="col-md-3">
				<label for="YRes"><translate>Y Resolution</translate> <span class="label label-default translate">μm</span>{{helpModal("y-resolution,xy-resolution")}}{{regenerateRequired()}}</label>
				<input class="form-control" value="{{YRes}}" name="YRes" id="YRes" step="0.001" type="number">
			</div>
		</div>
		<div class="row flex-row conditional" data-condition="['2'].includes(#SetupMode)">
			<div class="col-md-3">
				<label for="BarrelFactor"><translate>Lens Barrel Factor</translate>{{helpModal("barrel")}}{{regenerateRequired()}}</label>
				<input class="form-control" value="{{BarrelFactor}}" name="BarrelFactor" id="BarrelFactor" step="0.001" type="number">
				<br>
			</div>
			<div class="col-md-3">
				<label for="BarrelX"><translate>Center of Barrel - X</translate> <span class="label label-default" translate>Pixel</span>{{regenerateRequired()}}</label>
				<input class="form-control" value="{{BarrelX}}" name="BarrelX" id="BarrelX" type="number">
			</div>
			<div class="col-md-3">
				<label for="BarrelY"><translate>Center of Barrel - Y</translate> <span class="label label-default" translate>Pixel</span>{{regenerateRequired()}}</label>
				<input class="form-control" value="{{BarrelY}}" name="BarrelY" id="BarrelY" type="number">
			</div>
			<div class="col-md-3">
				<label for="ImageMirror"><translate>Mirror Layers</translate> {{regenerateRequired()}}</label>
				<select class="form-control" name="ImageMirror" id="ImageMirror">
					<option value="0" {% if ImageMirror==0 %}selected{% endif %} translate>Disabled</option>
					<option value="1" {% if ImageMirror==1 %}selected{% endif %} translate>Horizontally</option>
					<option value="2" {% if ImageMirror==2 %}selected{% endif %} translate>Vertically</option>
					<option value="3" {% if ImageMirror==3 %}selected{% endif %} translate>Both</option>
				</select>
			</div>
			<div class="col-md-3">
				<label for="ProjectorType"><translate>Display Communication Type</translate>{{helpModal("projector-control")}}</label>
				<select class="form-control" name="ProjectorType" id="ProjectorType">
					<option value="0" {% if ProjectorType==0 %}selected{% endif %} translate>Disabled</option>
					<option value="1" {% if ProjectorType==1 %}selected{% endif %} translate>USB / Serial Port - ASCII (\r\n)</option>
					<option value="5" {% if ProjectorType==5 %}selected{% endif %} translate>USB / Serial Port - ASCII (\r)</option>
					<option value="6" {% if ProjectorType==6 %}selected{% endif %} translate>USB / Serial Port - ASCII (\n)</option>
					<option value="2" {% if ProjectorType==2 %}selected{% endif %} translate>USB / Serial Port - Binary</option>
					<option value="3" {% if ProjectorType==3 %}selected{% endif %} translate>Execution Only</option>
				</select>
				<br>
			</div>
			<div class="col-md-3 ProjectorType_toggle">
				<label for="ProjectorWarmup"><translate>Display Warm-up Time</translate> <span class="label label-default" translate>Second</span></label>
				<input class="form-control" value="{{ProjectorWarmup}}" name="ProjectorWarmup" id="ProjectorWarmup" type="number">
			</div>
			<div class="col-md-3 ProjectorType_toggle">
				<label for="ProjectorLampQuery"><translate>Query Lamp Hours</translate>{{helpModal("lamp-query")}}</label>
				<input class="form-control" value="{{ProjectorLampQuery}}" name="ProjectorLampQuery" id="ProjectorLampQuery">
			</div>
			<div class="col-md-3 ProjectorType_toggle">
				<label for="ProjectorLampEffect"><translate>Lamp Brightness</translate> <span class="label label-default" translate>Percentage</span>{{helpModal("lamp-effect")}}</label>
				<input class="form-control" value="{{ProjectorLampEffect}}" name="ProjectorLampEffect" id="ProjectorLampEffect" step="0.01" type="number">
			</div>
			<div class="col-md-3 ProjectorType_toggle">
				
				{{ speed_select("ProjectorSpeed","Baud Rate",ProjectorSpeed) }}
			</div>
			<div class="col-md-3 ProjectorType_toggle">
				<label for="ProjectorAddress"><translate>USB/Serial Port Address</translate></label>
				<input class="form-control" value="{{ProjectorAddress}}" name="ProjectorAddress" id="ProjectorAddress" list="devices">
			</div>
			<div class="col-md-3 ProjectorType_toggle">
				<label for="ProjectorOn"><translate>Display Turn On Command</translate></label>
				<input class="form-control" value="{{ProjectorOn}}" name="ProjectorOn" id="ProjectorOn">
			</div>
			<div class="col-md-3 ProjectorType_toggle">
				<label for="ProjectorOff"><translate>Display Turn Off Command</translate></label>
				<input class="form-control" value="{{ProjectorOff}}" name="ProjectorOff" id="ProjectorOff">
				<br>
			</div>
			<div class="col-md-6 ProjectorType_toggle">
				<label for="ProjectorPowerCycle"><translate>Display Power Cycle</translate></label>
				<select class="form-control" name="ProjectorPowerCycle" id="ProjectorPowerCycle">
					<option value="0" {% if ProjectorPowerCycle==0 %}selected{% endif %} translate>Power-Up on Start / Power-Down on Stop</option>
					<option value="1" {% if ProjectorPowerCycle==1 %}selected{% endif %} translate>Power-Up on Start / Power-Down on Shutdown</option>
					<option value="2" {% if ProjectorPowerCycle==2 %}selected{% endif %} translate>Power-Up on Start / Power-Down on Last Layer</option>
				</select>
			</div>
			<div class="col-md-3 ProjectorType_toggle">
				<label for="ProjectorOnSyscall"><translate>Execute to Turn Display On</translate>{{helpModal("projector-syscall")}}</label>
				<input class="form-control" value="{{ProjectorOnSyscall}}" name="ProjectorOnSyscall" id="ProjectorOnSyscall">
			</div>
			<div class="col-md-3 ProjectorType_toggle">
				<label for="ProjectorOffSyscall"><translate>Execute to Turn Display Off</translate>{{helpModal("projector-syscall")}}</label>
				<input class="form-control" value="{{ProjectorOffSyscall}}" name="ProjectorOffSyscall" id="ProjectorOffSyscall">
				<br>
			</div>
			<div class="col-md-3">
				<label for="DisplayID"> <translate>Display Number</translate>{{helpModal("rpi-display")}}</label>
				<input class="form-control" value="{{DisplayID}}" name="DisplayID" id="DisplayID">
			</div>
			<div class="col-md-3">
				<label for="FBPath"> <translate>Framebuffer Path</translate>{{helpModal("framebuffer")}}</label>
				<input class="form-control" value="{{FBPath}}" name="FBPath" id="FBPath" list="framebuffers">
				<datalist id="framebuffers">
					{% for path in framebuffers %}
						<option value="{{path}}">
					{% endfor %}
				</datalist>
				<br>
			</div>
			<div class="col-md-6">
				<label for="LightOutputFormula"> <translate>Light Output Formula</translate>  <span class="label label-default" translate>Percentage</span> {{helpModal("light-output-formula")}} {{formulaModal()}}</label>
				<input class="form-control" value="{{LightOutputFormula}}" name="LightOutputFormula" id="LightOutputFormula">
				<br>
			</div>
		</div>
		
		<div class="conditional" data-condition="['1','2'].includes(#SetupMode)">
			<h3 translate>Platform / Resin</h3>
			<div class="row">
				<div class="col-md-3">
					<label for="StopPositionMm"><translate>Platform Wait Position</translate> <span class="label label-default" translate>Millimeter</span>{{helpModal("wait-position")}}</label>
					<input class="form-control" value="{{StopPositionMm}}" name="StopPositionMm" id="StopPositionMm" type="number" step="0.001">
				</div>
				<div class="col-md-3">
					<label for="ResinDistanceMm"><translate>Resin Depth</translate> <span class="label label-default" translate>Millimeter</span>{{helpModal("resin-level")}}</label>
					<input class="form-control" value="{{ResinDistanceMm}}" name="ResinDistanceMm" id="ResinDistanceMm" type="number" step="0.001">
				</div>
			</div>
		
			<h3 translate>Motor</h3>
			<div class="row flex-row">
				<div class="col-md-3">
					<label for="MaxSpeed"><translate>Max Speed</translate> <span class="label label-default" translate>μm/Second</span>{{helpModal("speed")}}</label>
					<input class="form-control" value="{{MaxSpeed}}" name="MaxSpeed" id="MaxSpeed" type="number" step="0.001">
				</div>
				<div class="col-md-3">
					<label for="MinSpeed"><translate>Min Speed</translate>{{helpModal("resin-level,speed")}}</label>
					<input class="form-control" value="{{MinSpeed}}" name="MinSpeed" id="MinSpeed" type="number" min="1">
				</div>
				<div class="col-md-3">
					<label for="StartupSpeed"><translate>Motor Startup Speed</translate>{{helpModal("speed")}}</label>
					<input class="form-control" value="{{StartupSpeed}}" name="StartupSpeed" id="StartupSpeed" type="number" min="1">
				</div>
				<div class="col-md-3">
					<label for="MotorDegree"><translate>Motor Step Angle</translate></label>
					<input class="form-control" value="{{MotorDegree}}" name="MotorDegree" id="MotorDegree" type="number" step="0.01">
					<br>
				</div>
				<div class="col-md-3">
					<label for="MicroStep"><translate>Microstep</translate>{{helpModal("microstepping")}}</label>
					<input class="form-control" value="{{MicroStep}}" name="MicroStep" type="number">
				</div>
				<div class="col-md-3">
					<label for="LeadscrewPitch"><translate>Leadscrew Pitch</translate> <span class="label label-default" translate>Millimeter</span>{{helpModal("pitch")}}</label>
					<input class="form-control" value="{{LeadscrewPitch}}" name="LeadscrewPitch" id="LeadscrewPitch" step="0.0001" type="number">
				</div>
				<div class="col-md-3">
					<label for="ZAxisHeight"><translate>Z-Axis Height</translate> <span class="label label-default" translate>Pulse</span>{{helpModal("zaxis-height")}}</label>
					<input class="form-control" value="{{ZAxisHeight}}" name="ZAxisHeight" id="ZAxisHeight" type="number">
				</div>
			</div>
		</div>
	
		<div class="conditional" data-condition="#arch=='arm' && ['2'].includes(#SetupMode)">
			<h3 translate>Camera Module</h3>
			<div class="row">
				<div class="col-md-3">
					<label for="CameraFrequency"><translate>Camera Photo Frequency</translate></label>
					<select class="form-control" name="CameraFrequency" id="CameraFrequency">
						<option value="0" {% if CameraFrequency==0 %}selected{% endif %} translate>Disabled</option>
						<option value="-1" {% if CameraFrequency==-1 %}selected{% endif %} translate>Only Manually</option>
						<option value="1" {% if CameraFrequency==1 %}selected{% endif %} translate>Once Per Layer</option>
						<option value="2" {% if CameraFrequency==2 %}selected{% endif %} translate>Once Per 2 Layers</option>
						<option value="3" {% if CameraFrequency==3 %}selected{% endif %} translate>Once Per 3 Layers</option>
						<option value="5" {% if CameraFrequency==5 %}selected{% endif %} translate>Once Per 5 Layers</option>
						<option value="10" {% if CameraFrequency==10 %}selected{% endif %} translate>Once Per 10 Layers</option>
					</select>
				</div>
				<div class="col-md-3 CameraFrequency_toggle">
					<label for="CameraStore"><translate>Storage Mode</translate></label>
					<select class="form-control" name="CameraStore" id="CameraStore">
						<option value="0" {% if CameraStore==0 %}selected{% endif %} translate>Only Last Image</option>
						<option value="1" {% if CameraStore==1 %}selected{% endif %} translate>All Images</option>
					</select>
				</div>
				<div class="col-md-6 CameraFrequency_toggle">
					<label for="CameraCommand"><translate>Camera Command</translate> {{helpModal("camera")}}</label>
					<input class="form-control" value="{{CameraCommand}}" name="CameraCommand" id="CameraCommand">
				</div>
			</div>

			<h3 translate>AMLCD</h3>
			<div class="row">
				<div class="col-md-6">
					<label for="LCDType"><translate>LCD Type</translate> <span class="label label-warning" translate>Restart Required</span></label>
					<select class="form-control" name="LCDType" id="LCDType">
						<option value="0" {% if LCDType==0 %}selected{% endif %} translate>Not Available</option>
						<option value="1" {% if LCDType==1 %}selected{% endif %} translate>16x2</option>
					</select>
				</div>
				<div class="LCDType_toggle col-md-3">
					<label for="LCDPath"> <translate>i2c Bus Path</translate> {{helpModal("lcd-i2c")}}</label>
					<input class="form-control" value="{{LCDPath}}" name="LCDPath" id="LCDPath" list="i2cbus">
					<datalist id="i2cbus">
						{% for path in i2cbuses %}
							<option value="{{path}}">
						{% endfor %}
					</datalist>
				</div>
				<div class="LCDType_toggle col-md-3">
					<label for="LCDAdress"> <translate>i2c Address</translate> {{helpModal("lcd-i2c")}}</label>
					<input class="form-control" value="{{LCDAdress}}" name="LCDAdress" id="LCDAdress" type="number" min="0" max="127">
				</div>
			</div>
	
			<h3 translate>Physical Buttons</h3>
			<label for="ShutdownPin"> <translate>Stop/Shutdown Physical GPIO</translate></label>
			{{ gpio_select("ShutdownPin",ShutdownPin) }}
		
			<h3 translate>Hardware Fault Detection</h3>
			<div class="row">
				<div class="col-md-6">
					<label for="FaultPin"> <translate>Stepper Driver Fault Detection GPIO</translate>{{helpModal("gpio")}}</label>
					{{ gpio_select("FaultPin",FaultPin) }}
				</div>
				<div class="col-md-6 FaultPin_toggle">
					<label for="FaultPinState"><translate>Fault GPIO Default State</translate></label>
					<select class="form-control" name="FaultPinState" id="FaultPinState">
						<option value="0" {% if FaultPinState==0 %}selected{% endif %} translate>Low</option>
						<option value="1" {% if FaultPinState==1 %}selected{% endif %} translate>High</option>
					</select>
				</div>
			</div>
		</div>
	
		<div class="conditional" data-condition="['2'].includes(#SetupMode)">
		<h3 translate>Various Settings</h3>
		<div class="row flex-row">
			<div class="col-md-3">
				<label for="Port"><translate>TCP Port to Listen</translate> <span class="label label-warning" translate>Restart Required</span></label>
				<input class="form-control" value="{{Port}}" name="Port" id="Port" min="80" max="65535" type="number">
			</div>
			<div class="col-md-3">
				<label for="Mute"><translate>Play Sound After Print Stop</translate></label>
				<select class="form-control" name="Mute" id="Mute">
					<option value="0" {% if Mute==0 %}selected{% endif %} translate>Enable</option>
					<option value="1" {% if Mute==1 %}selected{% endif %} translate>Disable</option>
				</select>
				<br>
			</div>
			<div class="col-md-3">
				<label for="RemoteSlicer"><translate>Remote Slicer</translate> {{helpModal("remote-slicer")}}</label>
				<input class="form-control" value="{{RemoteSlicer}}" name="RemoteSlicer" id="RemoteSlicer" placeholder="IP:Port">
			</div>
			<div class="col-md-3">
				<label for="AutoSlice"><translate>Auto Slice</translate></label>
				<select class="form-control" name="AutoSlice" id="AutoSlice">
					<option value="0" {% if AutoSlice==0 %}selected{% endif %} translate>Enable</option>
					<option value="1" {% if AutoSlice==1 %}selected{% endif %} translate>Disable</option>
				</select>
			</div>
			<div class="col-md-3">
				<label for="PreviewGenerate"><translate>Generate 3D Preview</translate></label>
				<select class="form-control" name="PreviewGenerate" id="PreviewGenerate">
					<option value="0" {% if PreviewGenerate==0 %}selected{% endif %} translate>Enable</option>
					<option value="1" {% if PreviewGenerate==1 %}selected{% endif %} translate>Disable</option>
				</select>
				<input type="hidden" value="{{PreviewHeight}}" name="PreviewHeight" id="PreviewHeight">
				<input type="hidden" value="{{PreviewWidth}}" name="PreviewWidth" id="PreviewWidth">
			</div>
			<div class="col-md-3">
				<label for="USBDisplayAddress"><translate>Nextion Display Port Address</translate>{{helpModal("nextion,shield-port-path")}}</label>
				<input class="form-control" value="{{USBDisplayAddress}}" name="USBDisplayAddress" id="USBDisplayAddress" list="devices">
				<datalist id="devices">
					{% for path in devices %}
						<option value="{{path}}">
					{% endfor %}
				</datalist>
				<br>
			</div>
			
		</div>
		<input class="form-control" value="{{DefaultProfile}}" name="DefaultProfile" type="hidden">
		</div>
		<br>
		<button type="submit" class="btn btn-success" translate>Submit</button>
	</form>
	
	{% if inputs %}
	<form action="/setup/save-custom-inputs" method="post" class="edit-page">
		<h3 translate>Other Settings</h3>
		<div class="row">
			{% for input in inputs %}
			<div class="col-md-3">
				<label for="{{input.Name}}">{{input.Title}}{% if input.Unit!="" %} <span class="label label-default">{{input.Unit}}</span>{% endif %}</label>
				<input class="form-control" type="{% if input.Type==1 %}{{input.Type}}{% endif %}" value="{% for key, value in CustomValues %}{% if key==input.Name %}{{value}}{% endif %}{% endfor %}" name="{{input.Name}}" id="{{input.Name}}"{% if input.Type==1 %} min="{{input.Min}}" max="{{input.Max}}"{% endif %}>
			</div>
			{% endfor %}
		</div>
	<br>
	<button type="submit" class="btn btn-success" translate>Submit</button>
	</form>
	{% endif %}
	
	<br>
	<br>
	<br>
	<br>
</div>
{% endblock %}
