コード例 #1
0
ファイル: qsensor.cpp プロジェクト: xjohncz/qt5
/*!
    Try to connect to a sensor backend.

    Returns true if a suitable backend could be found, false otherwise.

    The type must be set before calling this method if you are using QSensor directly.

    \sa isConnectedToBackend()
*/
bool QSensor::connectToBackend()
{
    Q_D(QSensor);
    if (isConnectedToBackend())
        return true;

    int dataRate = d->dataRate;
    int outputRange = d->outputRange;

    d->backend = QSensorManager::createBackend(this);

    if (d->backend) {
        // Reset the properties to their default values and re-set them now so
        // that the logic we've put into the setters gets called.
        if (dataRate != 0) {
            d->dataRate = 0;
            setDataRate(dataRate);
        }
        if (outputRange != -1) {
            d->outputRange = -1;
            setOutputRange(outputRange);
        }
    }

    return isConnectedToBackend();
}
コード例 #2
0
void Pterodactyl::setTarget(float target) {
	pid->Reset();
	this->target = target;
	this->initialError = target - getAngle();

	// PID values get updated here
	setOutputRange();

	pid->SetSetpoint(target / (double) PTERODACTYL_MAX_ANGLE);

	// PID values get updated here (again because multithreading)
	setOutputRange();

	if (!pid->IsEnabled()) {
		pid->Enable();
	}
}
コード例 #3
0
ファイル: ScaleMap.cpp プロジェクト: kamend/ofxToxiclibs
		ScaleMap::ScaleMap( const double minIn, const double maxIn, const double minOut, const double maxOut )
		{
			setInputRange( minIn, maxIn );
			setOutputRange( minOut, maxOut );
			mapFunction = LinearInterpolation();
		}