Exemplo n.º 1
0
int getCompassReading(int avg){
	double newDigitHeading;
	double old_value;
	//txs=0;
	newDigitHeading=get_digital_heading();
	//txs=1;
	//old_value=heading.current;
	newDigitHeading-=180;//flip the compass to correct digital compass position
    if (newDigitHeading < 0) newDigitHeading += 360;//correct for 0 turns to 360
	if(avg&&degreeDifferance(1,newDigitHeading,heading.current)<=7){
		if(abs(heading.current-newDigitHeading)>180){//for across 360 zero area
			//required for averaging across 360 zero area
			old_value=newDigitHeading+degreeDifferance(0,heading.current,newDigitHeading);
		}
		else{
			old_value=heading.current;
		}
		newDigitHeading=((11.0/16.0)*old_value)+(((16.0-11.0)/16.0)*newDigitHeading);
		if(newDigitHeading>360)
			newDigitHeading-=360;
		if(newDigitHeading<0){
			newDigitHeading+=360;
		}
		bailOutBadCompass=0;
	}
	else if(avg){
		newDigitHeading=(double)heading.current;
		if(bailOutBadCompass++>3){
			newDigitHeading=startCompass();
			bailOutBadCompass=0;
		}
	}
return (int)newDigitHeading;
}
Exemplo n.º 2
0
void View::createActions()
{

    for (int i=0; i<m_sensors.length();i++){
        QAction* tmp = new QAction(m_sensors.at(i), this);

        const QString sensor = m_sensors.at(i);
        do{
            if (sensor==InputController::QACCELEROMETER){
                connect(tmp, SIGNAL(triggered()), this, SLOT(startAccelerometer()));
                break;
            }
            if (sensor==InputController::QORIENTATIONSENSOR){
                connect(tmp, SIGNAL(triggered()), this, SLOT(startOrientationSensor()));
                break;
            }
            if (sensor==InputController::QROTATIONSENSOR){
                connect(tmp, SIGNAL(triggered()), this, SLOT(startRotationSensor()));
                break;
            }
            if (sensor==InputController::QMAGNETOMETER){
                connect(tmp, SIGNAL(triggered()), this, SLOT(startMagnetometer()));
                break;
            }
            if (sensor==InputController::QTAPSENSOR){
                connect(tmp, SIGNAL(triggered()), this, SLOT(startTapSensor()));
                break;
            }
            if (sensor==InputController::QCOMPASS){
                connect(tmp, SIGNAL(triggered()), this, SLOT(startCompass()));
                break;
            }
            if (sensor==InputController::QKEYS){
                connect(tmp, SIGNAL(triggered()), this, SLOT(startKeys()));
                break;
            }
        }while (true);
        m_menu->addAction(tmp);
    }

}