'************************************************* '* Download this program and pull the Commit Pin * '* Data downloads at inverted 2400 baud * '* through pin 13 * '************************************************* ' {$STAMP BS2pe} ' {$PBASIC 2.5} ' {$PORT COM5} '*********************************** '* Near Space Easy Pin Definitions * '*********************************** LCD CON 0 CS CON 1 DIO CON 2 CLK CON 3 Commit CON 4 Servo1 CON 5 Servo2 CON 6 Servo3 CON 7 GPS CON 8 MicroTrak CON 9 D6 CON 10 D5 CON 11 D4 CON 12 D3 CON 13 D2 CON 14 D1 CON 15 '*********************************** '* Near Space Easy Variables * '*********************************** I2400 CON 16780 DownloadPin CON 13 Flights VAR Word Record VAR Word StoredData VAR Byte Index VAR Nib Analogs VAR Nib Digitals VAR Nib Message VAR Bit MaxRecord VAR Word MemoryBanks VAR Nib ' maximum memory banks being used MemoryBank VAR Nib ' keep track of which memory bank is being read Altitude VAR Word GPSAltitude VAR Bit GPSTime VAR Bit SkipBanks VAR Nib Read_NearSpace_Easy: STORE 0 READ 0,Flights ' read number of this mission READ 1,SkipBanks ' how many memory banks to skip because of tables READ 2,GPSAltitude ' read if gps altitude was recorded READ 3,GPSTime ' read if gps time was recorded READ 4,Analogs ' read the number of analog banks used for this mission READ 5,Digitals ' read the number of digital banks used for this mission READ 6,Message ' read if a message was logged READ 7,MaxRecord ' what was the last record recorded MemoryBanks = (GPSAltitude * 2) + GPSTime + Analogs + Digitals + Message Begin: IF IN4 = 0 THEN Begin Write_Title: SEROUT DownloadPin,I2400,["Flight-", DEC2 Flights] IF GPSAltitude = 0 THEN No_Altitude_Title SEROUT DownloadPin,I2400,[", Altitude"] No_Altitude_Title: IF GPSTime = 0 THEN No_Time_Title SEROUT DownloadPin,I2400,[", Time"] No_Time_Title: IF Analogs = 0 THEN No_Analog_Title FOR index = 1 TO Analogs SEROUT DownloadPin,I2400,[", A", DEC index] NEXT No_Analog_Title: IF Digitals = 0 THEN No_Digital_Title FOR index = 1 TO Digitals SEROUT DownloadPin,I2400,[", D", DEC index] NEXT No_Digital_Title: IF Message THEN SEROUT DownloadPin,I2400,[", Message"] ELSE ENDIF SEROUT DownloadPin,I2400,[10,CR] Read_Data: FOR Record = 1 TO MaxRecord SEROUT DownloadPin,I2400,["R-", DEC3 Record] MemoryBank = SkipBanks + 1 STORE MemoryBank IF GPSAltitude = 0 THEN Rest_of_Data READ Record,Altitude.BYTE1 MemoryBank = MemoryBank + 1 STORE MemoryBank READ Record,Altitude.BYTE0 SEROUT DownloadPin,I2400,[",", DEC Altitude] MemoryBank = MemoryBank + 1 Rest_of_Data: FOR index = MemoryBank TO (SkipBanks + MemoryBanks) STORE index READ Record,StoredData IF (index = (SkipBanks + MemoryBanks)) AND (Message = 1) THEN SEROUT DownloadPin,I2400,[",", StoredData] ELSE SEROUT DownloadPin,I2400,[",", DEC StoredData] ENDIF NEXT SEROUT DownloadPin,I2400,[CR] NEXT END