Exemplo n.º 1
0
void readConfig(config_t *pConfig)
{
	u32 configInFlash;
	configInFlash = PARA_START_ADDRESS;
	memcpy(pConfig, (void *)configInFlash, sizeof(config_t));
	if(pConfig->magicNumber != MAGIC_FLAG){
		restoreConfig();
		NVIC_SystemReset();	
	}
}
Exemplo n.º 2
0
void FanControl::start() {
	// Setting Menu
	int input = 1;   
    // Motor Test ///////////////////////
	cout << "[Test Motors - Speed at 1200]\n";
	while(1) {
		setMotorSpeedAll(1200);
		sleep(1);
		setMotorSpeedAll(1);
		cout << "\n(1).Again?\n(ANY).Next Step \n";
		cin >> input;
		cout << endl;
		if ( input != 1 ) break;
	}

	input = 0;
    // Pid Setting ///////////////////////
	cout << "\n\t[Do you want to set PID values?]\n(Enter 1, if Yes.\nEnter any to use previous values\n";
	cin >> input;
	if ( input == 1)
		setPID();
	else {
		cout << "Restoring Setting ...\n";
		
		try {
			restoreConfig();
		} catch (int e) {
			if ( e == 1) {
				cout << "\nPrevious Configuration Does not exist!\n";
			} else{
				cout << "\nWarning: /config/config.txt is Broken\n";	
			}
		}
	}
	system("clear");
	cout << "\n\t Current Setting is ... \n";
	displaySetting();
	cout << "\n\t[Do you want to set output speed Limit?]\n";
	cout << "Enter 1, if Yes.nEnter any, if No. \n";
	cin >> input;
	if ( input == 1) {
		// char buffer[10];
		int max, min;
		cout << "Max speed = ";
		cin >> max;
		//pidOutLimitMax = atof(buffer);
		cout << "\nMin speed = ";
		cin >> min;
		// pidOutLimitMin = atof(buffer);
		//setOutputLimitsX(pidOutLimitMin, pidOutLimitMax);
		//setOutputLimitsY(pidOutLimitMin, pidOutLimitMax);
		setMaxMinSpeed(max, min);
		cout<<"\n[New setting applied]\n";
		saveConfig();
	}
Exemplo n.º 3
0
    //-----------------------------------------------------------------------
    bool Root::showConfigDialog(void)
    {
        // Displays the standard config dialog
        // Will use stored defaults if available
        ConfigDialog* dlg;
        bool isOk;

        restoreConfig();

        dlg = OGRE_NEW ConfigDialog();

        if ((isOk = dlg->display()))
            saveConfig();

        OGRE_DELETE dlg;
        return isOk;
    }
Exemplo n.º 4
0
int main(void)
{
    halInit();
    chSysInit();
    sdStart(&STDOUT_SD, NULL);

    watchdogInit(WATCHDOG_TIMEOUT_MS);
    const int wdid = watchdogStart();

    restoreConfig();
    magnetInit();
    consoleInit();

    int res = canasctlInit();
    if (res)
    {
        TRACE("init", "CANAS NOT INITED (%d), FIX CONFIG AND RESTART", res);
        while (1)
        {
            ledOn();
            watchdogReset(wdid);
            chThdSleepMilliseconds(100);
        }
    }

#if RELEASE
    TRACE("init", "debug port will be disabled %d sec later", DEBUG_PORT_DISABLE_DEADLINE_SEC);
#endif

    bool debug_port_disabled = false;
    while (1)
    {
        const bool
            feedback = magnetReadFeedback(),
            requested = magnetGetRequestedState();

        ledOn();

        if (feedback != requested)
        {
            chThdSleepMilliseconds(70);
            ledOff();
            chThdSleepMilliseconds(70);
        }
        else if (feedback)
        {
            chThdSleepMilliseconds(500);
            ledOff();
            chThdSleepMilliseconds(500);
        }
        else
        {
            chThdSleepMilliseconds(70);
            ledOff();
            chThdSleepMilliseconds(930);
        }

        if (!debug_port_disabled)
        {
            if (sysTimestampMicros() / 1000000 > DEBUG_PORT_DISABLE_DEADLINE_SEC)
            {
#if RELEASE
                debugPortDisable();
#endif
                debug_port_disabled = true;
            }
        }

        watchdogReset(wdid);
    }
    return 0;
}