Skip to content

Distance RC Widget

Cristina Suciu edited this page Dec 23, 2020 · 1 revision

The Distance RC Widget is a Text type of the Base Telemetry Widget. It shows the distance between the current location of the aircraft and the location of the RC (pilot).

Following are the states of the widget.

State Image
Disconnected
Metric Unit System
Imperial Unit System

Usage

If creating the distance RC widget through code it can be added using the convenience method:

- (void)installInViewController:(nullable UIViewController *)viewController

which adds the widget the method is called on, as a subview of the ViewController, that is passed in as an argument. Following this, add constraints to the widget using its widgetSizeHint property to determine width, height and aspect ratio constraints.

If creating the widget through storyboard use the object library to drag a container view controller into the desired view controller like so:

Following this make sure to change the class of the child view controller to be DUXBetaDistanceRCWidget. From here you can create the constraints on the container view using the Telemetry Panel Widget's widgetSizeHint property.

Customizations

The UI elements can be customized to match the style of the user's application. The widget supports all the Text Customizations provided in the Base Telemetry Widget.

State Image
Disconnected
Metric Unit System
Imperial Unit System

Swift Example

distanceRCWidget.backgroundColor = UIColor.white
distanceRCWidget.labelTextColor = UIColor.black
distanceRCWidget.valueTextColor = UIColor.blue
distanceRCWidget.unitTextColor = UIColor.blue

Objective-C Example

distanceRCWidget.backgroundColor = [UIColor whiteColor];
distanceRCWidget.labelTextColor = [UIColor blackColor];
distanceRCWidget.valueTextColor = [UIColor blueColor];
distanceRCWidget.unitTextColor = [UIColor blueColor];

Hooks

The widget provides hooks for the users to add functionality based on the state changes in the widget. The DUXBetaDistanceRCWidget provides the following hooks:

  1. DistanceRCModelState - Provides hooks in events received by the widget from the widget model.
    • public static func productConnected(_ isConnected: Bool) -> DistanceRCModelState - Event when the product is connected or disconnected.
    • public static func distanceRCStateUpdated(_ distanceRCState: DistanceRCState) -> DistanceRCModelState - Event when the distance to RC state is updated.
Clone this wiki locally