⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 data logging in mmc in KML format
💻 C
字号:
#include <ez8.h>
#include <sio.h>
#include <string.h>
#include <stdlib.h>
#include "mmc.h"
#include "spi.h"
#include "fat.h"
#include "GPS_parsing.h"

#define STR_LEN 15

char timeRMC[STR_LEN];
char latRMC[STR_LEN];
char NS;
int degLAT;
char longRMC[STR_LEN];
int degLONG;
char EW;
char satusedGGA[STR_LEN];
float coordLAT;
float coordLONG;


char strfile[10]="000000";		// KML Filename (numeric only)
char newdata[100];				// MMC Buffer

void main (void)
{
	char filename[9]="000000";	// YYMMDD__, create_csv_file will automatically append two digits after, alphanumeric only
	extern char *RMC;
	extern char *GGA;
	float coordLAT;
	float coordLONG;
	int i = 0;


	init_uart(_UART0, _DEFFREQ, 4800);		//initialize UART0
	init_uart(_UART1, _DEFFREQ, 4800);		//initialize UART1
	PBDD=0x3F;
	PBAF=0x3F;
	PBOC &= ~0xFF;
	PBHDE |= 0xFF;
	
	PDDD &= ~0x03;		// PD0,PD1 Output
	PDDD |=  0x40;		// PD6 Input 

	if(!(PDIN & 0x40))	// Press PD6 before Reset to Format MMC
		format_to_fat16();
	
	printf("\n\nCreating KML\n");
	create_folder_file(filename,1,0);
	printf("Writing KML code in MMC\n");

	sprintf(newdata,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>%c%c", 13, 10);
	writetommc(newdata,strfile,0);
	sprintf(newdata,"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n\t<Document>%c%c", 13, 10);
	writetommc(newdata,strfile,0);
	
	while (PDIN & 0x08) {
		select_port(_UART1);
		strcpy(GGA, GGAstring());
		printf("\n\nGGA Reading: \n%s\n", GGA);
	
		strncpy(satusedGGA, &GGA[45], 2);
		satusedGGA[2] = '\0';
	
		printf("Satelllites used: %s", satusedGGA);
		strcpy(RMC, RMCstring());
		printf("\n\nRMC Reading:\n");
	   	printf("%s\n", RMC);   
		RMCtime(RMC);
		printf("Time: %s\n", timeRMC);
		RMClat();
		printf("Latitude: %s %c\n", latRMC, NS);
		RMClong();
		printf("Longitude: %s %c\n", longRMC, EW);
				
		coordLAT = atof(latRMC);
		coordLAT = coordLAT*0.01;
		degLAT = coordLAT;
		coordLAT = ((coordLAT - degLAT)*100/60) + degLAT;
		coordLONG = atof(longRMC);
		coordLONG = coordLONG*0.01;
		degLONG = coordLONG;
		coordLONG = ((coordLONG - degLONG)*100/60) + degLONG;
	

		printf("\n\t%d %f %d %f\n\n", degLONG, coordLONG, degLAT, coordLAT);
	
		sprintf(newdata,"\t\t<Placemark>%c%c", 13, 10);
		writetommc(newdata,strfile,0);
	
		sprintf(newdata,"\t\t\t<name>%s</name>%c%c", timeRMC, 13, 10);
		writetommc(newdata,strfile,0);
		
		sprintf(newdata,"\t\t\t<description>CoRe Tracker</description>%c%c", 13, 10);   
	   	writetommc(newdata,strfile,0);
	
		sprintf(newdata,"\t\t\t<Point>%c%c", 13, 10);
		writetommc(newdata,strfile,0);
	
		sprintf(newdata,"\t\t\t\t<coordinates>%f, %f</coordinates>%c%c", coordLONG, coordLAT, 13, 10);
		writetommc(newdata,strfile,0);
	
		sprintf(newdata,"\t\t\t</Point>%c%c", 13, 10);
		writetommc(newdata,strfile,0);
			
		sprintf(newdata,"\t\t</Placemark>%c%c", 13, 10);
		writetommc(newdata,strfile,0);
			
	
	}	
	
	sprintf(newdata,"\t</Document>%c%c", 13, 10);
	writetommc(newdata,strfile,0);
	sprintf(newdata,"</kml>%c%c", 13, 10);
	writetommc(newdata,strfile,0);
	PDOUT |= 0x02;
	printf("\nLogging stopped. Press reset to start logging again.\n");
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -