Widget

2023-03-29
No Rating

The header file for custom control related functions is dji_widget.h. This document describes the key information and usage of the structure and function prototypes in the dji_widget.h file.

Catalog

#define DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN         255

Enum

typedef enum E_DjiWidgetType

typedef enum {
    DJI_WIDGET_TYPE_BUTTON = 1, /*!< button widget type */
    DJI_WIDGET_TYPE_SWITCH = 2, /*!< switch widget type */
    DJI_WIDGET_TYPE_SCALE = 3, /*!< scale widget type */
    DJI_WIDGET_TYPE_LIST = 4, /*!< list widget type */
    DJI_WIDGET_TYPE_INT_INPUT_BOX = 5, /*!< integer input box widget type */
} E_DjiWidgetType;

typedef enum E_DjiWidgetButtonState

typedef enum {
    DJI_WIDGET_BUTTON_STATE_PRESS_DOWN = 1, /*!< Button is pressed down */
    DJI_WIDGET_BUTTON_STATE_RELEASE_UP = 0, /*!< Button is released up */
} E_DjiWidgetButtonState;

typedef enum E_DjiWidgetSwitchState

typedef enum {
    DJI_WIDGET_SWITCH_STATE_OFF = 0, /*!< Switch is turned off */
    DJI_WIDGET_SWITCH_STATE_ON = 1 /*!< Switch is turned on */
} E_DjiWidgetSwitchState;

Struct

typedef struct T_DjiWidgetFileBinaryArray

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_DjiWidgetFileBinaryArray;

typedef struct T_DjiWidgetBinaryArrayConfig

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

typedef struct T_DjiWidgetHandlerListItem

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_DjiWidgetType */
    E_DjiWidgetType 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_DjiWidgetType.
     * @param index: the index of widget.
     * @param value: the value of widget, need be set.
     * if the widget type is DJI_WIDGET_TYPE_BUTTON, the value is refer to ::E_DjiWidgetButtonState;
     * if the widget type is DJI_WIDGET_TYPE_SWITCH, the value is refer to ::E_DjiWidgetSwitchState;
     * if the widget type is DJI_WIDGET_TYPE_SCALE, the value is range from 0 to 100, which represents the percentage
     * of the scale slider;
     * if the Widget type is DJI_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 DJI_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_DjiReturnCode (*SetWidgetValue)(E_DjiWidgetType 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_DjiWidgetType.
     * @param index
     * @param value: the value of widget, need be set.
     * if the widget type is DJI_WIDGET_TYPE_BUTTON, the value is refer to ::E_DjiWidgetButtonState;
     * if the widget type is DJI_WIDGET_TYPE_SWITCH, the value is refer to ::E_DjiWidgetSwitchState;
     * if the widget type is DJI_WIDGET_TYPE_SCALE, the value is range from 0 to 100, which represents the percentage
     * of the scale slider;
     * if the Widget type is DJI_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 DJI_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_DjiReturnCode (*GetWidgetValue)(E_DjiWidgetType widgetType, uint32_t index, int32_t *value, void *userData);

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

Function

function DjiWidget_Init

Function:Initialise widget module product:all
T_DjiReturnCode DjiWidget_Init(void);


Return
The details for the return code please refer to: DjiErrorCode

function DjiWidget_RegDefaultUiConfigByDirPath

Function:Register default widget UI configuration file directory path.product:all
T_DjiReturnCode DjiWidget_RegDefaultUiConfigByDirPath(const char *widgetConfigDirPath);
Parameter
widgetConfigDirPath:the widget UI configuration directory path.
Return
The details for the return code please refer to: DjiErrorCode

function DjiWidget_RegUiConfigByDirPath

Function:Register widget UI configuration file directory path. product:all
T_DjiReturnCode DjiWidget_RegUiConfigByDirPath(E_DjiMobileAppLanguage appLanguage,
                                               E_DjiMobileAppScreenType appScreenType,
                                               const char *widgetConfigDirPath);
Parameter
appLanguage:mobile app language type.
appScreenType:mobile app screen type.
widgetConfigDirPath:the widget UI configuration directory path.
Return
The details for the return code please refer to: DjiErrorCode

function DjiWidget_RegDefaultUiConfigByBinaryArray

Function:Register default widget UI config by binary array configuration. product:all
T_DjiReturnCode DjiWidget_RegDefaultUiConfigByBinaryArray(const T_DjiWidgetBinaryArrayConfig *binaryArrayConfig);
Parameter
binaryArrayConfig: * @param binaryArrayConfig:
Return
The details for the return code please refer to: DjiErrorCode

function DjiWidget_RegUiConfigByBinaryArray

Function:Register widget UI config by binary array configuration. product:all
T_DjiReturnCode DjiWidget_RegUiConfigByBinaryArray(E_DjiMobileAppLanguage appLanguage,
                                                   E_DjiMobileAppScreenType screenType,
                                                   const T_DjiWidgetBinaryArrayConfig *binaryArrayConfig);
Parameter
appLanguage:mobile app language type.
screenType:mobile app screen type.
binaryArrayConfig:the binary array config for widget UI configuration.
Return
The details for the return code please refer to: DjiErrorCode

function DjiWidget_RegHandlerList

Function:Register handler list for widgets. product:all
T_DjiReturnCode DjiWidget_RegHandlerList(const T_DjiWidgetHandlerListItem *widgetHandlerList, uint32_t itemCount);
Parameter
widgetHandlerList:widget handler list for widgets.
itemCount:the item count of widget handler list.
Return
The details for the return code please refer to: DjiErrorCode

function PsdkWidgetFloatingWindow_ShowMessage

Function:Send message to mobile app floating window. product:all
T_DjiReturnCode DjiWidgetFloatingWindow_ShowMessage(const char *str);
Parameter
str:pointer to message string.
Return
The details for the return code please refer to: DjiErrorCode

function PsdkWidgetFloatingWindow_GetChannelState

Function:Get data transmission state of floating window channel. User can use the state as base for controlling floating windows message send. product:all
T_DjiReturnCode DjiWidgetFloatingWindow_GetChannelState(T_DjiDataChannelState *state);
Parameter
state:pointer to floating window channel state.
Return
The details for the return code please refer to: DjiErrorCode
If you have any comments or confusion about our documentation, you can click here to give feedback and we will get back to you as soon as possible.