![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
test
Dependencies: Hepta2_9axis HeptaBattery Hepta_Serial HeptaTemp HeptaXbee SDHCFileSystem mbed
Fork of HEPTA2_ALL by
main.cpp@5:aedf4491aa0f, 2017-08-05 (annotated)
- Committer:
- hepta2ume
- Date:
- Sat Aug 05 13:37:01 2017 +0000
- Revision:
- 5:aedf4491aa0f
- Parent:
- 4:6565d9843337
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sunifu | 0:0482779cd78e | 1 | #include "mbed.h" |
hepta2ume | 1:890188e041da | 2 | #include "SDHCFileSystem.h" |
hepta2ume | 2:726072016da1 | 3 | #include "HeptaXbee.h" |
hepta2ume | 1:890188e041da | 4 | #include "HeptaSerial.h" |
hepta2ume | 2:726072016da1 | 5 | #include "Hepta9axis.h" |
hepta2ume | 2:726072016da1 | 6 | #include "HeptaTemp.h" |
hepta2ume | 3:4854731e663d | 7 | #include "HeptaBattery.h" |
sunifu | 0:0482779cd78e | 8 | #define USE_JPEG_HIGH_RESOLUTION 1 |
sunifu | 0:0482779cd78e | 9 | |
hepta2ume | 2:726072016da1 | 10 | Serial pc(USBTX,USBRX); |
hepta2ume | 2:726072016da1 | 11 | SDFileSystem sd(p5, p6, p7, p8, "fs"); |
hepta2ume | 2:726072016da1 | 12 | HeptaXbee xbee(p9,p10); |
hepta2ume | 2:726072016da1 | 13 | HeptaSerial camera(p13, p14); |
hepta2ume | 2:726072016da1 | 14 | HeptaMPU9250 MPU9250(p28,p27,0xD0,0x18);//sda,scl,acc&gyro_address,mag_gyro |
hepta2ume | 2:726072016da1 | 15 | HeptaTemp heptatemp(p17); |
hepta2ume | 3:4854731e663d | 16 | HeptaBattery bat(p16,p26); |
hepta2ume | 2:726072016da1 | 17 | DigitalOut CAM_SW(p25);//CAM_control |
hepta2ume | 2:726072016da1 | 18 | DigitalOut GPS_SW(p24);//GPS_control |
hepta2ume | 2:726072016da1 | 19 | |
hepta2ume | 2:726072016da1 | 20 | int main() |
hepta2ume | 2:726072016da1 | 21 | { |
hepta2ume | 2:726072016da1 | 22 | char mode; |
hepta2ume | 4:6565d9843337 | 23 | //pc.baud(9600); |
hepta2ume | 2:726072016da1 | 24 | |
hepta2ume | 2:726072016da1 | 25 | while(1) { |
hepta2ume | 2:726072016da1 | 26 | |
hepta2ume | 2:726072016da1 | 27 | /* |
hepta2ume | 2:726072016da1 | 28 | ************ |
hepta2ume | 2:726072016da1 | 29 | Mode select |
hepta2ume | 2:726072016da1 | 30 | *********** |
hepta2ume | 2:726072016da1 | 31 | */ |
hepta2ume | 2:726072016da1 | 32 | pc.printf("\r\n"); |
hepta2ume | 2:726072016da1 | 33 | pc.printf("*********************************\r\n"); |
hepta2ume | 2:726072016da1 | 34 | pc.printf("Hello world.\r\n"); |
hepta2ume | 2:726072016da1 | 35 | pc.printf("My name is HEPTA2\r\n"); |
hepta2ume | 2:726072016da1 | 36 | pc.printf("Please select mode.\r\n"); |
hepta2ume | 3:4854731e663d | 37 | pc.printf("a:SD test Mode\r\n"); |
hepta2ume | 3:4854731e663d | 38 | pc.printf("b:Check Battery Level\r\n"); |
hepta2ume | 3:4854731e663d | 39 | pc.printf("c:Gyro Sening Mode\r\n"); |
hepta2ume | 3:4854731e663d | 40 | pc.printf("d:Accel Sensing Mode\r\n"); |
hepta2ume | 3:4854731e663d | 41 | pc.printf("e:Magnet Sensig Mode\r\n"); |
hepta2ume | 3:4854731e663d | 42 | pc.printf("f:GPS Test Sensing Mode\r\n"); |
hepta2ume | 4:6565d9843337 | 43 | pc.printf("g:GPS data_GPGGA Mode\r\n"); |
hepta2ume | 4:6565d9843337 | 44 | pc.printf("h:Camera Synchro Mode\r\n"); |
hepta2ume | 4:6565d9843337 | 45 | pc.printf("i:CAM SnapShot Mode\r\n"); |
hepta2ume | 4:6565d9843337 | 46 | pc.printf("j:Saving Camera Data Mode\r\n"); |
hepta2ume | 4:6565d9843337 | 47 | pc.printf("k:Camera Data Transmitting Mode\r\n"); |
hepta2ume | 4:6565d9843337 | 48 | pc.printf("l:Temperature Sensing Mode\r\n"); |
hepta2ume | 4:6565d9843337 | 49 | pc.printf("m:Xbee Mode\r\n"); |
hepta2ume | 4:6565d9843337 | 50 | pc.printf("n:Xbee & Temperature Mode\r\n");//恒温槽用 |
hepta2ume | 4:6565d9843337 | 51 | pc.printf("o:All Transmitting Mode\r\n"); |
hepta2ume | 2:726072016da1 | 52 | pc.printf("*********************************\r\n"); |
hepta2ume | 2:726072016da1 | 53 | |
hepta2ume | 5:aedf4491aa0f | 54 | mode = xbee.getc(); |
hepta2ume | 2:726072016da1 | 55 | pc.printf("\r\n"); |
hepta2ume | 2:726072016da1 | 56 | pc.printf("Your select Mode = %c\r\n",mode); |
hepta2ume | 2:726072016da1 | 57 | wait(0.5); |
hepta2ume | 3:4854731e663d | 58 | |
hepta2ume | 2:726072016da1 | 59 | switch(mode) { |
hepta2ume | 3:4854731e663d | 60 | case'a': { |
hepta2ume | 2:726072016da1 | 61 | |
hepta2ume | 2:726072016da1 | 62 | printf("=============\r\n"); |
hepta2ume | 2:726072016da1 | 63 | printf("SD test Mode\r\n"); |
hepta2ume | 2:726072016da1 | 64 | printf("=============\r\n"); |
hepta2ume | 2:726072016da1 | 65 | FILE *fp = fopen("/fs/myfile.txt", "w"); |
hepta2ume | 2:726072016da1 | 66 | if(fp == NULL) { |
hepta2ume | 2:726072016da1 | 67 | pc.printf("Could not open file for write\r\n"); |
hepta2ume | 2:726072016da1 | 68 | } else { |
hepta2ume | 2:726072016da1 | 69 | fprintf(fp, "\n\rHello World!\n\r"); |
hepta2ume | 2:726072016da1 | 70 | printf("SD Check Complete!!\r\n"); |
hepta2ume | 2:726072016da1 | 71 | fclose(fp); |
hepta2ume | 2:726072016da1 | 72 | } |
hepta2ume | 2:726072016da1 | 73 | |
hepta2ume | 2:726072016da1 | 74 | |
hepta2ume | 2:726072016da1 | 75 | break; |
hepta2ume | 2:726072016da1 | 76 | }//case'1' |
hepta2ume | 2:726072016da1 | 77 | |
hepta2ume | 2:726072016da1 | 78 | /* |
hepta2ume | 3:4854731e663d | 79 | ************************ |
hepta2ume | 3:4854731e663d | 80 | Check Battery Level mode |
hepta2ume | 3:4854731e663d | 81 | ************************ |
hepta2ume | 3:4854731e663d | 82 | */ |
hepta2ume | 3:4854731e663d | 83 | case'b': { |
hepta2ume | 3:4854731e663d | 84 | float bt; |
hepta2ume | 4:6565d9843337 | 85 | for(int i = 0;i<50;i++){ |
hepta2ume | 3:4854731e663d | 86 | bat.vol(&bt); |
hepta2ume | 3:4854731e663d | 87 | pc.printf("V = %f\r\n",bt); |
hepta2ume | 4:6565d9843337 | 88 | } |
hepta2ume | 3:4854731e663d | 89 | break; |
hepta2ume | 3:4854731e663d | 90 | } |
hepta2ume | 3:4854731e663d | 91 | |
hepta2ume | 3:4854731e663d | 92 | /* |
hepta2ume | 2:726072016da1 | 93 | ****************** |
hepta2ume | 2:726072016da1 | 94 | Gyro sensing mode |
hepta2ume | 2:726072016da1 | 95 | ****************** |
hepta2ume | 2:726072016da1 | 96 | */ |
sunifu | 0:0482779cd78e | 97 | |
hepta2ume | 3:4854731e663d | 98 | case'c': { |
hepta2ume | 2:726072016da1 | 99 | printf("===================\r\n"); |
hepta2ume | 2:726072016da1 | 100 | printf("Gyro sensing Mode\r\n"); |
hepta2ume | 2:726072016da1 | 101 | printf("===================\r\n"); |
hepta2ume | 2:726072016da1 | 102 | float gx,gy,gz; |
hepta2ume | 2:726072016da1 | 103 | for(int i = 0; i < 10; i++) { |
hepta2ume | 2:726072016da1 | 104 | MPU9250.sen_gyro(&gx,&gy,&gz); |
hepta2ume | 2:726072016da1 | 105 | pc.printf("GX = %f,GY = %f,GZ = %f\r\n",gx,gy,gz); |
hepta2ume | 2:726072016da1 | 106 | wait(0.5); |
hepta2ume | 2:726072016da1 | 107 | } |
hepta2ume | 2:726072016da1 | 108 | break; |
hepta2ume | 2:726072016da1 | 109 | }//case'2' |
hepta2ume | 2:726072016da1 | 110 | |
hepta2ume | 2:726072016da1 | 111 | /* |
hepta2ume | 2:726072016da1 | 112 | ****************** |
hepta2ume | 2:726072016da1 | 113 | Accel sensing mode |
hepta2ume | 2:726072016da1 | 114 | ****************** |
hepta2ume | 2:726072016da1 | 115 | */ |
hepta2ume | 2:726072016da1 | 116 | |
hepta2ume | 3:4854731e663d | 117 | case'd': { |
hepta2ume | 2:726072016da1 | 118 | printf("===================\r\n"); |
hepta2ume | 2:726072016da1 | 119 | printf("Accel sensing Mode\r\n"); |
hepta2ume | 2:726072016da1 | 120 | printf("===================\r\n"); |
hepta2ume | 2:726072016da1 | 121 | float ax,ay,az; |
hepta2ume | 2:726072016da1 | 122 | for(int i = 0; i < 10; i++) { |
hepta2ume | 2:726072016da1 | 123 | MPU9250.sen_acc(&ax,&ay,&az); |
hepta2ume | 2:726072016da1 | 124 | pc.printf("AX = %f,AY = %f,AZ = %f\r\n",ax,ay,az); |
hepta2ume | 2:726072016da1 | 125 | wait(0.5); |
hepta2ume | 2:726072016da1 | 126 | } |
hepta2ume | 2:726072016da1 | 127 | break; |
hepta2ume | 2:726072016da1 | 128 | }//case'3' |
hepta2ume | 2:726072016da1 | 129 | |
hepta2ume | 2:726072016da1 | 130 | /* |
hepta2ume | 2:726072016da1 | 131 | ****************** |
hepta2ume | 2:726072016da1 | 132 | Magnet sensing mode |
hepta2ume | 2:726072016da1 | 133 | ****************** |
hepta2ume | 2:726072016da1 | 134 | */ |
hepta2ume | 2:726072016da1 | 135 | |
hepta2ume | 3:4854731e663d | 136 | case'e': { |
hepta2ume | 2:726072016da1 | 137 | float mx,my,mz; |
hepta2ume | 2:726072016da1 | 138 | printf("===================\r\n"); |
hepta2ume | 2:726072016da1 | 139 | printf("Magnet sensing Mode\r\n"); |
hepta2ume | 2:726072016da1 | 140 | printf("===================\r\n"); |
hepta2ume | 2:726072016da1 | 141 | for(int i = 0; i < 10; i++) { |
hepta2ume | 2:726072016da1 | 142 | MPU9250.sen_mag(&mx,&my,&mz); |
hepta2ume | 2:726072016da1 | 143 | pc.printf("MX = %f,MY = %f,MZ = %f\r\n",mx,my,mz); |
hepta2ume | 2:726072016da1 | 144 | wait(0.5); |
hepta2ume | 2:726072016da1 | 145 | } |
hepta2ume | 2:726072016da1 | 146 | break; |
hepta2ume | 2:726072016da1 | 147 | }//case'4' |
hepta2ume | 2:726072016da1 | 148 | |
hepta2ume | 2:726072016da1 | 149 | /* |
hepta2ume | 2:726072016da1 | 150 | ****************** |
hepta2ume | 3:4854731e663d | 151 | GPS sensing mode |
hepta2ume | 3:4854731e663d | 152 | ****************** |
hepta2ume | 3:4854731e663d | 153 | */ |
hepta2ume | 3:4854731e663d | 154 | |
hepta2ume | 3:4854731e663d | 155 | case'f': { |
hepta2ume | 4:6565d9843337 | 156 | GPS_SW = 1; |
hepta2ume | 4:6565d9843337 | 157 | CAM_SW = 0; |
hepta2ume | 3:4854731e663d | 158 | printf("===================\r\n"); |
hepta2ume | 3:4854731e663d | 159 | printf("GPS sensing Mode\r\n"); |
hepta2ume | 3:4854731e663d | 160 | printf("===================\r\n"); |
hepta2ume | 3:4854731e663d | 161 | while(1) pc.putc(camera.getc()); |
hepta2ume | 3:4854731e663d | 162 | break; |
hepta2ume | 3:4854731e663d | 163 | }//case'4' |
hepta2ume | 3:4854731e663d | 164 | |
hepta2ume | 4:6565d9843337 | 165 | |
hepta2ume | 4:6565d9843337 | 166 | case'g': { |
hepta2ume | 4:6565d9843337 | 167 | GPS_SW = 1; |
hepta2ume | 4:6565d9843337 | 168 | CAM_SW = 0; |
hepta2ume | 4:6565d9843337 | 169 | pc.printf("GPS GPGGA Mode\r\n"); |
hepta2ume | 4:6565d9843337 | 170 | int quality=0,stnum=0,gps_check=0; |
hepta2ume | 4:6565d9843337 | 171 | char ns='A',ew='B',aunit='m'; |
hepta2ume | 4:6565d9843337 | 172 | float time=0.0,latitude=0.0,longitude=0.0,hacu=0.0,altitude=0.0; |
hepta2ume | 4:6565d9843337 | 173 | for(int i=1; i<10; i++) { |
hepta2ume | 4:6565d9843337 | 174 | camera.gga_sensing(&time, &latitude, &ns, &longitude, &ew, &quality, &stnum, &hacu, &altitude, &aunit, &gps_check); |
hepta2ume | 4:6565d9843337 | 175 | if((gps_check==0)|(gps_check==1)) { |
hepta2ume | 4:6565d9843337 | 176 | 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); |
hepta2ume | 4:6565d9843337 | 177 | } |
hepta2ume | 4:6565d9843337 | 178 | } |
hepta2ume | 4:6565d9843337 | 179 | break; |
hepta2ume | 4:6565d9843337 | 180 | } |
hepta2ume | 4:6565d9843337 | 181 | |
hepta2ume | 4:6565d9843337 | 182 | /* |
hepta2ume | 4:6565d9843337 | 183 | ****************** |
hepta2ume | 4:6565d9843337 | 184 | Camera Synchro mode |
hepta2ume | 4:6565d9843337 | 185 | ****************** |
hepta2ume | 4:6565d9843337 | 186 | */ |
hepta2ume | 4:6565d9843337 | 187 | |
hepta2ume | 4:6565d9843337 | 188 | case'h': { |
hepta2ume | 4:6565d9843337 | 189 | GPS_SW = 0; |
hepta2ume | 4:6565d9843337 | 190 | CAM_SW = 1; |
hepta2ume | 4:6565d9843337 | 191 | wait(0.5); |
hepta2ume | 4:6565d9843337 | 192 | printf("\r\n"); |
hepta2ume | 4:6565d9843337 | 193 | printf("==========\r\n"); |
hepta2ume | 4:6565d9843337 | 194 | printf("CameraC1098\r\n"); |
hepta2ume | 4:6565d9843337 | 195 | printf("==========\r\n"); |
hepta2ume | 4:6565d9843337 | 196 | camera.Sync(); |
hepta2ume | 4:6565d9843337 | 197 | break; |
hepta2ume | 4:6565d9843337 | 198 | }//case'6' |
hepta2ume | 4:6565d9843337 | 199 | |
hepta2ume | 3:4854731e663d | 200 | /* |
hepta2ume | 3:4854731e663d | 201 | ****************** |
hepta2ume | 2:726072016da1 | 202 | Cam Snapshot mode |
hepta2ume | 2:726072016da1 | 203 | ****************** |
hepta2ume | 2:726072016da1 | 204 | */ |
hepta2ume | 2:726072016da1 | 205 | |
hepta2ume | 4:6565d9843337 | 206 | case'i': { |
hepta2ume | 2:726072016da1 | 207 | GPS_SW = 0; |
hepta2ume | 2:726072016da1 | 208 | CAM_SW = 1; |
hepta2ume | 2:726072016da1 | 209 | printf("\r\n"); |
hepta2ume | 2:726072016da1 | 210 | printf("==========\r\n"); |
hepta2ume | 2:726072016da1 | 211 | printf("CameraC1098\r\n"); |
hepta2ume | 2:726072016da1 | 212 | printf("==========\r\n"); |
hepta2ume | 4:6565d9843337 | 213 | //camera.Sync(); |
hepta2ume | 5:aedf4491aa0f | 214 | //camera.initialize(HeptaSerial::Baud115200, HeptaSerial::JpegResolution320x240); |
hepta2ume | 2:726072016da1 | 215 | camera.test_jpeg_snapshot_picture(1); |
sunifu | 0:0482779cd78e | 216 | |
hepta2ume | 2:726072016da1 | 217 | break; |
hepta2ume | 2:726072016da1 | 218 | }//case'6' |
hepta2ume | 2:726072016da1 | 219 | |
hepta2ume | 2:726072016da1 | 220 | /* |
hepta2ume | 2:726072016da1 | 221 | ****************** |
hepta2ume | 4:6565d9843337 | 222 | Cam Snapshot mode |
hepta2ume | 4:6565d9843337 | 223 | ****************** |
hepta2ume | 4:6565d9843337 | 224 | */ |
hepta2ume | 4:6565d9843337 | 225 | |
hepta2ume | 4:6565d9843337 | 226 | case'j': { |
hepta2ume | 4:6565d9843337 | 227 | GPS_SW = 0; |
hepta2ume | 4:6565d9843337 | 228 | CAM_SW = 1; |
hepta2ume | 4:6565d9843337 | 229 | printf("\r\n"); |
hepta2ume | 4:6565d9843337 | 230 | printf("==========\r\n"); |
hepta2ume | 4:6565d9843337 | 231 | printf("CameraC1098\r\n"); |
hepta2ume | 4:6565d9843337 | 232 | printf("==========\r\n"); |
hepta2ume | 4:6565d9843337 | 233 | //camera.Sync(); |
hepta2ume | 5:aedf4491aa0f | 234 | //camera.initialize(HeptaSerial::Baud115200, HeptaSerial::JpegResolution320x240); |
hepta2ume | 4:6565d9843337 | 235 | camera.test_jpeg_snapshot_data(1); |
hepta2ume | 4:6565d9843337 | 236 | |
hepta2ume | 4:6565d9843337 | 237 | break; |
hepta2ume | 4:6565d9843337 | 238 | }//case'6' |
hepta2ume | 4:6565d9843337 | 239 | |
hepta2ume | 4:6565d9843337 | 240 | |
hepta2ume | 4:6565d9843337 | 241 | |
hepta2ume | 4:6565d9843337 | 242 | case'k': { |
hepta2ume | 4:6565d9843337 | 243 | GPS_SW = 0; |
hepta2ume | 4:6565d9843337 | 244 | CAM_SW = 1; |
hepta2ume | 4:6565d9843337 | 245 | printf("\r\n"); |
hepta2ume | 4:6565d9843337 | 246 | printf("==========\r\n"); |
hepta2ume | 4:6565d9843337 | 247 | printf("CameraC1098\r\n"); |
hepta2ume | 4:6565d9843337 | 248 | printf("==========\r\n"); |
hepta2ume | 4:6565d9843337 | 249 | //camera.Sync(); |
hepta2ume | 5:aedf4491aa0f | 250 | //camera.initialize(HeptaSerial::Baud115200, HeptaSerial::JpegResolution320x240); |
hepta2ume | 4:6565d9843337 | 251 | camera.test_jpeg_snapshot_picture(1); |
hepta2ume | 4:6565d9843337 | 252 | |
hepta2ume | 4:6565d9843337 | 253 | FILE *fp = fopen("/fs/test.txt", "r"); |
hepta2ume | 4:6565d9843337 | 254 | if(fp == NULL) { |
hepta2ume | 4:6565d9843337 | 255 | pc.printf("Could not open file for write\r\n"); |
hepta2ume | 4:6565d9843337 | 256 | } else { |
hepta2ume | 4:6565d9843337 | 257 | char str[1024]; |
hepta2ume | 4:6565d9843337 | 258 | while((fgets(str,256,fp))!=NULL) { |
hepta2ume | 4:6565d9843337 | 259 | pc.printf("%s",str); |
hepta2ume | 4:6565d9843337 | 260 | } |
hepta2ume | 4:6565d9843337 | 261 | fclose(fp); |
hepta2ume | 4:6565d9843337 | 262 | } |
hepta2ume | 4:6565d9843337 | 263 | |
hepta2ume | 4:6565d9843337 | 264 | break; |
hepta2ume | 4:6565d9843337 | 265 | } |
hepta2ume | 4:6565d9843337 | 266 | |
hepta2ume | 4:6565d9843337 | 267 | /* |
hepta2ume | 4:6565d9843337 | 268 | ****************** |
hepta2ume | 2:726072016da1 | 269 | Temp sensing mode |
hepta2ume | 2:726072016da1 | 270 | ****************** |
hepta2ume | 2:726072016da1 | 271 | */ |
hepta2ume | 2:726072016da1 | 272 | |
hepta2ume | 4:6565d9843337 | 273 | case'l': { |
hepta2ume | 2:726072016da1 | 274 | printf("==================\r\n"); |
hepta2ume | 2:726072016da1 | 275 | printf("Temp sensing Mode\r\n"); |
hepta2ume | 2:726072016da1 | 276 | printf("==================\r\n"); |
hepta2ume | 2:726072016da1 | 277 | float temp; |
hepta2ume | 2:726072016da1 | 278 | for(int i = 0; i<100; i++) { |
hepta2ume | 2:726072016da1 | 279 | heptatemp.temp_sense(&temp); |
hepta2ume | 2:726072016da1 | 280 | pc.printf("%f\r\n",temp); |
hepta2ume | 2:726072016da1 | 281 | //xbee.printf("%f\r\n",temp); |
hepta2ume | 2:726072016da1 | 282 | } |
hepta2ume | 2:726072016da1 | 283 | break; |
hepta2ume | 2:726072016da1 | 284 | }//case'7' |
hepta2ume | 2:726072016da1 | 285 | |
hepta2ume | 2:726072016da1 | 286 | /* |
hepta2ume | 2:726072016da1 | 287 | *********** |
hepta2ume | 2:726072016da1 | 288 | Xbee mode |
hepta2ume | 2:726072016da1 | 289 | *********** |
hepta2ume | 2:726072016da1 | 290 | */ |
hepta2ume | 2:726072016da1 | 291 | |
hepta2ume | 4:6565d9843337 | 292 | case'm': { |
hepta2ume | 2:726072016da1 | 293 | |
hepta2ume | 2:726072016da1 | 294 | int i=0,rcmd=0,cmdflag=0; |
hepta2ume | 2:726072016da1 | 295 | xbee.printf("Count Up!\r"); |
hepta2ume | 2:726072016da1 | 296 | while(1) { |
hepta2ume | 2:726072016da1 | 297 | xbee.printf("num = %d\r",i); |
hepta2ume | 2:726072016da1 | 298 | i++; |
hepta2ume | 2:726072016da1 | 299 | wait(1.0); |
hepta2ume | 2:726072016da1 | 300 | xbee.xbee_recieve(&rcmd,&cmdflag); |
hepta2ume | 2:726072016da1 | 301 | pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag); |
hepta2ume | 2:726072016da1 | 302 | if (cmdflag == 1) { |
hepta2ume | 2:726072016da1 | 303 | if (rcmd == 'a') { |
hepta2ume | 2:726072016da1 | 304 | pc.printf("Command Get %d\r\n",rcmd); |
hepta2ume | 2:726072016da1 | 305 | xbee.printf("HEPTA Uplink OK\r"); |
hepta2ume | 2:726072016da1 | 306 | } |
hepta2ume | 2:726072016da1 | 307 | xbee.initialize(); |
hepta2ume | 2:726072016da1 | 308 | } |
hepta2ume | 2:726072016da1 | 309 | } |
hepta2ume | 2:726072016da1 | 310 | |
hepta2ume | 2:726072016da1 | 311 | break; |
hepta2ume | 2:726072016da1 | 312 | }//case'8' |
hepta2ume | 2:726072016da1 | 313 | |
hepta2ume | 2:726072016da1 | 314 | /* |
hepta2ume | 2:726072016da1 | 315 | ****************** |
hepta2ume | 2:726072016da1 | 316 | Temp sensing mode by Xbbe |
hepta2ume | 2:726072016da1 | 317 | ****************** |
hepta2ume | 2:726072016da1 | 318 | */ |
hepta2ume | 2:726072016da1 | 319 | |
hepta2ume | 4:6565d9843337 | 320 | case'n': { |
hepta2ume | 2:726072016da1 | 321 | |
hepta2ume | 2:726072016da1 | 322 | printf("==================\r\n"); |
hepta2ume | 2:726072016da1 | 323 | printf("Temp sensing Mode & Xbee\r\n"); |
hepta2ume | 2:726072016da1 | 324 | printf("==================\r\n"); |
hepta2ume | 2:726072016da1 | 325 | |
hepta2ume | 2:726072016da1 | 326 | float temp; |
hepta2ume | 3:4854731e663d | 327 | while(1) { |
hepta2ume | 3:4854731e663d | 328 | FILE *fp = fopen("/fs/myfile.csv", "a"); |
hepta2ume | 3:4854731e663d | 329 | heptatemp.temp_sense(&temp); |
hepta2ume | 3:4854731e663d | 330 | pc.printf("%f\r\n",temp); |
hepta2ume | 3:4854731e663d | 331 | xbee.printf("%f\r\n",temp); |
hepta2ume | 3:4854731e663d | 332 | fprintf(fp, "%f\n",temp); |
hepta2ume | 3:4854731e663d | 333 | fclose(fp); |
hepta2ume | 3:4854731e663d | 334 | } |
hepta2ume | 2:726072016da1 | 335 | break; |
hepta2ume | 2:726072016da1 | 336 | }//case'9' |
hepta2ume | 2:726072016da1 | 337 | |
hepta2ume | 2:726072016da1 | 338 | /* |
hepta2ume | 2:726072016da1 | 339 | ********************* |
hepta2ume | 2:726072016da1 | 340 | All Transmitting Mode |
hepta2ume | 2:726072016da1 | 341 | ********************* |
hepta2ume | 2:726072016da1 | 342 | */ |
hepta2ume | 2:726072016da1 | 343 | |
hepta2ume | 4:6565d9843337 | 344 | case'o': { |
hepta2ume | 4:6565d9843337 | 345 | GPS_SW = 1; |
hepta2ume | 4:6565d9843337 | 346 | CAM_SW = 0; |
hepta2ume | 2:726072016da1 | 347 | |
hepta2ume | 2:726072016da1 | 348 | printf("==================\r\n"); |
hepta2ume | 2:726072016da1 | 349 | printf("All Transmitting Mode\r\n"); |
hepta2ume | 2:726072016da1 | 350 | printf("==================\r\n"); |
hepta2ume | 5:aedf4491aa0f | 351 | 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],temp[4]; |
hepta2ume | 5:aedf4491aa0f | 352 | char ddata[64]; |
hepta2ume | 5:aedf4491aa0f | 353 | int dsize[7]; |
hepta2ume | 2:726072016da1 | 354 | while(1) { |
hepta2ume | 4:6565d9843337 | 355 | |
hepta2ume | 4:6565d9843337 | 356 | MPU9250.sen_gyro_u16(gx,gy,gz,&dsize[0]); |
hepta2ume | 4:6565d9843337 | 357 | MPU9250.sen_acc_u16(ax,ay,az,&dsize[1]); |
hepta2ume | 4:6565d9843337 | 358 | MPU9250.sen_mag_u16(mx,my,mz,&dsize[2]); |
hepta2ume | 5:aedf4491aa0f | 359 | camera.lat_log_sensing_u16(lad,log,height,&dsize[3],&dsize[4]); |
hepta2ume | 5:aedf4491aa0f | 360 | bat.vol_u16(bt,&dsize[5]); |
hepta2ume | 5:aedf4491aa0f | 361 | heptatemp.temp_sense_u16(temp,&dsize[6]); |
hepta2ume | 5:aedf4491aa0f | 362 | xbee.xbee_transmit(ddata,64,gx,gy,gz,ax,ay,az,mx,my,mz,lad,log,height,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],dsize[6],14); |
hepta2ume | 2:726072016da1 | 363 | } |
hepta2ume | 2:726072016da1 | 364 | break; |
hepta2ume | 2:726072016da1 | 365 | }//case'9' |
hepta2ume | 3:4854731e663d | 366 | |
hepta2ume | 2:726072016da1 | 367 | default: |
hepta2ume | 2:726072016da1 | 368 | break; |
hepta2ume | 2:726072016da1 | 369 | |
hepta2ume | 2:726072016da1 | 370 | |
hepta2ume | 2:726072016da1 | 371 | } |
hepta2ume | 2:726072016da1 | 372 | } |
hepta2ume | 2:726072016da1 | 373 | } |