Skip to main content

自定义控件

自定义控件相关功能的头文件为 uav_widget.h,本文档描述了 uav_widget.h 文件中结构体和函数原型的关键信息和使用方法。

目录

  • 枚举
    E_UAVWidgetType
    E_UAVWidgetButtonState
    E_UAVWidgetSwitchState

  • 结构体
    T_UavWidgetFileBinaryArray
    T_UavWidgetBinaryArrayConfig
    T_UavWidgetHandlerListItem

  • 函数原型
    UavWidget_Init
    UavWidget_RegDefaultUiConfigByDirPath
    UavWidget_RegUiConfigByDirPath
    UavWidget_RegDefaultUiConfigByBinaryArray
    UavWidget_RegUiConfigByBinaryArray
    UavWidget_RegHandlerList
    UavWidget_RegCommonHandler
    UavWidgetFloatingWindow_ShowMessage

  • Autel Robotics 或基于MSDK 开发的移动端App 浮动窗口可显示的信息最长为255

#define UAV_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN 255

枚举

typedef enum E_UAVWidgetType

控件类型

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

按钮控件状态枚举。

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

开关控件状态枚举。

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

结构体

typedef struct T_UavWidgetFileBinaryArray

二进制数组控件文件

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

开关控件值结构体。

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

typedef struct T_UavWidgetHandlerListItem

滑动条控件值结构体。

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 UavWidget_Init

  • 功能: 初始化自定义控件模块
  • product: all。

使用自定义控件功能时,请先初始化自定义控件模块。

T_UAVReturnCode UavWidget_Init(void);
  • 参数none
  • 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码

function UavWidget_RegDefaultUiConfigByDirPath

  • 功能: 注册配置文件默认的路径
  • product: all。

注册自定义控件配置文件默认的路径。

说明:

  • 仅基于linux 开发的负载设备支持使用本接口;
  • 在Linux 操作系统中可使用UavWidget_RegDefaultConfigByDirPath()和 UavWidget_RegUiConfigByDirPath() 函数设置自定义控件配置文件的路径;
  • 当不需要自定义控件配置支持多语言和适配不同大小的屏幕时,只需使用接口UavWidget_RegDefaultUiConfigByDIrPath()注册控件的配置文件;
  • 当需要支持多语言和适配不同大小屏幕时,需使用接口UavWidget_RegUiConfigByDIrPath()指定特定语言和屏幕大小下的控件配置;若APP语言和屏幕大小没有对应的控件配置,则使用UavWidget_RegDefaultUiConfigByDirPath()注册控件的配置文件。
T_UAVReturnCode UavWidget_RegDefaultUiConfigByDirPath(const char *widgetConfigDirPath);
  • 参数widgetConfigDirPath:自定义控件配置文件的路径
  • 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码

function UavWidget_RegUiConfigByDirPath

  • 功能: 注册配置文件的路径
  • product: all。

注册自定义控件配置文件的路径。

说明:

  • 仅基于linux 开发的负载设备支持使用本接口;
  • 不同语言和屏幕尺寸下的控件配置需要有相同的控件类型,索引和数量。
T_UAVReturnCode UavWidget_RegUiConfigByDirPath(E_UavMobileAppLanguage appLanguage,
E_UavMobileAppScreenType appScreenType,
const char *widgetConfigDirPath);
  • 参数appLanguage:基于MSDK 开发的移动端App 的语言类型appScreenType:终端设备的屏幕类型widgetConfigDirPath:自定义控件配置文件的地址
  • 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码

function UavWidget_RegDefaultUiConfigByBinaryArray

  • 功能: 注册二进制配置文件默认的路径
  • product: all。

通过二进制数组控件文件注册默认控件配置。

说明:

  • 在无文件管理系统的操作系统中(如RTOS),请调用该接口和UavWidget_RegDefaultUiConfigBinaryArray 接口设置设置控件配置参数;
  • 若没有使用UavWidget_RegUiConfigByBinaryArray()注册与系统语言和屏幕大小对应的控件配置信息时,将使用此函数中的配置信息。
T_UAVReturnCode UavWidget_RegDefaultUiConfigByBinaryArray(const T_UavWidgetBinaryArrayConfig *binaryArrayConfig);
  • 参数binaryArrayConfig:二进制数组控件配置文件
  • 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码

function UavWidget_RegUiConfigByBinaryArray

  • 功能: 注册控件配置信息
  • product: all。

通过二进制数组控件文件注册控件配置信息。

说明:

  • 不同语言和屏幕尺寸下的控件配置需要有相同的控件类型,索引和数量。
T_UAVReturnCode UavWidget_RegUiConfigByBinaryArray(E_UavMobileAppLanguage appLanguage,
E_UavMobileAppScreenType appScreenType,
const T_UavWidgetBinaryArrayConfig *binaryArrayConfig);
  • 参数appLanguage:基于MSDK 开发的移动端App 的语言类型appScreenType:终端设备的屏幕类型binaryArrayConfig:二进制数组控件配置文件
  • 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码

function UavWidget_RegHandlerList

  • 功能: 注册处理函数列表
  • product: all。

注册自定义控件处理函数列表。

T_UAVReturnCode UavWidget_RegHandlerList(const T_UavWidgetHandlerListItem *widgetHandlerList, uint32_t itemCount);
  • 参数appLangwidgetHandlerListuage:自定义控件处理函数列表itemCount:列表项数量
  • 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码

function UavWidgetFloatingWindow_ShowMessage

  • 功能: 向移动端App 的浮窗发送消息。
  • product: all。

向 Autel Robotics 或基于MSDK 开发的移动端App 的浮窗发送消息。

T_UAVReturnCode UavWidgetFloatingWindow_ShowMessage(const char *str);
  • 参数str:指向所需向 Autel Robotics 或基于MSDK 开发的移动端App 的浮窗发送的消息
  • 返回值 根据程序执行的情况输出对应的返回值,详情请参见:UAV 错误码