Esempio n. 1
0
void initCommands()
{
    Serial.println("Init command...");
    Serial1.begin(57600);
    cmdMessenger.printLfCr();
    
    cmdMessenger.attach(onUnknownCommand);
    cmdMessenger.attach(kSetAnglePID, onSetAnglePID);
    cmdMessenger.attach(kSetAngleOutputLimits, onSetAngleOutputLimits);
    cmdMessenger.attach(kSetAcceleration, onSetAcceleration);
    cmdMessenger.attach(kSetSpeed, onSetSpeed);
    cmdMessenger.attach(kSetAverage, onSetAverage);
    cmdMessenger.attach(kRecalibrate, onRecalibrate);
    Timer3.getAvailable().attachInterrupt(processCommands).setPeriod(100000).start();
    cmdMessenger.sendCmd(kStatus, "System ready");
}
Esempio n. 2
0
void setup()
{
	delay(1000);
	Serial.begin(38400);
	sysStatus = sysBootTest();

	if (!((sysStatus==SYS_STATUS_NO_CLIMATE) || (sysStatus==SYS_STATUS_NO_SENSORS)))
	{
		climateSensor.settings.commInterface = I2C_MODE;
		climateSensor.settings.I2CAddress = 0x76;
		climateSensor.settings.runMode = 3;
		climateSensor.settings.tStandby = 5;
		climateSensor.settings.filter = 0;
		climateSensor.settings.tempOverSample = 1;
		climateSensor.settings.pressOverSample = 1;
		climateSensor.settings.humidOverSample = 1;
		climateSensor.begin();
	}

	if (!((sysStatus==SYS_STATUS_NO_ALS) || (sysStatus==SYS_STATUS_NO_SENSORS)))
	{
		alsSensor.alsConf(0x4C);
		alsSensor.psConf(0x0E, 0x08, 0, 0x07);
		alsSensor.ps();
		alsSensor.lux();
	}

	Timer1.initialize(400);
	Timer1.attachInterrupt(sysTaskTimer);
	Timer1.pwm(LEDPIN, 0);

	sysLoadSettings();
	if (sensorPsCalibrated) {
		alsSensor.psSetCanc(psCal);
		ps=alsSensor.ps();
		lux=alsSensor.lux();
	}
	cmdMessenger.printLfCr();
	attachCommandCallbacks();
	cmdMessenger.sendCmd(kRStatus,sysStatus);
}