Add option to turn on the camera torch

Add --camera-torch to turn on the camera torch when the camera starts.

TODO ref 6243.

Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
Tommie
2025-07-20 11:50:16 -04:00
committed by Romain Vimont
parent 8cb601f602
commit 7bbfce9348
11 changed files with 37 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ public class Options {
private CameraAspectRatio cameraAspectRatio;
private int cameraFps;
private boolean cameraHighSpeed;
private boolean cameraTorch;
private boolean showTouches;
private boolean stayAwake;
private int screenOffTimeout = -1;
@@ -176,6 +177,10 @@ public class Options {
return cameraHighSpeed;
}
public boolean getCameraTorch() {
return cameraTorch;
}
public boolean getShowTouches() {
return showTouches;
}
@@ -474,6 +479,9 @@ public class Options {
case "camera_high_speed":
options.cameraHighSpeed = Boolean.parseBoolean(value);
break;
case "camera_torch":
options.cameraTorch = Boolean.parseBoolean(value);
break;
case "new_display":
options.newDisplay = parseNewDisplay(value);
break;

View File

@@ -64,6 +64,7 @@ public class CameraCapture extends SurfaceCapture {
private final Rect crop;
private final Orientation captureOrientation;
private final float angle;
private final boolean initialTorch;
private String cameraId;
private Size captureSize;
@@ -94,6 +95,7 @@ public class CameraCapture extends SurfaceCapture {
this.captureOrientation = options.getCaptureOrientation();
assert captureOrientation != null;
this.angle = options.getAngle();
this.initialTorch = options.getCameraTorch();
}
@Override
@@ -291,6 +293,10 @@ public class CameraCapture extends SurfaceCapture {
if (fps > 0) {
requestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<>(fps, fps));
}
if (initialTorch) {
Ln.i("Turn camera torch on");
requestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_TORCH);
}
CaptureRequest request = requestBuilder.build();
setRepeatingRequest(session, request);