<root>
<document scada='0' schema='103' license='1,MartinW,EJZTNW' title='' description='' fcversion='655363' target='ESP.ESP32.TTGO_T_Display' >
	<config data='' clkspd='240000000' simspd='0' usewdt='1' constif='0' commport='9' Use3V3='0' />
	<plugins >
		<dll_models enabled='1' />
	</plugins>
	<supplement use='1' head='#include &quot;esp_ota_ops.h&quot;
#include &quot;esp_flash_partitions.h&quot;
#include &quot;esp_partition.h&quot;

' body='' />
	<debug >
		<watch expr='Alarm' />
		<watch expr='Current' />
		<watch expr='Energy' />
		<watch expr='Frequency' />
		<watch expr='Power' />
		<watch expr='PowerFactor' />
		<watch expr='Voltage' />
		<watch expr='EnergyOffset' />
		<watch expr='WriteEEPROM.EnergyInt0' />
		<watch expr='WriteEEPROM.EnergyInt1' />
		<watch expr='ReadEEPROM.EnergyInt0' />
		<watch expr='ReadEEPROM.EnergyInt1' />
		<watch expr='TempUnIt0' />
		<watch expr='TempUnIt1' />
		<watch expr='TempUnIt2' />
		<watch expr='TempUnIt3' />
		<watch expr='Temp' />
		<watch expr='SendUARTString' />
		<watch expr='RxString' />
		<watch expr='ReceiveStart' />
		<watch expr='CostPerKWh' />
		<watch expr='ReadEEPROM.TempFloat' />
		<watch expr='ReadEEPROM.TempString' />
		<watch expr='Main.OptionString' />
		<watch expr='Main.Option' />
		<watch expr='CheckForValidData.OptionString' />
		<watch expr='CheckForValidData.Option' />
		<watch expr='CheckForValidData.RXStringLength' />
		<watch expr='CheckForValidData.StringRX' />
		<watch expr='CheckForValidData.data' />
	</debug>
	<traces />
	<ghost >
		<FK2 >
			<data name='FK2D0' port='4294967295' pin='4294967295' />
			<data name='FK2D1' port='4294967295' pin='4294967295' />
			<data name='FK2D2' port='4294967295' pin='4294967295' />
			<data name='FK2D3' port='4294967295' pin='4294967295' />
			<data name='FK2D4' port='4294967295' pin='4294967295' />
			<data name='FK2D5' port='4294967295' pin='4294967295' />
			<data name='FK2D6' port='4294967295' pin='4294967295' />
			<data name='FK2D7' port='4294967295' pin='4294967295' />
			<data name='FK2D8' port='4294967295' pin='4294967295' />
			<data name='FK2D9' port='4294967295' pin='4294967295' />
			<data name='FK2D10' port='4294967295' pin='4294967295' />
			<data name='FK2D11' port='4294967295' pin='4294967295' />
			<data name='FK2D12' port='4294967295' pin='4294967295' />
			<data name='FK2D13' port='4294967295' pin='4294967295' />
			<data name='FK2D14' port='4294967295' pin='4294967295' />
			<data name='FK2D15' port='4294967295' pin='4294967295' />
			<data name='FK2A0' port='4294967295' pin='4294967295' />
			<data name='FK2A1' port='4294967295' pin='4294967295' />
			<data name='FK2A2' port='4294967295' pin='4294967295' />
			<data name='FK2A3' port='4294967295' pin='4294967295' />
			<data name='FK2A4' port='4294967295' pin='4294967295' />
			<data name='FK2A5' port='4294967295' pin='4294967295' />
		</FK2>
		<ICD >
			<data name='AnalogPrescaleValue' value='19' />
			<data name='DigitalSampleRate' value='100000' />
			<data name='BreakpointCount' value='8' />
			<data name='CallStackDepthCount' value='8' />
			<data name='ClockPort' value='1' />
			<data name='ClockPin' value='6' />
			<data name='DataPort' value='1' />
			<data name='DataPin' value='7' />
			<data name='UseDefaultPins' value='1' />
			<data name='WrapEnabled' value='1' />
			<data name='CommsDelayOverridden' value='0' />
			<data name='CommsDelay' value='1' />
			<data name='CalculatedCommsDelay' value='1' />
			<data name='AnalogEB2PrescaleValue' value='2' />
			<data name='DigitalEB2SampleRate' value='100000' />
		</ICD>
		<pins >
			<digital A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
			<analog A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
		</pins>
	</ghost>
	<components >
		<settings autoimg='0' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='44996872-3874-4fc2-b63c-5e89dd415aa7' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' category2='' category3='' bIs2dOnly='0' bIs3dOnly='0' catenable='1' author='' manuname='' manucode='' sysinfo='0' keywords='' dynamic='1' scadaCompatible='0' embeddedCompatible='1' showmacros='1' iconpath='' />
		<component class_type='root' codename='panel' panelId='-1' x='0' y='0' z='0' xsz='1' ysz='1' zsz='1' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='0' poslock='0' comp2dType='0' >
			<resources />
			<properties >
				<property name='Alarm Threshold Level (W)' target='AlarmThresholdLevel' typeid='21' hidden='0' locked='0' info='Sets the threshold level of the alarm in Watts
When the threshold leve level is exceed,
the alarm value read from the PZEM-004T changes from 0 to 65535' />
			</properties>
			<values >
				<value target='AlarmThresholdLevel' data='25000' />
			</values>
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='DisplayString' type='T8' description='' isconst='0' isHidden='0' isinit='1' usrinit='&quot;&quot;' setinit='&quot;&quot;' >
						<array size='25' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='PZEM004TInitRtrnValue' type='u8' description='' isconst='0' isHidden='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='idx' type='u8' description='' isconst='0' isHidden='0' isinit='1' usrinit='1' setinit='1' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='ReadReadPZEM004Uint' type='u16' description='' isconst='0' isHidden='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='ReadPZEM004Float' type='f32' description='' isconst='0' isHidden='0' isinit='1' usrinit='0.0' setinit='0.0' />
				</variable>
			</variables>
			<macros >
				<macro >
					<flowline name='ReadSwitches' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<local name='Temp' type='u8' description='' isconst='0' isHidden='0' isinit='1' usrinit='0' setinit='0' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='DisplayString = &quot;Sw = &quot;' />
							<exp exp='' />
						</command>
						<command class_type='call' title='Check reset energy switch on io0' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='Switch_Push_Button1' macro='ReadState' >
							<return exp='.Temp' />
						</command>
						<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='0' cmdgradient='4' cmdopacity='0.64' exp='.Temp' swap='0' >
							<flowline >
								<command class_type='comment' title='' comment='GPIO0' textarea='12,0,12,0' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' />
								<command class_type='call' title='Reset energy reading to zero' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='ResetEnergy' />
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='DisplayString = DisplayString + &quot;Rst Egy&quot;' />
									<exp exp='' />
								</command>
							</flowline>
							<flowline />
						</command>
						<command class_type='call' title='Check set alarm threshold switch on io35' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='Switch_Push_Button2' macro='ReadState' >
							<return exp='.Temp' />
						</command>
						<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='0' cmdgradient='4' cmdopacity='0.64' exp='.Temp' swap='0' >
							<flowline >
								<command class_type='comment' title='' comment='GPIO35' textarea='12,0,12,0' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' />
								<command class_type='call' title='Set alarm threshold  to value within properties' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='SetPowerThresholdLevel' >
									<argument exp='AlarmThresholdLevel' />
								</command>
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='.Temp = Length$(DisplayString)' />
								</command>
								<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='0' cmdgradient='4' cmdopacity='0.64' exp='.Temp &gt; 5' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
											<exp exp='DisplayString = DisplayString + &quot; &amp; &quot;' />
										</command>
									</flowline>
									<flowline />
								</command>
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='DisplayString = DisplayString + &quot;St thr&quot;' />
									<exp exp='' />
								</command>
							</flowline>
							<flowline />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='Example program that uses a PZEM-004T energy monitor to monitor mains voltage, current, frequency, power factor, energy, and over specified power alarm.
The alarm threshold is set within properties.' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<local name='SimulationOnly' type='b1' description='' isconst='0' isHidden='0' isinit='1' usrinit='0' setinit='0' />
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='Initialise' />
						<command class_type='call' title='Check if running embedded or sim' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='IsSim1' macro='Check' >
							<return exp='.SimulationOnly' />
						</command>
						<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='0' cmdgradient='4' cmdopacity='0.64' exp='.SimulationOnly' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='PZEM004TInitRtrnValue = 0 //Simulate comms is working' />
								</command>
							</flowline>
							<flowline />
						</command>
						<command class_type='loop' title='Loop' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='0' cmdgradient='4' cmdopacity='0.64' type='0' exp='!PZEM004TInitRtrnValue' >
							<flowline >
								<command class_type='switch' title='Switch' textarea='36,25,36,25' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='0' cmdgradient='4' cmdopacity='0.64' exp='idx' >
									<case >
										<flowline />
									</case>
									<case exp='1' >
										<flowline >
											<command class_type='call' title='Read PZEM-004T voltage value' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='ReadVoltage' >
												<return exp='ReadPZEM004Float' />
											</command>
											<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
												<exp exp='DisplayString = &quot;Voltage=&quot; + FloatToString$(ReadPZEM004Float,2) + &quot;V &quot;' />
											</command>
										</flowline>
									</case>
									<case exp='2' >
										<flowline >
											<command class_type='call' title='Read PZEM-004T current value' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='ReadCurrent' >
												<return exp='ReadPZEM004Float' />
											</command>
											<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
												<exp exp='DisplayString = &quot;Current=&quot; + FloatToString$(ReadPZEM004Float,3) + &quot;A &quot;' />
											</command>
										</flowline>
									</case>
									<case exp='3' >
										<flowline >
											<command class_type='call' title='Read PZEM-004T power value' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='ReadPower' >
												<return exp='ReadPZEM004Float' />
											</command>
											<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
												<exp exp='DisplayString = &quot;Power=&quot; + FloatToString$(ReadPZEM004Float,1) + &quot;W &quot;' />
											</command>
										</flowline>
									</case>
									<case exp='4' >
										<flowline >
											<command class_type='call' title='Read PZEM-004T power factor value' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='ReadPowerFactor' >
												<return exp='ReadPZEM004Float' />
											</command>
											<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
												<exp exp='DisplayString = &quot;PF=&quot; + FloatToString$(ReadPZEM004Float,2) + &quot; &quot;' />
												<exp exp='' />
											</command>
										</flowline>
									</case>
									<case exp='5' >
										<flowline >
											<command class_type='call' title='Read PZEM-004T frequency value' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='ReadFrequency' >
												<return exp='ReadPZEM004Float' />
											</command>
											<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
												<exp exp='DisplayString = &quot;Freq=&quot; + FloatToString$(ReadPZEM004Float,1) + &quot;Hz &quot;' />
											</command>
										</flowline>
									</case>
									<case exp='6' >
										<flowline >
											<command class_type='call' title='Read PZEM-004T energy value' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='ReadEnergy' >
												<return exp='ReadPZEM004Float' />
											</command>
											<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
												<exp exp='DisplayString = &quot;Energy=&quot; + FloatToString$(ReadPZEM004Float,1) + &quot;W &quot;' />
												<exp exp='' />
											</command>
										</flowline>
									</case>
									<case exp='7' >
										<flowline >
											<command class_type='call' title='Read PZEM-004T power alarm threshold value' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='ReadPowerAlarmThreshold' >
												<return exp='ReadReadPZEM004Uint' />
											</command>
											<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
												<exp exp='DisplayString = &quot;Alarm Thresh=&quot; + ToString$(ReadReadPZEM004Uint) + &quot;W &quot;' />
												<exp exp='' />
											</command>
										</flowline>
									</case>
									<case exp='8' >
										<flowline >
											<command class_type='call' title='Read PZEM-004T alarm status value. 0=alarm off, 65535=alarm trig' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='ReadAlarmStatus' >
												<return exp='ReadReadPZEM004Uint' />
											</command>
											<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
												<exp exp='DisplayString = &quot;Alarm Status=&quot; + ToString$(ReadReadPZEM004Uint)' />
											</command>
											<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='0' cmdgradient='4' cmdopacity='0.64' exp='ReadReadPZEM004Uint' swap='0' >
												<flowline >
													<command class_type='call' title='Component Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='gLCD_ST7789V1' macro='Print' >
														<argument exp='&quot;OVER POWER!&quot;' />
														<argument exp='0' />
														<argument exp='(10)* 16 + 2' />
														<argument exp='1' />
														<argument exp='0' />
													</command>
												</flowline>
												<flowline >
													<command class_type='call' title='Component Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='gLCD_ST7789V1' macro='Print' >
														<argument exp='&quot;                &quot;' />
														<argument exp='0' />
														<argument exp='(10)* 16 + 2' />
														<argument exp='1' />
														<argument exp='0' />
													</command>
												</flowline>
											</command>
										</flowline>
									</case>
									<case exp='9' >
										<flowline >
											<command class_type='call' title='Read switches state' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='ReadSwitches' />
										</flowline>
									</case>
								</command>
								<command class_type='calculation' title='Overwrite old chars that should not be displayed' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='DisplayString = DisplayString + &quot;             &quot;' />
								</command>
								<command class_type='call' title='Print on Y of (idx - 1)* 16 + 2  = line0, line1 etc.' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='gLCD_ST7789V1' macro='Print' >
									<argument exp='DisplayString' />
									<argument exp='0' />
									<argument exp='(idx - 1)* 16 + 2' />
									<argument exp='1' />
									<argument exp='0' />
								</command>
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='idx = idx + 1' />
								</command>
								<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='0' cmdgradient='4' cmdopacity='0.64' exp='idx = 10' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
											<exp exp='idx = 1' />
										</command>
									</flowline>
									<flowline />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='Component Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='gLCD_ST7789V1' macro='Print' >
							<argument exp='&quot;PZEM-004 Comms Error&quot;' />
							<argument exp='0' />
							<argument exp='10' />
							<argument exp='1' />
							<argument exp='0' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Initialise' description='Initialise the display and the PZEM-004T' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<command class_type='call' title='Initiliase display' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='gLCD_ST7789V1' macro='Initialise' />
						<command class_type='call' title='Prin software version' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='gLCD_ST7789V1' macro='Print' >
							<argument exp='&quot;Power Monitor v1.3&quot;' />
							<argument exp='0' />
							<argument exp='2' />
							<argument exp='0' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='return the result of being initialised' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='PZEM004T1' macro='Initialise' >
							<return exp='PZEM004TInitRtrnValue' />
						</command>
						<command class_type='delay' title='Delay' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='1' type='2' />
						<command class_type='call' title='Component Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='gLCD_ST7789V1' macro='ClearDisplay' />
						<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='0' cmdgradient='4' cmdopacity='0.64' exp='PZEM004TInitRtrnValue' swap='0' >
							<flowline >
								<command class_type='comment' title='' comment='Return = 255 = PZEM-004T not detected.
Print not detected at the end of main.' textarea='67,12,67,12' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' />
							</flowline>
							<flowline >
								<command class_type='comment' title='' comment='Return = 0 = PZEM-004T detected.' textarea='67,12,67,12' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' />
								<command class_type='call' title='Component Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='gLCD_ST7789V1' macro='Print' >
									<argument exp='&quot;PZEM-004 detected OK&quot;' />
									<argument exp='0' />
									<argument exp='10' />
									<argument exp='1' />
									<argument exp='0' />
								</command>
							</flowline>
						</command>
						<command class_type='delay' title='Delay' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='1' type='2' />
						<command class_type='call' title='Component Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' component='gLCD_ST7789V1' macro='ClearDisplay' />
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='4e30b15e-2507-4583-995d-b2056e04a286' vmin='6' vmaj='1' codename='gLCD_ST7789V1' panelId='0' x='167.089' y='-210.087' z='0' xsz='40.514' ysz='40.2946' zsz='1.21206' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='2' poslock='1' comp2dType='0' >
				<resources />
				<properties />
				<values >
					<value target='pixel_width' data='135' />
					<value target='pixel_height' data='240' />
					<value target='XOffset' data='52' />
					<value target='YOffset' data='40' />
					<value target='monochrome' data='0' />
					<value target='foreground_colour' data='65280' />
					<value target='background_colour' data='0' />
					<value target='InvColours' data='1' />
					<value target='colour_bit_depth' data='16' />
					<value target='red_bit_depth' data='5' />
					<value target='green_bit_depth' data='6' />
					<value target='blue_bit_depth' data='5' />
					<value target='FGCOL' data='4032' />
					<value target='BGCOL' data='0' />
					<value target='data_pin' data='$LCD DATA' />
					<value target='clock_pin' data='$LCD SCLK' />
					<value target='UseCS' data='1' />
					<value target='ToggleCS' data='1' />
					<value target='chip_sel_pin' data='$LCD CS' />
					<value target='UseReset' data='1' />
					<value target='ResetPin' data='$LCD RST' />
					<value target='UseBacklight' data='1' />
					<value target='BacklightPin' data='$LCD BL' />
					<value target='UseDC' data='1' />
					<value target='DCPin' data='$LCD DC' />
					<value target='Base_GLCD::FontCount' data='002' />
					<value target='Base_GLCD::gLCD_Font1::Font' data='000' />
					<value target='Base_GLCD::gLCD_Font1::FontSpace' data='001' />
					<value target='Base_GLCD::gLCD_Font1::SpaceWidth' data='004' />
					<value target='Base_GLCD::gLCD_Font2::Font' data='007' />
					<value target='Base_GLCD::gLCD_Font2::FontSpace' data='001' />
					<value target='Base_GLCD::gLCD_Font2::SpaceWidth' data='004' />
					<value target='Base_GLCD::gLCD_Font3::Font' data='002' />
					<value target='Base_GLCD::gLCD_Font3::FontSpace' data='001' />
					<value target='Base_GLCD::gLCD_Font3::SpaceWidth' data='004' />
					<value target='Base_GLCD::gLCD_Font4::Font' data='015' />
					<value target='Base_GLCD::gLCD_Font4::FontSpace' data='001' />
					<value target='Base_GLCD::gLCD_Font4::SpaceWidth' data='004' />
					<value target='Base_GLCD::ComponentLabel' data='000' />
					<value target='Base_GLCD::GdiText1::sText' data='gLCD_ST7789V1' />
					<value target='Base_GLCD::GdiText1::dScale' data='1.000000' />
					<value target='DisplayMethod' data='000' />
					<value target='Base_GLCD::PhysicalOrientation' data='' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='ef2427ea-7767-43be-a0c5-6f705e3c2668' vmin='0' vmaj='1' codename='PZEM004T1' panelId='0' x='335' y='-277.671' z='1' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='2' poslock='1' comp2dType='0' >
				<resources />
				<properties />
				<values >
					<value target='cal_uart::CHANNEL' data='003' />
					<value target='cal_uart::TX' data='$PORTA.13' />
					<value target='cal_uart::OutputPins' data='006' />
					<value target='cal_uart::TXAlt' data='0' />
					<value target='cal_uart::RX' data='$PORTA.15' />
					<value target='cal_uart::InputPins' data='018' />
					<value target='cal_uart::RXAlt' data='0' />
					<value target='cal_uart::BAUD_LIST' data='004' />
					<value target='cal_uart::BAUD' data='9600' />
					<value target='UARTidx' data='003' />
					<value target='BaudByteDelay' data='1040' />
					<value target='BusType' data='000' />
					<value target='DDRP' data='$PORTA.0' />
					<value target='ReadDDRState' data='000' />
					<value target='ReceiveBufferSize' data='20' />
					<value target='AddressBytes' data='1' />
					<value target='SilentInterval' data='60' />
					<value target='RXTOUT' data='220' />
					<value target='TOUTCNT' data='2' />
					<value target='label' data='Modbus' />
					<value target='cal_uart::ScopeTraces' data='1' />
					<value target='cal_uart::ConsoleData' data='1' />
					<value target='cal_uart::ConsoleColumns' data='64' />
					<value target='cal_uart::DataSource' data='000' />
					<value target='cal_uart::com_port' data='000' />
					<value target='cal_uart::Injector' data='000' />
					<value target='cal_uart::APIUseDDR' data='' />
					<value target='cal_uart::APIDDRPin' data='' />
					<value target='cal_uart::APIDDRRXState' data='' />
					<value target='cal_uart::APIUseFC' data='' />
					<value target='cal_uart::APICTSPin' data='' />
					<value target='cal_uart::APIRTSPin' data='' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='5f7b77e5-e979-4010-93f1-e6d98f83bd71' vmin='0' vmaj='1' codename='IsSim1' panelId='0' x='335' y='-118' z='2' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='2' poslock='0' comp2dType='0' >
				<resources />
				<properties />
				<values >
					<value target='Sim' data='0' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='e2698f3e-1168-4f25-9c50-24a74ea7e34a' vmin='0' vmaj='1' codename='Switch_Push_Button1' panelId='0' x='143.131' y='-428' z='3' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='2' poslock='0' comp2dType='0' >
				<resources />
				<properties />
				<values >
					<value target='AppDevDetected' data='0' />
					<value target='Pin' data='$pin0' />
					<value target='Polarity' data='001' />
					<value target='debounce' data='0' />
					<value target='Latching' data='1' />
					<value target='ComponentLabel' data='001' />
					<value target='GdiText2::sText' data='Energy Reset' />
					<value target='ComponentLabelPosition' data='000' />
					<value target='ComponentLabelXPostion' data='0' />
					<value target='ComponentLabelYPostion' data='0.800000' />
					<value target='LabelColour' data='0' />
					<value target='ShowConnectionLabel' data='1' />
					<value target='ShowPinValue' data='0' />
					<value target='PinLabelPosition' data='001' />
					<value target='PinLabelXPostion' data='0' />
					<value target='PinLabelYPostion' data='-1.000000' />
					<value target='Style' data='000' />
					<value target='GdiSwitch1::nType' data='  2' />
					<value target='GdiSwitch1::sLabelOn' data='On' />
					<value target='GdiSwitch1::sLabelOff' data='Off' />
					<value target='FontType' data='Calibri' />
					<value target='GdiSwitch1::dScale' data='0.65' />
					<value target='GdiText2::dScale' data='0.65' />
					<value target='GdiText1::dScale' data='0.65' />
					<value target='GdiSwitch1::brOutline' data='71776119072336297' />
					<value target='GdiSwitch1::brOuterFillOn' data='251262225375821824' />
					<value target='GdiSwitch1::brFill' data='251262225375821824' />
					<value target='GdiSwitch1::brOutlineThumb' data='71917408452870144' />
					<value target='GdiSwitch1::brFillThumb' data='288090190566653952' />
					<value target='GdiSwitch1::brFillOn' data='648292728253186048' />
					<value target='GdiSwitch1::brLabelOn' data='0' />
					<value target='GdiSwitch1::brFillOff' data='648237171995574272' />
					<value target='GdiSwitch1::brLabelOff' data='0' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='e2698f3e-1168-4f25-9c50-24a74ea7e34a' vmin='0' vmaj='1' codename='Switch_Push_Button2' panelId='0' x='261.131' y='-428' z='4' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='2' poslock='0' comp2dType='0' >
				<resources />
				<properties />
				<values >
					<value target='AppDevDetected' data='0' />
					<value target='Pin' data='$pin35' />
					<value target='Polarity' data='001' />
					<value target='debounce' data='0' />
					<value target='Latching' data='1' />
					<value target='ComponentLabel' data='001' />
					<value target='GdiText2::sText' data='Set energy
threshold value' />
					<value target='ComponentLabelPosition' data='000' />
					<value target='ComponentLabelXPostion' data='0' />
					<value target='ComponentLabelYPostion' data='0.800000' />
					<value target='LabelColour' data='0' />
					<value target='ShowConnectionLabel' data='1' />
					<value target='ShowPinValue' data='0' />
					<value target='PinLabelPosition' data='001' />
					<value target='PinLabelXPostion' data='0' />
					<value target='PinLabelYPostion' data='-1.000000' />
					<value target='Style' data='000' />
					<value target='GdiSwitch1::nType' data='  2' />
					<value target='GdiSwitch1::sLabelOn' data='On' />
					<value target='GdiSwitch1::sLabelOff' data='Off' />
					<value target='FontType' data='Calibri' />
					<value target='GdiSwitch1::dScale' data='0.65' />
					<value target='GdiText2::dScale' data='0.65' />
					<value target='GdiText1::dScale' data='0.65' />
					<value target='GdiSwitch1::brOutline' data='71776119073454778' />
					<value target='GdiSwitch1::brOuterFillOn' data='251262225375821824' />
					<value target='GdiSwitch1::brFill' data='251262225375821824' />
					<value target='GdiSwitch1::brOutlineThumb' data='71917408452870144' />
					<value target='GdiSwitch1::brFillThumb' data='288090190566653952' />
					<value target='GdiSwitch1::brFillOn' data='648292728253186048' />
					<value target='GdiSwitch1::brLabelOn' data='0' />
					<value target='GdiSwitch1::brFillOff' data='648237171995574272' />
					<value target='GdiSwitch1::brLabelOff' data='0' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
		</component>
	</components>
	<scadaresourcelookup />
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' >
		<background rgb='1710618' img='' style='0' />
		<camera xe='361.481' ye='-0.175965' ze='1130.76' xt='361.481' yt='-0.175965' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<viewport dx='576' dy='368' zoom='61.6366' fix_topleft='0' />
		<page x='1000' y='1000' show='0' rgb='0' />
		<winpos ID='7005' RectRecentFloat='1632,728,2236,1194' RectRecentDocked='731,416,1327,851' RecentFrameAlignment='8192' RecentRowIndex='0' IsFloating='0' MRUWidth='32767' PinState='0' IsMaximized='0' IsVisible='0' />
	</panel2d>
	<panel3d shadows='0' lighting='2' brightness='0' perspective='1' >
		<background rgb='8409120' img='' style='0' />
		<table rgb='7360576' img='' style='0' size='0' />
		<camera xe='9.8684' ye='-34.6603' ze='249.26' xt='9.8684' yt='-34.6603' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey0 xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey1 xe='-3.67394e-14' ye='0' ze='-300' xt='0' yt='0' zt='0' xquat='0' yquat='1' zquat='0' wquat='6.12323e-17' />
		<camerakey2 xe='0' ye='-300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.707107' yquat='0' zquat='0' wquat='0.707107' />
		<camerakey3 xe='-3.67394e-14' ye='300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-4.32978e-17' yquat='0.707107' zquat='0.707107' wquat='4.32978e-17' />
		<camerakey4 xe='-300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='0.5' zquat='0.5' wquat='0.5' />
		<camerakey5 xe='300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='-0.5' zquat='-0.5' wquat='0.5' />
		<camerakey6 xe='-173.205' ye='-173.205' ze='173.205' xt='0' yt='0' zt='0' xquat='-0.424708' yquat='0.17592' zquat='0.339851' wquat='0.820473' />
		<winpos ID='7004' RectRecentFloat='556,304,1206,754' RectRecentDocked='0,0,210,771' RecentFrameAlignment='16384' RecentRowIndex='0' IsFloating='0' MRUWidth='32767' PinState='0' IsMaximized='0' IsVisible='0' />
	</panel3d>
	<panels2d count='1' >
		<panel2d_0 id='0' name='Power Monitor' >
			<winpos ID='1171' RectRecentFloat='343,265,1120,935' RectRecentDocked='950,141,1286,912' RecentFrameAlignment='16384' RecentRowIndex='0' IsFloating='0' MRUWidth='32767' PinState='0' IsMaximized='0' IsVisible='1' />
			<background fill='72057594034572492' showgrid='0' gridstyle='0' gridsize='10' gridbrush='71776119075691740' snaptogrid='1' />
		</panel2d_0>
	</panels2d>
	<layout >
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAYAAAARQEAAP4CAAA' zoom='75' scrollx='2394' scrolly='0' flags='0' />
		<view type='0' name='Initialise' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAYAAAARQEAAP4CAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='ReadSwitches' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAYAAAARQEAAP4CAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
