AccelSensor::AccelSensor()
        : SensorBase(NULL, ACC_DATA_NAME),
        mEnabled(0),
        mPendingMask(0),
        convert(0.0),
        direct_x(0),
        direct_y(0), 
        direct_z(0), 
        direct_xy(-1),
        mInputReader(16),
        mDelay(0)
{
#ifdef DEBUG_SENSOR
        ALOGD("sensorName:%s,classPath:%s,lsg:%f\n",
                gsensorInfo.sensorName, gsensorInfo.classPath, gsensorInfo.priData);
#endif
        if (strlen(gsensorInfo.sensorName)) {
                if(! gsensor_cfg())
                        ALOGE("gsensor config error!\n"); 
        }
        
        memset(&mPendingEvent, 0, sizeof(mPendingEvent));
        memset(&mAccData, 0, sizeof(mAccData));
	
        mPendingEvent.version = sizeof(sensors_event_t);
        mPendingEvent.sensor = ID_A;
        mPendingEvent.type = SENSOR_TYPE_ACCELEROMETER;
        mPendingEvent.acceleration.status = SENSOR_STATUS_ACCURACY_HIGH;
        
	mUser = 0;
	
#ifdef DEBUG_SENSOR	
	ALOGD("%s:data_fd:%d\n", __func__, data_fd);
#endif	
	
	if(!strcmp(ACC_DATA_NAME, "lsm303d_acc")) {
	        sprintf(gsensorInfo.classPath, "%s/%s/%s", gsensorInfo.classPath, 
	                "device", "accelerometer");
	        ALOGD("gsensorInfo.classPath:%s", gsensorInfo.classPath);
	}
}
예제 #2
0
파일: sensors.cpp 프로젝트: garyhsh/device
static int sensor_init(struct sensors_poll_context_t *dev)
{
    int ret = -1;
    
    strcpy(class_path,"\0"); 
    strcpy(sensor_name,"\0");
    if(sensor_get_class_path() < 0) {
             ALOGD("sensor get class path error \n");
             return 0;
    }
    if(!(ret = gsensor_cfg())){
               ALOGD("gsensor config error!\n");
               return 0;
    }
    dev->fd = 0;
    dev->fd = open_input_device();
    if(dev->fd <0)
    {
        ALOGD("%s:open device error!",__func__);
        return 0;
    }
    return 1;
}