<root>
<document schema='101' license='50,Dev User,XDKHX7' title='' description='' target='PIC16.33E.ECIO40P16' >
	<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='0' />
			<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='0' />
			<data name='monitor' value='1' />
			<data name='ictloop' value='0' />
			<data name='ictrate' value='20000' />
			<data name='ictmask' value='0' />
		</dll_dbg_icd>
		<dll_models enabled='1' />
		<dll_upgrader enabled='1' />
		<dll_webhelp enabled='1' />
	</plugins>
	<supplement use='0' head='' body='' />
	<debug />
	<components >
		<settings autoimg='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='84648b1e-3b7b-4c82-b436-8463509db9ba' 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='1' poslock='0' >
			<resources />
			<properties />
			<values />
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='done' type='u16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='DataByte' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Length' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</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='retval' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='InsertionPoint' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='FileLength' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='InsertionData' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
						<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='LoadInsertionDataIntoBuffer' description='' >
						<local name='idx' type='u16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
						<command class_type='calculation' title='Calculation' >
							<exp exp='length = Length$ (InsertionData)' />
						</command>
						<command class_type='loop' title='Loop' type='0' exp='.idx &lt; length' >
							<flowline >
								<command class_type='call' title='Call Component Macro' component='CircularBuffer1' macro='PutByte' >
									<argument exp='InsertionData[.idx]' />
								</command>
								<command class_type='calculation' title='Calculation' >
									<exp exp='.idx = .idx + 1' />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='LoadSectorIntoBuffer' description='' >
						<param name='StartLocation' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='DataByte' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='loop' title='Loop' type='0' exp='.StartLocation &lt; 512' >
							<flowline >
								<command class_type='call' title='Call Component Macro' component='FAT1' macro='ReadByteFromBuffer' >
									<return exp='.DataByte' />
									<argument exp='.StartLocation' />
								</command>
								<command class_type='call' title='Call Component Macro' component='CircularBuffer1' macro='PutByte' >
									<argument exp='.DataByte' />
								</command>
								<command class_type='calculation' title='Calculation' >
									<exp exp='.StartLocation = .StartLocation + 1' />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='OpenFile' description='' >
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='Clear' />
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='PrintString' >
							<argument exp='&quot;Open &quot;' />
						</command>
						<command class_type='call' title='Open File' component='FAT1' macro='OpenFile' >
							<return exp='retval' />
							<argument exp='&quot;Test.txt&quot;' />
						</command>
						<command class_type='decision' title='Decision' exp='retval = 0' swap='0' >
							<flowline >
								<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='PrintString' >
									<argument exp='&quot;OK&quot;' />
								</command>
							</flowline>
							<flowline >
								<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='PrintString' >
									<argument exp='&quot;Fail&quot;' />
								</command>
							</flowline>
						</command>
						<command class_type='delay' title='Delay' exp='2' type='2' />
					</flowline>
				</macro>
				<macro >
					<flowline name='InitFat' description='' >
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='Start' />
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='PrintString' >
							<argument exp='&quot;Startup &quot;' />
						</command>
						<command class_type='calculation' title='Calculation' >
							<exp exp='retval = 1' />
						</command>
						<command class_type='loop' title='Loop' type='0' exp='retval &gt; 0' >
							<flowline >
								<command class_type='delay' title='Delay' exp='10' type='1' />
								<command class_type='call' title='Call Component Macro' component='FAT1' macro='Initialise' >
									<return exp='retval' />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='PrintString' >
							<argument exp='&quot;OK&quot;' />
						</command>
						<command class_type='delay' title='Delay' exp='2' type='2' />
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' >
						<command class_type='calculation' title='Insert Data at Byte 980' >
							<exp exp='InsertionPoint = 980' />
							<exp exp='done = 0' />
						</command>
						<command class_type='calculation' title='Set Data to Insert' >
							<exp exp='InsertionData = &quot;xx Inserted Into File xx&quot;' />
						</command>
						<command class_type='call' title='Startup FAT' macro='InitFat' />
						<command class_type='call' title='Open File' macro='OpenFile' />
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='Clear' />
						<command class_type='call' title='Call Component Macro' component='lcd_eb005' macro='PrintString' >
							<argument exp='&quot;Inserting Data&quot;' />
						</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 Macro' macro='LoadInsertionDataIntoBuffer' />
						<command class_type='loop' title='Loop to find start sector' type='0' exp='done = 0' >
							<flowline >
								<command class_type='call' title='Call Component Macro' component='FAT1' macro='ReadFileLength' >
									<return exp='FileLength' />
								</command>
								<command class_type='decision' title='Decision' exp='InsertionPoint &gt; FileLength' swap='0' >
									<flowline >
										<command class_type='call' title='Move to next 512 Byte sector' component='FAT1' macro='MoveToNextFileSector' >
											<argument exp='0' />
										</command>
										<command class_type='calculation' title='Decrement Insertion Point' >
											<exp exp='InsertionPoint = InsertionPoint - 512' />
										</command>
									</flowline>
									<flowline >
										<command class_type='call' title='Copy the rest of the sector after the insert point' macro='LoadSectorIntoBuffer' >
											<argument exp='InsertionPoint' />
										</command>
										<command class_type='calculation' title='Calculation' >
											<exp exp='done = 1' />
										</command>
									</flowline>
								</command>
							</flowline>
						</command>
						<command class_type='loop' title='Loop to append data to file' type='0' exp='done = 1' >
							<flowline >
								<command class_type='call' title='Call Component Macro' component='FAT1' macro='ReadFileLength' >
									<return exp='FileLength' />
								</command>
								<command class_type='loop' title='Loop' type='0' exp='(InsertionPoint &lt; 512)' >
									<flowline >
										<command class_type='call' title='Call Component Macro' component='CircularBuffer1' macro='GetByte' >
											<return exp='DataByte' />
										</command>
										<command class_type='call' title='Call Component Macro' component='FAT1' macro='WriteByteToBuffer' >
											<argument exp='InsertionPoint' />
											<argument exp='DataByte' />
										</command>
										<command class_type='calculation' title='Calculation' >
											<exp exp='InsertionPoint = InsertionPoint + 1' />
										</command>
									</flowline>
								</command>
								<command class_type='call' title='Write new 512 Byte buffer to card' component='FAT1' macro='WriteFileSector' />
								<command class_type='call' title='Move to next 512 Byte sector' component='FAT1' macro='MoveToNextFileSector' >
									<return exp='retval' />
									<argument exp='0' />
								</command>
								<command class_type='call' title='Call Macro' macro='LoadSectorIntoBuffer' >
									<argument exp='0' />
								</command>
								<command class_type='calculation' title='Calculation' >
									<exp exp='InsertionPoint = 0' />
								</command>
								<command class_type='decision' title='Decision' exp='(FileLength &lt; 512) | (retval &gt; 0)' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' >
											<exp exp='done = 0' />
										</command>
										<command class_type='decision' title='Decision' exp='retval &gt; 0' swap='0' >
											<flowline >
												<command class_type='call' title='Move to next 512 Byte sector' component='FAT1' macro='MoveToNextFileSector' >
													<return exp='retval' />
													<argument exp='1' />
												</command>
											</flowline>
											<flowline />
										</command>
									</flowline>
									<flowline />
								</command>
							</flowline>
						</command>
						<command class_type='decision' title='Decision' exp='FileLength = 512' swap='0' >
							<flowline >
								<command class_type='loop' title='Final Loop to finish off' type='0' exp='Length' >
									<flowline >
										<command class_type='call' title='Call Component Macro' component='CircularBuffer1' macro='GetByte' >
											<return exp='DataByte' />
										</command>
										<command class_type='call' title='Call Component Macro' component='FAT1' macro='WriteByteToBuffer' >
											<argument exp='InsertionPoint' />
											<argument exp='DataByte' />
										</command>
										<command class_type='calculation' title='Calculation' >
											<exp exp='InsertionPoint = InsertionPoint + 1' />
										</command>
									</flowline>
								</command>
								<command class_type='call' title='Write new 512 Byte buffer to card' component='FAT1' macro='WriteFileSector' />
							</flowline>
							<flowline />
						</command>
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='0b61bd39-05a3-46ee-a2a5-da7bffb583c5' vmin='2' vmaj='2' codename='FAT1' x='-64' y='16' z='1.4' 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='max_concurrent_files' data='2' />
					<value target='Channel' data='000' />
					<value target='PR_SCALE' data='004' />
					<value target='cs_pin' data='$PORTD.2' />
					<value target='mosi_pin' data='$PORTD.5' />
					<value target='miso_pin' data='$PORTD.4' />
					<value target='sck_pin' data='$PORTD.3' />
					<value target='MosiRemap' data='000' />
					<value target='MisoRemap' data='000' />
					<value target='ClkRemap' data='000' />
					<value target='root_dir' data='$(srcdir)' />
					<value target='AutoInsertCard' data='1' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='c34f9b8a-a915-4f75-ad0c-87f2ad670a8a' vmin='1' vmaj='1' codename='CircularBuffer1' x='56' y='0' z='0' xsz='20' ysz='20' zsz='20' 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='BufferSize' data='650' />
					<value target='StorageType' data='000' />
					<value target='MemType' data='000' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='d29dda88-17de-4008-991a-c881890d4c57' vmin='1' vmaj='1' codename='lcd_eb005' x='0' y='0' 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='15335401' 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='256' perspective='0' >
		<background rgb='16777215' img='' style='0' />
		<table rgb='7360576' img='' style='0' size='0' />
		<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='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA1QQAALkDAAA' zoom='75' scrollx='0' scrolly='312' flags='0' />
		<view type='0' name='LoadInsertionDataIntoBuffer' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA1QQAALkDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='LoadSectorIntoBuffer' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA1QQAALkDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='OpenFile' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA1QQAALkDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='InitFat' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA1QQAALkDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
