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