Exemplo n.º 1
0
void getSensorData()
{
	temperature = sensorManager.getTemperature();
	rainStatus = sensorManager.getRainStatus();
	lightLevel = sensorManager.getLightLevel();
	pressure = sensorManager.getPressure(altitude);
}
Exemplo n.º 2
0
void sensorUpdater()
{
	SensorManager sm;
	int fixedValues[4];
	int rateValues[4];
	while( true )
	{
		sm.update();
		sm.getValues( fixedValues );
		sm.getRates( rateValues );
		
		m.lock();
		
		yaw = fixedValues[2];
		pitch = fixedValues[1];
		roll = fixedValues[0];
		height = fixedValues[3];
		
		yawRate = rateValues[2];
		pitchRate = rateValues[1];
		rollRate = rateValues[0];
		heightRate = rateValues[3];
		
		m.unlock();
	}
}
// for tracking new sensors that connect to the system
void SensorManager::NuiStatusCallback( HRESULT hrStatus, const OLECHAR* connectionId, const OLECHAR* uniqueDeviceName, void* pUserData )
{
    SensorManager* pThis = nullptr;
    pThis = reinterpret_cast<SensorManager*>(pUserData);
    if( nullptr != pThis )
    {
        pThis->UpdateSensorOnList(connectionId, hrStatus);
    }
}
Exemplo n.º 4
0
void Player::setSupressionField(float distance)
{
   if(!isGhost())
   {
      disableSupressionField();
		if(distance > 0) {
	      SensorManager *rm = (SensorManager *) manager->findObject(SensorManagerId);
	      if(rm)
	         rm->addPlayerSupressor(this);
		}
      supressionDist = distance;
   }
}
static jlong nativeInitSensorEventQueue(JNIEnv *env, jclass clazz, jlong sensorManager,
        jobject eventQWeak, jobject msgQ, jfloatArray scratch, jstring packageName, jint mode) {
    SensorManager* mgr = reinterpret_cast<SensorManager*>(sensorManager);
    ScopedUtfChars packageUtf(env, packageName);
    String8 clientName(packageUtf.c_str());
    sp<SensorEventQueue> queue(mgr->createEventQueue(clientName, mode));

    sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, msgQ);
    if (messageQueue == NULL) {
        jniThrowRuntimeException(env, "MessageQueue is not initialized.");
        return 0;
    }

    sp<Receiver> receiver = new Receiver(queue, messageQueue, eventQWeak, scratch);
    receiver->incStrong((void*)nativeInitSensorEventQueue);
    return jlong(receiver.get());
}
Exemplo n.º 6
0
void setup() {
	lcd.print("LOADING");

	lcd.begin(20, 4);
	sensorManager.init();
	initButtons();
	Serial.begin(9600);
	setSyncProvider(RTC.get);

	EEPROM_readAnything(0, altitude);
}
static jboolean
nativeGetSensorAtIndex(JNIEnv *env, jclass clazz, jlong sensorManager, jobject sensor, jint index)
{
    SensorManager* mgr = reinterpret_cast<SensorManager*>(sensorManager);

    Sensor const* const* sensorList;
    size_t count = mgr->getSensorList(&sensorList);
    if (size_t(index) >= count) {
        return false;
    }

    Sensor const* const list = sensorList[index];
    const SensorOffsets& sensorOffsets(gSensorOffsets);
    jstring name = getInternedString(env, &list->getName());
    jstring vendor = getInternedString(env, &list->getVendor());
    jstring requiredPermission = getInternedString(env, &list->getRequiredPermission());
    env->SetObjectField(sensor, sensorOffsets.name,      name);
    env->SetObjectField(sensor, sensorOffsets.vendor,    vendor);
    env->SetIntField(sensor, sensorOffsets.version,      list->getVersion());
    env->SetIntField(sensor, sensorOffsets.handle,       list->getHandle());
    env->SetFloatField(sensor, sensorOffsets.range,      list->getMaxValue());
    env->SetFloatField(sensor, sensorOffsets.resolution, list->getResolution());
    env->SetFloatField(sensor, sensorOffsets.power,      list->getPowerUsage());
    env->SetIntField(sensor, sensorOffsets.minDelay,     list->getMinDelay());
    env->SetIntField(sensor, sensorOffsets.fifoReservedEventCount,
                     list->getFifoReservedEventCount());
    env->SetIntField(sensor, sensorOffsets.fifoMaxEventCount,
                     list->getFifoMaxEventCount());
    env->SetObjectField(sensor, sensorOffsets.requiredPermission,
                        requiredPermission);
    env->SetIntField(sensor, sensorOffsets.maxDelay, list->getMaxDelay());
    env->SetIntField(sensor, sensorOffsets.flags, list->getFlags());
    if (env->CallBooleanMethod(sensor, sensorOffsets.setType, list->getType()) == JNI_FALSE) {
        jstring stringType = getInternedString(env, &list->getStringType());
        env->SetObjectField(sensor, sensorOffsets.stringType, stringType);
    }
    return true;
}
int main(int argc, char** argv) {
  SensorManager sensors;
  sensors.initialize();
  VehicleControl control;
  control.initialize();
  //control.setSpeed(1);
  while (1) {
    sensors.update();
    char c = getchar();
    if (c == '\n') {
      std::cout << "Ultrasonic = " << sensors.getUltrasonic() << std::endl;
      std::cout << "Light_Left = " << sensors.getLeftLightTrip() << std::endl;
      std::cout << "Light_Right = " << sensors.getRightLightTrip() << std::endl;
      std::cout << "IR_Left = " << sensors.getLeftInfraredTrip() << std::endl;
      std::cout << "IR_Right = " << sensors.getRightInfraredTrip() << std::endl;
    }
  }
  return 0;
}
/**
 * small static wrapper function to start thread
 */
void* SensorManager::threadWrapper(void* instance)
{
	SensorManager* sm = reinterpret_cast<SensorManager*>(instance);
	sm->collectDataWorker();
	return 0;
}
static jboolean nativeIsDataInjectionEnabled(JNIEnv *_env, jclass _this, jlong sensorManager) {
    SensorManager* mgr = reinterpret_cast<SensorManager*>(sensorManager);
    return mgr->isDataInjectionEnabled();
}