<root>
<document schema='101' license='1,30Day_64900870,H89H1W' title='' description='' target='PIC16.33E.EB091' >
	<config data='' clkspd='140000000' simspd='1' usewdt='0' constif='0' />
	<plugins >
		<dll_dbg_icd enabled='0' >
			<data name='debug' value='1' />
			<data name='userpins' value='0' />
			<data name='speed' value='2' />
			<data name='usev9' value='0' />
			<data name='breaks' value='8' />
			<data name='stacks' value='8' />
			<data name='clkport' value='1' />
			<data name='clkbit' value='6' />
			<data name='dataport' value='1' />
			<data name='databit' value='7' />
			<data name='ghostype' value='1' />
			<data name='monitor' value='1' />
			<data name='ictloop' value='0' />
			<data name='ictrate' value='20000' />
			<data name='ictmask' value='0' />
			<data name='anlpres' value='255' />
			<data name='digmask1' value='-1' />
			<data name='digmask2' value='-1' />
		</dll_dbg_icd>
		<dll_models enabled='1' />
		<dll_upgrader enabled='1' />
		<dll_webhelp enabled='1' />
	</plugins>
	<supplement use='0' head='' body='' />
	<debug >
		<watch expr='$PORTF' />
		<watch expr='humidity' />
		<watch expr='n' />
		<watch expr='temperature' />
	</debug>
	<components >
		<settings autoimg='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='7e111c12-60c9-4123-8734-0d4dc5c7e542' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' catenable='1' author='' manuname='' manucode='' sysinfo='0' keywords='' dynamic='0' iconpath='' />
		<component class_type='root' codename='panel' 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' interactive='1' solid='1' layer='0' poslock='0' >
			<resources />
			<properties />
			<values />
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='Humid_str' type='T8' description='strings' isconst='0' isinit='1' usrinit='&quot;&quot;' setinit='&quot;&quot;' >
						<array size='20' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='false' type='b1' description='' isconst='1' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='temp_str' type='T8' description='strings' isconst='0' isinit='1' usrinit='&quot;&quot;' setinit='&quot;&quot;' >
						<array size='20' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='true' type='b1' description='' isconst='1' isinit='1' usrinit='1' setinit='1' />
				</variable>
			</variables>
			<macros >
				<macro >
					<flowline name='disply' description='write to  display' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='Cursor' >
							<argument exp='0' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='PrintString' >
							<argument exp='temp_str' />
						</command>
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='Cursor' >
							<argument exp='0' />
							<argument exp='1' />
						</command>
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='PrintString' >
							<argument exp='Humid_str' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='DHT22' description='measure temp and RH with DHT22

pin F0' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='bit' type='b1' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
						<local name='CRC' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
						<local name='n' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
						<local name='Humid_str' type='T8' description='' isconst='0' isinit='1' usrinit='&quot;&quot;' setinit='&quot;&quot;' >
							<array size='20' />
						</local>
						<local name='temp_str' type='T8' description='' isconst='0' isinit='1' usrinit='&quot;&quot;' setinit='&quot;&quot;' >
							<array size='20' />
						</local>
						<local name='Temp_flt' type='f32' description='' isconst='0' isinit='1' usrinit='0.0' setinit='0.0' />
						<local name='humidity_flt' type='f32' description='' isconst='0' isinit='1' usrinit='0.0' setinit='0.0' />
						<local name='humidity' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
						<local name='temperature' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
						<command class_type='comment' title='' comment='Start conversion' textarea='12,0,487,300' />
						<command class_type='output' title='start bus low' textarea='36,0,511,300' mode='1' port='1048581' mask='1' exp='0' />
						<command class_type='comment' title='' comment='10ms for DHT11
1ms for DHT22 or AM2302' textarea='12,0,487,300' />
						<command class_type='delay' title='host start power down' textarea='36,0,511,300' exp='1' type='1' />
						<command class_type='output' title='bus set to 1' textarea='36,0,511,300' mode='1' port='1048581' mask='1' exp='1' />
						<command class_type='delay' title='bus master release time ' textarea='36,0,511,300' exp='30' type='0' />
						<command class_type='output' title='bus set to 0' textarea='36,0,511,300' mode='1' port='1048581' mask='1' exp='0' />
						<command class_type='comment' title='' comment='start read sequence' textarea='12,0,487,300' />
						<command class_type='loop' title='wait for bus to go high' textarea='36,0,511,300' type='0' exp='$PORTF.0 = 0' >
							<flowline />
						</command>
						<command class_type='loop' title='Is bus high for 80us' textarea='36,0,511,300' type='0' exp='$PORTF.0 = 1' >
							<flowline />
						</command>
						<command class_type='comment' title='' comment='read 40 bits
16 bits humidity
16 bits température
8 bits CRC' textarea='50,62,525,362' />
						<command class_type='loop' title='Start with Bit 39' textarea='36,0,511,300' type='2' forvar='.n' exp='40' start='0' >
							<flowline >
								<command class_type='loop' title='80 us' textarea='36,0,511,300' type='0' exp='$PORTF.0 = 0' start='0' >
									<flowline />
								</command>
								<command class_type='delay' title='Pause' exp='54' type='0' />
								<command class_type='decision' title='Décision' textarea='36,0,511,300' exp='$PORTF.0 = 1' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calcul' textarea='36,0,511,300' >
											<exp exp='.bit = 1' />
										</command>
										<command class_type='loop' title='80 us' textarea='36,0,511,300' type='0' exp='$PORTF.0 = 1' start='0' >
											<flowline />
										</command>
									</flowline>
									<flowline >
										<command class_type='calculation' title='Calcul' textarea='36,0,511,300' >
											<exp exp='.bit = 0' />
										</command>
									</flowline>
								</command>
								<command class_type='decision' title='Decision' exp='.n &gt; 15' swap='0' >
									<flowline >
										<command class_type='decision' title='Décision' exp='.n &gt; 31' swap='0' >
											<flowline >
												<command class_type='calculation' title='creat octet' >
													<exp exp='.CRC = .CRC &lt;&lt; 1' />
													<exp exp='.CRC = .CRC OR .bit' />
													<exp exp='' />
												</command>
											</flowline>
											<flowline >
												<command class_type='calculation' title='create octet' >
													<exp exp='.temperature = .temperature &lt;&lt; 1' />
													<exp exp='.temperature = .temperature OR .bit' />
													<exp exp='' />
												</command>
											</flowline>
										</command>
									</flowline>
									<flowline >
										<command class_type='calculation' title='create octet' textarea='36,0,511,300' >
											<exp exp='.humidity = .humidity &lt;&lt; 1' />
											<exp exp='.humidity = .humidity OR .bit' />
										</command>
									</flowline>
								</command>
							</flowline>
						</command>
						<command class_type='comment' title='' comment='Conversion' textarea='12,0,12,0' />
						<command class_type='calculation' title='Calculation' >
							<exp exp='.Temp_flt = .temperature' />
							<exp exp='.Temp_flt = .Temp_flt / 10' />
							<exp exp='.humidity_flt = .humidity' />
							<exp exp='.humidity_flt = .humidity_flt / 10' />
							<exp exp='.temp_str = FloatToString$ (.Temp_flt)' />
							<exp exp='.Humid_str = FloatToString$ (.humidity_flt)' />
						</command>
						<command class_type='calculation' title='Calculation' >
							<exp exp='.temp_str = Left$ (.temp_str,4)' />
							<exp exp='.temp_str = .temp_str + &quot; &quot; + &quot;C &quot;' />
							<exp exp='.Humid_str = Left$ (.Humid_str,4)' />
							<exp exp='.Humid_str = .Humid_str + &quot; &quot; + &quot;%  &quot;' />
						</command>
						<command class_type='calculation' title='Calculation' >
							<exp exp='Humid_str = .Humid_str' />
							<exp exp='temp_str = .temp_str' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='init' description='initialise components' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='call' title='start LCD' component='lcd_eb005' macro='Start' />
						<command class_type='delay' title='delay before reading DHT22' exp='2' type='2' />
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='call' title='Call Macro' macro='init' />
						<command class_type='loop' title='Loop' type='0' exp='1' >
							<flowline >
								<command class_type='call' title='Call Component Macro' component='led_5mm1' macro='TurnOn' />
								<command class_type='call' title='Call Macro' macro='DHT22' />
								<command class_type='call' title='Call Macro' macro='disply' />
								<command class_type='delay' title='Delay' exp='1' type='2' />
								<command class_type='call' title='Call Component Macro' component='led_5mm1' macro='TurnOff' />
								<command class_type='delay' title='Delay' exp='5' type='2' />
							</flowline>
						</command>
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='d92e8259-f3a8-4176-a8c4-fe7ca42b2c3f' vmin='1' vmaj='1' codename='led_5mm1' x='0' y='0' z='-1.90735e-007' xsz='1' ysz='1' zsz='1' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='pin' data='$PORTE.0' />
					<value target='polarity' data='001' />
					<value target='on_color' data='10551200' />
					<value target='length' data='4.000000' />
					<value target='show_label' data='002' />
					<value target='label_property' data='b0' />
					<value target='label_color' data='16777215' />
					<value target='label_scale' data='1.000000' />
					<value target='label_auto_scale' data='1' />
					<value target='label_position' data='003' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='d29dda88-17de-4008-991a-c881890d4c57' vmin='1' vmaj='1' codename='lcd_eb005' x='-8' y='30' z='3.575' xsz='1' ysz='1' zsz='1' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='Pin_Data_0' data='$PORTB.0' />
					<value target='Pin_Data_1' data='$PORTB.1' />
					<value target='Pin_Data_2' data='$PORTB.2' />
					<value target='Pin_Data_3' data='$PORTB.3' />
					<value target='Pin_RS' data='$PORTB.4' />
					<value target='Pin_E' data='$PORTB.5' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
		</component>
	</components>
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' perspective='0' >
		<background rgb='12632256' img='' style='0' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel2d>
	<panel3d shadows='0' lighting='2' brightness='-128' perspective='0' >
		<background rgb='8409120' img='' style='5' />
		<table rgb='13816530' img='' style='0' size='25' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel3d>
	<layout >
		<view type='0' name='DHT22' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAACgcAABkFAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAACgcAABkFAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='disply' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAACgcAABkFAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='init' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAACgcAABkFAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
