本文整理汇总了C++中ARMING_FLAG函数的典型用法代码示例。如果您正苦于以下问题:C++ ARMING_FLAG函数的具体用法?C++ ARMING_FLAG怎么用?C++ ARMING_FLAG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ARMING_FLAG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ltm_sframe
static void ltm_sframe(void)
{
uint8_t lt_flightmode;
uint8_t lt_statemode;
if (FLIGHT_MODE(PASSTHRU_MODE))
lt_flightmode = 0;
else if (FLIGHT_MODE(NAV_WP_MODE))
lt_flightmode = 10;
else if (FLIGHT_MODE(NAV_RTH_MODE))
lt_flightmode = 13;
else if (FLIGHT_MODE(NAV_POSHOLD_MODE))
lt_flightmode = 9;
else if (FLIGHT_MODE(HEADFREE_MODE) || FLIGHT_MODE(MAG_MODE))
lt_flightmode = 11;
else if (FLIGHT_MODE(NAV_ALTHOLD_MODE))
lt_flightmode = 8;
else if (FLIGHT_MODE(ANGLE_MODE))
lt_flightmode = 2;
else if (FLIGHT_MODE(HORIZON_MODE))
lt_flightmode = 3;
else
lt_flightmode = 1; // Rate mode
lt_statemode = (ARMING_FLAG(ARMED)) ? 1 : 0;
if (failsafeIsActive())
lt_statemode |= 2;
ltm_initialise_packet('S');
ltm_serialise_16(vbat * 100); //vbat converted to mv
ltm_serialise_16(0); // current, not implemented
ltm_serialise_8((uint8_t)((rssi * 254) / 1023)); // scaled RSSI (uchar)
ltm_serialise_8(0); // no airspeed
ltm_serialise_8((lt_flightmode << 2) | lt_statemode);
ltm_finalise();
}
示例2: applyLedThrustRingLayer
static void applyLedThrustRingLayer(bool updateNow, uint32_t *timer)
{
static uint8_t rotationPhase;
int ledRingIndex = 0;
if (updateNow) {
rotationPhase = rotationPhase > 0 ? rotationPhase - 1 : ledCounts.ringSeqLen - 1;
int scale = scaledThrottle; // ARMING_FLAG(ARMED) ? scaleRange(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, 10, 100) : 10;
*timer += LED_STRIP_HZ(5) * 10 / scale; // 5 - 50Hz update rate
}
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
const ledConfig_t *ledConfig = ¤tLedStripConfig->ledConfigs[ledIndex];
if (ledGetFunction(ledConfig) == LED_FUNCTION_THRUST_RING) {
bool applyColor;
if (ARMING_FLAG(ARMED)) {
applyColor = (ledRingIndex + rotationPhase) % ledCounts.ringSeqLen < ROTATION_SEQUENCE_LED_WIDTH;
} else {
applyColor = !(ledRingIndex % 2); // alternating pattern
}
if (applyColor) {
const hsvColor_t *ringColor = ¤tLedStripConfig->colors[ledGetColor(ledConfig)];
setLedHsv(ledIndex, ringColor);
}
ledRingIndex++;
}
}
}
示例3: taskUpdateBattery
void taskUpdateBattery(void)
{
static uint32_t vbatLastServiced = 0;
static uint32_t ibatLastServiced = 0;
if (feature(FEATURE_VBAT)) {
if (cmp32(currentTime, vbatLastServiced) >= VBATINTERVAL) {
vbatLastServiced = currentTime;
voltageMeterUpdate();
batteryUpdate();
}
}
if (feature(FEATURE_AMPERAGE_METER)) {
int32_t ibatTimeSinceLastServiced = cmp32(currentTime, ibatLastServiced);
if (ibatTimeSinceLastServiced >= IBATINTERVAL) {
ibatLastServiced = currentTime;
if (batteryConfig()->amperageMeterSource == AMPERAGE_METER_ADC) {
amperageUpdateMeter(ibatTimeSinceLastServiced);
} else {
throttleStatus_e throttleStatus = calculateThrottleStatus(rxConfig(), rcControlsConfig()->deadband3d_throttle);
bool throttleLowAndMotorStop = (throttleStatus == THROTTLE_LOW && feature(FEATURE_MOTOR_STOP));
int32_t throttleOffset = (int32_t)rcCommand[THROTTLE] - 1000;
amperageUpdateVirtualMeter(ibatTimeSinceLastServiced, ARMING_FLAG(ARMED), throttleLowAndMotorStop, throttleOffset);
}
}
}
}
示例4: disarm
void disarm(void)
{
if (ARMING_FLAG(ARMED)) {
DISABLE_ARMING_FLAG(ARMED);
lastDisarmTimeUs = micros();
#ifdef USE_BLACKBOX
if (blackboxConfig()->device && blackboxConfig()->mode != BLACKBOX_MODE_ALWAYS_ON) { // Close the log upon disarm except when logging mode is ALWAYS ON
blackboxFinish();
}
#endif
BEEP_OFF;
#ifdef USE_DSHOT
if (isMotorProtocolDshot() && flipOverAfterCrashMode && !feature(FEATURE_3D)) {
pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_SPIN_DIRECTION_NORMAL, false);
}
#endif
flipOverAfterCrashMode = false;
// if ARMING_DISABLED_RUNAWAY_TAKEOFF is set then we want to play it's beep pattern instead
if (!(getArmingDisableFlags() & ARMING_DISABLED_RUNAWAY_TAKEOFF)) {
beeper(BEEPER_DISARMING); // emit disarm tone
}
}
}
示例5: updateCurrentMeter
void updateCurrentMeter(int32_t lastUpdateAt, rxConfig_t *rxConfig, uint16_t deadband3d_throttle)
{
static int32_t amperageRaw = 0;
static int64_t mAhdrawnRaw = 0;
int32_t throttleOffset = (int32_t)rcCommand[THROTTLE] - 1000;
int32_t throttleFactor = 0;
switch(batteryConfig->currentMeterType) {
case CURRENT_SENSOR_ADC:
amperageRaw -= amperageRaw / 8;
amperageRaw += (amperageLatestADC = adcGetChannel(ADC_CURRENT));
amperage = currentSensorToCentiamps(amperageRaw / 8);
break;
case CURRENT_SENSOR_VIRTUAL:
amperage = (int32_t)batteryConfig->currentMeterOffset;
if (ARMING_FLAG(ARMED)) {
throttleStatus_e throttleStatus = calculateThrottleStatus(rxConfig, deadband3d_throttle);
if (throttleStatus == THROTTLE_LOW && feature(FEATURE_MOTOR_STOP))
throttleOffset = 0;
throttleFactor = throttleOffset + (throttleOffset * throttleOffset / 50);
amperage += throttleFactor * (int32_t)batteryConfig->currentMeterScale / 1000;
}
break;
case CURRENT_SENSOR_NONE:
amperage = 0;
break;
}
mAhdrawnRaw += (amperage * lastUpdateAt) / 1000;
mAhDrawn = mAhdrawnRaw / (3600 * 100);
}
示例6: ltm_sframe
static void ltm_sframe(void)
{
uint8_t lt_flightmode;
uint8_t lt_statemode;
if (FLIGHT_MODE(PASSTHRU_MODE))
lt_flightmode = 0;
else if (FLIGHT_MODE(GPS_HOME_MODE))
lt_flightmode = 13;
else if (FLIGHT_MODE(GPS_HOLD_MODE))
lt_flightmode = 9;
else if (FLIGHT_MODE(HEADFREE_MODE))
lt_flightmode = 4;
else if (FLIGHT_MODE(BARO_MODE))
lt_flightmode = 8;
else if (FLIGHT_MODE(ANGLE_MODE))
lt_flightmode = 2;
else if (FLIGHT_MODE(HORIZON_MODE))
lt_flightmode = 3;
else
lt_flightmode = 1; // Rate mode
lt_statemode = (ARMING_FLAG(ARMED)) ? 1 : 0;
if (failsafeIsActive())
lt_statemode |= 2;
ltm_initialise_packet('S');
ltm_serialise_16(getBatteryVoltage() * 100); //vbat converted to mv
ltm_serialise_16(0); // current, not implemented
ltm_serialise_8((uint8_t)((getRssi() * 254) / 1023)); // scaled RSSI (uchar)
ltm_serialise_8(0); // no airspeed
ltm_serialise_8((lt_flightmode << 2) | lt_statemode);
ltm_finalise();
}
示例7: applyLedThrustRingLayer
static void applyLedThrustRingLayer(bool updateNow, timeUs_t *timer)
{
static uint8_t rotationPhase;
int ledRingIndex = 0;
if (updateNow) {
rotationPhase = rotationPhase > 0 ? rotationPhase - 1 : ledCounts.ringSeqLen - 1;
*timer += HZ_TO_US(5 + (45 * scaledThrottle) / 100); // 5 - 50Hz update rate
}
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
if (ledGetFunction(ledConfig) == LED_FUNCTION_THRUST_RING) {
bool applyColor;
if (ARMING_FLAG(ARMED)) {
applyColor = (ledRingIndex + rotationPhase) % ledCounts.ringSeqLen < ROTATION_SEQUENCE_LED_WIDTH;
} else {
applyColor = !(ledRingIndex % 2); // alternating pattern
}
if (applyColor) {
const hsvColor_t *ringColor = &ledStripConfig()->colors[ledGetColor(ledConfig)];
setLedHsv(ledIndex, ringColor);
}
ledRingIndex++;
}
}
}
示例8: applyLedAnimationLayer
static void applyLedAnimationLayer(bool updateNow, uint32_t *timer)
{
static uint8_t frameCounter = 0;
const int animationFrames = ledGridHeight;
if(updateNow) {
frameCounter = (frameCounter + 1 < animationFrames) ? frameCounter + 1 : 0;
*timer += LED_STRIP_HZ(20);
}
if (ARMING_FLAG(ARMED))
return;
int previousRow = frameCounter > 0 ? frameCounter - 1 : animationFrames - 1;
int currentRow = frameCounter;
int nextRow = (frameCounter + 1 < animationFrames) ? frameCounter + 1 : 0;
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
const ledConfig_t *ledConfig = &masterConfig.ledConfigs[ledIndex];
if (ledGetY(ledConfig) == previousRow) {
setLedHsv(ledIndex, getSC(LED_SCOLOR_ANIMATION));
scaleLedValue(ledIndex, 50);
} else if (ledGetY(ledConfig) == currentRow) {
setLedHsv(ledIndex, getSC(LED_SCOLOR_ANIMATION));
} else if (ledGetY(ledConfig) == nextRow) {
scaleLedValue(ledIndex, 50);
}
}
}
示例9: taskCameraControl
static void taskCameraControl(uint32_t currentTime)
{
if (ARMING_FLAG(ARMED)) {
return;
}
cameraControlProcess(currentTime);
}
示例10: mwArm
void mwArm(void)
{
if (ARMING_FLAG(OK_TO_ARM)) {
if (ARMING_FLAG(ARMED)) {
//led0_op(true);
return;
}
if (IS_RC_MODE_ACTIVE(BOXFAILSAFE)) {
return;
}
if (!ARMING_FLAG(PREVENT_ARMING)) {
ENABLE_ARMING_FLAG(ARMED);
headFreeModeHold = heading;
// led2_op(1);//drona led
// led1_op(1);//drona led
// led0_op(0);//drona led
#ifdef BLACKBOX
if (feature(FEATURE_BLACKBOX)) {
serialPort_t *sharedBlackboxAndMspPort = findSharedSerialPort(FUNCTION_BLACKBOX, FUNCTION_MSP);
if (sharedBlackboxAndMspPort) {
mspReleasePortIfAllocated(sharedBlackboxAndMspPort);
}
startBlackbox();
}
#endif
disarmAt = millis() + masterConfig.auto_disarm_delay * 1000; // start disarm timeout, will be extended when throttle is nonzero
//beep to indicate arming
#ifdef GPS
if (feature(FEATURE_GPS) && STATE(GPS_FIX) && GPS_numSat >= 5)
beeper(BEEPER_ARMING_GPS_FIX);
else
beeper(BEEPER_ARMING);
#else
beeper(BEEPER_ARMING);
#endif
return;
}
}
if (!ARMING_FLAG(ARMED)) {
beeperConfirmationBeeps(1);
}
}
示例11: mwArm
void mwArm(void)
{
if (ARMING_FLAG(OK_TO_ARM)) {
if (ARMING_FLAG(ARMED)) {
return;
}
if (!ARMING_FLAG(PREVENT_ARMING)) {
ENABLE_ARMING_FLAG(ARMED);
headFreeModeHold = heading;
return;
}
}
if (!ARMING_FLAG(ARMED)) {
blinkLedAndSoundBeeper(2, 255, 1);
}
}
示例12: applyLedWarningLayer
static void applyLedWarningLayer(bool updateNow, uint32_t *timer)
{
static uint8_t warningFlashCounter = 0;
static uint8_t warningFlags = 0; // non-zero during blinks
if (updateNow) {
// keep counter running, so it stays in sync with blink
warningFlashCounter++;
warningFlashCounter &= 0xF;
if (warningFlashCounter == 0) { // update when old flags was processed
warningFlags = 0;
if (feature(FEATURE_VBAT) && getBatteryState() != BATTERY_OK)
warningFlags |= 1 << WARNING_LOW_BATTERY;
if (feature(FEATURE_FAILSAFE) && failsafeIsActive())
warningFlags |= 1 << WARNING_FAILSAFE;
if (!ARMING_FLAG(ARMED) && !ARMING_FLAG(OK_TO_ARM))
warningFlags |= 1 << WARNING_ARMING_DISABLED;
}
*timer += LED_STRIP_HZ(10);
}
if (warningFlags) {
const hsvColor_t *warningColor = NULL;
bool colorOn = (warningFlashCounter % 2) == 0; // w_w_
warningFlags_e warningId = warningFlashCounter / 4;
if (warningFlags & (1 << warningId)) {
switch (warningId) {
case WARNING_ARMING_DISABLED:
warningColor = colorOn ? &HSV(GREEN) : &HSV(BLACK);
break;
case WARNING_LOW_BATTERY:
warningColor = colorOn ? &HSV(RED) : &HSV(BLACK);
break;
case WARNING_FAILSAFE:
warningColor = colorOn ? &HSV(YELLOW) : &HSV(BLUE);
break;
default:;
}
}
if (warningColor)
applyLedHsv(LED_MOV_OVERLAY(LED_FLAG_OVERLAY(LED_OVERLAY_WARNING)), warningColor);
}
}
示例13: mwArm
void mwArm(void)
{
if (ARMING_FLAG(OK_TO_ARM)) {
if (ARMING_FLAG(ARMED)) {
return;
}
if (IS_RC_MODE_ACTIVE(BOXFAILSAFE)) {
return;
}
if (!ARMING_FLAG(PREVENT_ARMING)) {
ENABLE_ARMING_FLAG(ARMED);
ENABLE_ARMING_FLAG(WAS_EVER_ARMED);
headFreeModeHold = DECIDEGREES_TO_DEGREES(attitude.values.yaw);
resetMagHoldHeading(DECIDEGREES_TO_DEGREES(attitude.values.yaw));
#ifdef BLACKBOX
if (feature(FEATURE_BLACKBOX)) {
serialPort_t *sharedBlackboxAndMspPort = findSharedSerialPort(FUNCTION_BLACKBOX, FUNCTION_MSP);
if (sharedBlackboxAndMspPort) {
mspSerialReleasePortIfAllocated(sharedBlackboxAndMspPort);
}
startBlackbox();
}
#endif
disarmAt = millis() + masterConfig.auto_disarm_delay * 1000; // start disarm timeout, will be extended when throttle is nonzero
//beep to indicate arming
#ifdef NAV
if (navigationPositionEstimateIsHealthy())
beeper(BEEPER_ARMING_GPS_FIX);
else
beeper(BEEPER_ARMING);
#else
beeper(BEEPER_ARMING);
#endif
return;
}
}
if (!ARMING_FLAG(ARMED)) {
beeperConfirmationBeeps(1);
}
}
示例14: taskVtxControl
// Everything that listens to VTX devices
void taskVtxControl(uint32_t currentTime)
{
if (ARMING_FLAG(ARMED))
return;
#ifdef VTX_COMMON
vtxCommonProcess(currentTime);
#endif
}
示例15: taskBatteryAlerts
static void taskBatteryAlerts(timeUs_t currentTimeUs)
{
if (!ARMING_FLAG(ARMED)) {
// the battery *might* fall out in flight, but if that happens the FC will likely be off too unless the user has battery backup.
batteryUpdatePresence();
}
batteryUpdateStates(currentTimeUs);
batteryUpdateAlarms();
}