예제 #1
0
파일: sensors.c 프로젝트: shivamdaboss/750E
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;
}
예제 #2
0
파일: accero.cpp 프로젝트: doorway/EasyVex
void Accelerometer::pollSensor()
{
	if(sensorport != 13)
		curval = analogReadCalibratedHR(sensorport);
}