Skip to content

Commit

Permalink
Dev - camera controls (#129)
Browse files Browse the repository at this point in the history
- Need to fix autofocus
- Need to fix number of requests sent per second
- Need to maintain state for settings panel
Never again will I use the dart vscode plugin.

---------

Co-authored-by: AndyZ54 <[email protected]>
Co-authored-by: Levi Lesches <[email protected]>
Co-authored-by: aidan ahram <[email protected]>
  • Loading branch information
4 people authored May 22, 2024
1 parent 60f8dd4 commit a1795c2
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 75 deletions.
7 changes: 4 additions & 3 deletions lib/src/models/data/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ class VideoModel extends Model {
}

/// Updates settings for the given camera.
Future<void> updateCamera(String id, CameraDetails details) async {
Future<void> updateCamera(String id, CameraDetails details, {bool verify = true}) async {
_handshake = null;
final command = VideoCommand(id: id, details: details);
models.sockets.video.sendMessage(command);
if (!verify) return;
await Future<void>.delayed(const Duration(seconds: 2));
if (_handshake == null) throw RequestNotAccepted();
}
Expand All @@ -144,11 +145,11 @@ class VideoModel extends Model {
text: "Could not ${enable ? 'enable' : 'disable'} the ${name.humanName} camera",
);
}
}
}
}

/// An exception thrown when the rover does not respond to a handshake.
///
///
/// Certain changes require a handshake to ensure the rover has received and applied the change.
/// If the rover fails to acknowledge or apply the change, a response will not be sent. Throw
/// this error to indicate that.
Expand Down
16 changes: 13 additions & 3 deletions lib/src/models/view/builders/video_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ class CameraDetailsBuilder extends ValueBuilder<CameraDetails> {
/// Whether changes are loading.
bool isLoading = false;

/// The error that occurrec when changing these settings, if any.
/// The error that occurred when changing these settings, if any.
String? error;

/// Current status of the camera's autofocus
bool autofocus = true;

@override
List<ValueBuilder<dynamic>> get otherBuilders => [resolutionHeight, resolutionWidth, quality, fps];

Expand All @@ -45,7 +48,8 @@ class CameraDetailsBuilder extends ValueBuilder<CameraDetails> {
quality = NumberBuilder(data.quality, min: 0, max: 100),
fps = NumberBuilder(data.fps, min: 0, max: 60),
name = data.name,
status = CameraStatus.CAMERA_ENABLED;
status = CameraStatus.CAMERA_ENABLED,
autofocus = data.autofocus;

@override
bool get isValid => resolutionHeight.isValid
Expand All @@ -54,14 +58,20 @@ class CameraDetailsBuilder extends ValueBuilder<CameraDetails> {
&& fps.isValid
&& okStatuses.contains(status);

@override

@override
CameraDetails get value => CameraDetails(
resolutionHeight: resolutionHeight.value,
resolutionWidth: resolutionWidth.value,
quality: quality.value,
fps: fps.value,
name: name,
status: status,
focus: 0,
zoom: 100,
pan: 0,
tilt: 0,
autofocus: true,
);

/// Updates the [status] field.
Expand Down
Loading

0 comments on commit a1795c2

Please sign in to comment.