cansat program1
Dependencies: ADXL345 BME280 HMC5883L ITG3200 MBed_Adafruit-GPS-Library XBee agzIDLIST cansat mbed
Fork of Cansat_program4_1 by
Diff: main.cpp
- Revision:
- 21:18a196d3021c
- Parent:
- 20:f92bdcda5a60
- Child:
- 22:92408c551605
--- a/main.cpp Fri Aug 14 04:56:21 2015 +0000 +++ b/main.cpp Sat Aug 15 01:57:35 2015 +0000 @@ -68,6 +68,8 @@ int short_flag = 0; int running_flag = 0; +Timer pressure_Timer; +const int pressure_Time = 10000; Timer compass_Timer; const int compass_Time = 50; Timer running_Timer; @@ -93,7 +95,7 @@ const int ofsX = -102; //calibration x const int ofsY = -381; //calibration y - int16_t raw[3]; + int16_t raw[3]; ///////////////////////////////////////// // @@ -116,7 +118,7 @@ int mode = -1; //ロボットのモード double target_x = 139.987305,target_y = 40.142655; -double goal_Pressure = 1002.20, goal_Temperature,goal_Humidity; //地表地点の気圧、気温、湿度 +double goal_Pressure = 0.0, goal_Temperature,goal_Humidity; //地表地点の気圧、気温、湿度 Timer sep_Timer; const int sep_Time = 3000; //seperate time in ms @@ -318,6 +320,14 @@ void standby(){ cansat.control_Motor(1, cansat.get_speed()); + cansat.set_temperature(sensor.getTemperature()); + cansat.set_pressure(sensor.getPressure()); + cansat.set_humidity(sensor.getHumidity()); + + if(cansat.get_pressure() > goal_Pressure){ + goal_Pressure = cansat.get_pressure(); + } + if(!short_in){ xbee.printf("change mode: falling\n"); short_flag++; @@ -325,11 +335,13 @@ else{ if(running_Timer.read_ms() >= running_Time){ running_Timer.reset(); - xbee.printf("stand by\n"); + xbee.printf("stand by, %f, %f\n", goal_Pressure, cansat.get_pressure()); } } if(short_flag >= 5){ mode = 1; + goal_Pressure = goal_Pressure + 0.5; + pressure_Timer.start(); parachute_Timer.start(); } @@ -359,12 +371,20 @@ nic = 1; fall_flag = 1; sep_Timer.reset(); - mode = 2; - xbee.printf("my pressure is high!\n"); - xbee.printf("remove the parachute\n"); - xbee.printf("change mode: running\n"); + //mode = 2; + //xbee.printf("my pressure is high!\n"); + //xbee.printf("remove the parachute\n"); + //xbee.printf("change mode: running\n"); } } + + if(fall_flag == 1 && pressure_Timer.read_ms() >= pressure_Time){ + mode = 2; + xbee.printf("my pressure is high!\n"); + xbee.printf("remove the parachute\n"); + xbee.printf("change mode: running\n"); + } + if(fall_flag == 0 && parachute_Timer.read_ms() >= parachute_Time){ mode = 2; nic = 1;