![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Hepta
Dependencies: Hepta2_9axis HeptaBattery HeptaTemp HeptaXbee SDHCFileSystem mbed
Fork of HEPTA2_ALL_ver0803_02 by
Diff: main.cpp
- Revision:
- 3:4854731e663d
- Parent:
- 2:726072016da1
- Child:
- 4:6565d9843337
--- a/main.cpp Fri Jul 21 10:38:11 2017 +0000 +++ b/main.cpp Mon Jul 24 05:54:59 2017 +0000 @@ -2,22 +2,22 @@ ************************************************************* H29/07_20/T.Umezawa 1:SD.....OK! -2:MPU9250(Accel) = -3:MPU9250(Gyro) = -4:MPU9250(Mag_compass) = -5:GPS sensing Mode = -6:CAM Mode = OK! -7:Temperature sensing = -8:Xbee mode = +2:MPU9250(Accel) = OK +3:MPU9250(Gyro) = OK +4:MPU9250(Mag_compass) = 微妙 +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" #include "HeptaSerial.h" #include "Hepta9axis.h" #include "HeptaTemp.h" +#include "HeptaBattery.h" #define USE_JPEG_HIGH_RESOLUTION 1 Serial pc(USBTX,USBRX); @@ -26,6 +26,7 @@ HeptaSerial camera(p13, p14); HeptaMPU9250 MPU9250(p28,p27,0xD0,0x18);//sda,scl,acc&gyro_address,mag_gyro HeptaTemp heptatemp(p17); +HeptaBattery bat(p16,p26); DigitalOut CAM_SW(p25);//CAM_control DigitalOut GPS_SW(p24);//GPS_control @@ -46,24 +47,28 @@ pc.printf("Hello world.\r\n"); pc.printf("My name is HEPTA2\r\n"); pc.printf("Please select mode.\r\n"); - pc.printf("1:SD test Mode\r\n"); - pc.printf("2:Gyro sening ModeE\r\n"); - pc.printf("3:Accel sensing Mode\r\n"); - pc.printf("4:Magnet sensig Mode\r\n"); - pc.printf("5:GPS sensing Mode\r\n"); - pc.printf("6:CAM mode\r\n"); - pc.printf("7:Temperature sensing Mode\r\n"); - pc.printf("8:Xbee Mode\r\n"); - pc.printf("9:Xbee & Temperature Mode\r\n");//恒温槽用 - pc.printf("10:All Transmitting Mode Mode\r\n"); + pc.printf("a:SD test Mode\r\n"); + pc.printf("b:Check Battery Level\r\n"); + pc.printf("c:Gyro Sening Mode\r\n"); + 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("*********************************\r\n"); mode = pc.getc(); pc.printf("\r\n"); pc.printf("Your select Mode = %c\r\n",mode); wait(0.5); + switch(mode) { - case'1': { + case'a': { printf("=============\r\n"); printf("SD test Mode\r\n"); @@ -82,12 +87,24 @@ }//case'1' /* + ************************ + Check Battery Level mode + ************************ + */ + case'b': { + float bt; + bat.vol(&bt); + pc.printf("V = %f\r\n",bt); + break; + } + + /* ****************** Gyro sensing mode ****************** */ - case'2': { + case'c': { printf("===================\r\n"); printf("Gyro sensing Mode\r\n"); printf("===================\r\n"); @@ -106,7 +123,7 @@ ****************** */ - case'3': { + case'd': { printf("===================\r\n"); printf("Accel sensing Mode\r\n"); printf("===================\r\n"); @@ -125,7 +142,7 @@ ****************** */ - case'4': { + case'e': { float mx,my,mz; printf("===================\r\n"); printf("Magnet sensing Mode\r\n"); @@ -140,11 +157,26 @@ /* ****************** + GPS sensing mode + ****************** + */ + + case'f': { + + printf("===================\r\n"); + printf("GPS sensing Mode\r\n"); + printf("===================\r\n"); + while(1) pc.putc(camera.getc()); + break; + }//case'4' + + /* + ****************** Cam Snapshot mode ****************** */ - case'6': { + case'g': { GPS_SW = 0; CAM_SW = 1; printf("\r\n"); @@ -164,7 +196,7 @@ ****************** */ - case'7': { + case'h': { printf("==================\r\n"); printf("Temp sensing Mode\r\n"); printf("==================\r\n"); @@ -183,7 +215,7 @@ *********** */ - case'8': { + case'i': { int i=0,rcmd=0,cmdflag=0; xbee.printf("Count Up!\r"); @@ -211,29 +243,21 @@ ****************** */ - case'9': { + case'j': { printf("==================\r\n"); printf("Temp sensing Mode & Xbee\r\n"); printf("==================\r\n"); float temp; - //FILE *fp = fopen("/fs/myfile.csv", "a"); -// if(fp == NULL) { -// pc.printf("Could not open file for write\r\n"); -// } else { - while(1) - { - //for(int i = 0; i<100; i++) { - FILE *fp = fopen("/fs/myfile.csv", "a"); - heptatemp.temp_sense(&temp); - pc.printf("%f\r\n",temp); - xbee.printf("%f\r\n",temp); - fprintf(fp, "%f\n",temp); - fclose(fp); - } -// fclose(fp); -// } + while(1) { + FILE *fp = fopen("/fs/myfile.csv", "a"); + heptatemp.temp_sense(&temp); + pc.printf("%f\r\n",temp); + xbee.printf("%f\r\n",temp); + fprintf(fp, "%f\n",temp); + fclose(fp); + } break; }//case'9' @@ -243,7 +267,7 @@ ********************* */ - case'a': { + case'k': { printf("==================\r\n"); printf("All Transmitting Mode\r\n"); @@ -252,15 +276,13 @@ 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]); - gps.sensing_u16(lad,log,&dsize[3]); - battery.vol_u16(bt,&dsize[4]); + camera.lat_log_sensing_u16(lad,log,&dsize[3]); + bat.vol_u16(bt,&dsize[4]); heptatemp.temp_sense_u16(temp,&dsize[5]); - */ - //gyro.x_u16(gx,4); 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; @@ -271,7 +293,7 @@ ****************** */ - case'b': { + case'l': { GPS_SW = 0; CAM_SW = 1; printf("\r\n"); @@ -285,6 +307,20 @@ 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;