'**************************************************************** '* Name : 24LC-page.bas * '* Author : Harm de Vries * '* Notice : Copyright (c) 2007 Funny Faces Hard & Software * '* : All Rights Reserved * '* Date : 09-08-2007 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** Device 18F242 Declare XTAL 10 @CONFIG_REQ @__CONFIG config1h, OSCS_OFF_1 & HS_OSC_1 @__CONFIG config2l, BOR_ON_2 & BORV_20_2 & PWRT_ON_2 @__CONFIG config2h, WDT_OFF_2 & WDTPS_128_2 @__CONFIG config3h, CCP2MX_OFF_3 @__CONFIG config4l, STVR_ON_4 & LVP_OFF_4 & DEBUG_OFF_4 @__CONFIG config5l, CP0_OFF_5 & CP1_OFF_5 & CP2_OFF_5 & CP3_OFF_5 @__CONFIG config5h, CPB_OFF_5 & CPD_OFF_5 @__CONFIG config6l, WRT0_OFF_6 & WRT1_OFF_6 & WRT2_OFF_6 & WRT3_OFF_6 @__CONFIG config6h, WRTC_OFF_6 & WRTB_OFF_6 & WRTD_OFF_6 @__CONFIG config7l, EBTR0_OFF_7 & EBTR1_OFF_7 & EBTR2_OFF_7 & EBTR3_OFF_7 @__CONFIG config7h, EBTRB_OFF_7 ALL_DIGITAL = 1 TRISA = 255 Declare HSERIAL_BAUD = 4800 ' Set baud rate to 4800 Declare HSERIAL_RCSTA = %10010000 ' Enable serial port and continuous receive Declare HSERIAL_TXSTA = %00100100 ' Enable transmit and asynchronous mode, BRGH=1 ;DECLARE HSERIAL_TXSTA = %00100000 ' Enable transmit and asynchronous mode, BRGH=0 Declare HSERIAL_CLEAR = On ' Optionally clear the buffer before receiving Declare LCD_TYPE = ALPHA Declare LCD_RSPIN PORTB.4 Declare LCD_ENPIN PORTB.5 Declare LCD_DTPIN PORTB.0 Declare LCD_LINES = 2 Declare LCD_INTERFACE = 4 Dim aWerk[80] As Byte Dim iWerk As Byte Dim aNext[15] As Byte Dim aDate[7] As Byte Dim aTime[11] As Byte Dim iIx As Byte Dim iNx As Byte Dim iLen As Byte Dim iFromIx As Byte Dim iToIx As Byte Dim bKlaar As Bit Dim bEOL As Bit Dim iTemp As Byte Dim iFill As Byte Dim iRX As Byte Dim iDay As Byte Dim iMon As Byte Dim iYea As Byte Dim iHou As Byte Dim iMin As Byte Dim iSec As Byte Dim iConv As Byte Dim iMar As Byte Dim iOkt As Byte Dim iTemp2 As Byte Dim aMonth[12] As Byte Dim iAdd As Byte Dim bFlag As Byte Dim iDum As Byte Dim iAddr As Byte Dim iVal As Byte Dim iSub As Byte Clear GoTo MAIN GetNextString: For iToIx = 1 To 15 aNext[iToIx] = " " Next bKlaar = 0 bEOL = 0 iLen = 0 iFromIx = iIx iToIx = 1 If aWerk[iFromIx] = "," Then bKlaar = 1 Inc iIx EndIf If aWerk[iFromIx] = "*" Then bKlaar = 1 bEOL = 1; EndIf If aWerk[iFromIx] = 0 Then bKlaar = 1 bEOL = 1 EndIf While bKlaar = 0 aNext[iToIx] = aWerk[iFromIx] Inc iFromIx Inc iToIx Inc iLen Inc iIx If aWerk[iFromIx] = "," Then bKlaar = 1 Inc iIx EndIf If aWerk[iFromIx] = "*" Then bKlaar = 1 bEOL = 1 EndIf If aWerk[iFromIx] = 0 Then bKlaar = 1 bEOL = 1 EndIf Wend ; gosub dump Return RMC_Time: iFill = 6 iNx = 1 For iTemp = 1 To iFill aTime[iTemp] = " " Next If iLen > iFill Then iLen = iFill For iTemp = 1 To iLen iVal = aNext[iNx] aTime[iTemp] = iVal iNx = iNx + 1 Next Return RMC_Date: iFill = 7 iNx = 1 For iTemp = 1 To iFill aDate[iTemp] = " " Next If iLen > iFill Then iLen = iFill For iTemp = 1 To iLen iVal = aNext[iNx] aDate[iTemp] = iVal iNx = iNx + 1 Next Return Dump: For iDum = 1 To 15 iVal = aNext[iDum] EWrite iAddr, [iVal] iAddr = iAddr + 1 Next EWrite iAddr, [iSub] iAddr = iAddr + 1 iSub = iSub + 1 Return ProcessLine: iIx = 1 GoSub GetNextString ; print at 2,1, aNext[4],aNext[5],aNext[6] If aNext[4] = "G" Then If aNext[5] = "G" Then If aNext[6] = "A" Then ; Print At 2,4, " " ; For iDum = 8 To 17 ; Print aWerk[iDum] ; Next GoSub GetNextString ; time GoSub RMC_Time Print At 1,5, aTime[1],aTime[2], ":", aTime[3], aTime[4],":", aTime[5],aTime[6] EndIf EndIf EndIf If aNext[4] = "R" Then If aNext[5] = "M" Then If aNext[6] = "C" Then iAddr = 0 ; print at 1,1, "RMC " ; print at 2,1, " " ; for iDum = 8 to 17 ; print aWerk[iDum] ; next iSub = 0 GoSub GetNextString ; time GoSub RMC_Time Print At 1,5, aTime[1],aTime[2], ":", aTime[3], aTime[4],":", aTime[5],aTime[6] GoSub GetNextString ; Status : A/V GoSub GetNextString ; latitude GoSub GetNextString ; N/S GoSub GetNextString ; longitude GoSub GetNextString ; E/W GoSub GetNextString ; speed in knots GoSub GetNextString ; Course GoSub GetNextString ; date GoSub RMC_Date ; gosub Kalender ; gosub AdjustDateTime ; print at 1,5, atime[1],atime[2], ":", atime[3], atime[4],":", atime[5],atime[6] ; Print At 1,5, DEC2 iHou, ":", DEC2 iMin, ":", DEC2 iSec Print At 2,5, aDate[1],aDate[2], "-", aDate[3], aDate[4],"-", aDate[5],aDate[6] ; Print At 2,5, DEC2 iDay, "-", DEC2 iMon, "-", DEC2 iYea Else Print At 1,3, " " EndIf Else Print At 1,2, " " EndIf Else Print At 1,1, " " EndIf Return MAIN: Cls Print At 1,1, "Hi" ma_00: For iTemp = 1 To 80 aWerk[iTemp] = " " Next iTemp = 1 While iRX <> "$" HSerIn [iRX] HSerOut [iRX] Wend aWerk[iTemp] = iRX Inc iTemp Repeat HSerIn [iRX] HSerOut [iRX] aWerk[iTemp] = iRX Inc iTemp Until iRX = "$" Or iRX = "*" GoSub ProcessLine GoTo ma_00