return 0;
int ret =0;
+ double sensitivity;
ALOGD(">>%s enabled:%d", __func__, enabled);
goto err_ret;
if (DeviceActivate(GetDeviceNumber(), 1) < 0)
goto err_ret;
- if (DeviceSetSensitivity(GetDeviceNumber(), DEF_HYST_VALUE) < 0)
+ sensitivity = DeviceGetSensitivity(GetDeviceNumber());
+ if (DeviceSetSensitivity(GetDeviceNumber(), sensitivity) < 0)
goto err_ret;
if (AllocateRxBuffer() < 0)
goto err_ret;
goto err_ret;
if (DeviceActivate(GetDeviceNumber(), 0) < 0)
goto err_ret;
- if (DeviceSetSensitivity(GetDeviceNumber(), 0))
- goto err_ret;
if (FreeRxBuffer() < 0)
goto err_ret;
mDevPath = "";
return 0;
}
+// Get sensitivity in absolute terms
+double SensorIIODev::DeviceGetSensitivity(int dev_num){
+ std::stringstream filename;
+ std::string sensitivity_str;
+ double value;
+
+ filename << IIO_DIR << "/" << "iio:device" << dev_num << "/" << channel_prefix_str << "hysteresis";
+
+ PathOps path_ops;
+ int ret = path_ops.read(filename.str(), sensitivity_str);
+ if (ret < 0) {
+ ALOGE("Read Error %s", filename.str().c_str());
+ return DEF_HYST_VALUE;
+ }
+ istringstream buffer(sensitivity_str);
+ buffer >> value;
+ return value;
+}
+
// Set sensitivity in absolute terms
-int SensorIIODev::DeviceSetSensitivity(int dev_num, int value){
+int SensorIIODev::DeviceSetSensitivity(int dev_num, double value){
std::stringstream filename;
std::stringstream sensitivity_str;
int EnableBuffer(int status);
int SetSampleDelay(int dev_num, int rate);
int DeviceActivate(int dev_num, int state);
- int DeviceSetSensitivity(int dev_num, int value);
+ double DeviceGetSensitivity(int dev_num);
+ int DeviceSetSensitivity(int dev_num, double value);
long GetUnitValue();
long GetExponentValue();
int ReadHIDMeasurmentUnit(long *unit);