mavlink-camera-manager icon indicating copy to clipboard operation
mavlink-camera-manager copied to clipboard

Suggestion: Control components extend basic control type

Open rafaellehmkuhl opened this issue 2 years ago • 0 comments

Today, the structure (typescript version) of the controls are something like this:

export interface V4LMenuOption {
  name: string
  value: number
}

export interface V4LMenu {
  default: number
  value: number
  options: V4LMenuOption
}

export interface V4LBool {
  default: number
  value: number
}

export interface V4LSlider {
  default: number
  max: number
  min: number
  step: number
  value: number
}

export interface V4LConfiguration {
  Slider?: V4LSlider
  Menu?: V4LMenu
  Bool?: V4LBool
}

export interface V4LControl {
  configuration: V4LConfiguration
  cpp_type: string
  id: number
  name: string
}

The problem with this structure is that we have to check if the component we want (slider, menu or bool) actually exist before consuming it.

if (control.configuration.Slider !== undefined) {
  # use slider data
}

A suggestion would be to remove the V4LConfiguration and make Slider, Menu and Bool extend from V4LControl.

rafaellehmkuhl avatar Sep 10 '21 19:09 rafaellehmkuhl