davinci: parts: Add a setting to calibrate the motor
Change-Id: I9f76124759bf8497b5cd72293b5c36f85b4d1787
This commit is contained in:
parent
236c8747e3
commit
cf282db685
9
parts/res/drawable/ic_popup_calibration.xml
Normal file
9
parts/res/drawable/ic_popup_calibration.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#000" android:pathData="M15.9,18.45C17.25,18.45 18.35,17.35 18.35,16C18.35,14.65 17.25,13.55 15.9,13.55C14.54,13.55 13.45,14.65 13.45,16C13.45,17.35 14.54,18.45 15.9,18.45M21.1,16.68L22.58,17.84C22.71,17.95 22.75,18.13 22.66,18.29L21.26,20.71C21.17,20.86 21,20.92 20.83,20.86L19.09,20.16C18.73,20.44 18.33,20.67 17.91,20.85L17.64,22.7C17.62,22.87 17.47,23 17.3,23H14.5C14.32,23 14.18,22.87 14.15,22.7L13.89,20.85C13.46,20.67 13.07,20.44 12.71,20.16L10.96,20.86C10.81,20.92 10.62,20.86 10.54,20.71L9.14,18.29C9.05,18.13 9.09,17.95 9.22,17.84L10.7,16.68L10.65,16L10.7,15.31L9.22,14.16C9.09,14.05 9.05,13.86 9.14,13.71L10.54,11.29C10.62,11.13 10.81,11.07 10.96,11.13L12.71,11.84C13.07,11.56 13.46,11.32 13.89,11.15L14.15,9.29C14.18,9.13 14.32,9 14.5,9H17.3C17.47,9 17.62,9.13 17.64,9.29L17.91,11.15C18.33,11.32 18.73,11.56 19.09,11.84L20.83,11.13C21,11.07 21.17,11.13 21.26,11.29L22.66,13.71C22.75,13.86 22.71,14.05 22.58,14.16L21.1,15.31L21.15,16L21.1,16.68M6.69,8.07C7.56,8.07 8.26,7.37 8.26,6.5C8.26,5.63 7.56,4.92 6.69,4.92A1.58,1.58 0 0,0 5.11,6.5C5.11,7.37 5.82,8.07 6.69,8.07M10.03,6.94L11,7.68C11.07,7.75 11.09,7.87 11.03,7.97L10.13,9.53C10.08,9.63 9.96,9.67 9.86,9.63L8.74,9.18L8,9.62L7.81,10.81C7.79,10.92 7.7,11 7.59,11H5.79C5.67,11 5.58,10.92 5.56,10.81L5.4,9.62L4.64,9.18L3.5,9.63C3.41,9.67 3.3,9.63 3.24,9.53L2.34,7.97C2.28,7.87 2.31,7.75 2.39,7.68L3.34,6.94L3.31,6.5L3.34,6.06L2.39,5.32C2.31,5.25 2.28,5.13 2.34,5.03L3.24,3.47C3.3,3.37 3.41,3.33 3.5,3.37L4.63,3.82L5.4,3.38L5.56,2.19C5.58,2.08 5.67,2 5.79,2H7.59C7.7,2 7.79,2.08 7.81,2.19L8,3.38L8.74,3.82L9.86,3.37C9.96,3.33 10.08,3.37 10.13,3.47L11.03,5.03C11.09,5.13 11.07,5.25 11,5.32L10.03,6.06L10.06,6.5L10.03,6.94Z"/>
|
||||
</vector>
|
@ -16,7 +16,7 @@
|
||||
-->
|
||||
<resources>
|
||||
<!-- Popup camera settings -->
|
||||
<string name="popup_title">Front camera effects</string>
|
||||
<string name="popup_title">Front camera settings</string>
|
||||
<string name="popup_led_title">Camera LED</string>
|
||||
<string name="popup_led_summary">Enable LED light while the front camera appears and retracts</string>
|
||||
<string name="popup_sound_title">Sound effects</string>
|
||||
@ -26,6 +26,8 @@
|
||||
<string name="popup_sound_jijia">Mecha</string>
|
||||
<string name="popup_sound_chilun">Gearwheel</string>
|
||||
<string name="popup_sound_cangmen">Cabin door</string>
|
||||
<string name="popup_calibration_title">Calibration</string>
|
||||
<string name="popup_calibration_summary">Calibrate the popup camera motor</string>
|
||||
|
||||
<!-- Popup camera strings -->
|
||||
<string name="popup_camera_tip">Warning</string>
|
||||
|
@ -17,4 +17,10 @@
|
||||
android:summary="%s"
|
||||
android:title="@string/popup_sound_title" />
|
||||
|
||||
<Preference
|
||||
android:key="motor_calibration"
|
||||
android:title="@string/popup_calibration_title"
|
||||
android:summary="@string/popup_calibration_summary"
|
||||
android:icon="@drawable/ic_popup_calibration" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@ -166,7 +166,6 @@ public class PopupCameraService extends Service implements Handler.Callback {
|
||||
synchronized (mLock) {
|
||||
if (status == Constants.MOTOR_STATUS_CALIB_OK
|
||||
|| status == Constants.MOTOR_STATUS_CALIB_ERROR) {
|
||||
mMotorCalibrating = false;
|
||||
showCalibrationResult(status);
|
||||
} else if (status == Constants.MOTOR_STATUS_PRESSED) {
|
||||
updateMotor(Constants.CLOSE_CAMERA_STATE);
|
||||
@ -179,16 +178,26 @@ public class PopupCameraService extends Service implements Handler.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
private void calibrateMotor() {
|
||||
protected void calibrateMotor() {
|
||||
synchronized (mLock) {
|
||||
if (mMotorCalibrating || mMotor == null)
|
||||
if (mMotorCalibrating)
|
||||
return;
|
||||
if (mMotor == null) {
|
||||
try {
|
||||
mMotor = IMotor.getService();
|
||||
} catch (RemoteException e) {
|
||||
// Do nothing
|
||||
}
|
||||
if (mMotor == null)
|
||||
return;
|
||||
}
|
||||
try {
|
||||
mMotorCalibrating = true;
|
||||
mMotor.calibration();
|
||||
} catch (RemoteException e) {
|
||||
// Do nothing
|
||||
}
|
||||
mHandler.postDelayed(() -> mMotorCalibrating = false, 7000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,16 +21,25 @@ import android.view.MenuItem;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.Preference.OnPreferenceClickListener;
|
||||
import androidx.preference.PreferenceFragment;
|
||||
|
||||
import org.lineageos.settings.R;
|
||||
|
||||
public class PopupCameraSettingsFragment
|
||||
extends PreferenceFragment implements OnPreferenceChangeListener {
|
||||
public class PopupCameraSettingsFragment extends PreferenceFragment
|
||||
implements OnPreferenceChangeListener, OnPreferenceClickListener {
|
||||
private Preference mCalibrationPreference;
|
||||
private static final String MOTOR_CALIBRATION_KEY = "motor_calibration";
|
||||
|
||||
private PopupCameraService mPopupCameraService = new PopupCameraService();
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.popup_settings);
|
||||
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
mCalibrationPreference = (Preference) findPreference(MOTOR_CALIBRATION_KEY);
|
||||
mCalibrationPreference.setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,4 +55,13 @@ public class PopupCameraSettingsFragment
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (MOTOR_CALIBRATION_KEY.equals(preference.getKey())) {
|
||||
mPopupCameraService.calibrateMotor();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user