HEPTA-Sat Training 2017~2018 / Mbed 2 deprecated Lab9-01_All_transmit

Dependencies:   Hepta9axis HeptaBattery HeptaCamera_GPS HeptaTemp HeptaXbee SDFileSystem mbed

Fork of Lab7-01_template by HEPTA-Sat Training 2017~2018

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SDFileSystem.h"
00003 #include "HeptaXbee.h"
00004 #include "HeptaCamera_GPS.h"
00005 #include "Hepta9axis.h"
00006 #include "HeptaTemp.h"
00007 #include "HeptaBattery.h"
00008 
00009 Serial pc(USBTX,USBRX);
00010 SDFileSystem sd(p5, p6, p7, p8, "sd");
00011 HeptaXbee xbee(p9,p10);
00012 HeptaCamera_GPS cam_gps(p13, p14,p25,p24);
00013 Hepta9axis n_axis(p28,p27,0xD0,0x18);
00014 HeptaTemp temp(p17);
00015 HeptaBattery bat(p16,p26);
00016 
00017 int main()
00018 {
00019     int rcmd=0,cmdflag=0;
00020     while(1) {
00021         wait(1.0);
00022         xbee.xbee_recieve(&rcmd,&cmdflag);
00023         pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag);
00024         if (cmdflag == 1) {
00025             pc.printf("Command Get %d\r\n",rcmd);
00026             pc.printf("HEPTA Uplink OK\r\n");
00027             if(rcmd == 'h') {
00028                 cam_gps.gps_setting();
00029                 char gx[4],gy[4],gz[4],ax[4],ay[4],az[4],mx[4],my[4],mz[4],lad[8],log[8],height[4],bt[4],temper[4];
00030                 char ddata[64];
00031                 int dsize[7];
00032                 for(int i = 0;i < 50;i++) {
00033                     n_axis.sen_gyro_u16(gx,gy,gz,&dsize[0]);
00034                     n_axis.sen_acc_u16(ax,ay,az,&dsize[1]);
00035                     n_axis.sen_mag_u16(mx,my,mz,&dsize[2]);
00036                     bat.vol_u16(bt,&dsize[5]);
00037                     temp.temp_sense_u16(temper,&dsize[6]);
00038                     cam_gps.lat_log_sensing_u16(lad,log,height,&dsize[3],&dsize[4]);
00039                     xbee.putc('H');
00040                     xbee.xbee_transmit(ddata,64,gx,gy,gz,ax,ay,az,mx,my,mz,lad,log,height,bt,temper,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],dsize[6],14);
00041                 }
00042             }
00043             xbee.initialize();
00044         }
00045     }
00046 }