v1
Dependencies: Nichrome_lib mbed mpu9250_i2c IM920 INA226_lib PQLPS22HB EEPROM_lib GPS_interrupt
Diff: main.cpp
- Revision:
- 1:3151936d9c55
- Parent:
- 0:4e38f8b1c183
- Child:
- 2:980edad0eea2
diff -r 4e38f8b1c183 -r 3151936d9c55 main.cpp --- a/main.cpp Thu Jul 29 16:38:36 2021 +0000 +++ b/main.cpp Thu Jul 29 18:37:34 2021 +0000 @@ -7,6 +7,7 @@ #include "Nichrome_lib.h" #include "EEPROM_lib.h" +#define FIRE_TIME 3.0 #define CURRENT_LOCATION_PRESS 1022.624268//投下前に設定 #define CURRENT_LOCATION_TEMP 10.650000//投下前に設定 #define ACC_RANGE _16G @@ -34,6 +35,8 @@ DigitalOut pinB(p22); DigitalOut pinC(p23); +Ticker send_data; +Timeout fire_time; // *************************************************** // 関数の宣言 // *************************************************** @@ -63,6 +66,8 @@ // *************************************************** // 変数の宣言 // *************************************************** +char nich_status; + bool header_set = false; char im_buf[55];//16なのって意味ある? int im_buf_n = 0; @@ -83,10 +88,9 @@ pc.printf("Hello Main!\r\n"); SetSensor(); im920.attach(&uplink, 0xF0); + send_data.attach(&GetData, 1.0); while(1){ - GetData(); - wait(0.5f); } } // *************************************************** @@ -124,7 +128,8 @@ // 分離実行 // *************************************************** void Separate(){ - nich.fire(3.0f); + nich.fire_on(); + fire_time.attach(&StopSeparate,FIRE_TIME); } void StopSeparate(){ @@ -204,8 +209,8 @@ //INA226 ina226_main.set_callibretion(); ina226_sep.set_callibretion(); - ina226_main.setup(1); - ina226_sep.setup(1); + //ina226_main.setup(1); + //ina226_sep.setup(1); if(ina226_main.Connection_check()==0){ pc.printf("INA226 Main : OK!\r\n"); @@ -256,11 +261,25 @@ header_set = true; } + pc.printf("********************\r\n\r\n"); + //Nichrome + if(nich.status){ + nich_status = '1'; + }else{ + nich_status = '0'; + } + pc.printf("Nichrome_status : %c\r\n",nich_status); + im920.write((char)nich_status); + im_buf_n ++; + //GPS lat = gps.Latitude(); lon = gps.Longitude(); height = gps.Height(); - pc.printf("%f\t%f\t%f\t\r\n", lat, lon, height); + pc.printf("Latitude : %f\r\n",lat); + pc.printf("Longitude : %f\r\n",lon); + pc.printf("Height : %f\r\n",height); + //pc.printf("%f\t%f\t%f\t\r\n", lat, lon, height); im920.write((float)lat); im_buf_n ++; im920.write((float)lon); @@ -272,7 +291,10 @@ lps22hb.read_press(&press); lps22hb.read_temp(&temp); altitude = (CURRENT_LOCATION_TEMP + 273.15)/0.0065*(1 - powf(press/CURRENT_LOCATION_PRESS, 287 * 0.0065/9.80665)); - pc.printf("%f\t%f\t%f\r\n",press, temp, altitude); + pc.printf("Pressure : %f\r\n",press); + pc.printf("Temperarure : %f\r\n",temp); + pc.printf("Altitude : %f\r\n",altitude); + //pc.printf("%f\t%f\t%f\r\n",press, temp, altitude); im920.write((float)press); im_buf_n ++; im920.write((float)temp); @@ -307,7 +329,15 @@ //INA226 ina226_main.get_Voltage_current(&voltage_main, ¤t_main); ina226_sep.get_Voltage_current(&voltage_sep, ¤t_sep); - pc.printf("MainVol : %.2f, SepVol : %.2f, MainCur : %.2f, SepCur : %.2f\r\n", voltage_main*(1/1000), voltage_sep, current_main, current_sep); + voltage_main /= 1000; + current_main /= 1000; + voltage_sep /= 1000; + current_sep /= 1000; + pc.printf("Vlotage Mian : %.2f\r\n",voltage_main); + pc.printf("Current Main : %.2f\r\n",current_main); + pc.printf("Voltage Sep : %.2f\r\n",voltage_sep); + pc.printf("Current Sep : %.2f\r\n",current_sep); + //pc.printf("MainVol : %.2f, SepVol : %.2f, MainCur : %.2f, SepCur : %.2f\r\n", voltage_main, voltage_sep, current_main, current_sep); //pc.printf("MainVol : %f, SepVol : %f, MainCur : %f, SepCur : %f\r\n", voltage_main*(1/1000), voltage_sep, current_main, current_sep); im920.write((float)voltage_main); im_buf_n ++; @@ -317,6 +347,9 @@ im_buf_n ++; im920.write((float)current_sep); im_buf_n ++; + + pc.printf("********************\r\n\r\n"); + if(header_set){ im920.send();