Skip to main content

Custom Widget

The header file for custom widget-related functions is uav_widget.h. This document describes the key information and usage of the structures and function prototypes in the uav_widget.h file.

Content

  • Enum
    E_UAVWidgetType
    E_UAVWidgetButtonState
    E_UAVWidgetSwitchState

  • Structures
    T_UavWidgetFileBinaryArray
    T_UavWidgetBinaryArrayConfig
    T_UavWidgetHandlerListItem

  • Function Prototype
    UavWidget_Init
    UavWidget_RegDefaultUiConfigByDirPath
    UavWidget_RegUiConfigByDirPath
    UavWidget_RegDefaultUiConfigByBinaryArray
    UavWidget_RegUiConfigByBinaryArray
    UavWidget_RegHandlerList
    UavWidget_RegCommonHandler
    UavWidgetFloatingWindow_ShowMessage

  • The floating window in Autel Robotics mobile apps or MSDK-based apps can display up to 255 characters

#define UAV_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN 255

Enum

typedef enum E_UAVWidgetType

Widget type

typedef enum {
UAV_WIDGET_TYPE_UNKNOWN = 0,
UAV_WIDGET_TYPE_BUTTON = 1, /* button widget type */
UAV_WIDGET_TYPE_SWITCH = 2, /* switch widget type */
UAV_WIDGET_TYPE_SCALE = 3, /* scale widget type */
UAV_WIDGET_TYPE_LIST = 4, /* list widget type */
UAV_WIDGET_TYPE_INT_INPUT_BOX = 5, /* integer input box widget type */
}E_UAVWidgetType;

typedef enum E_UAVWidgetButtonState

Widget button state enumeration.

typedef enum {
UAV_WIDGET_BUTTON_STATE_UP = 0, /* button widget up state */
UAV_WIDGET_BUTTON_STATE_DOWN = 1, /* button widget press down state */
}E_UAVWidgetButtonState;

typedef enum E_UAVWidgetSwitchState

Switch widget state enumeration.

typedef enum {
UAV_WIDGET_SWITCH_STATE_OFF = 0, /* switch widget off state */
UAV_WIDGET_SWITCH_STATE_ON = 1, /* switch widget on state */
}E_UAVWidgetSwitchState;

Structures

typedef struct T_UavWidgetFileBinaryArray

Binary array widget file

typedef struct {
char *fileName; /*!< The file name of the widget file */
uint32_t fileSize; /*!< The file size of the widget file, uint : byte */
const uint8_t *fileBinaryArray; /*!< The binary C array of the widget file */
} T_UavWidgetFileBinaryArray;

typedef struct T_UavWidgetBinaryArrayConfig

Switch widget value structure.

typedef struct {
uint16_t binaryArrayCount; /*!< Binary array count. */
T_UavWidgetFileBinaryArray *fileBinaryArrayList; /*!< Pointer to binary array list */
} T_UavWidgetBinaryArrayConfig;

typedef struct T_UavWidgetHandlerListItem

Slider widget value structure.

typedef struct {
/*! The index of widget, the index can be numbered starting from 0 and cannot be repeated */
uint32_t widgetIndex;

/*! The type of widget, refer to ::E_UavWidgetType */
E_UAVWidgetType widgetType;

/**
* @brief Prototype of callback function used to set widget value, the function will be call when the user triggers
* the widget.
* @param widgetType: the type of widget, refer to ::E_UavWidgetType.
* @param index: the index of widget.
* @param value: the value of widget, need be set.
* if the widget type is UAV_WIDGET_TYPE_BUTTON, the value is refer to ::E_UavWidgetButtonState;
* if the widget type is UAV_WIDGET_TYPE_SWITCH, the value is refer to ::E_UavWidgetSwitchState;
* if the widget type is UAV_WIDGET_TYPE_SCALE, the value is range from 0 to 100, which represents the percentage
* of the scale slider;
* if the Widget type is UAV_WIDGET_TYPE_LIST, the value is range from 0 to N-1 (N is the value of list item
* count), which represents which item is chosen;
* if the widget type is UAV_WIDGET_TYPE_INT_INPUT_BOX, the value is the input value of int input box widget.
* @param userData: the user data need used in callback.
* @return Execution result.
*/
T_UAVReturnCode (*SetWidgetValue)(E_UAVWidgetType widgetType, uint32_t index, int32_t value, void *userData);

/**
* @brief Prototype of callback function used to get widget value.
* @param widgetType: the type of widget, refer to ::E_UavWidgetType.
* @param index
* @param value: the value of widget, need be set.
* if the widget type is UAV_WIDGET_TYPE_BUTTON, the value is refer to ::E_UavWidgetButtonState;
* if the widget type is UAV_WIDGET_TYPE_SWITCH, the value is refer to ::E_UavWidgetSwitchState;
* if the widget type is UAV_WIDGET_TYPE_SCALE, the value is range from 0 to 100, which represents the percentage
* of the scale slider;
* if the Widget type is UAV_WIDGET_TYPE_LIST, the value is range from 0 to N-1 (N is the value of list item
* count), which represents which item is chosen;
* if the widget type is UAV_WIDGET_TYPE_INT_INPUT_BOX, the value is the input value of int input box widget.
* @param userData: the user data need used in callback function.
* @return Execution result.
*/
T_UAVReturnCode (*GetWidgetValue)(E_UAVWidgetType widgetType, uint32_t index, int32_t *value, void *userData);

/*! the user data need used in SetWidgetValue and GetWidgetValue callback function. */
void *userData;
} T_UavWidgetHandlerListItem;

Function Prototype

function UavWidget_Init

  • Function: Initialize the custom widget module
  • Product: All.

Before using the custom widget features, please initialize the custom widget module.

T_UAVReturnCode UavWidget_Init(void);
  • Parameternone
  • Return code The corresponding return code is output based on the program execution. For details, please refer to: UAV Error Codes.

function UavWidget_RegDefaultUiConfigByDirPath

  • Function: Register the default configuration file directory path
  • Product: All.

Register the default custom widget configuration file directory path.

Note:

  • This interface is only supported by payloads developed based on Linux.
  • In Linux systems, the functions UavWidget_RegDefaultConfigByDirPath() and UavWidget_RegUiConfigByDirPath() can be used to set the directory path for custom widget configuration files.
  • If multi-language support and screen size adaptation are not required, you only need to use UavWidget_RegDefaultUiConfigByDirPath() to register the widget configuration file.
  • If multi-language support and screen size adaptation are required, use UavWidget_RegUiConfigByDirPath() to specify the widget configuration for a particular language and screen size. If no corresponding configuration is found for the app’s language and screen size, the configuration registered via UavWidget_RegDefaultUiConfigByDirPath() will be used as a fallback.
T_UAVReturnCode UavWidget_RegDefaultUiConfigByDirPath(const char *widgetConfigDirPath);
  • ParameterwidgetConfigDirPath: the custom widget configuration file directory path
  • Return code The corresponding return code is output based on the program execution. For details, please refer to: UAV Error Codes.

function UavWidget_RegUiConfigByDirPath

  • Function: Register the configuration file directory path
  • Product: All.

Register the custom widget configuration file directory path.

Note:

  • This interface is supported only by payloads developed based on Linux,
  • The widget configurations for different languages and screen sizes must have the same widget types, indexes, and quantities.
T_UAVReturnCode UavWidget_RegUiConfigByDirPath(E_UavMobileAppLanguage appLanguage,
E_UavMobileAppScreenType appScreenType,
const char *widgetConfigDirPath);
  • ParameterappLanguage: the language type of the mobile app developed based on MSDKappScreenType: the screen type of the terminal devicewidgetConfigDirPath: the custom widget configuration file directory path
  • Return code The corresponding return code is output based on the program execution. For details, please refer to: UAV Erro Codes.

function UavWidget_RegDefaultUiConfigByBinaryArray

  • Function: Register the default binary configuration file directory path
  • Product: All.

Register the default widget configuration using a binary array widget file.

Note:

  • In operating systems without a file management system (such as RTOS), please use this interface together with UavWidget_RegDefaultUiConfigBinaryArray() to set the widget configuration parameters.
  • If UavWidget_RegUiConfigByBinaryArray() is not used to register the widget configuration corresponding to the system language and screen size, the configuration provided by this function will be used as a fallback.
T_UAVReturnCode UavWidget_RegDefaultUiConfigByBinaryArray(const T_UavWidgetBinaryArrayConfig *binaryArrayConfig);
  • ParameterbinaryArrayConfig: binary array widget configuration file
  • Return code The corresponding return code is output based on the program execution. For details, please refer to: UAV Error Codes.

function UavWidget_RegUiConfigByBinaryArray

  • Function: Register widget configuration information
  • Product: All.

Register widget configuration information using a binary array widget file.

Note:

  • The widget configurations for different languages and screen sizes must have the same widget types, indexes, and quantities.
T_UAVReturnCode UavWidget_RegUiConfigByBinaryArray(E_UavMobileAppLanguage appLanguage,
E_UavMobileAppScreenType appScreenType,
const T_UavWidgetBinaryArrayConfig *binaryArrayConfig);
  • Parameter

    appLanguage: the language type of the mobile app developed based on MSDKappScreenType: the screen type of the terminal devicebinaryArrayConfig: binary array widget configuration file
  • Return code The corresponding return code is output based on the program execution. For details, please refer to:

    UAV Error Codes.

function UavWidget_RegHandlerList

  • Function: Register the handler list
  • Product: All.

Register the handler list for custom widget.

T_UAVReturnCode UavWidget_RegHandlerList(const T_UavWidgetHandlerListItem *widgetHandlerList, uint32_t itemCount);
  • Parameter

    appLangwidgetHandlerListuage: handler list for custom widgetsitemCount: number of items in the list
  • Return code The corresponding return code is output based on the program execution. For details, please refer to:

    UAV Error Codes.

function UavWidgetFloatingWindow_ShowMessage

  • Function: Send a message to the floating window of the mobile app.
  • Product: All.

Send a message to the floating window of the Autel Robotics mobile app or a mobile app developed based on MSDK.

T_UAVReturnCode UavWidgetFloatingWindow_ShowMessage(const char *str);
  • Parameter

    str: Pointer to the message to be sent to the floating window of the Autel Robotics mobile app or a mobile app developed based on MSDK
  • Return code The corresponding return code is output based on the program execution. For details, please refer to:

    UAV Error Codes.