Beispiel #1
0
short getSensorValue(Sensor s) {
	short retVal = -1;
	switch (s.type) {
	case SHAFT_ENCODER:
		if (DEBUG) {
			print("got encoder value");
		}
		retVal = (short)encoderGet(s.enc);
		break;
	case GYROSCOPE:
		retVal = (short)gyroGet(s.gyr);
		break;
	case ULTRASONIC:
		retVal = (short)ultrasonicGet(s.ult);
		break;
	case ACCELEROMETER:
		retVal = (short)analogReadCalibratedHR(s.port);
		break;
	case BUMPER_SWITCH:
	case LIMIT_SWITCH:
		retVal = (short)digitalRead(s.port);
		break;
	case LINE_TRACKER:
	case POTENTIOMETER:
		retVal = (short)analogRead(s.port);
		break;
	case TIME:
		retVal = (short)getTimer(s.port, true);
		break;
	case IME: ; // so apparently due to history this ";" has to be here to declare
	// a variable inside a case statement?
	int imeVal = -1;
	imeGet(s.port, &imeVal);
	retVal = (short)imeVal;
	break;
	}
	return retVal;
}
Beispiel #2
0
void Accelerometer::pollSensor()
{
	if(sensorport != 13)
		curval = analogReadCalibratedHR(sensorport);
}