Cmera and GPS labrary

Dependents:   HEPTA_SENSOR HEPTA_SENSOR

Revision:
9:591580af98be
Parent:
8:6d9c33df4c09
Child:
10:d4ecef9ef8fd
Child:
11:7230a20e8992
--- a/HeptaCamera_GPS.cpp	Wed Aug 23 06:18:42 2017 +0000
+++ b/HeptaCamera_GPS.cpp	Mon Sep 04 16:27:45 2017 +0000
@@ -612,7 +612,6 @@
     err = sync();
     int count=0;
     while(err) {
-        //printf("count = %d\r\n",count);
         switch(count) {
             case 0:
                 printf("Connection of camera and mbed at baudrate 14400\r\n");
@@ -632,13 +631,6 @@
         if(!err) {
             printf("synchro setting finish\r\n");
         }
-        /*  if(!err) {
-              printf("to 115200\r\n");
-              init(HeptaCamera_GPS::Baud115200, HeptaCamera_GPS::JpegResolution320x240);
-              printf("init err2=%d\r\n", err);
-              setmbedBaud(HeptaCamera_GPS::Baud115200);
-              printf("init err3=%d\r\n", err);
-          }*/
     }
 }
 
@@ -647,7 +639,7 @@
     HeptaCamera_GPS::ErrorNumber err = HeptaCamera_GPS::NoError;
     for (int i = 0; i < CAPTURE_FRAMES; i++) {
         char fname[64];
-        snprintf(fname, sizeof(fname), "/fs/test.jpg");
+        snprintf(fname, sizeof(fname), "/sd/test.jpg");
         fp_jpeg = fopen(fname, "w");
 
         err = getJpegSnapshotPicture();
@@ -666,7 +658,7 @@
     HeptaCamera_GPS::ErrorNumber err = HeptaCamera_GPS::NoError;
     for (int i = 0; i < CAPTURE_FRAMES; i++) {
         char fname[64];
-        snprintf(fname, sizeof(fname), "/fs/test.txt");
+        snprintf(fname, sizeof(fname), "/sd/test.txt");
         fp_jpeg = fopen(fname, "w");
 
         err = getJpegSnapshotPicture_data();
@@ -705,20 +697,16 @@
 
 char HeptaCamera_GPS::getc()
 {
-    //gps_setting();
-    //flushSerialBuffer();
     c = serial.getc();
     return c;
 }
 int HeptaCamera_GPS::readable()
 {
-    //gps_setting();
     i = serial.readable();
     return i;
 }
 void HeptaCamera_GPS::flushSerialBuffer(void)
 {
-    //gps_setting();
     ite = 0;
     while (serial.readable()) {
         serial.getc();
@@ -731,7 +719,6 @@
 }
 void HeptaCamera_GPS::gga_sensing(float *time, float *latitude, char *ns, float *longitude, char *ew, int *quality, int *stnum, float *hacu, float *altitude, char *aunit, int *serial_check)
 {
-    //flushSerialBuffer();
     int ite = 0;
     while(serial.getc()!='$') {
         ite++;
@@ -787,9 +774,6 @@
 
 void HeptaCamera_GPS::lat_log_sensing_u16(char *lat, char *log, char *height, int *dsize1, int *dsize2)
 {
-    //flushSerialBuffer();
-    //gps_setting();
-    //height_1 = 29.4;
     char gph1[8]= {0x00},gph2[8]= {0x00},gph3[8]= {0x00},gph4[8]= {0x00},gpt1[8]= {0x00},gpt2[8]= {0x00},gpt3[8]= {0x00},gpt4[8]= {0x00};
     char hei1[8]= {0x00},hei2[8]= {0x00};
     int i=0,j=0;
@@ -851,7 +835,7 @@
         sprintf( gpt4, "%02X", (char(((m_tokei-char(m_tokei))*100-char((m_tokei-char(m_tokei))*100))*100)) & 0xFF);
 
         m_height = int(_altitude);
-        cm_height = int((height_1-m_height)*100 );
+        cm_height = int((_altitude-m_height)*100 );
         // printf("%f\r\n",_altitude);
         sprintf( hei1, "%02X", (char(m_height)) & 0xFF);
         sprintf( hei2, "%02X", (char(cm_height)) & 0xFF);
@@ -880,203 +864,3 @@
     *dsize1 = 8;
     *dsize2 = 4;
 }
-/*
-void HeptaCamera_GPS::lat_log_sensing_u16(char *lat, char *log, char *height, int *dsize1, int *dsize2)
-{
-    flushSerialBuffer();
-    //gps_setting();
-    //height_1 = 29.4;
-    char gph1[8]= {0x00},gph2[8]= {0x00},gph3[8]= {0x00},gph4[8]= {0x00},gpt1[8]= {0x00},gpt2[8]= {0x00},gpt3[8]= {0x00},gpt4[8]= {0x00};
-    char hei1[8]= {0x00},hei2[8]= {0x00};
-    int i=0,j=0;
-    while (serial.readable()) {
-        serial.getc();
-    }
-loop:
-    while(serial.getc()!='$') {}
-    for(j=0; j<5; j++) {
-        gps_data[1][j]=serial.getc();
-    }
-    if((gps_data[1][2]==0x52)&(gps_data[1][3]==0x4d)&(gps_data[1][4]==0x43)) {
-        for(j=0; j<1; j++) {
-            if(j==0) {
-                i=0;
-                while((gps_data[j+1][i+5] = serial.getc()) != '\r') {
-                    //pc.putc(gps_data[j+1][i+5]);
-                    i++;
-                }
-                gps_data[j+1][i+5]='\0';
-                i=0;
-                //pc.printf("\n\r");
-            } else {
-                while(serial.getc()!='$') {}
-                i=0;
-                while((gps_data[j+1][i] = serial.getc()) != '\r') {
-                    //pc.putc(gps_data[j+1][i]);
-                    i++;
-                }
-                gps_data[j+1][i]='\0';
-                i=0;
-                //pc.printf("\n\r");
-            }
-        }
-    } else {
-        goto loop;
-    }
-    if( sscanf(gps_data[1],"GPRMC,%f,%c,%f,%c,%f,%c,%f",&time,&statas,&hokui,&ns,&tokei,&ew,&vel) >= 1) {
-        //hokui
-        d_hokui=int(hokui/100);
-        m_hokui=(hokui-d_hokui*100);
-        //m_hokui=(hokui-d_hokui*100)/60;
-        g_hokui=d_hokui+(hokui-d_hokui*100)/60;
-        sprintf( gph1, "%02X", (char(d_hokui)) & 0xFF);
-        sprintf( gph2, "%02X", (char(m_hokui)) & 0xFF);
-        sprintf( gph3, "%02X", (char((m_hokui-char(m_hokui))*100)) & 0xFF);
-        sprintf( gph4, "%02X", (char(((m_hokui-char(m_hokui))*100-char((m_hokui-char(m_hokui))*100))*100)) & 0xFF);
-
-        //tokei
-        d_tokei=int(tokei/100);
-        m_tokei=(tokei-d_tokei*100);
-        //m_tokei=(tokei-d_tokei*100)/60;
-        g_tokei=d_tokei+(tokei-d_tokei*100)/60;
-        sprintf( gpt1, "%02X", (char(d_tokei)) & 0xFF);
-        sprintf( gpt2, "%02X", (char(m_tokei)) & 0xFF);
-        sprintf( gpt3, "%02X", (char((m_tokei-char(m_tokei))*100)) & 0xFF);
-        sprintf( gpt4, "%02X", (char(((m_tokei-char(m_tokei))*100-char((m_tokei-char(m_tokei))*100))*100)) & 0xFF);
-
-        m_height = int(height_1);
-        cm_height = int((height_1-m_height)*100 );
-        //printf("%d\r\n",cm_height);
-        sprintf( hei1, "%02X", (char(m_height)) & 0xFF);
-        sprintf( hei2, "%02X", (char(cm_height)) & 0xFF);
-
-        lat[0] = gph1[0];
-        lat[1] = gph1[1];
-        lat[2] = gph2[0];
-        lat[3] = gph2[1];
-        lat[4] = gph3[0];
-        lat[5] = gph3[1];
-        lat[6] = gph4[0];
-        lat[7] = gph4[1];
-        log[0] = gpt1[0];
-        log[1] = gpt1[1];
-        log[2] = gpt2[0];
-        log[3] = gpt2[1];
-        log[4] = gpt3[0];
-        log[5] = gpt3[1];
-        log[6] = gpt4[0];
-        log[7] = gpt4[1];
-        height[0] = hei1[0];
-        height[1] = hei1[1];
-        height[2] = hei2[0];
-        height[3] = hei2[1];
-    }
-    *dsize1 = 8;
-    *dsize2 = 4;
-}*/
-/*
-void HeptaCamera_GPS::lat_log_sensing_u16(char *lat, char *log, char *height, int *serial_check ,int *dsize1, int *dsize2)
-{
-    int quality=0,stnum=0;
-    char ns='A',ew='B',aunit='m';
-    float time=0.0,latitude=0.0,longitude=0.0,hacu=0.0,altitude=0.0;
-
-    flushSerialBuffer();
-    char gph1[8]= {0x00},gph2[8]= {0x00},gph3[8]= {0x00},gph4[8]= {0x00},gpt1[8]= {0x00},gpt2[8]= {0x00},gpt3[8]= {0x00},gpt4[8]= {0x00};
-    char hei1[8]= {0x00},hei2[8]= {0x00};
-    int ite = 0;
-    while(serial.getc()!='$') {
-        ite++;
-        if(ite==10000) break;
-    }
-    for(int i=0; i<5; i++) {
-        msg[i] = serial.getc();
-    }
-    if((msg[2]=='G')&(msg[3]=='G')&(msg[4]=='A')) {
-        for(int j=0; j<6; j++) {
-            if(j==0) {
-                for(int i=5; i<256; i++) {
-                    msg[i] = serial.getc();
-                    if(msg[i] == '\r') {
-                        msg[i] = 0;
-                        break;
-                    }
-                }
-            } else {
-                for(int i=0; i<256; i++) {
-                    msgd[i] = serial.getc();
-                    if(msgd[i] == '\r') {
-                        break;
-                    }
-                }
-                if((msgd[4]=='V')&(msgd[5]=='T')&(msgd[6]=='G')) {
-                    break;
-                }
-            }
-        }
-        if(sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d,%d,%f,%f,%c", &time, &latitude, &ns, &longitude, &ew, &quality, &stnum, &hacu, &altitude, &aunit) >= 1) {
-            if(!(quality)) {
-
-                *serial_check = 0;
-            } else {
-
-                *serial_check = 1;
-            }
-        } else {
-            printf("No Data");
-            *serial_check = 2;
-        }
-    } else {
-        *serial_check = 3;
-    }
-    //hokui
-    d_hokui=int(latitude/100);
-    m_hokui=(latitude-d_hokui*100);
-    //m_hokui=(hokui-d_hokui*100)/60;
-    g_hokui=d_hokui+(latitude-d_hokui*100)/60;
-    printf("%f\r\n",latitude);
-    sprintf( gph1, "%02X", (char(d_hokui)) & 0xFF);
-    sprintf( gph2, "%02X", (char(m_hokui)) & 0xFF);
-    sprintf( gph3, "%02X", (char((m_hokui-char(m_hokui))*100)) & 0xFF);
-    sprintf( gph4, "%02X", (char(((m_hokui-char(m_hokui))*100-char((m_hokui-char(m_hokui))*100))*100)) & 0xFF);
-
-    //tokei
-    d_tokei=int(longitude/100);
-    m_tokei=(longitude-d_tokei*100);
-    //m_tokei=(tokei-d_tokei*100)/60;
-    g_tokei=d_tokei+(longitude-d_tokei*100)/60;
-    printf("%f\r\n",longitude);
-    sprintf( gpt1, "%02X", (char(d_tokei)) & 0xFF);
-    sprintf( gpt2, "%02X", (char(m_tokei)) & 0xFF);
-    sprintf( gpt3, "%02X", (char((m_tokei-char(m_tokei))*100)) & 0xFF);
-    sprintf( gpt4, "%02X", (char(((m_tokei-char(m_tokei))*100-char((m_tokei-char(m_tokei))*100))*100)) & 0xFF);
-
-    m_height = int(altitude);
-    cm_height = int((altitude-m_height)*100 );
-    printf("%f\r\n",altitude);
-    sprintf( hei1, "%02X", (char(m_height)) & 0xFF);
-    sprintf( hei2, "%02X", (char(cm_height)) & 0xFF);
-
-    lat[0] = gph1[0];
-    lat[1] = gph1[1];
-    lat[2] = gph2[0];
-    lat[3] = gph2[1];
-    lat[4] = gph3[0];
-    lat[5] = gph3[1];
-    lat[6] = gph4[0];
-    lat[7] = gph4[1];
-    log[0] = gpt1[0];
-    log[1] = gpt1[1];
-    log[2] = gpt2[0];
-    log[3] = gpt2[1];
-    log[4] = gpt3[0];
-    log[5] = gpt3[1];
-    log[6] = gpt4[0];
-    log[7] = gpt4[1];
-    height[0] = hei1[0];
-    height[1] = hei1[1];
-    height[2] = hei2[0];
-    height[3] = hei2[1];
-    *dsize1 = 8;
-    *dsize2 = 4;
-}*/
\ No newline at end of file