Group B Mission
Dependencies: mbed HeptaBattery SDFileSystem Hepta9axis HeptaTemp
Diff: main.cpp
- Revision:
- 22:228f5d9aed7b
- Parent:
- 21:9592659dd31f
- Child:
- 23:3dad6c03c214
--- a/main.cpp Sun Aug 25 00:10:19 2019 +0000 +++ b/main.cpp Sun Aug 25 03:19:04 2019 +0000 @@ -42,39 +42,40 @@ float mx,my,mz; int rcmd=0,cmdflag=0; int flag = 0; - + FILE *dummy = fopen("/sd/dummy.txt","w"); + fclose(dummy); while(1) { battery.power_saving_mode(&flag,&bt); temp.temp_sense(&temper); wait(0.5); + mkdir("/sd/mydir", 0777); + FILE *fp = fopen("/sd/mydir/data.txt","w"); + if(fp == NULL) { + error("Could not open file for write\r\n"); + } pc.printf("flag = %d, bt = %.2f [V], temp = %.1f [C]\r\n",flag,bt,temper); xbee.printf("flag = %d, bt = %.2f [V], temp = %.1f [C]\r\n",flag,bt,temper); + fprintf(fp,"flag = %d, bt = %.2f [V], temp = %.1f [C]\r\n",flag,bt,temper); xbee.xbee_receive(&rcmd,&cmdflag); + if(flag == 1) { pc.printf("Low Battery\r\n"); xbee.printf("Low Battery\r\n"); } else if(temper > 35.0) { - pc.printf("High Temperaturer\n"); - xbee.printf("High Temperaturer\n"); + pc.printf("High Temperature\n\r"); + xbee.printf("High Temperature\n\r"); } else if((flag == 1) & (temper > 35.0)) { - pc.printf("Low Battery and High Temperaturer\n"); - xbee.printf("Low Battery and High Temperaturer\n"); + pc.printf("Low Battery and High Temperature\n\r"); + xbee.printf("Low Battery and High Temperature\n\r"); } if (cmdflag == 1) { pc.printf("Command Get = %d\r\n",rcmd); xbee.printf("Command Get = %d\r\n",rcmd); switch (rcmd) { - case 't': + case 'a': pc.printf("Command Get %d\r\n",rcmd); xbee.printf("HEPTA Uplink OK\r\n"); break; - case 'a': - for(int i = 0; i < 10; i++) { - pc.printf("Count = %d\r\n",i); - xbee.printf("Count = %d\r\n",i); - wait(1.0); - } - break; case 'b': airqualitysensor.init(analogPin, AirQualityInterrupt); for(int i = 0; i < 10; i++){ @@ -104,8 +105,8 @@ float value; for(int i = 0; i < 10; i++){ value = sensorUV; - pc.printf("\rUV Value = %3.2f%%",value*100); - xbee.printf("\rUV Value = %3.2f%%",value*100); + pc.printf("\rUV Value = %3.2f%%\r\n",value*100); + xbee.printf("\rUV Value = %3.2f%%\r\n",value*100); wait(1.0); } break; @@ -115,7 +116,7 @@ pc.printf("Hit Any Key To Take Picture\r\n"); xbee.printf("Camera Snapshot Mode\r\n"); xbee.printf("Hit Any Key To Take Picture\r\n"); - while(!pc.readable()) {} + while(!xbee.readable()) {} cam_gps.Sync(); cam_gps.initialize(HeptaCamera_GPS::Baud115200, HeptaCamera_GPS::JpegResolution320x240); cam_gps.test_jpeg_snapshot_picture("/sd/test.jpg"); @@ -162,9 +163,8 @@ } break; default: - pc.printf("Unknown command."); - xbee.printf("Unknown command."); - continue; + pc.printf("Unknown command.\r\n"); + xbee.printf("Unknown command.\r\n"); } xbee.initialize();