<root>
<document schema='101' license='1,mnfisher,347PHF' title='' description='' target='AVR.ATMEGA.Arduino Uno PDIP' >
	<config data='' clkspd='16000000' 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' />
			<data name='anlpres' value='19' />
			<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='Send.x' />
	</debug>
	<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='1' />
			<data name='DataPort' value='1' />
			<data name='DataPin' value='0' />
			<data name='UseDefaultPins' value='1' />
			<data name='WrapEnabled' value='1' />
			<data name='CommsDelayOverridden' value='0' />
			<data name='CommsDelay' value='11' />
			<data name='CalculatedCommsDelay' value='11' />
		</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='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='110e738a-13bf-46c2-b5fc-7fc491a12dec' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' catenable='1' author='' manuname='' manucode='' sysinfo='0' keywords='' dynamic='1' 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='dateStamp' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='d' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='c' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='b' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='a' type='u8' 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='timeStamp' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</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='GetDateStamp' description='' >
						<return name='Return' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='y' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='m' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='d' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='comment' title='' comment='Formula for SD card date and time stamps
    struct tm *ptm = localtime(&amp;rawtime);
    return (DWORD)(ptm-&gt;tm_year - 80) &lt;&lt; 25  Don&apos;t need - 80
         | (DWORD)(ptm-&gt;tm_mon + 1  ) &lt;&lt; 21  Don&apos;t need + 1
         | (DWORD)(ptm-&gt;tm_mday     ) &lt;&lt; 16
         | (DWORD)(ptm-&gt;tm_hour     ) &lt;&lt; 11
         | (DWORD)(ptm-&gt;tm_min      ) &lt;&lt; 5
         | (DWORD)(ptm-&gt;tm_sec/2    );       
}
 ' textarea='12,0,12,0' cmdcolor='1975743' cmdcolor_sec='1975743' />
						<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='RTC1' macro='GetYear' >
							<return exp='.y' />
						</command>
						<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='RTC1' macro='GetMonth' >
							<return exp='.m' />
						</command>
						<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='RTC1' macro='GetDate' >
							<return exp='.d' />
						</command>
						<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
							<exp exp='.y = .y + 20' />
							<exp exp='.Return = (.y &lt;&lt; 9) + (.m &lt;&lt; 5) + .d' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='SetImageSize' description='SetImageSize' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<param name='sz' type='u8' description='0 = 640x480, 1 = 320x240, 2 = 160x120' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='cmd' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='20' />
						</local>
						<local name='buf' type='u8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='5' />
						</local>
						<command class_type='switch' title='Switch' textarea='36,25,36,25' cmdcolor='3568629' cmdcolor_sec='3568629' exp='0' >
							<case >
								<flowline />
							</case>
							<case exp='0' >
								<flowline >
									<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
										<exp exp='.cmd = &quot;5600540100&quot;' />
									</command>
								</flowline>
							</case>
							<case exp='1' >
								<flowline >
									<command class_type='calculation' title='Calculation' disable='1' cmdcolor='7895044' cmdcolor_sec='7895044' >
										<exp exp='.cmd[17] = &apos;1&apos;' />
										<exp exp='.cmd[18] = &apos;1&apos;' />
									</command>
								</flowline>
							</case>
							<case exp='2' >
								<flowline >
									<command class_type='calculation' title='Calculation' disable='1' cmdcolor='7895044' cmdcolor_sec='7895044' >
										<exp exp='.cmd[17] = &apos;2&apos;' />
										<exp exp='.cmd[18] = &apos;2&apos;' />
									</command>
								</flowline>
							</case>
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='Send' >
							<argument exp='.cmd' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ReadRaw' >
							<argument exp='5' />
							<argument exp='.buf' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='ReadRaw' description='Read a string of bytes from camera.  Returns number of bytes read.' >
						<return name='Return' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='len' type='u8' description='Number of bytes to read' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='buf' type='T8*' description='Byte buffer - must be len bytes long minimum' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='20' />
						</param>
						<local name='i' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='loop' title='Loop' cmdcolor='3568629' cmdcolor_sec='3568629' type='2' forvar='.i' exp='.len' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
									<exp exp='.buf[.i] = cal_uart1 :: Receive (200)' />
								</command>
							</flowline>
						</command>
						<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
							<exp exp='.Return = .len' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='HexToDigit' description='Convert a hex character 0.9 A..F to a number ' >
						<return name='Return' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='c' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='decision' title='Decision' cmdcolor='3568629' cmdcolor_sec='3568629' exp='.c &gt;= &apos;A&apos;' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
									<exp exp='.Return = 10 + .c - &apos;A&apos;' />
								</command>
							</flowline>
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
									<exp exp='.Return = .c - &apos;0&apos;' />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Send' description='Send a command - passed as a string of hex digits to the camera' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<param name='cmd' type='T8*' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='20' />
						</param>
						<local name='i' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='x' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='len' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
							<exp exp='.len = Length$ (.cmd)' />
							<exp exp='.i = 0' />
						</command>
						<command class_type='loop' title='Loop' cmdcolor='3568629' cmdcolor_sec='3568629' type='1' exp='.i &gt;= .len' start='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
									<exp exp='.x = HexToDigit (.cmd[.i]) * 16 + HexToDigit (.cmd[.i + 1])' />
									<exp exp='.i = .i + 2' />
								</command>
								<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='cal_uart1' macro='Send' >
									<argument exp='.x' />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='GetTimeStamp' description='' >
						<return name='Return' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='h' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='m' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='s' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='comment' title='' comment='Formula for SD card date and time stamps
    struct tm *ptm = localtime(&amp;rawtime);
    return (DWORD)(ptm-&gt;tm_year - 80) &lt;&lt; 25  Don&apos;t need - 80
         | (DWORD)(ptm-&gt;tm_mon + 1  ) &lt;&lt; 21  Don&apos;t need + 1
         | (DWORD)(ptm-&gt;tm_mday     ) &lt;&lt; 16
         | (DWORD)(ptm-&gt;tm_hour     ) &lt;&lt; 11
         | (DWORD)(ptm-&gt;tm_min      ) &lt;&lt; 5
         | (DWORD)(ptm-&gt;tm_sec/2    );       Why / 2?
}
 ' textarea='12,0,12,0' cmdcolor='1975743' cmdcolor_sec='1975743' />
						<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='RTC1' macro='GetHours' >
							<return exp='.h' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='RTC1' macro='GetMins' >
							<return exp='.m' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='RTC1' macro='GetSecs' >
							<return exp='.s' />
							<argument exp='0' />
						</command>
						<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
							<exp exp='.Return = (.h &lt;&lt; 11) + (.m &lt;&lt; 5) + (.s / 2)' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='TakePicture' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='b' type='u8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='5' />
						</local>
						<command class_type='call' title='Take pictures' cmdcolor='1975743' cmdcolor_sec='1975743' macro='Send' >
							<argument exp='&quot;5600360100&quot;' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ReadRaw' >
							<argument exp='5' />
							<argument exp='.b' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='SetCompression' description='Set JPEG compression level' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<param name='level' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='cmd' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='20' />
						</local>
						<local name='buf' type='u8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='5' />
						</local>
						<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
							<exp exp='.cmd = &quot;560031050101120400&quot;' />
							<exp exp='.cmd[15] = DigitToHex (.level &gt;&gt; 4)' />
							<exp exp='.cmd[16] = DigitToHex (.level &amp; 0xf)' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='Send' >
							<argument exp='.cmd' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ReadRaw' >
							<argument exp='5' />
							<argument exp='.buf' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='DigitToHex' description='Return hex digit corresponding to b' >
						<return name='Return' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='b' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='decision' title='Decision' cmdcolor='3568629' cmdcolor_sec='3568629' exp='.b &gt;= 10' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
									<exp exp='.Return = .b - 10 + &apos;A&apos;' />
								</command>
							</flowline>
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
									<exp exp='.Return = &apos;0&apos; + .b' />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='GetImageData' description='Read image data from camera.  Size must be a multiple of 8
Fills buffer with data - look for FFD9 for end of data.
Returns address of next block to read' >
						<return name='Return' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='sz' type='u8' description='Number of bytes to read' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='pos' type='u16' description='Data position' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='delay' type='u8' description='Delay in 0.01ms - Keep small ~10' isconst='0' isinit='0' usrinit='0' setinit='' />
						<param name='buf' type='T8*' description='Buffer for data - must be big enough' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='20' />
						</param>
						<local name='cmd' type='T8' description='Command string' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='32' />
						</local>
						<local name='hdr' type='u8' description='Small buffer for pre and post amble data' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='5' />
						</local>
						<command class_type='calculation' title='Patch variables into the command string.' cmdcolor='7895044' cmdcolor_sec='7895044' >
							<exp exp='.cmd = &quot;5600320C000A0000MMMM00000040000A&quot;' />
							<exp exp='.cmd[16] = DigitToHex ((.pos &gt;&gt; 12) &amp; 0xf)' />
							<exp exp='.cmd[17] = DigitToHex ((.pos &gt;&gt; 8) &amp; 0xf)' />
							<exp exp='.cmd[18] = DigitToHex ((.pos &gt;&gt; 4) &amp; 0xf)' />
							<exp exp='.cmd[19] = DigitToHex (.pos &amp; 0xf)' />
							<exp exp='.cmd[24] = DigitToHex ((.sz &gt;&gt; 12) &amp; 0xf)' />
							<exp exp='.cmd[25] = DigitToHex ((.sz &gt;&gt; 8) &amp; 0xf)' />
							<exp exp='.cmd[26] = DigitToHex ((.sz &gt;&gt; 4) &amp; 0xf)' />
							<exp exp='.cmd[27] = DigitToHex (.sz &amp; 0xf)' />
							<exp exp='.cmd[31] = DigitToHex (.delay &amp; 0xf)' />
							<exp exp='.Return = .pos + .sz' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='Send' >
							<argument exp='.cmd' />
						</command>
						<command class_type='call' title='Read 5 byte pre-amble' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ReadRaw' >
							<argument exp='5' />
							<argument exp='.hdr' />
						</command>
						<command class_type='delay' title='Delay' cmdcolor='7895044' cmdcolor_sec='7895044' exp='10 * .delay' type='0' />
						<command class_type='call' title='Fill buffer with data' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ReadRaw' >
							<argument exp='.sz' />
							<argument exp='.buf' />
						</command>
						<command class_type='delay' title='Delay' cmdcolor='7895044' cmdcolor_sec='7895044' exp='10 * .delay' type='0' />
						<command class_type='call' title='Read post amble' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ReadRaw' >
							<argument exp='5' />
							<argument exp='.hdr' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='GetDataLength' description='' >
						<return name='Return' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='length' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='s' type='u8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='9' />
						</local>
						<local name='cmd' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='6' />
						</local>
						<command class_type='calculation' title='Calculation' textarea='36,8,36,8' cmdcolor='7895044' cmdcolor_sec='7895044' >
							<exp exp='.cmd = &quot;5600340100&quot;' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='Send' >
							<argument exp='.cmd' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ReadRaw' >
							<argument exp='9' />
							<argument exp='.s' />
						</command>
						<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
							<exp exp='.Return = .s[7] &lt;&lt; 8 + .s[8]' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='ResetCamera' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='b' type='u8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='4' />
						</local>
						<command class_type='call' title='Call Macro' textarea='36,-11,36,-11' break='1' cmdcolor='1975743' cmdcolor_sec='1975743' macro='Send' >
							<argument exp='&quot;56002600&quot;' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ReadRaw' >
							<argument exp='4' />
							<argument exp='.b' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='Use a linksprite serial camera to take timelapse photos and save to SD' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='s' type='T8' description='Our data buffer - we read 64 byte blocks' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='64' />
						</local>
						<local name='start' type='u16' description='Start address of data from jpeg' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='i' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='x' type='u8' description='Current byte read' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='more' type='b1' description='' isconst='0' isinit='1' usrinit='1' setinit='true' />
						<local name='last' type='u8' description='Last byte read from data' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='sd' type='u8' description='Return value for init of SD card' isconst='0' isinit='1' usrinit='0' setinit='0' />
						<local name='fname' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='20' />
						</local>
						<local name='id' type='u16' description='id of current image' isconst='0' isinit='1' usrinit='0' setinit='0' />
						<local name='spos' type='u16' description='position in current sector of SD file' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='BufSize' type='s16' description='' isconst='1' isinit='1' usrinit='64' setinit='64' />
						<local name='res' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='RTC1' macro='Initialise' />
						<command class_type='call' title='Call Component Macro' textarea='36,22,36,22' cmdcolor='1975743' cmdcolor_sec='1975743' component='cal_uart1' macro='Init' />
						<command class_type='delay' title='wait for camera to stabilise.  Should look for init code from ca' cmdcolor='7895044' cmdcolor_sec='7895044' exp='5' type='2' />
						<command class_type='loop' title='Wait for the SD card to init' cmdcolor='3568629' cmdcolor_sec='3568629' type='1' exp='.sd == 0' start='0' >
							<flowline >
								<command class_type='delay' title='Delay' cmdcolor='7895044' cmdcolor_sec='7895044' exp='1' type='2' />
								<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='Initialise' >
									<return exp='.sd' />
								</command>
							</flowline>
						</command>
						<command class_type='loop' title='Find first available file id' cmdcolor='3568629' cmdcolor_sec='3568629' type='1' exp='.res != 0' start='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
									<exp exp='.id = .id + 1' />
									<exp exp='.fname = &quot;Im&quot; + ToString$ (.id) + &quot;.jpg&quot;' />
								</command>
								<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='OpenFile' >
									<return exp='.res' />
									<argument exp='.fname' />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='Reset camera.  Ignore it&apos;s reply.' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ResetCamera' />
						<command class_type='delay' title='Delay' cmdcolor='7895044' cmdcolor_sec='7895044' exp='1' type='2' />
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='SetImageSize' >
							<argument exp='0' />
						</command>
						<command class_type='call' title='Set jpeg compression level (default is 36) to desired level' cmdcolor='1975743' cmdcolor_sec='1975743' macro='SetCompression' >
							<argument exp='10' />
						</command>
						<command class_type='delay' title='Delay' textarea='36,-22,36,-22' cmdcolor='7895044' cmdcolor_sec='7895044' exp='1' type='2' />
						<command class_type='loop' title='Take photos repeatedly' cmdcolor='3568629' cmdcolor_sec='3568629' type='0' exp='1' >
							<flowline >
								<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='TakePicture' />
								<command class_type='delay' title='Delay' cmdcolor='7895044' cmdcolor_sec='7895044' exp='1' type='2' />
								<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
									<exp exp='.last = 0' />
									<exp exp='.more = true' />
									<exp exp='.fname = &quot;Im&quot; + ToString$ (.id) + &quot;.jpg&quot;' />
									<exp exp='.id = .id + 1' />
									<exp exp='.start = 0' />
									<exp exp='.spos = 0' />
									<exp exp='' />
								</command>
								<command class_type='call' title='Create and then open a file on sd card' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='CreateFile' >
									<argument exp='.fname' />
								</command>
								<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='OpenFile' >
									<argument exp='.fname' />
								</command>
								<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='SetTimeAndDate' >
									<argument exp='GetTimeStamp()' />
									<argument exp='GetDateStamp()' />
								</command>
								<command class_type='loop' title='Read jpeg data blocks and write to SD card,' cmdcolor='3568629' cmdcolor_sec='3568629' type='1' exp='.more = false' start='0' >
									<flowline >
										<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='GetImageData' >
											<return exp='.start' />
											<argument exp='.BufSize' />
											<argument exp='.start' />
											<argument exp='10' />
											<argument exp='.s' />
										</command>
										<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
											<exp exp='.i = 0' />
										</command>
										<command class_type='loop' title='Loop  over all BufSize bytes or until we hit 0xFFD9 - end jpeg' cmdcolor='3568629' cmdcolor_sec='3568629' type='1' exp='.i == .BufSize OR .more = false' start='0' >
											<flowline >
												<command class_type='calculation' title='Read next byte from buffer' cmdcolor='7895044' cmdcolor_sec='7895044' >
													<exp exp='.x = .s[.i]' />
													<exp exp='.i = .i + 1' />
												</command>
												<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='WriteByteToBuffer' >
													<argument exp='.spos' />
													<argument exp='.x' />
												</command>
												<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
													<exp exp='.spos = .spos + 1' />
												</command>
												<command class_type='decision' title='Is current sector full' cmdcolor='3568629' cmdcolor_sec='3568629' exp='.spos = 512' swap='0' >
													<flowline >
														<command class_type='call' title='Write the sector to SD' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='WriteFileSector' />
														<command class_type='call' title='Expand the file' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='MoveToNextFileSector' >
															<argument exp='1' />
														</command>
														<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
															<exp exp='.spos = 0' />
														</command>
													</flowline>
													<flowline />
												</command>
												<command class_type='decision' title='Decision' cmdcolor='3568629' cmdcolor_sec='3568629' exp='.last = 0xff &amp;&amp; .x = 0xd9' swap='0' >
													<flowline >
														<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
															<exp exp='.more = false' />
														</command>
													</flowline>
													<flowline >
														<command class_type='calculation' title='Calculation' cmdcolor='7895044' cmdcolor_sec='7895044' >
															<exp exp='.last = .x' />
														</command>
													</flowline>
												</command>
											</flowline>
										</command>
										<command class_type='delay' title='Delay' cmdcolor='7895044' cmdcolor_sec='7895044' exp='1' type='1' />
									</flowline>
								</command>
								<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='StopTakingPictures' />
								<command class_type='decision' title='Write out final sector if necessary' cmdcolor='3568629' cmdcolor_sec='3568629' exp='.spos &gt; 0' swap='0' >
									<flowline >
										<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='WriteFileSector' />
										<command class_type='call' title='Call Component Macro' cmdcolor='1975743' cmdcolor_sec='1975743' component='FAT1' macro='MoveToNextFileSector' >
											<argument exp='0' />
										</command>
									</flowline>
									<flowline />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='StopTakingPictures' description='Tell the camera to stop taking photos.  Not sure this is necessary' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='s' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='6' />
						</local>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='Send' >
							<argument exp='&quot;5600360103&quot;' />
						</command>
						<command class_type='call' title='Call Macro' cmdcolor='1975743' cmdcolor_sec='1975743' macro='ReadRaw' >
							<argument exp='5' />
							<argument exp='.s' />
						</command>
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='91b64b1d-b8b2-40f1-b073-e953a91fa234' vmin='2' vmaj='1' codename='cal_uart1' x='0' y='0' z='0' xsz='25' ysz='25' zsz='25' 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='CHANNEL' data='000' />
					<value target='TX' data='$PORTD.6' />
					<value target='OutputPins' data='000' />
					<value target='TXAlt' data='0' />
					<value target='RX' data='$PORTD.7' />
					<value target='InputPins' data='000' />
					<value target='RXAlt' data='0' />
					<value target='CTS_PORT' data='$PORTC.5' />
					<value target='CTS_PIN' data='5' />
					<value target='CTS_TRIS' data='$PORTC.5' />
					<value target='RTS_PORT' data='$PORTC.4' />
					<value target='RTS_PIN' data='4' />
					<value target='RTS_TRIS' data='$PORTC.4' />
					<value target='BAUD_LIST' data='007' />
					<value target='BAUD' data='38400' />
					<value target='DBITS' data='008' />
					<value target='RETURN' data='000' />
					<value target='ECHO' data='000' />
					<value target='INT' data='000' />
					<value target='FLOWEN' data='000' />
					<value target='RTS' data='$PORTC.4' />
					<value target='CTS' data='$PORTC.5' />
					<value target='REF' data='0' />
					<value target='TX_PORT' data='$PORTD.6' />
					<value target='TX_TRIS' data='$PORTD.6' />
					<value target='TX_PIN' data='6' />
					<value target='RX_PORT' data='$PORTD.7' />
					<value target='RX_TRIS' data='$PORTD.7' />
					<value target='RX_PIN' data='7' />
					<value target='REMAPPABLE' data='' />
					<value target='OutputReg' data='000' />
					<value target='InputReg' data='000' />
					<value target='TXRPNUM' data='1' />
					<value target='TXBank' data='a' />
					<value target='RXRPREG' data='U1RXR' />
					<value target='RXBank' data='c' />
					<value target='Injector' data='000' />
					<value target='InjectorHandle' data='0' />
					<value target='ScopeTraces' data='0' />
					<value target='ConsoleData' data='0' />
					<value target='UARTName' data='USART1' />
					<value target='UARTClock' data='' />
					<value target='UartNumber' data='' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='0b61bd39-05a3-46ee-a2a5-da7bffb583c5' vmin='7' vmaj='2' codename='FAT1' x='0' y='0' z='2.66' 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='1' />
					<value target='EOFtype' data='000' />
					<value target='Channel' data='000' />
					<value target='PR_SCALE' data='016' />
					<value target='PR_SCALE2' data='001' />
					<value target='cs_pin' data='$PORTB.2' />
					<value target='mosi_pin' data='$PORTB.3' />
					<value target='miso_pin' data='$PORTB.4' />
					<value target='sck_pin' data='$PORTB.5' />
					<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='f0e01201-8951-4748-87c3-d1f8423bb6e4' vmin='0' vmaj='2' codename='RTC1' x='0' y='0' z='0' xsz='25' ysz='25' zsz='25' 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='RTCModule' data='001' />
					<value target='I2CAddr' data='208' />
					<value target='cal_i2c1::CHANNEL' data='001' />
					<value target='cal_i2c1::SDA' data='$PORTC.4' />
					<value target='cal_i2c1::SCL' data='$PORTC.5' />
					<value target='cal_i2c1::BAUD_LIST' data='001' />
					<value target='cal_i2c1::BAUD' data='400000' />
					<value target='cal_i2c1::StopDel' data='0' />
					<value target='Simulation' data='0' />
					<value target='RTCType' data='0' />
					<value target='ClockSource' data='000' />
					<value target='FracDiv' data='000' />
					<value target='Prescaler' data='000' />
					<value target='Divider' data='0' />
					<value target='MaxDivider' data='0' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
		</component>
	</components>
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' perspective='0' >
		<background rgb='2105930' 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='0' perspective='0' >
		<background rgb='8409120' img='' style='0' />
		<table rgb='7360576' 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' />
		<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' />
	</panel3d>
	<layout >
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='70' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='SetImageSize' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='GetTimeStamp' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='GetDateStamp' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='DigitToHex' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='ResetCamera' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='SetCompression' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='StopTakingPictures' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='ReadRaw' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='TakePicture' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='GetImageData' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='GetDataLength' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='HexToDigit' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAeAAAAgQcAAMAEAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
