增加夜晚模式的设置

serial
BlueMatthew 1 year ago
parent 86b00231b0
commit 2e2d9c3e2f

@ -52,6 +52,11 @@ public:
setInt(CMD_SET_OTG_STATE, on ? 1 : 0); setInt(CMD_SET_OTG_STATE, on ? 1 : 0);
} }
static bool getOtgState()
{
return getInt(CMD_SET_OTG_STATE) != 0;
}
static void setCam3V3Enable(bool enabled) static void setCam3V3Enable(bool enabled)
{ {
setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0); setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0);

@ -69,8 +69,25 @@ public class ChannelActivity extends AppCompatActivity {
saveChannelParams(channel); saveChannelParams(channel);
} }
}); });
binding.btnNightMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (binding.btnNightMode.isChecked() && binding.btnHdrMode.isChecked()) {
binding.btnHdrMode.setChecked(false);
} }
}
});
binding.btnHdrMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (binding.btnHdrMode.isChecked() && binding.btnNightMode.isChecked()) {
binding.btnNightMode.setChecked(false);
}
}
});
}
private View.OnFocusChangeListener onFocusChangeListener = new View.OnFocusChangeListener() { private View.OnFocusChangeListener onFocusChangeListener = new View.OnFocusChangeListener() {
@Override @Override
@ -129,7 +146,8 @@ public class ChannelActivity extends AppCompatActivity {
binding.btnUsbCamera.setChecked(jsonObject.optInt("usbCamera", 0) == 1); binding.btnUsbCamera.setChecked(jsonObject.optInt("usbCamera", 0) == 1);
binding.btnAutoExplosure.setChecked(jsonObject.optInt("autoExposure", 1) == 1); binding.btnAutoExplosure.setChecked(jsonObject.optInt("autoExposure", 1) == 1);
binding.btnAutoFocus.setChecked(jsonObject.optInt("autoFocus", 1) == 1); binding.btnAutoFocus.setChecked(jsonObject.optInt("autoFocus", 1) == 1);
binding.btnHdrMode.setChecked(jsonObject.optInt("hdr", 1) == 1); binding.btnHdrMode.setChecked(jsonObject.optInt("hdr", 0) == 1);
binding.btnNightMode.setChecked(jsonObject.optInt("nightMode", 0) == 1);
binding.exposuretime.setText(Integer.toString(jsonObject.optInt("exposureTime", 0))); binding.exposuretime.setText(Integer.toString(jsonObject.optInt("exposureTime", 0)));
binding.sensitivity.setText(Integer.toString(jsonObject.optInt("sensibility", 0))); binding.sensitivity.setText(Integer.toString(jsonObject.optInt("sensibility", 0)));
binding.orientations.setSelection(jsonObject.optInt("orientation", 0)); binding.orientations.setSelection(jsonObject.optInt("orientation", 0));
@ -191,6 +209,7 @@ public class ChannelActivity extends AppCompatActivity {
jsonObject.put("autoExposure", binding.btnAutoExplosure.isChecked() ? 1 : 0); jsonObject.put("autoExposure", binding.btnAutoExplosure.isChecked() ? 1 : 0);
jsonObject.put("autoFocus", binding.btnAutoFocus.isChecked() ? 1 : 0); jsonObject.put("autoFocus", binding.btnAutoFocus.isChecked() ? 1 : 0);
jsonObject.put("hdrMode", binding.btnHdrMode.isChecked() ? 1 : 0); jsonObject.put("hdrMode", binding.btnHdrMode.isChecked() ? 1 : 0);
jsonObject.put("nightMode", binding.btnNightMode.isChecked() ? 1 : 0);
jsonObject.put("exposureTime", Integer.parseInt(binding.exposuretime.getText().toString())); jsonObject.put("exposureTime", Integer.parseInt(binding.exposuretime.getText().toString()));
jsonObject.put("sensibility", Integer.parseInt(binding.sensitivity.getText().toString())); jsonObject.put("sensibility", Integer.parseInt(binding.sensitivity.getText().toString()));
jsonObject.put("orientation", binding.orientations.getSelectedItemPosition()); jsonObject.put("orientation", binding.orientations.getSelectedItemPosition());

@ -509,6 +509,13 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
SysApi.setOtgState(true); SysApi.setOtgState(true);
try {
Thread.sleep(100);
} catch (Exception e) {
}
SysApi.setOtgState(true);
SysApi.setCam3V3Enable(true); SysApi.setCam3V3Enable(true);
String cameraInfo = CameraUtils.getAllCameraInfo(view.getContext()); String cameraInfo = CameraUtils.getAllCameraInfo(view.getContext());

@ -116,6 +116,16 @@
app:layout_constraintStart_toEndOf="@+id/btnAutoFocus" app:layout_constraintStart_toEndOf="@+id/btnAutoFocus"
app:layout_constraintTop_toBottomOf="@+id/resolutionCX" /> app:layout_constraintTop_toBottomOf="@+id/resolutionCX" />
<Switch
android:id="@+id/btnNightMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:text="Night"
app:layout_constraintStart_toEndOf="@+id/btnHdrMode"
app:layout_constraintTop_toBottomOf="@+id/resolutionCX" />
<TextView <TextView
android:id="@+id/textViewExplosure" android:id="@+id/textViewExplosure"
android:layout_width="wrap_content" android:layout_width="wrap_content"

@ -6,6 +6,7 @@ import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager; import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraMetadata; import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.params.StreamConfigurationMap; import android.hardware.camera2.params.StreamConfigurationMap;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.Size; import android.util.Size;
@ -22,6 +23,11 @@ public class CameraUtils {
builder.append("\n"); builder.append("\n");
int idx = 1; int idx = 1;
for (String cameraId : cameraIds) { for (String cameraId : cameraIds) {
builder.append(idx++);
builder.append(": Id=");
builder.append(cameraId);
CameraCharacteristics cameraCharacteristics = null; CameraCharacteristics cameraCharacteristics = null;
try { try {
@ -32,11 +38,7 @@ public class CameraUtils {
if (cameraCharacteristics != null) { if (cameraCharacteristics != null) {
builder.append(idx++);
builder.append(": Id=");
builder.append(cameraId);
builder.append(" facing="); builder.append(" facing=");
Integer facing = cameraCharacteristics.get(CameraCharacteristics.LENS_FACING); Integer facing = cameraCharacteristics.get(CameraCharacteristics.LENS_FACING);
builder.append(facing == null ? "" : facing.toString()); builder.append(facing == null ? "" : facing.toString());
builder.append(" orientation="); builder.append(" orientation=");
@ -44,7 +46,7 @@ public class CameraUtils {
builder.append(orientation == null ? "" : orientation.toString()); builder.append(orientation == null ? "" : orientation.toString());
StreamConfigurationMap map = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); StreamConfigurationMap map = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
Size[] sizes = map.getOutputSizes(ImageFormat.JPEG); Size[] sizes = map.getOutputSizes(ImageFormat.YUV_420_888);
for (int i = 0; i < sizes.length; i++) { for (int i = 0; i < sizes.length; i++) {
Size itemSize = sizes[i]; Size itemSize = sizes[i];

Loading…
Cancel
Save