Exemplo n.º 1
0
int CGitIndexList::ReadIndex(CString dgitdir)
{
	this->clear();

	m_critRepoSec.Lock();
	if (repository.Open(dgitdir))
	{
		m_critRepoSec.Unlock();
		return -1;
	}

	// add config files
	CAutoConfig config(true);

	CString projectConfig = dgitdir + _T("config");
	CString globalConfig = g_Git.GetGitGlobalConfig();
	CString globalXDGConfig = g_Git.GetGitGlobalXDGConfig();
	CString systemConfig(CRegString(REG_SYSTEM_GITCONFIGPATH, _T(""), FALSE));

	git_config_add_file_ondisk(config, CGit::GetGitPathStringA(projectConfig), GIT_CONFIG_LEVEL_LOCAL, FALSE);
	git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalConfig), GIT_CONFIG_LEVEL_GLOBAL, FALSE);
	git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalXDGConfig), GIT_CONFIG_LEVEL_XDG, FALSE);
	if (!systemConfig.IsEmpty())
		git_config_add_file_ondisk(config, CGit::GetGitPathStringA(systemConfig), GIT_CONFIG_LEVEL_SYSTEM, FALSE);

	git_repository_set_config(repository, config);

	CAutoIndex index;
	// load index in order to enumerate files
	if (git_repository_index(index.GetPointer(), repository))
	{
		repository.Free();
		m_critRepoSec.Unlock();
		return -1;
	}

	size_t ecount = git_index_entrycount(index);
	resize(ecount);
	for (size_t i = 0; i < ecount; ++i)
	{
		const git_index_entry *e = git_index_get_byindex(index, i);

		this->at(i).m_FileName.Empty();
		this->at(i).m_FileName = CUnicodeUtils::GetUnicode(e->path);
		this->at(i).m_FileName.MakeLower();
		this->at(i).m_ModifyTime = e->mtime.seconds;
		this->at(i).m_Flags = e->flags | e->flags_extended;
		this->at(i).m_IndexHash = e->id.id;
		this->at(i).m_Size = e->file_size;
	}

	g_Git.GetFileModifyTime(dgitdir + _T("index"), &this->m_LastModifyTime);
	std::sort(this->begin(), this->end(), SortIndex);

	m_critRepoSec.Unlock();

	return 0;
}
Exemplo n.º 2
0
displayPort_t *max7456DisplayPortInit(const vcdProfile_t *vcdProfile)
{
    displayInit(&max7456DisplayPort, &max7456VTable);
#ifdef USE_OSD_SLAVE
    max7456Init(max7456Config(), vcdProfile, false);
#else
    max7456Init(max7456Config(), vcdProfile, systemConfig()->cpu_overclock);
#endif
    resync(&max7456DisplayPort);
    return &max7456DisplayPort;
}
Exemplo n.º 3
0
ConfigurationProvider::shared_pointer ConfigurationFactory::getProvider()
{
	Lock guard(conf_factory_mutex);
	if(configurationProvider.get() == NULL)
	{
		configurationProvider.reset(new ConfigurationProviderImpl());
		// default
		Configuration::shared_pointer systemConfig(new SystemConfigurationImpl());
		configurationProvider->registerConfiguration("system", systemConfig);
	}
	return configurationProvider;
}
Exemplo n.º 4
0
int CGitIndexList::ReadIndex(CString dgitdir)
{
	this->clear();

	CAutoLocker lock(m_critRepoSec);
	if (repository.Open(dgitdir))
		return -1;

	// add config files
	CAutoConfig config(true);

	CString projectConfig = dgitdir + _T("config");
	CString globalConfig = g_Git.GetGitGlobalConfig();
	CString globalXDGConfig = g_Git.GetGitGlobalXDGConfig();
	CString systemConfig(CRegString(REG_SYSTEM_GITCONFIGPATH, _T(""), FALSE));
	CString programDataConfig(GetProgramDataGitConfig());

	git_config_add_file_ondisk(config, CGit::GetGitPathStringA(projectConfig), GIT_CONFIG_LEVEL_LOCAL, FALSE);
	git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalConfig), GIT_CONFIG_LEVEL_GLOBAL, FALSE);
	git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalXDGConfig), GIT_CONFIG_LEVEL_XDG, FALSE);
	if (!systemConfig.IsEmpty())
		git_config_add_file_ondisk(config, CGit::GetGitPathStringA(systemConfig), GIT_CONFIG_LEVEL_SYSTEM, FALSE);
	if (!programDataConfig.IsEmpty())
		git_config_add_file_ondisk(config, CGit::GetGitPathStringA(programDataConfig), GIT_CONFIG_LEVEL_PROGRAMDATA, FALSE);

	git_repository_set_config(repository, config);

	CAutoIndex index;
	// load index in order to enumerate files
	if (git_repository_index(index.GetPointer(), repository))
	{
		repository.Free();
		return -1;
	}

	m_bHasConflicts = FALSE;

	size_t ecount = git_index_entrycount(index);
	try
	{
		resize(ecount);
	}
	catch (const std::bad_alloc& ex)
	{
		repository.Free();
		CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Could not resize index-vector: %s\n", ex.what());
		return -1;
	}
	for (size_t i = 0; i < ecount; ++i)
	{
		const git_index_entry *e = git_index_get_byindex(index, i);

		this->at(i).m_FileName = CUnicodeUtils::GetUnicode(e->path);
		this->at(i).m_FileName.MakeLower();
		this->at(i).m_ModifyTime = e->mtime.seconds;
		this->at(i).m_Flags = e->flags;
		this->at(i).m_FlagsExtended = e->flags_extended;
		this->at(i).m_IndexHash = e->id.id;
		this->at(i).m_Size = e->file_size;
		m_bHasConflicts |= GIT_IDXENTRY_STAGE(e);
	}

	CGit::GetFileModifyTime(dgitdir + _T("index"), &this->m_LastModifyTime);
	std::sort(this->begin(), this->end(), SortIndex);

	return 0;
}
Exemplo n.º 5
0
uint32_t
sdHalInit()
{
	enableIfaceAndFunctionalClock();

	if ( softwareReset() )
	{
		return 1;
	}

	if ( resetLines( MMCHS_SYSCTL_SRA_BIT ) )
	{
		return 1;
	}

	selectSupportedVoltage( MMCHS_CAPA_VS18_BIT | MMCHS_CAPA_VS30_BIT );

	// want enable wakeup when card is inserted
	systemConfig( MMCHS_SYSCONFIG_AUTOIDLE_BIT /*| MMCHS_SYSCONFIG_ENAWAKEUP_BIT */ );

	setBusWidth( BUS_WIDTH_1BIT );

	setBusVoltage( MMCHS_HCTL_SDVS_30V_BIT );

	if ( setBusPower( TRUE ) )
	{
		return 1;
	}

	// need some initial clock divider otherwise would not work to set the bus frequency
	MMCHS_SYSCTL = 0x0000a007;

	if ( setBusFrequency( SDMMC_CONTROLLER_CLOCK, SDMMC_BUS_CLOCK, FALSE ) )
	{
		return 1;
	}

	/*
	// wake-up event enabled on card-insertion
	MMCHS_HCTL |= MMCHS_HCTL_INS_BIT;
	// clear all and set card-interrupt enable
	MMCHS_ISE = MMCHS_ISE_CIRQ_SIGEN_BIT;

	// TODO: the next only when card is inserted!
	*/

	sendInitStream();

	if ( identifyCard() )
	{
		return 1;
	}

	if ( configBusWidth() )
	{
		return 1;
	}

	configTransferSpeed();

	return 0;
}
Exemplo n.º 6
0
void updateArmingStatus(void)
{
    if (ARMING_FLAG(ARMED)) {
        LED0_ON;
    } else {
        // Check if the power on arming grace time has elapsed
        if ((getArmingDisableFlags() & ARMING_DISABLED_BOOT_GRACE_TIME) && (millis() >= systemConfig()->powerOnArmingGraceTime * 1000)) {
            // If so, unset the grace time arming disable flag
            unsetArmingDisabled(ARMING_DISABLED_BOOT_GRACE_TIME);
        }

        // Clear the crash flip active status
        flipOverAfterCrashMode = false;

        // If switch is used for arming then check it is not defaulting to on when the RX link recovers from a fault
        if (!isUsingSticksForArming()) {
            static bool hadRx = false;
            const bool haveRx = rxIsReceivingSignal();

            const bool justGotRxBack = !hadRx && haveRx;

            if (justGotRxBack && IS_RC_MODE_ACTIVE(BOXARM)) {
                // If the RX has just started to receive a signal again and the arm switch is on, apply arming restriction
                setArmingDisabled(ARMING_DISABLED_BAD_RX_RECOVERY);
            } else if (haveRx && !IS_RC_MODE_ACTIVE(BOXARM)) {
                // If RX signal is OK and the arm switch is off, remove arming restriction
                unsetArmingDisabled(ARMING_DISABLED_BAD_RX_RECOVERY);
            }

            hadRx = haveRx;
        }

        if (IS_RC_MODE_ACTIVE(BOXFAILSAFE)) {
            setArmingDisabled(ARMING_DISABLED_BOXFAILSAFE);
        } else {
            unsetArmingDisabled(ARMING_DISABLED_BOXFAILSAFE);
        }

        if (calculateThrottleStatus() != THROTTLE_LOW) {
            setArmingDisabled(ARMING_DISABLED_THROTTLE);
        } else {
            unsetArmingDisabled(ARMING_DISABLED_THROTTLE);
        }

        if (!STATE(SMALL_ANGLE) && !IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) {
            setArmingDisabled(ARMING_DISABLED_ANGLE);
        } else {
            unsetArmingDisabled(ARMING_DISABLED_ANGLE);
        }

        if (averageSystemLoadPercent > 100) {
            setArmingDisabled(ARMING_DISABLED_LOAD);
        } else {
            unsetArmingDisabled(ARMING_DISABLED_LOAD);
        }

        if (isCalibrating()) {
            setArmingDisabled(ARMING_DISABLED_CALIBRATING);
        } else {
            unsetArmingDisabled(ARMING_DISABLED_CALIBRATING);
        }

        if (isModeActivationConditionPresent(BOXPREARM)) {
            if (IS_RC_MODE_ACTIVE(BOXPREARM) && !ARMING_FLAG(WAS_ARMED_WITH_PREARM)) {
                unsetArmingDisabled(ARMING_DISABLED_NOPREARM);
            } else {
                setArmingDisabled(ARMING_DISABLED_NOPREARM);
            }
        }

#ifdef USE_GPS_RESCUE
        if (isModeActivationConditionPresent(BOXGPSRESCUE)) {
            if (!gpsRescueConfig()->minSats || STATE(GPS_FIX_HOME) || ARMING_FLAG(WAS_EVER_ARMED)) {
                unsetArmingDisabled(ARMING_DISABLED_GPS);
            } else {
                setArmingDisabled(ARMING_DISABLED_GPS);
            }
        }
#endif

        if (IS_RC_MODE_ACTIVE(BOXPARALYZE)) {
            setArmingDisabled(ARMING_DISABLED_PARALYZE);
        }

        if (!isUsingSticksForArming()) {
          /* Ignore ARMING_DISABLED_CALIBRATING if we are going to calibrate gyro on first arm */
          bool ignoreGyro = armingConfig()->gyro_cal_on_first_arm
                         && !(getArmingDisableFlags() & ~(ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_CALIBRATING));

          /* Ignore ARMING_DISABLED_THROTTLE (once arm switch is on) if we are in 3D mode */
          bool ignoreThrottle = feature(FEATURE_3D)
                             && !IS_RC_MODE_ACTIVE(BOX3D)
                             && !flight3DConfig()->switched_mode3d
                             && !(getArmingDisableFlags() & ~(ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_THROTTLE));

#ifdef USE_RUNAWAY_TAKEOFF
           if (!IS_RC_MODE_ACTIVE(BOXARM)) {
               unsetArmingDisabled(ARMING_DISABLED_RUNAWAY_TAKEOFF);
           }
#endif

          // If arming is disabled and the ARM switch is on
          if (isArmingDisabled()
              && !ignoreGyro
              && !ignoreThrottle
              && IS_RC_MODE_ACTIVE(BOXARM)) {
              setArmingDisabled(ARMING_DISABLED_ARM_SWITCH);
          } else if (!IS_RC_MODE_ACTIVE(BOXARM)) {
              unsetArmingDisabled(ARMING_DISABLED_ARM_SWITCH);
          }
        }

        if (isArmingDisabled()) {
            warningLedFlash();
        } else {
            warningLedDisable();
        }

        warningLedUpdate();
    }
}
Exemplo n.º 7
0
int main(void) {
    float distanceNear = kDistanceNearInitial;
    ControllMode currentMode = ControllModeSearching;
    int approachCount = 30000, backOffCount = 0;
    int iDontKnowCountPrimary = 30, iDontKnowCountSecondary = 500;
    bool USSensorWorking = false;
    distance = usSensor.getResult();
    if(distance > kApproachDistanceMin && distance < distanceNear) USSensorWorking = true;
    int programCount = 0;

    systemConfig();
    stopMove();
    delay(200);
    beginMoveForward();
    delay(75);
    beginTurnRight();
    delay(9);
    stopMove();
    delay(100);
    beginMoveForward();
    delay(100);
    beginTurnRight();
    delay(5);
    beginMoveForward();
    delay(150);
    beginMoveBackward();
    delay(8);
    beginTurnRight();
    delay(40);
    beginMoveForward();
    delay(60);
    beginMoveBackward();
    delay(30);
    beginTurnRight();
    delay(40);
    beginMoveForward();
    delay(60);
    beginMoveBackward();
    delay(30);
    while (true) {
        // Stop watchdog timer to prevent time out reset
        WDTCTL = WDTPW + WDTHOLD;
        /*programCount ++;
        if (programCount == 0xffff) {
            WDTCTL = WDTPW|0xff00;
        }
                */
        //delay(10);
        usSensor.beginSensing();
        distance = usSensor.getResult();
        USSensorWorking = false;
        if(distance > kApproachDistanceMin && distance < distanceNear) USSensorWorking = true;
        switch (currentMode) {

        case ControllModeSearching:
            if (USSensorWorking) {
                beginMoveForward();
                if (currentMode != ControllModeApproaching) {
                    approachCount = kApproachCountMax;
                }
                currentMode = ControllModeApproaching;
            }
            else {
                beginTurnLeft();
                iDontKnowCountPrimary --;
                if (iDontKnowCountPrimary == 0) {
                    iDontKnowCountPrimary = 10;
                    iDontKnowCountSecondary --;
                    if (iDontKnowCountSecondary == 0) {
                        iDontKnowCountSecondary = 500;
                        currentMode = ControllModeIDontKnowWhatTheHellShouldIDo;
                    }
                }
            }
            break;

        case ControllModeIDontKnowWhatTheHellShouldIDo:
            beginMoveForward();
            iDontKnowCountPrimary --;
            if (iDontKnowCountPrimary == 0) {
                iDontKnowCountPrimary = 20;
                iDontKnowCountSecondary --;
                if (iDontKnowCountSecondary == 0) {
                    iDontKnowCountSecondary = 500;
                    currentMode = ControllModeSearching;
                }
            }
            break;

        case ControllModeApproaching:
            if(USSensorWorking) {
                beginMoveForward();
                delay(1);
                if(distance < 0.2)
                {
                    delay(240);
                    approachCount = kApproachCountMax;
                    currentMode = ControllModeBackingOff;
                }
                else if(distance < 0.5)
                {
                    approachCount = 600;
                }
                else if(distance < 1.0)
                {
                    approachCount = 1200;
                }
            }
            else {
                approachCount--;
                beginMoveForward();
                delay(1);
                if (approachCount <= 0) {
                    approachCount = kApproachCountMax;
                    currentMode = ControllModeBackingOff;
                }
            }
            /*
            if (distance < kApproachDistanceMin) {
                approachCount = 0;
                currentMode = ControllModeBackingOff;
            }
            */
            break;

        case ControllModeBackingOff:
            if (backOffCount == 0) {
                stopMove();
                beginRotateBackward(MotorLeft);
                delay(60);
            }
            beginMoveBackward();
            delay(120);
            /*
            backOffCount++;
            if (backOffCount >= kBackOffCountMax) {
            	        backOffCount = 0;
                                */
            currentMode = ControllModeSearching;
            //}
            break;
        }
    }
}
Exemplo n.º 8
0
void processRcAdjustments(controlRateConfig_t *controlRateConfig)
{
    const uint32_t now = millis();

    int newValue = -1;

    const bool canUseRxData = rxIsReceivingSignal();

    for (int adjustmentIndex = 0; adjustmentIndex < MAX_SIMULTANEOUS_ADJUSTMENT_COUNT; adjustmentIndex++) {
        adjustmentState_t *adjustmentState = &adjustmentStates[adjustmentIndex];

        if (!adjustmentState->config) {
            continue;
        }
        const uint8_t adjustmentFunction = adjustmentState->config->adjustmentFunction;
        if (adjustmentFunction == ADJUSTMENT_NONE) {
            continue;
        }

        if (cmp32(now, adjustmentState->timeoutAt) >= 0) {
            adjustmentState->timeoutAt = now + RESET_FREQUENCY_2HZ;
            MARK_ADJUSTMENT_FUNCTION_AS_READY(adjustmentIndex);

#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
            adjustmentRangeValue = -1;
#endif
        }

        if (!canUseRxData) {
            continue;
        }

        const uint8_t channelIndex = NON_AUX_CHANNEL_COUNT + adjustmentState->auxChannelIndex;

        if (adjustmentState->config->mode == ADJUSTMENT_MODE_STEP) {
            int delta;
            if (rcData[channelIndex] > rxConfig()->midrc + 200) {
                delta = adjustmentState->config->data.step;
            } else if (rcData[channelIndex] < rxConfig()->midrc - 200) {
                delta = -adjustmentState->config->data.step;
            } else {
                // returning the switch to the middle immediately resets the ready state
                MARK_ADJUSTMENT_FUNCTION_AS_READY(adjustmentIndex);
                adjustmentState->timeoutAt = now + RESET_FREQUENCY_2HZ;
                continue;
            }
            if (IS_ADJUSTMENT_FUNCTION_BUSY(adjustmentIndex)) {
                continue;
            }

            newValue = applyStepAdjustment(controlRateConfig, adjustmentFunction, delta);
            pidInitConfig(pidProfile);
        } else if (adjustmentState->config->mode == ADJUSTMENT_MODE_SELECT) {
            int switchPositions = adjustmentState->config->data.switchPositions;
            if (adjustmentFunction == ADJUSTMENT_RATE_PROFILE && systemConfig()->rateProfile6PosSwitch) {
                switchPositions =  6;
            }
            const uint16_t rangeWidth = (2100 - 900) / switchPositions;
            const uint8_t position = (constrain(rcData[channelIndex], 900, 2100 - 1) - 900) / rangeWidth;
            newValue = applySelectAdjustment(adjustmentFunction, position);
        }

#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
        if (newValue != -1 && adjustmentState->config->adjustmentFunction != ADJUSTMENT_RATE_PROFILE) { // Rate profile already has an OSD element
            adjustmentRangeName = &adjustmentLabels[adjustmentFunction - 1][0];
            adjustmentRangeValue = newValue;
        }
#else
        UNUSED(newValue);
#endif
        MARK_ADJUSTMENT_FUNCTION_AS_BUSY(adjustmentIndex);
    }
}