a
Dependencies: HEPTA_CDH HEPTA_EPS HEPTA_SENSOR mbed
main.cpp
00001 #include "mbed.h" 00002 #include "HEPTA_CDH.h" 00003 #include "HEPTA_EPS.h" 00004 #include "HEPTA_SENSOR.h" 00005 #include "HEPTA_COM.h" 00006 HEPTA_CDH cdh(p5, p6, p7, p8, "sd"); 00007 HEPTA_EPS eps(p16,p26); 00008 HEPTA_SENSOR sensor(p17, 00009 p28,p27,0x19,0x69,0x13, 00010 p13, p14,p25,p24); 00011 HEPTA_COM com(p9,p10); 00012 DigitalOut condition(LED1); 00013 Serial sat(USBTX,USBRX,9600); 00014 Timer sattime; 00015 int rcmd = 0,cmdflag = 0; //command variable 00016 //getting command and flag 00017 void commandget() 00018 { 00019 rcmd = sat.getc(); 00020 cmdflag = 1; 00021 } 00022 //interrupting 00023 void receive(int rcmd, int cmdflag) 00024 { 00025 sat.attach(commandget,Serial::RxIrq); 00026 } 00027 00028 int main() { 00029 sat.printf("HEPTA-Sat Debug Program start\r\n"); 00030 while(1){ 00031 sat.printf("Please sellect a mode bellow\r\n"); 00032 sat.printf("========================================\r\n"); 00033 sat.printf("a: Check saving to SD card Mode\r\n"); 00034 sat.printf("b: Check the battery voltage Mode\r\n"); 00035 sat.printf("c: Check the temp sensor Mode\r\n"); 00036 sat.printf("d: Check the 9 axis Mode\r\n"); 00037 sat.printf("e: Check GPS rawdata Mode\r\n"); 00038 sat.printf("f: Chec Camera snapchat Mode\r\n"); 00039 sat.printf("g: \r\n"); 00040 sat.printf("========================================\r\n"); 00041 int rcmd=0,cmdflag=0; //command variable 00042 sattime.start(); 00043 eps.turn_on_regulator();//turn on 3.3V conveter 00044 //for(int i = 0; i < 100; i++) { 00045 rcmd = sat.getc(); 00046 cmdflag = 1; 00047 //receive(rcmd,cmdflag); 00048 00049 //satellite condition led 00050 condition = !condition; 00051 //Contents of command 00052 if (cmdflag == 1) { 00053 if (rcmd == 'a') { 00054 //SD mode 00055 char str[100]; 00056 mkdir("/sd/mydir", 0777); 00057 FILE *fp = fopen("/sd/mydir/test.txt","w"); 00058 if(fp == NULL) { 00059 error("Could not open file for write\r\n"); 00060 } 00061 for(int i=0; i<10; i++)fprintf(fp,"Hello my name is HEPTA!\r\n"); 00062 fclose(fp); 00063 fp = fopen("/sd/mydir/test.txt","r"); 00064 for(int j = 0; j < 10; j++) { 00065 fgets(str,100,fp); 00066 sat.puts(str); 00067 } 00068 fclose(fp); 00069 sat.printf("Goodbye!!\r\n"); 00070 }else if (rcmd == 'b') { 00071 float bt; 00072 for(int i = 0; i < 10; i++) { 00073 eps.vol(&bt); 00074 sat.printf("Vol = %f\r\n",bt); 00075 wait(0.5); 00076 } 00077 }else if (rcmd == 'c') { 00078 //Please insert your answer 00079 float temp; 00080 for (int i=0;i<10;i++) { 00081 sensor.temp_sense(&temp); 00082 sat.printf("temp = %f\r\n",temp); 00083 wait(0.5); 00084 } 00085 }else if (rcmd == 'd') { 00086 //Please insert your answer 00087 float ax,ay,az; 00088 float gx,gy,gz; 00089 float mx,my,mz; 00090 for(int i = 0; i<10; i++) { 00091 sensor.sen_acc(&ax,&ay,&az); 00092 sat.printf("acc : ax= %f, ay= %f, az= %f\r\n",ax,ay,az); 00093 sensor.sen_gyro(&gx,&gy,&gz); 00094 sat.printf("gyro: gx= %f, gy= %f, gz= %f\r\n",gx,gy,gz); 00095 sensor.sen_mag(&mx,&my,&mz); 00096 sat.printf("mag : mx= %f, my= %f, mz= %f\r\n",mx,my,mz); 00097 wait(0.5); 00098 } 00099 }else if (rcmd == 'e') { 00100 //Please insert your answer 00101 sensor.gps_setting(); 00102 sat.printf("GPS Raw Data Mode\r\n"); 00103 while(1) sat.putc(sensor.getc()); 00104 }else if (rcmd == 'f') { 00105 FILE *dummy = fopen("/sd/dummy.txt","w"); 00106 if(dummy == NULL) { 00107 error("Could not open file for write\r\n"); 00108 } 00109 fclose(dummy); 00110 00111 sat.printf("Camera Snapshot Mode\r\n"); 00112 sat.printf("Hit Any Key To Take Picture\r\n"); 00113 while(!sat.readable()) {} 00114 sensor.Sync(); 00115 sensor.initialize(HeptaCamera_GPS::Baud115200, HeptaCamera_GPS::JpegResolution320x240); 00116 sensor.test_jpeg_snapshot_picture("/sd/test.jpg"); 00117 }else if (rcmd == 'g'){ 00118 sat.printf("Xbee Count Up Mode\r\n"); 00119 for(int i = 0; i < 10; i++) { 00120 com.printf("num = %d\r\n",i); 00121 wait(0.5); 00122 } 00123 } 00124 rcmd=0,cmdflag=0; 00125 } 00126 //} 00127 } 00128 }
Generated on Mon Nov 14 2022 04:27:40 by
1.7.2