|
22 | 22 | #include "platform.h" |
23 | 23 |
|
24 | 24 | #include "blackbox/blackbox.h" |
| 25 | +#include "blackbox/blackbox_io.h" // CR148 |
25 | 26 |
|
26 | 27 | #include "build/debug.h" |
27 | 28 |
|
@@ -279,20 +280,16 @@ static void updateArmingStatus(void) |
279 | 280 | #endif |
280 | 281 |
|
281 | 282 | #ifdef USE_GEOZONE |
282 | | - if (feature(FEATURE_GEOZONE) && geozoneIsBlockingArming()) { |
283 | | - ENABLE_ARMING_FLAG(ARMING_DISABLED_GEOZONE); |
284 | | - } else { |
285 | | - DISABLE_ARMING_FLAG(ARMING_DISABLED_GEOZONE); |
286 | | - } |
| 283 | + if (feature(FEATURE_GEOZONE) && geozoneIsBlockingArming()) { |
| 284 | + ENABLE_ARMING_FLAG(ARMING_DISABLED_GEOZONE); |
| 285 | + } else { |
| 286 | + DISABLE_ARMING_FLAG(ARMING_DISABLED_GEOZONE); |
| 287 | + } |
287 | 288 | #endif |
288 | 289 |
|
289 | 290 | /* CHECK: */ |
290 | | - if ( |
291 | | - sensors(SENSOR_ACC) && |
292 | | - !STATE(ACCELEROMETER_CALIBRATED) && |
293 | | - // Require ACC calibration only if any of the setting might require it |
294 | | - isAccRequired() |
295 | | - ) { |
| 291 | + // Require ACC calibration only if any of the setting might require it |
| 292 | + if (sensors(SENSOR_ACC) && !STATE(ACCELEROMETER_CALIBRATED) && isAccRequired()) { |
296 | 293 | ENABLE_ARMING_FLAG(ARMING_DISABLED_ACCELEROMETER_NOT_CALIBRATED); |
297 | 294 | } |
298 | 295 | else { |
@@ -443,11 +440,11 @@ void disarm(disarmReason_t disarmReason) |
443 | 440 | DISABLE_ARMING_FLAG(ARMED); |
444 | 441 | DISABLE_STATE(IN_FLIGHT_EMERG_REARM); |
445 | 442 |
|
446 | | -#ifdef USE_BLACKBOX |
447 | | - if (feature(FEATURE_BLACKBOX)) { |
448 | | - blackboxFinish(); |
449 | | - } |
450 | | -#endif |
| 443 | +// #ifdef USE_BLACKBOX // CR148 |
| 444 | + // if (feature(FEATURE_BLACKBOX)) { |
| 445 | + // blackboxFinish(); |
| 446 | + // } |
| 447 | +// #endif |
451 | 448 | #ifdef USE_DSHOT |
452 | 449 | if (FLIGHT_MODE(TURTLE_MODE)) { |
453 | 450 | sendDShotCommand(DSHOT_CMD_SPIN_DIRECTION_NORMAL); |
@@ -589,15 +586,15 @@ void tryArm(void) |
589 | 586 |
|
590 | 587 | resetHeadingHoldTarget(DECIDEGREES_TO_DEGREES(attitude.values.yaw)); |
591 | 588 |
|
592 | | -#ifdef USE_BLACKBOX |
593 | | - if (feature(FEATURE_BLACKBOX)) { |
594 | | - serialPort_t *sharedBlackboxAndMspPort = findSharedSerialPort(FUNCTION_BLACKBOX, FUNCTION_MSP); |
595 | | - if (sharedBlackboxAndMspPort) { |
596 | | - mspSerialReleasePortIfAllocated(sharedBlackboxAndMspPort); |
597 | | - } |
598 | | - blackboxStart(); |
599 | | - } |
600 | | -#endif |
| 589 | +// #ifdef USE_BLACKBOX // CR148 |
| 590 | + // if (feature(FEATURE_BLACKBOX)) { |
| 591 | + // serialPort_t *sharedBlackboxAndMspPort = findSharedSerialPort(FUNCTION_BLACKBOX, FUNCTION_MSP); |
| 592 | + // if (sharedBlackboxAndMspPort) { |
| 593 | + // mspSerialReleasePortIfAllocated(sharedBlackboxAndMspPort); |
| 594 | + // } |
| 595 | + // blackboxStart(); |
| 596 | + // } |
| 597 | +// #endif |
601 | 598 |
|
602 | 599 | //beep to indicate arming |
603 | 600 | if (navigationPositionEstimateIsHealthy()) { |
@@ -879,10 +876,45 @@ static void applyThrottleTiltCompensation(void) |
879 | 876 | } |
880 | 877 | } |
881 | 878 | } |
| 879 | +// CR148 |
| 880 | +bool isMspConfigActive(bool isActive) |
| 881 | +{ |
| 882 | + static timeMs_t lastActive = 0; |
882 | 883 |
|
883 | | -void taskMainPidLoop(timeUs_t currentTimeUs) |
| 884 | + if (isActive) { |
| 885 | + lastActive = millis(); |
| 886 | + } |
| 887 | + |
| 888 | + return millis() - lastActive < 1000; |
| 889 | +} |
| 890 | +#ifdef USE_BLACKBOX |
| 891 | +static void processBlackbox(void) |
884 | 892 | { |
| 893 | + if (getBlackboxState() == BLACKBOX_STATE_DISABLED || isBlackboxDeviceFull()) { |
| 894 | + return; |
| 895 | + } |
885 | 896 |
|
| 897 | + if (getBlackboxState() == BLACKBOX_STATE_STOPPED) { |
| 898 | + if ((blackboxConfig()->arm_control == -1 && !areSensorsCalibrating() && !isMspConfigActive(NULL)) || ARMING_FLAG(ARMED)) { |
| 899 | + serialPort_t *sharedBlackboxAndMspPort = findSharedSerialPort(FUNCTION_BLACKBOX, FUNCTION_MSP); |
| 900 | + if (sharedBlackboxAndMspPort) { |
| 901 | + mspSerialReleasePortIfAllocated(sharedBlackboxAndMspPort); |
| 902 | + } |
| 903 | + blackboxStart(); |
| 904 | + } |
| 905 | + } else if (!ARMING_FLAG(ARMED)) { |
| 906 | + if ((blackboxConfig()->arm_control == -1 && isMspConfigActive(NULL)) || |
| 907 | + (blackboxConfig()->arm_control >= 0 && micros() - lastDisarmTimeUs > (timeUs_t)(USECS_PER_SEC * blackboxConfig()->arm_control))) { |
| 908 | + blackboxFinish(); |
| 909 | + } |
| 910 | + } |
| 911 | + |
| 912 | + blackboxUpdate(micros()); |
| 913 | +} |
| 914 | +#endif |
| 915 | +// CR148 |
| 916 | +void taskMainPidLoop(timeUs_t currentTimeUs) |
| 917 | +{ |
886 | 918 | cycleTime = getTaskDeltaTime(TASK_SELF); |
887 | 919 | dT = (float)cycleTime * 0.000001f; |
888 | 920 |
|
@@ -981,7 +1013,8 @@ void taskMainPidLoop(timeUs_t currentTimeUs) |
981 | 1013 |
|
982 | 1014 | #ifdef USE_BLACKBOX |
983 | 1015 | if (!cliMode && feature(FEATURE_BLACKBOX)) { |
984 | | - blackboxUpdate(micros()); |
| 1016 | + processBlackbox(); |
| 1017 | + // blackboxUpdate(micros()); // CR148 |
985 | 1018 | } |
986 | 1019 | #endif |
987 | 1020 |
|
|
0 commit comments