test

Dependencies:   Hepta2_9axis HeptaBattery Hepta_Serial HeptaTemp HeptaXbee SDHCFileSystem mbed

Fork of HEPTA2_ALL by Hepta 2

Revision:
4:6565d9843337
Parent:
3:4854731e663d
Child:
5:aedf4491aa0f
--- a/main.cpp	Mon Jul 24 05:54:59 2017 +0000
+++ b/main.cpp	Wed Jul 26 06:24:09 2017 +0000
@@ -5,12 +5,13 @@
 2:MPU9250(Accel) = OK
 3:MPU9250(Gyro) = OK
 4:MPU9250(Mag_compass) = 微妙
-5:GPS sensing Mode = (サンプリング時間の修正)
+5:GPS sensing Mode =
 6:CAM Mode = OK!(微妙だった)
 7:Temperature sensing = OK!
 8:Xbee mode = OK!
 *************************************************************
 */
+
 #include "mbed.h"
 #include "SDHCFileSystem.h"
 #include "HeptaXbee.h"
@@ -33,7 +34,7 @@
 int main()
 {
     char mode;
-    pc.baud(9600);
+    //pc.baud(9600);
 
     while(1) {
 
@@ -53,13 +54,15 @@
         pc.printf("d:Accel Sensing Mode\r\n");
         pc.printf("e:Magnet Sensig Mode\r\n");
         pc.printf("f:GPS Test Sensing Mode\r\n");
-        pc.printf("g:CAM Mode\r\n");
-        pc.printf("h:Temperature Sensing Mode\r\n");
-        pc.printf("i:Xbee Mode\r\n");
-        pc.printf("j:Xbee & Temperature Mode\r\n");//恒温槽用
-        pc.printf("k:All Transmitting Mode\r\n");
-        pc.printf("l:Test Mode\r\n");
-        pc.printf("m:Test Mode\r\n");
+        pc.printf("g:GPS data_GPGGA Mode\r\n");
+        pc.printf("h:Camera Synchro Mode\r\n");
+        pc.printf("i:CAM SnapShot Mode\r\n");
+        pc.printf("j:Saving Camera Data Mode\r\n");
+        pc.printf("k:Camera Data Transmitting Mode\r\n");
+        pc.printf("l:Temperature Sensing Mode\r\n");
+        pc.printf("m:Xbee Mode\r\n");
+        pc.printf("n:Xbee & Temperature Mode\r\n");//恒温槽用
+        pc.printf("o:All Transmitting Mode\r\n");
         pc.printf("*********************************\r\n");
 
         mode = pc.getc();
@@ -93,8 +96,10 @@
             */
             case'b': {
                 float bt;
+                for(int i = 0;i<50;i++){
                 bat.vol(&bt);
                 pc.printf("V = %f\r\n",bt);
+                }
                 break;
             }
 
@@ -162,7 +167,8 @@
             */
 
             case'f': {
-
+                GPS_SW = 1;
+                CAM_SW = 0;
                 printf("===================\r\n");
                 printf("GPS sensing Mode\r\n");
                 printf("===================\r\n");
@@ -170,20 +176,55 @@
                 break;
             }//case'4'
 
+
+            case'g': {
+                GPS_SW = 1;
+                CAM_SW = 0;
+                pc.printf("GPS GPGGA Mode\r\n");
+                int quality=0,stnum=0,gps_check=0;
+                char ns='A',ew='B',aunit='m';
+                float time=0.0,latitude=0.0,longitude=0.0,hacu=0.0,altitude=0.0;
+                for(int i=1; i<10; i++) {
+                    camera.gga_sensing(&time, &latitude, &ns, &longitude, &ew, &quality, &stnum, &hacu, &altitude, &aunit, &gps_check);
+                    if((gps_check==0)|(gps_check==1)) {
+                        pc.printf("GPGGA,%f,%f,%c,%f,%c,%d,%d,%f,%f,%c\r\n",time,latitude,ns,longitude,ew,quality,stnum,hacu,altitude,aunit);
+                    }
+                }
+                break;
+            }
+
+            /*
+            ******************
+            Camera Synchro  mode
+            ******************
+            */
+
+            case'h': {
+                GPS_SW = 0;
+                CAM_SW = 1;
+                wait(0.5);
+                printf("\r\n");
+                printf("==========\r\n");
+                printf("CameraC1098\r\n");
+                printf("==========\r\n");
+                camera.Sync();
+                break;
+            }//case'6'
+
             /*
             ******************
             Cam Snapshot mode
             ******************
             */
 
-            case'g': {
+            case'i': {
                 GPS_SW = 0;
                 CAM_SW = 1;
                 printf("\r\n");
                 printf("==========\r\n");
                 printf("CameraC1098\r\n");
                 printf("==========\r\n");
-                camera.Sync();
+                //camera.Sync();
                 camera.initialize(HeptaSerial::Baud115200, HeptaSerial::JpegResolution320x240);
                 camera.test_jpeg_snapshot_picture(1);
 
@@ -192,11 +233,58 @@
 
             /*
             ******************
+            Cam Snapshot mode
+            ******************
+            */
+
+            case'j': {
+                GPS_SW = 0;
+                CAM_SW = 1;
+                printf("\r\n");
+                printf("==========\r\n");
+                printf("CameraC1098\r\n");
+                printf("==========\r\n");
+                //camera.Sync();
+                camera.initialize(HeptaSerial::Baud115200, HeptaSerial::JpegResolution320x240);
+                camera.test_jpeg_snapshot_data(1);
+
+                break;
+            }//case'6'
+
+
+
+            case'k': {
+                GPS_SW = 0;
+                CAM_SW = 1;
+                printf("\r\n");
+                printf("==========\r\n");
+                printf("CameraC1098\r\n");
+                printf("==========\r\n");
+                //camera.Sync();
+                camera.initialize(HeptaSerial::Baud115200, HeptaSerial::JpegResolution320x240);
+                camera.test_jpeg_snapshot_picture(1);
+
+                FILE *fp = fopen("/fs/test.txt", "r");
+                if(fp == NULL) {
+                    pc.printf("Could not open file for write\r\n");
+                } else {
+                    char str[1024];
+                    while((fgets(str,256,fp))!=NULL) {
+                        pc.printf("%s",str);
+                    }
+                    fclose(fp);
+                }
+
+                break;
+            }
+
+            /*
+            ******************
             Temp sensing mode
             ******************
             */
 
-            case'h': {
+            case'l': {
                 printf("==================\r\n");
                 printf("Temp sensing Mode\r\n");
                 printf("==================\r\n");
@@ -215,7 +303,7 @@
             ***********
             */
 
-            case'i': {
+            case'm': {
 
                 int i=0,rcmd=0,cmdflag=0;
                 xbee.printf("Count Up!\r");
@@ -243,7 +331,7 @@
             ******************
             */
 
-            case'j': {
+            case'n': {
 
                 printf("==================\r\n");
                 printf("Temp sensing Mode & Xbee\r\n");
@@ -267,7 +355,9 @@
             *********************
             */
 
-            case'k': {
+            case'o': {
+                GPS_SW = 1;
+                CAM_SW = 0;
 
                 printf("==================\r\n");
                 printf("All Transmitting Mode\r\n");
@@ -276,50 +366,17 @@
                 char ddata[60];
                 int dsize[6];
                 while(1) {
-                    
-                     MPU9250.sen_gyro_u16(gx,gy,gz,&dsize[0]);
-                     MPU9250.sen_acc_u16(ax,ay,az,&dsize[1]);
-                     MPU9250.sen_mag_u16(mx,my,mz,&dsize[2]);
-                     camera.lat_log_sensing_u16(lad,log,&dsize[3]);
-                     bat.vol_u16(bt,&dsize[4]);
-                     heptatemp.temp_sense_u16(temp,&dsize[5]);
+
+                    MPU9250.sen_gyro_u16(gx,gy,gz,&dsize[0]);
+                    MPU9250.sen_acc_u16(ax,ay,az,&dsize[1]);
+                    MPU9250.sen_mag_u16(mx,my,mz,&dsize[2]);
+                    camera.lat_log_sensing_u16(lad,log,&dsize[3]);
+                    bat.vol_u16(bt,&dsize[4]);
+                    heptatemp.temp_sense_u16(temp,&dsize[5]);
                     xbee.xbee_transmit(ddata,60,gx,gy,gz,ax,ay,az,mx,my,mz,lad,log,bt,temp,dsize[0],dsize[0],dsize[0],dsize[1],dsize[1],dsize[1],dsize[2],dsize[2],dsize[2],dsize[3],dsize[3],dsize[4],dsize[5],13);
                 }
                 break;
             }//case'9'
-            /*
-                       ******************
-                       Cam Snapshot mode
-                       ******************
-                       */
-
-            case'l': {
-                GPS_SW = 0;
-                CAM_SW = 1;
-                printf("\r\n");
-                printf("==========\r\n");
-                printf("CameraC1098\r\n");
-                printf("==========\r\n");
-                camera.Sync();
-                camera.initialize(HeptaSerial::Baud115200, HeptaSerial::JpegResolution320x240);
-                camera.test_jpeg_snapshot_data(1);
-
-                break;
-            }//case'6'
-
-            case'm': {
-                pc.printf("L:GPS GPGGA Mode\r\n");
-                int quality=0,stnum=0,gps_check=0;
-                char ns='A',ew='B',aunit='m';
-                float time=0.0,latitude=0.0,longitude=0.0,hacu=0.0,altitude=0.0;
-                for(int i=1; i<10; i++) {
-                    camera.gga_sensing(&time, &latitude, &ns, &longitude, &ew, &quality, &stnum, &hacu, &altitude, &aunit, &gps_check);
-                    if((gps_check==0)|(gps_check==1)) {
-                        pc.printf("GPGGA,%f,%f,%c,%f,%c,%d,%d,%f,%f,%c\r\n",time,latitude,ns,longitude,ew,quality,stnum,hacu,altitude,aunit);
-                    }
-                }
-                break;
-            }
 
             default:
                 break;