|
楼主 |
发表于 2014-11-15 23:50:22
|
显示全部楼层
本帖最后由 hi55234 于 2014-11-16 20:40 编辑
A的程序 - #include <SoftwareSerial.h>
- SoftwareSerial gps(8, 9);
- char tempx[12];
- char tempxB[12];
- char GPRMC[95];
- char GPGGA[95];
- char MS[90];
- char AT[20];
- int gpschangertest;
- boolean gpschanger;
- int weiduA;
- unsigned long weiduB,weiduC;
- int jingduA;
- unsigned long jingduB,jingduC;
- boolean GPGGAget=0;
- boolean GPRMCget=0;
- boolean ATget=0;
- boolean MSget=0;
- unsigned long gpstimes;
- boolean konghangpanduan;
- boolean konghangpanduanB;
- boolean gpsshuchuqiehuanB;
- int jsq1=0;
- int jsq2=0;
- int jsq3=0;
- int jsq4=0;
- int jsq5=0;
- int jsq6=0;
- int jsq7=0;
- int GPGGAlong=0;
- int GPRMClong=0;
- int ATlong=0;
- int MSlong=0;
- int asllong=0;
- int yawlong=0;
- int sudulong=0;
- int chuankouzhuanyong;
- boolean jiaoyanjieguoA,jiaoyanjieguoC;
- float sudu;
- String jianyan="";
- int yihuoyunsuan;
- boolean dingweiok=0;
- /*---------------------GPS end---------------------------------*/
- int gpsshuchuqiehuanA;
-
- #include<EEPROM.h>
- int EEPROMvalue;
-
-
- #include <SD.h>
-
- const int chipSelect = 10;
-
- boolean gpxstart;
- boolean gpxmiddleA;
- boolean gpxmiddleB=1;
- boolean gpxendA;
- boolean gpxendB;
- int gpxjilujiangeA;
- int gpxjilujiangeB=256;
- int gpxjiludianshu;
- int gpxjiluguijishu;
- char TrackAL[4]="000";
- char TrackAN[6]="00000";
-
- char TrackB0[8]="-0000.0";
- char TrackB1[11]="00.0000000";
- char TrackB2[12]="000.0000000";
- char TrackB4[20]="2000-00-00T00:00:00";
- char TrackB5[8]="0000.00";
- char TrackB6[7]="000.00";
-
- char SDzhuangtai[7]="SDwait";
-
- boolean weiduxuweitiao=0;
- boolean jingduxuweitiao=0;
- int weiduzhanwei,jingduzhanwei;
-
- unsigned long fentodu;
- int Linenumber;
- int Tracknumber;
-
- void setup() {
-
-
-
-
-
- Serial.begin(9600);
- gps.begin(9600);
-
- EEPROMvalue= EEPROM.read(0);
- if(EEPROMvalue==0)gpsshuchuqiehuanB=0;
- else gpsshuchuqiehuanB=1;
-
-
- EEPROMvalue= EEPROM.read(1);
- if(EEPROMvalue==255) EEPROMvalue=0;
-
- Linename();
- Trackname();
-
-
- EEPROMvalue= EEPROM.read(2);
- if(EEPROMvalue==0)gpxjilujiangeA=1;
- else gpxjilujiangeA=EEPROMvalue;
-
-
-
- EEPROMvalue= EEPROM.read(3);
- gpxjiludianshu=EEPROMvalue*25;
-
- EEPROMvalue++;
- EEPROM.write(3, EEPROMvalue);
-
-
- pinMode(10, OUTPUT);
-
-
- if (!SD.begin(chipSelect)) {
- Serial.println("$MS,SD Card failed! ,*xx");
- return;
- }
- }
- void loop() {
- while (Serial.available() > 0) {
- gpstimes=millis();
- konghangpanduanB=0;
- if(ATget){
- AT[chuankouzhuanyong]=Serial.read();
- if(AT[chuankouzhuanyong-2]=='*'){
- ATlong=chuankouzhuanyong;
- ATget=0;
- chuankouzhuanyong=0;
- }else if(chuankouzhuanyong<18)chuankouzhuanyong++;
- }else if(MSget){
- MS[chuankouzhuanyong]=Serial.read();
- if(MS[chuankouzhuanyong-2]=='*'){
- MSlong=chuankouzhuanyong;
- MSget=0;
- chuankouzhuanyong=0;
- }else if(chuankouzhuanyong<88)chuankouzhuanyong++;
- }else{
- tempxB[chuankouzhuanyong]=Serial.read();
- if(chuankouzhuanyong<3)chuankouzhuanyong++;
- }
- if(chuankouzhuanyong==3){
-
- if(tempxB[1]=='A' && tempxB[2]=='T'){
- ATget=1;
- MSget=0;
- for(int col=0;col<20;col++)AT[col]=0;
- for(int col=0;col<3;col++)AT[col]=tempxB[col];
- for(int col=0;col<3;col++)tempxB[col]=0;
- }else if(tempxB[1]=='M' && tempxB[2]=='S'){
- MSget=1;
- ATget=0;
- for(int col=0;col<90;col++)MS[col]=0;
- for(int col=0;col<3;col++)MS[col]=tempxB[col];
- for(int col=0;col<3;col++)tempxB[col]=0;
- }else{
- for(int col=0;col<2;col++)tempxB[col]=tempxB[col+1];
- chuankouzhuanyong=2;
- }
-
- }
- }
- ruanchuankou();
- if(millis()-gpstimes>10 && !konghangpanduan){
- konghangpanduan=1;
- gpxjilujiangeB++;
- gpsdechuli();
- if(jiaoyanjieguoA)jiexiGPGGA();
- if(jiaoyanjieguoC)jiexiGPRMC();
-
- if(dingweiok) {
- gpschanger=0;
- if(gpxjilujiangeB>gpxjilujiangeA){
- gpxjilujiangeB=0;
- gpxjiludianshu++;
- if(gpxjiludianshu%25==0){
- EEPROMvalue= EEPROM.read(3);
- EEPROMvalue++;
- if(EEPROMvalue>108){
- EEPROMvalue=0;
- EEPROM.write(3, 0);
- gpxjiludianshu=0;
- EEPROM.write(8,0);
- EEPROM.write(9,0);
-
- }else {
- EEPROM.write(3, EEPROMvalue);
- }
- }
- sdcaozuo();
- }
- }
- if(dingweiok && !gpsshuchuqiehuanB){
- /*
- $MS,TrackAL,TrackAN,TrackB1,TrackB2,TrackB4,TrackB0,TrackB5,TrackB6,SDzhuangtai*XX
- $MS,000,00000,00.0000000,000.0000000,2000-00-00T00:00:00,-0000.0,0000.00,000.00,SDGood,*XX
- ----4---8----14----------25----------37------------------57-----后面就是动态的了
- 极限长度90,最小数组长度81
- */
- for(int col=0;col<95;col++)GPRMC[col]=0;
- GPRMC[0]='$';
- GPRMC[1]='M';
- GPRMC[2]='S';
- GPRMC[3]=44;
- memcpy(GPRMC+4,TrackAL,3);
- GPRMC[7]=44;
- memcpy(GPRMC+8,TrackAN,5);
- GPRMC[13]=44;
- memcpy(GPRMC+14,TrackB1,10);
- GPRMC[24]=44;
- memcpy(GPRMC+25,TrackB2,11);
- GPRMC[36]=44;
- memcpy(GPRMC+37,TrackB4,19);
- GPRMC[56]=44;
- memcpy(GPRMC+57,TrackB0,asllong);
- GPRMC[57+asllong]=44;
- memcpy(GPRMC+58+asllong,TrackB5,sudulong);
- GPRMC[58+asllong+sudulong]=44;
- memcpy(GPRMC+59+asllong+sudulong,TrackB6,yawlong);
- GPRMC[59+asllong+sudulong+yawlong]=44;
- memcpy(GPRMC+60+asllong+sudulong+yawlong,SDzhuangtai,6);
- GPRMC[66+asllong+sudulong+yawlong]=44;
- GPRMC[67+asllong+sudulong+yawlong]=42;
- for(int col=1;col<67+asllong+sudulong+yawlong;col++){
- if(col==1)yihuoyunsuan=GPRMC[col];
- else yihuoyunsuan=yihuoyunsuan ^ GPRMC[col];
- }
- if(yihuoyunsuan==0){
- jianyan="00";
- }else if(yihuoyunsuan>15){
- jianyan = String(yihuoyunsuan,HEX);
- }else{
- jianyan = "0";
- jianyan += String(yihuoyunsuan,HEX);
- }
- jianyan.toUpperCase();
- GPRMC[68+asllong+sudulong+yawlong]=jianyan[0];
- GPRMC[69+asllong+sudulong+yawlong]=jianyan[1];
- jianyan="";
- Serial.println(GPRMC);
- }
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int col=0;col<95;col++)GPGGA[col]=0;
- for(int col=0;col<12;col++)tempx[col]=0;
- jsq1=0;
- GPGGAget=0;
- GPRMCget=0;
- }
- if(millis()-gpstimes>10 && !konghangpanduanB){
- konghangpanduanB=1;
-
- for(int col=1;col<ATlong-2;col++){
- if(col==1)yihuoyunsuan=AT[col];
- else yihuoyunsuan=yihuoyunsuan ^ AT[col];
- }
- if(yihuoyunsuan==0){
- jianyan="00";
- }else if(yihuoyunsuan>15){
- jianyan = String(yihuoyunsuan,HEX);
- }else{
- jianyan = "0";
- jianyan += String(yihuoyunsuan,HEX);
- }
- jianyan.toUpperCase();
- if(jianyan[0]==AT[ATlong-1] && jianyan[1]==AT[ATlong] ){
-
- if(AT[4]=='A'){
-
-
- if(gpsshuchuqiehuanB){
- gpsshuchuqiehuanB=0;
- EEPROM.write(0,0);
- }
-
- }else if(AT[4]=='B'){
-
- if(!gpsshuchuqiehuanB){
- gpsshuchuqiehuanB=1;
- EEPROM.write(0,1);
- }
- }
- for(int col=0;col<20;col++)AT[col]=0;
- ATlong=0;
- }else {
- for(int col=0;col<20;col++)AT[col]=0;
- ATlong=0;
- chuankouzhuanyong=0;
- ATget=0;
- }
- jianyan="";
- for(int col=1;col<MSlong-2;col++){
- if(col==1)yihuoyunsuan=MS[col];
- else yihuoyunsuan=yihuoyunsuan ^ MS[col];
- }
- if(yihuoyunsuan==0){
- jianyan="00";
- }else if(yihuoyunsuan>15){
- jianyan = String(yihuoyunsuan,HEX);
- }else{
- jianyan = "0";
- jianyan += String(yihuoyunsuan,HEX);
- }
- jianyan.toUpperCase();
- if(jianyan[0]==MS[MSlong-1] && jianyan[1]==MS[MSlong] ){
- }else {
- for(int col=0;col<90;col++)MS[col]=0;
- MSlong=0;
- chuankouzhuanyong=0;
- MSget=0;
- }
- jianyan="";
- }
- }
- void ruanchuankou()
- {
- while (gps.available() > 0) {
- gpstimes=millis();
- konghangpanduan=0;
- if(GPRMCget){
- GPRMC[jsq1]=gps.read();
- if(gpsshuchuqiehuanB)Serial.print(GPRMC[jsq1]);
- if(GPRMC[jsq1-3]=='*'){
- GPRMClong=jsq1;
- GPRMCget=0;
- jsq1=0;
- }else if(jsq1<93)jsq1++;
- }else if(GPGGAget){
- GPGGA[jsq1]=gps.read();
- if(gpsshuchuqiehuanB)Serial.print(GPGGA[jsq1]);
- if(GPGGA[jsq1-3]=='*'){
- GPGGAlong=jsq1;
- GPGGAget=0;
- jsq1=0;
- }else if(jsq1<93)jsq1++;
- }else{
- tempx[jsq1]=gps.read();
- if(gpsshuchuqiehuanB)Serial.print(tempx[jsq1]);
- if(jsq1<6)jsq1++;
- }
- if(jsq1==6){
-
-
- if(tempx[4]=='M' && tempx[5]=='C'){
- GPRMCget=1;
- GPGGAget=0;
- for(int col=0;col<6;col++)GPRMC[col]=tempx[col];
- for(int col=0;col<6;col++)tempx[col]=0;
- }else if(tempx[jsq1-2]=='G' && tempx[jsq1-1]=='A'){
- GPGGAget=1;
- GPRMCget=0;
- for(int col=0;col<6;col++)GPGGA[col]=tempx[col];
- for(int col=0;col<6;col++)tempx[col]=0;
- }else{
- for(int col=0;col<5;col++)tempx[col]=tempx[col+1];
- jsq1=5;
- }
-
- }
- }
- }
-
- void gpsdechuli()
- {
- for(int col=1;col<GPRMClong-3;col++){
- if(col==1)yihuoyunsuan=GPRMC[col];
- else yihuoyunsuan=yihuoyunsuan ^ GPRMC[col];
- }
- if(yihuoyunsuan==0){
- jianyan="00";
- }else if(yihuoyunsuan>15){
- jianyan = String(yihuoyunsuan,HEX);
- }else{
- jianyan = "0";
- jianyan += String(yihuoyunsuan,HEX);
- }
- jianyan.toUpperCase();
- if(jianyan[0]==GPRMC[GPRMClong-2] && jianyan[1]==GPRMC[GPRMClong-1] ){
- jiaoyanjieguoC=1;
- }else{
- jiaoyanjieguoC=0;
- for(int col=0;col<95;col++)GPRMC[col]=0;
- GPRMClong=0;
- jsq1=0;
- GPRMCget=0;
- }
- jianyan="";
- for(int col=1;col<GPGGAlong-3;col++){
- if(col==1)yihuoyunsuan=GPGGA[col];
- else yihuoyunsuan=yihuoyunsuan ^ GPGGA[col];
- }
- if(yihuoyunsuan==0){
- jianyan="00";
- }else if(yihuoyunsuan>15){
- jianyan = String(yihuoyunsuan,HEX);
- }else{
- jianyan = "0";
- jianyan += String(yihuoyunsuan,HEX);
- }
- jianyan.toUpperCase();
- if(jianyan[0]==GPGGA[GPGGAlong-2] && jianyan[1]==GPGGA[GPGGAlong-1] ){
- jiaoyanjieguoA=1;
- }else{
- jiaoyanjieguoA=0;
- for(int col=0;col<90;col++)GPGGA[col]=0;
- GPGGAlong=0;
- jsq1=0;
- GPGGAget=0;
- }
- jianyan="";
- }
-
-
- void jiexiGPGGA()
- {
-
- jsq2=0;
- jsq3=0;
- jsq4=0;
- jsq5=0;
- for(int col=1;col<GPGGAlong-3;col++){
- if(GPGGA[col]==',')jsq2++;
- if(jsq2==10){
- jsq3=col;
- col=GPGGAlong-3;
- }
-
-
- if(jsq2<9)jsq4=col;
-
- if(jsq2<7)jsq5=col;
-
- }
-
-
- if(GPGGA[jsq5]==49)dingweiok=1;
- else dingweiok=0;
-
-
- for(int col=0;col<8;col++)TrackB0[col]=0;
- memcpy(TrackB0,GPGGA+jsq4+2, jsq3-jsq4-2);
- asllong=jsq3-jsq4-2;
-
- }
-
-
- void jiexiGPRMC()
- {
-
- jsq2=0;
- jsq3=0;
- jsq4=0;
- jsq5=0;
- jsq6=0;
- jsq7=0;
-
- for(int col=1;col<GPRMClong-3;col++){
- if(GPRMC[col]==',')jsq2++;
- if(jsq2==9){
- jsq3=col;
- col=GPRMClong-3;
- }
-
- if(jsq2<8)jsq4=col;
- if(jsq2<6)jsq5=col;
- if(jsq2<4)jsq6=col;
- if(jsq2<2)jsq7=col;
- }
-
-
- if(GPRMC[jsq7+2]=='A')UTCtime();
-
-
- if(dingweiok){
- jingweiduchuli();
- hangxiangyusudu();
-
- }else {
- weiduA=0;
- weiduB=0;
- weiduC=0;
- jingduA=0;
- jingduB=0;
- jingduC=0;
- }
-
-
- }
-
-
- void UTCtime()
- {
-
- TrackB4[11]=GPRMC[7];
- TrackB4[12]=GPRMC[8];
-
-
- TrackB4[14]=GPRMC[9];
- TrackB4[15]=GPRMC[10];
-
- TrackB4[17]=GPRMC[11];
- TrackB4[18]=GPRMC[12];
- TrackB4[8]=GPRMC[jsq3+1];
- TrackB4[9]=GPRMC[jsq3+2];
- TrackB4[5]=GPRMC[jsq3+3];
- TrackB4[6]=GPRMC[jsq3+4];
-
- TrackB4[2]=GPRMC[jsq3+5];
- TrackB4[3]=GPRMC[jsq3+6];
-
- }
-
- void jingweiduchuli()
- {
-
-
- for(int col=0;col<12;col++)tempx[col]=0;
- memcpy(tempx,GPRMC+jsq7+4, 2);
- jianyan =tempx;
- gpschangertest=jianyan.toInt();
- if(weiduA!=gpschangertest){
- weiduA=gpschangertest;
- gpschanger=1;
- }
-
-
- if(GPRMC[jsq6+2]==83)weiduxuweitiao=1;
- if(GPRMC[jsq5+2]==87)jingduxuweitiao=1;
-
-
- memcpy(TrackB1,GPRMC+jsq7+4, 2);
-
- if(gpschangertest<10) {
- TrackB1[0]=32;
- weiduzhanwei=1;
- }else weiduzhanwei=2;
-
-
- for(int col=0;col<12;col++)tempx[col]=0;
-
- memcpy(tempx,GPRMC+jsq7+6, 2);
- jianyan =tempx;
- gpschangertest=jianyan.toInt();
- if(weiduB!=gpschangertest){
- weiduB=gpschangertest;
- gpschanger=1;
- }
-
-
-
- for(int col=0;col<12;col++)tempx[col]=0;
-
- memcpy(tempx,GPRMC+jsq7+9, 4);
- if(jsq6-jsq7==12) memcpy(tempx,GPRMC+jsq7+9, 4);
- else if(jsq6-jsq7==13)memcpy(tempx,GPRMC+jsq7+9, 5);
-
-
- jianyan =tempx;
- gpschangertest=jianyan.toInt();
- if(weiduC!=gpschangertest){
- weiduC=gpschangertest;
- gpschanger=1;
- }
-
- fentodu=weiduB*100000+weiduC*10;
- fentodu=fentodu/6;
-
- for(int col=0;col<12;col++)tempx[col]=0;
- dtostrf(fentodu,6,0,tempx);
-
-
- if(fentodu>99999){
- memcpy(TrackB1+3,tempx, 6);
- }else if(fentodu>9999){
- TrackB1[3]=48;
- memcpy(TrackB1+4,tempx, 5);
- }else if(fentodu>999){
- TrackB1[3]=48;
- TrackB1[4]=48;
- memcpy(TrackB1+5,tempx, 4);
-
- }else if(fentodu>99){
- TrackB1[3]=48;
- TrackB1[4]=48;
- TrackB1[5]=48;
- memcpy(TrackB1+6,tempx, 3);
-
- }else if(fentodu>9){
- TrackB1[3]=48;
- TrackB1[4]=48;
- TrackB1[5]=48;
- TrackB1[6]=48;
- memcpy(TrackB1+7,tempx, 2);
- }else{
- TrackB1[3]=48;
- TrackB1[4]=48;
- TrackB1[5]=48;
- TrackB1[6]=48;
- TrackB1[7]=48;
- memcpy(TrackB1+8,tempx, 1);
-
- }
-
-
-
-
- if(weiduxuweitiao){
- weiduxuweitiao=0;
-
- if(weiduzhanwei==2){
-
-
- for(int col=0;col<12;col++)tempx[col]=0;
- tempx[0]=45;
- memcpy(tempx+1,TrackB1, 9);
- memcpy(TrackB1,tempx, 10);
-
- }else{
-
- TrackB1[0]=45;
-
- }
-
- }
-
-
-
-
- for(int col=0;col<12;col++)tempx[col]=0;
-
- memcpy(tempx,GPRMC+jsq6+4, 3);
- jianyan =tempx;
- gpschangertest=jianyan.toInt();
- if(jingduA!=gpschangertest){
- jingduA=gpschangertest;
- gpschanger=1;
- }
-
-
-
-
- memcpy(TrackB2,GPRMC+jsq6+4, 3);
- jingduzhanwei=3;
-
- if(gpschangertest<100) {
- TrackB2[0]=32;
- jingduzhanwei=2;
- }
-
- if(gpschangertest<10) {
- TrackB2[1]=32;
- jingduzhanwei=1;
- }
-
- for(int col=0;col<12;col++)tempx[col]=0;
-
- memcpy(tempx,GPRMC+jsq6+7, 3);
- jianyan =tempx;
- gpschangertest=jianyan.toInt();
- if(jingduB!=gpschangertest){
- jingduB=gpschangertest;
- gpschanger=1;
- }
-
- for(int col=0;col<12;col++)tempx[col]=0;
-
- if(jsq5-jsq6==13)memcpy(tempx,GPRMC+jsq6+10, 4);
- else if(jsq5-jsq6==14)memcpy(tempx,GPRMC+jsq6+10, 5);
-
- jianyan =tempx;
- gpschangertest=jianyan.toInt();
- if(jingduC!=gpschangertest){
- jingduC=gpschangertest;
- gpschanger=1;
- }
-
- jianyan="";
-
- fentodu=jingduB*100000+jingduC*10;
- fentodu=fentodu/6;
-
- for(int col=0;col<12;col++)tempx[col]=0;
- dtostrf(fentodu,6,0,tempx);
-
-
-
- if(fentodu>99999){
- memcpy(TrackB2+4,tempx, 6);
- }else if(fentodu>9999){
- TrackB2[4]=48;
- memcpy(TrackB2+5,tempx, 5);
- }else if(fentodu>999){
- TrackB2[4]=48;
- TrackB2[5]=48;
- memcpy(TrackB2+6,tempx, 4);
-
- }else if(fentodu>99){
- TrackB2[4]=48;
- TrackB2[5]=48;
- TrackB2[6]=48;
- memcpy(TrackB2+7,tempx, 3);
-
- }else if(fentodu>9){
- TrackB2[4]=48;
- TrackB2[5]=48;
- TrackB2[6]=48;
- TrackB2[7]=48;
- memcpy(TrackB2+8,tempx, 2);
- }else{
- TrackB2[4]=48;
- TrackB2[5]=48;
- TrackB2[6]=48;
- TrackB2[7]=48;
- TrackB2[8]=48;
- memcpy(TrackB2+9,tempx, 1);
-
- }
-
-
-
-
- if(jingduxuweitiao){
- jingduxuweitiao=0;
-
- if(jingduzhanwei==3){
-
-
- for(int col=0;col<12;col++)tempx[col]=0;
- tempx[0]=45;
- memcpy(tempx+1,TrackB2, 10);
- memcpy(TrackB2,tempx, 11);
-
- }else if(jingduzhanwei==2){
-
- TrackB2[0]=45;
-
- }else{
- TrackB2[1]=45;
- }
-
- }
-
-
- }
-
-
- void hangxiangyusudu()
- {
-
- for(int col=0;col<12;col++)tempx[col]=0;
- memcpy(tempx,GPRMC+jsq5+4,jsq4-jsq5-3);
- for(int col=0;col<jsq4-jsq5-3;col++){
- if(tempx[col]==46){
- if(col==1)fentodu=(tempx[0]-48)*1000;
- else if(col==2)fentodu=(tempx[0]-48)*10000+(tempx[1]-48)*1000;
- else if(col==3)fentodu=(tempx[0]-48)*100000+(tempx[1]-48)*10000+(tempx[2]-48)*1000;
- if(jsq4-jsq5-col==5)fentodu=fentodu+(tempx[col+1]-48)*100;
- else if(jsq4-jsq5-col==6)fentodu=fentodu+(tempx[col+1]-48)*100+(tempx[col+2]-48)*10;
- else if(jsq4-jsq5-col==7)fentodu=fentodu+(tempx[col+1]-48)*100+(tempx[col+2]-48)*10+tempx[col+3]-48;
-
- fentodu=fentodu*1852*0.0001;
- col=jsq4-jsq5-3;
- }
- }
- sudu=fentodu*0.01;
- for(int col=0;col<8;col++)TrackB5[col]=0;
- dtostrf(sudu,1,2,TrackB5);
- if(sudu*0.001>1)sudulong=7;
- else if(sudu*0.01>1)sudulong=6;
- else if(sudu*0.1>1)sudulong=5;
- else sudulong=4;
-
- for(int col=0;col<7;col++)TrackB6[col]=0;
- memcpy(TrackB6,GPRMC+jsq4+2, jsq3-jsq4-2);
- yawlong=jsq3-jsq4-2;
-
-
- }
-
-
- void sdcaozuo()
- {
-
-
-
-
- for(int col=0;col<12;col++)tempx[col]=0;
-
- tempx[0]='L';
- tempx[1]='i';
- tempx[2]='n';
- tempx[3]='e';
- memcpy(tempx+4,TrackAL,3);
- tempx[7]='.';
- tempx[8]='g';
- tempx[9]='p';
- tempx[10]='x';
-
- File dataFile = SD.open(tempx, FILE_WRITE);
-
-
- if (dataFile) {
-
- for(int col=0;col<12;col++)tempx[col]=0;
- SDzhuangtai[0]='S';
- SDzhuangtai[1]='D';
- SDzhuangtai[2]='G';
- SDzhuangtai[3]='o';
- SDzhuangtai[4]='o';
- SDzhuangtai[5]='d';
-
-
-
- EEPROMvalue= EEPROM.read(4);
- if(EEPROMvalue==0) gpxstart=1;
- else gpxstart=0;
-
-
-
- EEPROMvalue= EEPROM.read(7);
- if(EEPROMvalue==0){
- gpxmiddleA=1;
-
-
- Trackname();
-
- }else gpxmiddleA=0;
-
- EEPROMvalue= EEPROM.read(8);
- if(EEPROMvalue==0) gpxendA=1;
- else gpxendA=0;
-
- EEPROMvalue= EEPROM.read(9);
- if(EEPROMvalue==0) gpxendB=1;
- else gpxendB=0;
-
-
- if(gpxstart){
- EEPROM.write(4, 1);
-
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int i=50;i<77;i++)GPRMC[i-50] = EEPROM.read(i);
-
- dataFile.print(GPRMC);
- }
-
-
- if(gpxmiddleA){
- EEPROM.write(7, 1);
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int i=77;i<89;i++)GPRMC[i-77] = EEPROM.read(i);
-
- dataFile.print(GPRMC);
- dataFile.print(TrackAN);
-
-
-
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int i=89;i<110;i++)GPRMC[i-89] = EEPROM.read(i);
-
- dataFile.println(GPRMC);
-
-
- }
-
-
- if(gpxmiddleB){
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int i=110;i<123;i++)GPRMC[i-110] = EEPROM.read(i);
- dataFile.print(GPRMC);
- dataFile.print(TrackB1);
-
-
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int i=123;i<131;i++)GPRMC[i-123] = EEPROM.read(i);
- dataFile.print(GPRMC);
-
- dataFile.print(TrackB2);
-
-
-
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int i=131;i<140;i++)GPRMC[i-131] = EEPROM.read(i);
- dataFile.print(GPRMC);
- dataFile.print(TrackB4);
-
-
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int i=140;i<158;i++)GPRMC[i-140] = EEPROM.read(i);
-
- if(MSlong>0){
-
- dataFile.print(GPRMC);
-
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- memcpy(GPRMC,MS+4,MSlong-6);
- dataFile.println(GPRMC);
-
-
- MSlong=0;
-
-
- }else dataFile.println(GPRMC);
-
-
-
- }
-
-
- if(gpxendA){
- EEPROM.write(8,1);
- EEPROM.write(7,0);
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int i=158;i<174;i++)GPRMC[i-158] = EEPROM.read(i);
- dataFile.print(GPRMC);
-
-
- EEPROMvalue= EEPROM.read(6);
- EEPROMvalue++;
- EEPROM.write(6,EEPROMvalue);
-
- }
-
-
- if(gpxendB){
- EEPROM.write(9,1);
-
- EEPROM.write(4,0);
-
-
- for(int col=0;col<95;col++)GPRMC[col]=0;
- for(int i=174;i<181;i++)GPRMC[i-174] = EEPROM.read(i);
- dataFile.print(GPRMC);
-
-
-
- EEPROMvalue= EEPROM.read(1);
- EEPROMvalue++;
- if(EEPROMvalue==255) EEPROMvalue=0;
- EEPROM.write(1, EEPROMvalue);
- Linename();
-
- }
-
-
- }else{
- for(int col=0;col<12;col++)tempx[col]=0;
- SDzhuangtai[0]='F';
- SDzhuangtai[1]='a';
- SDzhuangtai[2]='i';
- SDzhuangtai[3]='l';
- SDzhuangtai[4]='e';
- SDzhuangtai[5]='d';
-
-
- }
-
-
-
- dataFile.close();
-
-
-
- }
-
-
- void Linename()
- {
-
- for(int col=0;col<12;col++)tempx[col]=0;
-
- if(EEPROMvalue<10){
- tempx[0]=48;
- tempx[1]=48;
- tempx[2]=EEPROMvalue+48;
-
- }else if(EEPROMvalue<100){
- tempx[0]=48;
- Linenumber=EEPROMvalue*0.1;
- tempx[1]=Linenumber+48;
- Linenumber=EEPROMvalue%10;
- tempx[2]=Linenumber+48;
-
- }else{
-
- Linenumber=EEPROMvalue*0.01;
- tempx[0]=Linenumber+48;
- Linenumber=EEPROMvalue*0.1;
- Linenumber=Linenumber%10;
- tempx[1]=Linenumber+48;
- Linenumber=EEPROMvalue%10;
- tempx[2]=Linenumber+48;
-
- }
-
-
- for(int col=0;col<4;col++)TrackAL[col]=0;
- memcpy(TrackAL,tempx,3);
-
- }
-
-
-
- void Trackname()
- {
-
-
- EEPROMvalue= EEPROM.read(6);
- if(EEPROMvalue <250){
- gpxjiluguijishu=EEPROMvalue;
-
- EEPROMvalue= EEPROM.read(5);
- gpxjiluguijishu=EEPROMvalue*250+gpxjiluguijishu;
-
- }else{
- gpxjiluguijishu=0;
- EEPROM.write(6,gpxjiluguijishu);
-
- EEPROMvalue= EEPROM.read(5);
- if(EEPROMvalue<240){
- EEPROMvalue++;
- EEPROM.write(5,EEPROMvalue);
- gpxjiluguijishu=EEPROMvalue*250;
- }else{
- EEPROM.write(5,0);
- gpxjiluguijishu=0;
- }
-
- }
-
-
- for(int col=0;col<12;col++)tempx[col]=0;
-
- if(gpxjiluguijishu>9999)sprintf(tempx, "%d", gpxjiluguijishu);
- else if(gpxjiluguijishu>999){
- tempx[0]=48;
- sprintf(tempx+1, "%d", gpxjiluguijishu);
- }else if(gpxjiluguijishu>99){
- tempx[0]=48;
- tempx[1]=48;
- sprintf(tempx+2, "%d", gpxjiluguijishu);
- }else if(gpxjiluguijishu>9){
- tempx[0]=48;
- tempx[1]=48;
- tempx[2]=48;
- sprintf(tempx+3, "%d", gpxjiluguijishu);
- }else{
- tempx[0]=48;
- tempx[1]=48;
- tempx[2]=48;
- tempx[3]=48;
- sprintf(tempx+4, "%d", gpxjiluguijishu);
- }
-
- memcpy(TrackAN,tempx,5);
-
- }
-
-
-
-
复制代码 |
|