-
Notifications
You must be signed in to change notification settings - Fork 15
Telemetry Panel Widget
The Telemetry Panel Widget is a subclass of Freeform Panel Widget that aggregates important physical state information about the aircraft. It includes the following widgets:
- AGL Altitude
- AMSL Altitude
- Distance Home
- Distance RC
- Horizontal Velocity
- Location
- Vertical Velocity
- VPS
This is a good example of how you can create a self contained Freeform Panel Widget. In the viewDidLoad
subclass implementation, the widget is split into multiple sections as follows:
public override func viewDidLoad() {
super.viewDidLoad()
// Generate panel structure
let rowList = splitPane(rootPane(), along: .vertical, proportions: [0.25, 0.25, 0.25, 0.25])
let columnList1 = splitPane(rowList[1], along: .horizontal, proportions: [0.33, 0.33, 0.33])
let columnList2 = splitPane(rowList[2], along: .horizontal, proportions: [0.33, 0.33, 0.33])
...
}
- (void)viewDidLoad {
[super viewDidLoad];
// Generate panel structure
NSMutableArray *rowList = [self splitPane:0 along:DUXBetaFreeformPanelSplitTypeVertical proportions:@[@0.25, 0.25, 0.25, 0.25]];
NSMutableArray *columnList1 = [self splitPane:rowList[1] along:DUXBetaFreeformPanelSplitTypeHorizontal proportions:@[0.33, 0.33, 0.33]];
NSMutableArray *columnList2 = [self splitPane:rowList[2] along:DUXBetaFreeformPanelSplitTypeHorizontal proportions:@[0.33, 0.33, 0.33]];
...
}
The next step is to add each widget into its corresponding pane by using the following:
public override func viewDidLoad() {
...
var amslAltitudeWidget = DUXBetaAMSLAltitudeWidget()
var amslAltitudeWidgetPaneID = rowList[0]
addWidget(amslAltitudeWidget, toPane: amslAltitudeWidgetPaneID, position: .leading, margins: margins)
...
}
- (void)viewDidLoad {
...
DUXBetaAMSLAltitudeWidget *amslAltitudeWidget = [DUXBetaAMSLAltitudeWidget new];
NSInteger amslAltitudeWidgetPaneID = rowList[0];
[self addWidget:amslAltitudeWidget toPane:amslAltitudeWidgetPaneID position:DUXBetaFreformPanelWidgetAlignmentLeading margins:margins];
...
}
In order to instantiate and use this widget, do the following:
let telemetryPanelWidget = DUXBetaTelemetryPanelWidget()
telemetryPanel.install(in: self)
DUXBetaTelemetryPanelWidget *telemetryPanel = [[DUXBetaTelemetryPanelWidget alloc] init];
[telemetryPanel installInViewController:self];
This widget can be customized to match the style of the user's application by using the customizable methods defined by all the individual widgets and it also supports all the customizations implemented by its superclass Freeform Panel Widget.
This customization was achieved using the following:
let backgroundView = backgroundViewForPane(0)
backgroundView?.backgroundColor = .white
backgroundView?.layer.cornerRadius = 3.0
amslAltitudeWidget.labelTextColor = .black
aglAltitudeWidget.labelTextColor = .black
horizontalVelocityWidget.labelTextColor = .black
distanceHomeWidget.labelTextColor = .black
verticalVelocityWidget.labelTextColor = .black
vpsWidget.labelTextColor = .black
locationWidget.labelTextColor = .black
amslAltitudeWidget.valueTextColor = .blue
aglAltitudeWidget.valueTextColor = .blue
horizontalVelocityWidget.valueTextColor = .blue
distanceHomeWidget.valueTextColor = .blue
verticalVelocityWidget.valueTextColor = .blue
vpsWidget.normalValueColor = .blue
vpsWidget.errorValueColor = .orange
locationWidget.valueTextColor = .blue
amslAltitudeWidget.unitTextColor = .blue
aglAltitudeWidget.unitTextColor = .blue
horizontalVelocityWidget.unitTextColor = .blue
distanceHomeWidget.unitTextColor = .blue
verticalVelocityWidget.unitTextColor = .blue
vpsWidget.unitTextColor = .blue
locationWidget.unitTextColor = .blue
verticalVelocityWidget.downwardImage = UIImage.duxbeta_image(withAssetNamed: "down")
verticalVelocityWidget.upwardImage = UIImage.duxbeta_image(withAssetNamed: "up")
locationWidget.image = UIImage.duxbeta_image(withAssetNamed: "location_custom")
vpsWidget.vpsEnabledImage = UIImage.duxbeta_image(withAssetNamed: "vision_sensor_active")
vpsWidget.vpsDisabledImage = UIImage.duxbeta_image(withAssetNamed: "vision_sensor_active")
distanceRCWidget.view.isHidden = true
UIView *backgroundView = [self backgroundViewForPane:0];
backgroundView.backgroundColor = [UIColor whiteColor];
backgroundView.layer.cornerRadius = 3.0;
amslAltitudeWidget.labelTextColor = [UIColor blackColor];
aglAltitudeWidget.labelTextColor = [UIColor blackColor];
horizontalVelocityWidget.labelTextColor = [UIColor blackColor];
distanceHomeWidget.labelTextColor = [UIColor blackColor];
verticalVelocityWidget.labelTextColor = [UIColor blackColor];
vpsWidget.labelTextColor = [UIColor blackColor];
locationWidget.labelTextColor = [UIColor blackColor];
amslAltitudeWidget.valueTextColor = [UIColor blueColor];
aglAltitudeWidget.valueTextColor = [UIColor blueColor];
horizontalVelocityWidget.valueTextColor = [UIColor blueColor];
distanceHomeWidget.valueTextColor = [UIColor blueColor];
verticalVelocityWidget.valueTextColor = [UIColor blueColor];
vpsWidget.normalValueColor = [UIColor blueColor];
vpsWidget.errorValueColor = [UIColor orangeColor];
locationWidget.valueTextColor = [UIColor blueColor];
amslAltitudeWidget.unitTextColor = [UIColor blueColor];
aglAltitudeWidget.unitTextColor = [UIColor blueColor];
horizontalVelocityWidget.unitTextColor = [UIColor blueColor];
distanceHomeWidget.unitTextColor = [UIColor blueColor];
verticalVelocityWidget.unitTextColor = [UIColor blueColor];
vpsWidget.unitTextColor = [UIColor blueColor];
locationWidget.unitTextColor = [UIColor blueColor];
verticalVelocityWidget.downwardImage = [UIImage duxbeta_imageWithAssetNamed:@"donwn"];
verticalVelocityWidget.upwardImage = [UIImage duxbeta_imageWithAssetNamed:@"up"];
locationWidget.image = [UIImage duxbeta_imageWithAssetNamed:@"location_custom"];
vpsWidget.vpsEnabledImage = [UIImage duxbeta_imageWithAssetNamed:@"vision_sensor_active"];
vpsWidget.vpsDisabledImage = [UIImage duxbeta_imageWithAssetNamed:@"vision_sensor_active"];
distanceRCWidget.view.hidden = YES;
List of the customization APIs
-
var amslAltitudeWidgetPaneID: Int
- ID of the pane containing the AMSL Altitude Widget. -
var aglAltitudeWidgetPaneID: Int
- ID of the pane containing the AGL Altitude Widget. -
var horizontalVelocityWidgetPaneID: Int
- ID of the pane containing the Horizontal Velocity Widget. -
var distanceRCWidgetPaneID: Int
- ID of the pane containing the Distance RC Widget. -
var distanceHomeWidgetPaneID: Int
- ID of the pane containing the Distance Home Widget. -
var verticalVelocityWidgetPaneID: Int
- ID of the pane containing the Vertical Velocity Widget. -
var vpsWidgetPaneID: Int
- ID of the pane containing the VPS Widget. -
var locationWidgetPaneID: Int
- ID of the pane containing the Location Widget.
DJI UX SDK Version 5 Beta 4.1