diff options
author | tilaksidduram <tilaksidduram@gmail.com> | 2014-06-10 21:22:28 +0530 |
---|---|---|
committer | tilaksidduram <tilaksidduram@gmail.com> | 2014-06-10 21:22:28 +0530 |
commit | 25167a3ebc96d346ec41c8361a8396afac77ad5d (patch) | |
tree | 11d2068689ec561114a38db697679ea211b2dd56 /libsensors | |
parent | da70a1e85f9fbc0ed2be6821a739d23e141dc383 (diff) | |
download | device_samsung_n7100-25167a3ebc96d346ec41c8361a8396afac77ad5d.zip device_samsung_n7100-25167a3ebc96d346ec41c8361a8396afac77ad5d.tar.gz device_samsung_n7100-25167a3ebc96d346ec41c8361a8396afac77ad5d.tar.bz2 |
Revert "n7100: fix up sensors"
This reverts commit cd5145640187472147f77a2e9be8e7055097b581.
Diffstat (limited to 'libsensors')
-rw-r--r-- | libsensors/ProximitySensor.cpp | 1 | ||||
-rw-r--r-- | libsensors/SensorBase.cpp | 36 | ||||
-rw-r--r-- | libsensors/SensorBase.h | 1 | ||||
-rw-r--r-- | libsensors/sensors.h | 20 |
4 files changed, 16 insertions, 42 deletions
diff --git a/libsensors/ProximitySensor.cpp b/libsensors/ProximitySensor.cpp index f9579fa..404bdbc 100644 --- a/libsensors/ProximitySensor.cpp +++ b/libsensors/ProximitySensor.cpp @@ -88,7 +88,6 @@ int ProximitySensor::enable(int32_t handle, int en) { int flags = en ? 1 : 0; int err; - //ALOGD("%s: Enable: %i", __func__, en); if (flags != mEnabled) { err = sspEnable(LOGTAG, SSP_PROX, en); if(err >= 0){ diff --git a/libsensors/SensorBase.cpp b/libsensors/SensorBase.cpp index 2de3923..389edd7 100644 --- a/libsensors/SensorBase.cpp +++ b/libsensors/SensorBase.cpp @@ -144,49 +144,35 @@ int SensorBase::sspEnable(const char* sensorname, int sensorvalue, int en) int oldvalue = 0; int reset = 0; int newvalue; - int fd; + int fd, err; + char buf[10]; sspfile = fopen(SSP_DEVICE_ENABLE, "r+"); fscanf(sspfile, "%d", &oldvalue); fclose(sspfile); //Accel sensor is first on and last off, if we are disabling it -// assume the screen is off, disable all sensors and zero everything out -// to keep enable file in sync. +// assume the screen is off and zero everything out. if(sensorvalue == SSP_ACCEL && !en) { + newvalue = '\0'; //ALOGD("SensorBase: Resetting sensors"); - for(int i; i < 6; i++){ - newvalue = oldvalue - ssp_sensors[i]; - //ALOGD("SensorBase: newvalue: %i ",newvalue); - sspWrite(newvalue); - } - sspWrite('\0'); - return 0; } else if(en) { newvalue = oldvalue + sensorvalue; } else { newvalue = oldvalue - sensorvalue; } - //ALOGI("%s: name: %s sensor: %i old value: %i new value: %i ", __func__, sensorname, sensorvalue, oldvalue, newvalue); - sspWrite(newvalue); - return 0; -} -int SensorBase::sspWrite(int sensorvalue) -{ - char buf[10]; - int fd, ret, err; + sprintf(buf, "%d", newvalue); - sprintf(buf, "%d", sensorvalue); fd = open(SSP_DEVICE_ENABLE, O_RDWR); if (fd >= 0) { err = write(fd, buf, sizeof(buf)); - ret = 0; + //ALOGI("%s: sensor: %i old value: %i new value: %i ", sensorname, sensorvalue, oldvalue, newvalue); + close(fd); + return 0; } else { - ALOGI("%s: error writing to file", __func__); - ret = -1; + ALOGI("%s: error writing to file", sensorname); + close(fd); + return -1; } - - close(fd); - return ret; } diff --git a/libsensors/SensorBase.h b/libsensors/SensorBase.h index aeac510..d9e4b47 100644 --- a/libsensors/SensorBase.h +++ b/libsensors/SensorBase.h @@ -61,7 +61,6 @@ public: virtual int setDelay(int32_t handle, int64_t ns); virtual int enable(int32_t handle, int enabled) = 0; int sspEnable(const char* sensorname, int sensorvalue, int en); - int sspWrite(int sensorvalue); virtual int batch(int handle, int flags, int64_t period_ns, int64_t timeout); virtual int flush(int handle); diff --git a/libsensors/sensors.h b/libsensors/sensors.h index 713395b..a4fe794 100644 --- a/libsensors/sensors.h +++ b/libsensors/sensors.h @@ -52,16 +52,6 @@ __BEGIN_DECLS #define SSP_DEVICE_ENABLE "/sys/class/sensors/ssp_sensor/enable" -const int ssp_sensors[] = { - SSP_ACCEL, - SSP_GYRO, - SSP_MAG, - SSP_PRESS, - SSP_PROX, - SSP_LIGHT -}; - - /*****************************************************************************/ /* @@ -115,7 +105,7 @@ const int ssp_sensors[] = { // conversion of magnetic data to uT units #define CONVERT_M (1.0f/16.0f) -#define CONVERT_M_X (CONVERT_M) +#define CONVERT_M_X (-CONVERT_M) #define CONVERT_M_Y (CONVERT_M) #define CONVERT_M_Z (CONVERT_M) @@ -126,11 +116,11 @@ const int ssp_sensors[] = { #define CONVERT_O_R (CONVERT_O) // conversion of gyro data to SI units (radian/sec) -#define RANGE_GYRO (2000.0f*(float)M_PI/180.0f) +#define RANGE_GYRO (500.0f*(float)M_PI/180.0f) #define CONVERT_GYRO ((70.0f / 4000.0f) * ((float)M_PI / 180.0f)) -#define CONVERT_GYRO_X (CONVERT_GYRO) -#define CONVERT_GYRO_Y (CONVERT_GYRO) -#define CONVERT_GYRO_Z (CONVERT_GYRO) +#define CONVERT_GYRO_X (-CONVERT_GYRO) +#define CONVERT_GYRO_Y (-CONVERT_GYRO) +#define CONVERT_GYRO_Z (-CONVERT_GYRO) #define SENSOR_STATE_MASK (0x7FFF) |