int SensorBase::sensorBaseSetDelay(int32_t handle, int64_t ns){ char buf[6]; int ms; ms = ns/1000/1000; if(ms < mMinPollDelay) ms = mMinPollDelay ; else if(ms > mMaxPollDelay) ms = mMaxPollDelay; snprintf(buf,sizeof(buf),"%d",ms); return write_sysfs(sysfs_poll,buf,strlen(buf)); }
void GeneralInfo::refresh_backlight() { if (backlight < 5) backlight = 5; else if (backlight > 100) backlight = 100; snprintf(data[BACKLIGHT], sizeof(data[BACKLIGHT]), "%d", backlight); text_data[BACKLIGHT]->settext(data[BACKLIGHT]); #ifdef BUILD_FOR_ANDROID write_sysfs(SB_SYSFS_PATH_BACKLIGHT_BRIGHTNESS, data[BACKLIGHT]); #endif refresh_all(); }
int SensorBase::sensorBaseEnable(int32_t handle,int enabled){ char buf[6]; int enable = (enabled ? 1 : 0); int what = -1; /*if the munber of user > 1, do not disable sensor*/ switch (handle) { case ID_A : what = Accelerometer ;break; case ID_M : what = MagneticField; break; case ID_O : what = Orientation; break; case ID_GY : what = Gryo; break; case ID_L : what = Light; break; case ID_P : what = Pressure; break; case ID_T : what = Temperatury; break; case ID_PX : what = Proximity; break; } if (what < 0 || what >= numSensors) return -EINVAL; if(enable) mUser[what]++; else { mUser[what]--; if(mUser[what] < 0) mUser[what] = 0; } if((enable && mUser[what] == 1) || (enable ==0 && mUser[what] == 0 )) { snprintf(buf,sizeof(buf),"%d",enable); write_sysfs(sysfs_enable,buf,strlen(buf)); mEnabled &= ~(1<<what); mEnabled |= (uint32_t(enable)<<what); } ALOGD("sensor %d , usr count %d\n",handle,mUser[handle]); return 0; }