diff options
| author | sbrissen <sbrissen@hotmail.com> | 2014-02-26 20:26:52 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2014-02-26 20:26:52 +0000 |
| commit | 3aa03e8957cf198cc168a7a9fbe1a28efc2d9ec8 (patch) | |
| tree | eabf2534a316559d987d6a9ac07725de9908d43d | |
| parent | f8b76af3a3da4708c6270965026dfc5b46aae66c (diff) | |
| parent | 47d6b6ff1c11f7b9890c23dde4d18e11a15ab3dd (diff) | |
| download | device_samsung_t0lte-3aa03e8957cf198cc168a7a9fbe1a28efc2d9ec8.tar.gz device_samsung_t0lte-3aa03e8957cf198cc168a7a9fbe1a28efc2d9ec8.tar.bz2 device_samsung_t0lte-3aa03e8957cf198cc168a7a9fbe1a28efc2d9ec8.zip | |
Merge "t0lte: fix up sensors" into cm-11.0
| -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 | 22 |
4 files changed, 43 insertions, 17 deletions
diff --git a/libsensors/ProximitySensor.cpp b/libsensors/ProximitySensor.cpp index 404bdbc..f9579fa 100644 --- a/libsensors/ProximitySensor.cpp +++ b/libsensors/ProximitySensor.cpp @@ -88,6 +88,7 @@ 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 389edd7..2de3923 100644 --- a/libsensors/SensorBase.cpp +++ b/libsensors/SensorBase.cpp @@ -144,35 +144,49 @@ int SensorBase::sspEnable(const char* sensorname, int sensorvalue, int en) int oldvalue = 0; int reset = 0; int newvalue; - int fd, err; - char buf[10]; + int fd; 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 and zero everything out. +// assume the screen is off, disable all sensors and zero everything out +// to keep enable file in sync. 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; +} - sprintf(buf, "%d", newvalue); +int SensorBase::sspWrite(int sensorvalue) +{ + char buf[10]; + int fd, ret, err; + sprintf(buf, "%d", sensorvalue); fd = open(SSP_DEVICE_ENABLE, O_RDWR); if (fd >= 0) { err = write(fd, buf, sizeof(buf)); - //ALOGI("%s: sensor: %i old value: %i new value: %i ", sensorname, sensorvalue, oldvalue, newvalue); - close(fd); - return 0; + ret = 0; } else { - ALOGI("%s: error writing to file", sensorname); - close(fd); - return -1; + ALOGI("%s: error writing to file", __func__); + ret = -1; } + + close(fd); + return ret; } diff --git a/libsensors/SensorBase.h b/libsensors/SensorBase.h index d9e4b47..aeac510 100644 --- a/libsensors/SensorBase.h +++ b/libsensors/SensorBase.h @@ -61,6 +61,7 @@ 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 4b36ffe..089d446 100644 --- a/libsensors/sensors.h +++ b/libsensors/sensors.h @@ -50,6 +50,16 @@ __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 +}; + + /*****************************************************************************/ /* @@ -98,8 +108,8 @@ __BEGIN_DECLS // conversion of magnetic data to uT units #define CONVERT_M (1.0f/16.0f) -#define CONVERT_M_X (CONVERT_M) -#define CONVERT_M_Y (CONVERT_M) +#define CONVERT_M_X (-CONVERT_M) +#define CONVERT_M_Y (-CONVERT_M) #define CONVERT_M_Z (CONVERT_M) /* conversion of orientation data to degree units */ @@ -109,11 +119,11 @@ __BEGIN_DECLS #define CONVERT_O_R (CONVERT_O) // conversion of gyro data to SI units (radian/sec) -#define RANGE_GYRO (500.0f*(float)M_PI/180.0f) +#define RANGE_GYRO (2000.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) |
