RDA 工模

1、工模GUI如下图:

  注意两个API接口,_APP_Update_Layer()/UpdateNodeFunctionContent()

  这两个接口一个是刷新ListView,另一个刷新ListView对应的TextBox值,后面简称ListView为工模的“键”,对应的TextBox为对应的“值”,即工模为键-值对的组合。

  

  1) 刷新ListView以及TextBox值

static   GUIResult_e _APP_Update_Layer(int NodeId)
{
     GUIResult_e dRet = GUI_SUCCESS;
    int i=0;
    int ChildId = FactoryNode[NodeId].childID;

    if(ChildId==0)
        return dRet;

    // 检查ListView页面节点数
    int NextId =  FactoryNode[ChildId].nextID;
    int count = 1;
    while( (NextId!=0) && (count<FM_ITEMS_PER_PAGE) )
    {
        count ++;
        NextId = FactoryNode[NextId].nextID;
    }

    // 释放键内存
    Fee_LeftSide_List();
    
    // 开辟内存,存储ListView键
    StringList_of_LeftSide = (UINT8 **)malloc( sizeof(UINT8 *) * (FM_ITEMS_PER_PAGE+1) ); // Added 1 for End symbol
    for (i=0; i<=FM_ITEMS_PER_PAGE ; i++)
    {
        StringList_of_LeftSide[i] = (UINT8 *)malloc(sizeof(UINT8) * (MAX_TEXT_LENGTH+1));
        memcpy((void *)StringList_of_LeftSide[i], (void *)&string_last, sizeof(string_last));
    }

    // 清空ListView键
    GUI_FUNC_CALL( GEL_SetParam(g_fmFactorySetting_data, PARAM_STATIC_STRING, pEmptyStrings ) );
    
    // 拷贝页面节点字串,对ListView键赋值
    NextId =  ChildId;
    for(i=0; i<count; i++)
    {
        snprintf((char *)StringList_of_LeftSide[i], MAX_TEXT_LENGTH, "%s", FactoryNode[NextId].szItem);
        NextId = FactoryNode[NextId].nextID;
    }
    // 清空TextBox值
    for(i=0; i<FM_ITEMS_PER_PAGE; i++)
    {
        HWND Item_Handle;
        dRet = GEL_GetHandle(pWindowControl, nItemStart+i, &Item_Handle);
        dRet = GEL_SetParam(Item_Handle, PARAM_STATIC_STRING,String_null);
    }
    //刷新ListView键
    GUI_FUNC_CALL( GEL_SetParam(g_fmFactorySetting_data, PARAM_DYNAMIC_STRING, (void *)StringList_of_LeftSide) );
    GUI_FUNC_CALL( GEL_SetParam(g_fmFactorySetting_data, PARAM_SETNORMAL, 0) );
    //临时刷新TextBox为"-->",具体值由"UpdateNodeFunctionContent"刷新
    for(i=0; i<=FM_ITEMS_PER_PAGE; i++)
    {
        HWND FocusItem_Handle;
        dRet = GEL_GetHandle(pWindowControl, nItemStart+i, &FocusItem_Handle);
        if(i<count)
            dRet = GEL_SetParam(FocusItem_Handle, PARAM_STATIC_STRING, StringRightArrow);
        else
            dRet = GEL_SetParam(FocusItem_Handle, PARAM_STATIC_STRING,String_null);

        GUI_FUNC_CALL( GEL_SetParam(FocusItem_Handle, PARAM_SETNORMAL, NULL) );
        if (i<count)
            GUI_FUNC_CALL( GEL_SetParam(g_fmFactorySetting_data, PARAM_ITEM_ENABLE, &i) );

    }
    //获取页面节点数
    Current_Node_Count = count;
    UpdateNodeFunctionContent(ChildId,0,0);//刷新TextBox值
    return dRet;
}

  2)刷新菜单的Focus/Disable/Item滚动状态

static INT32 _APP_GUIOBJ_FM_FactorySetting_UpdateMenu(void)
{
    GUIResult_e dRet = GUI_SUCCESS;
    INT32 i32Index = 0;
    UINT32 NodeId = ID_ROOT;
    HWND hItem;
    HWND hFocusItem;
    State_e nState = NORMAL_STATE;
    APP_Source_Type_t eSourceType = APP_SOURCE_MAX;
    AL_ServiceDetail_t stServInfo;
    AL_RecHandle_t hProgHdl;
    UINT32 u32ColorSystem = 0;

    APP_GUIOBJ_Source_GetCurrSource(&eSourceType);
    //清除所有Item聚焦
    for(i32Index=nItemStart; i32Index<=nItemEnd; i32Index++)
    {
        dRet = GEL_GetHandle(pWindowControl,i32Index, &hItem);

        // Get state
        GUI_FUNC_CALL( GEL_GetParam(hItem, PARAM_STATE,&nState) );

        if(nState == FOCUS_STATE)
        {
            GUI_FUNC_CALL(GEL_SetAnimEnable(hItem, FALSE));
            GUI_FUNC_CALL( GEL_SetParam(hItem, PARAM_SETNORMAL, NULL));
        }
    }
    //设置特定Item的Disable状态
    if(nowNodeHeadId == ID_FM_Funct_Backlight)
    {
        for(i32Index=0;(int)i32Index<Current_Node_Count;i32Index++)
        {
            NodeId = FactoryNode[nowNodeHeadId].childID + i32Index;
            if(NodeId == ID_FM_Function_BlackLight_CURRENT
                || NodeId == ID_FM_Function_BlackLight_DUTY_VALUE)
            {
                dRet = GEL_SetParam(g_fmFactorySetting_data,PARAM_ITEM_DISABLE, (void*)&i32Index);
                dRet = GEL_GetHandle(pWindowControl, i32Index+nItemStart, &hItem);
                dRet = GEL_SetParam(hItem,PARAM_SETDISABLED, NULL);
            }
            else if(NodeId == ID_FM_Function_BlackLight_DUTY)
            {
                if((1 <= u16preBacklightValue) && (99 >= u16preBacklightValue))
                {
                    dRet = GEL_SetParam(g_fmFactorySetting_data,PARAM_ITEM_DISABLE, (void*)&i32Index);
                    dRet = GEL_GetHandle(pWindowControl, i32Index+nItemStart, &hItem);
                    dRet = GEL_SetParam(hItem,PARAM_SETDISABLED, NULL);
                }
                else
                {
                    dRet = GEL_SetParam(g_fmFactorySetting_data,PARAM_ITEM_ENABLE, (void*)&i32Index);
                    dRet = GEL_GetHandle(pWindowControl, i32Index+nItemStart, &hItem);
                    dRet = GEL_SetParam(hItem,PARAM_SETNORMAL, NULL);
                }    
            }
            else
            {
                dRet = GEL_SetParam(g_fmFactorySetting_data,PARAM_ITEM_ENABLE, (void*)&i32Index);
                dRet = GEL_GetHandle(pWindowControl, i32Index+nItemStart, &hItem);
                dRet = GEL_SetParam(hItem,PARAM_SETNORMAL, NULL);
            }
        }
    }

    // 设置Item的聚焦及滚动
    dRet = GEL_GetParam(g_fmFactorySetting_data, PARAM_CURRENT_INDEX, &i32Index);
    dRet = GEL_SetParam(g_fmFactorySetting_data, PARAM_SETFOCUSED, NULL);
    i32Index +=nItemStart;
    dRet = GEL_GetHandle(pWindowControl, i32Index, &hFocusItem);
    dRet = GEL_SetParam(hFocusItem, PARAM_SETFOCUSED, NULL);

    GUI_FUNC_CALL(GEL_SetAnimEnable(hFocusItem, FALSE)); 
    APP_GuiMgr_RegionBufferControl(&hFocusItem, 1); //设置滚动Item
    GUI_FUNC_CALL(GEL_SetAnimEnable(hFocusItem, TRUE)); 

    GUI_FUNC_CALL( GEL_ShowMenu(pWindow) );
    GUI_FUNC_CALL(GEL_UpdateOSD());

     return (UINT32)dRet;
}

   3)菜单联动显示

    即,当前聚焦的Item发生变化时,其它Item会联动变化,例如:工模调整背光百分比是,当前电流/占空比/PWM寄存器的值是应该跟随变化的

  调用API:    UpdateNodeFunctionContent(ID_FM_Function_BlackLight_Backlight, 0, 0)

  背灯例子:

void Factory_BackLight(BOOL bSet, BOOL path, FUNCTION_DATA *pValue, BOOL bDefault)
{
    FUNCTION_DATA * FuncData = (FUNCTION_DATA *)pValue;    
    Backlight_t BacklightSetting;
    BacklightSetting.Backlight_total_Stage = 100;    
    static char dutyBuff[10];
    INT16 u16Pwm = 0;
    UINT32 mapValue= 0;
    if (bSet)
    {
        //调整Backlight(OSD)的值
        u16Pwm= AL_FLASH_GetBackLight();
        if (gbIsFMRightKey == TRUE)
        {
            u16Pwm = (++u16Pwm>=100)?100:u16Pwm;

        }
        else if (gbIsFMLeftKey == TRUE)
        {
            u16Pwm = (--u16Pwm<=0)?0:u16Pwm;
        }
        AL_FLASH_SetBackLight(u16Pwm);        
        BacklightSetting.OSD_backlight_index = u16Pwm;
        //设置Backlight
        Cmd_SetLcdBackLight(BacklightSetting);
        mapValue = CONFIG_DEFAULT_PWM_REG_MAX - (CONFIG_DEFAULT_PWM_REG_MAX - CONFIG_DEFAULT_PWM_REG_MIN)*BacklightSetting.OSD_backlight_index / BacklightSetting.Backlight_total_Stage;
        sprintf(dutyBuff,"%d - reg[%d]",u16Pwm,mapValue);
        //Backlight 显示
        Update_TypeVersion_Node(dutyBuff, FuncData->nItem);
        MID_TVFE_GetCurrDutyPWM((short unsigned int *)&(u16DutyPWM));
        //联动Item  Duty/Current/Duty Value 跟随变化,刷新包含Backlight后面的各个节点
        UpdateNodeFunctionContent(ID_FM_Function_BlackLight_Backlight, 0, 0);
    }
    else
    {
        mapValue = CONFIG_DEFAULT_PWM_REG_MAX - (CONFIG_DEFAULT_PWM_REG_MAX - CONFIG_DEFAULT_PWM_REG_MIN)*AL_FLASH_GetBackLight() / BacklightSetting.Backlight_total_Stage;
        sprintf(dutyBuff,"%d - reg[%d]",(INT32)AL_FLASH_GetBackLight(),mapValue);
        Update_TypeVersion_Node((char * ) dutyBuff, FuncData->nItem);
    }    
}

   接口介绍:

static GUIResult_e UpdateNodeFunctionContent(int NodeId,UINT32 u32CurrentIndex,UINT32 dEventID)
{
    GUIResult_e dRet = GUI_SUCCESS ;
    NODE_FUNCTION * pFunc;
    FUNCTION_DATA FuncData;
    HWND FocusItem_Handle;
    dRet = GEL_GetHandle(pWindowControl, u32CurrentIndex+nItemStart, &FocusItem_Handle);
    UINT32 tmp=u32CurrentIndex;

    gbIsFMRightKey = (UI_EVENT_RIGHT == dEventID) ? TRUE : FALSE;
    gbIsFMLeftKey = (UI_EVENT_LEFT == dEventID) ? TRUE : FALSE;
    
    //迭代需要刷新的TextBox节点
    for(u32CurrentIndex=0; (int)u32CurrentIndex< Current_Node_Count; u32CurrentIndex++)
    {
        if(dEventID!=0)
        u32CurrentIndex = tmp;
        dRet = GEL_GetHandle(pWindowControl, u32CurrentIndex+nItemStart, &FocusItem_Handle);

        UINT32 nCurrNodeId = NodeId+ u32CurrentIndex;//nowNodeHeadId + u32CurrentIndex ;
        nowNodeId = nCurrNodeId;
        pFunc = FactoryNode[nCurrNodeId].pThis;
        
        //如果节点有回调,通过回调获取节点的值
        if(pFunc != NULL)
        {
            if(pFunc->type  == MENU_CTRL_TYPE_SLIDER)
            {
                if (pFunc->MenuSettingFun)
                    (pFunc->MenuSettingFun)(FALSE, 0, (FUNCTION_DATA*)&FuncData, FALSE);

            }
            else if(pFunc->type  == MENU_CTRL_TYPE_RADIOBUTTON)
            {
                FACT_RADIOBTN *pRad;
                if (pFunc->leaves)
                {
                    FuncData.nItem = 0;
                    FuncData.value = 0;
                    if (pFunc->MenuSettingFun)
                    {
                        (pFunc->MenuSettingFun)(FALSE,0, (FUNCTION_DATA*)&FuncData, FALSE);
                    }
                }
            }
            else if(pFunc->type  == MENU_CTRL_TYPE_PUSHBUTTON )
            {
                if (pFunc->MenuSettingFun)
                {
                    if( dEventID==UI_EVENT_RIGHT|| dEventID==UI_EVENT_ENTER )
                    (*pFunc->MenuSettingFun)(TRUE, 0, &FuncData, FALSE);//注意形参TRUE,为设置节点的值
                    else
                    (*pFunc->MenuSettingFun)(FALSE, 0, &FuncData, FALSE);//注意形参FALSE,为获取
                }
            }
            else if( MENU_CTRL_TYPE_VERSION == pFunc->type )
            {
                FuncData.nItem = u32CurrentIndex;
                if (pFunc->MenuSettingFun)
                {
                    if( dEventID==UI_EVENT_RIGHT|| dEventID==UI_EVENT_ENTER)
                        (pFunc->MenuSettingFun)(TRUE,/* MAIN*/ 0, &FuncData, FALSE); 
                    else
                        (pFunc->MenuSettingFun)(FALSE,/* MAIN*/ 0, &FuncData, FALSE); 
                }

            }
            else if(MENU_CTRL_TYPE_GROUPSTATICSTRINGS == pFunc->type)
            {
                if (pFunc->MenuSettingFun)
                {
                    (pFunc->MenuSettingFun)(FALSE,/* MAIN*/ 0, &FuncData, FALSE); // Get Value from UMF
                }
            }
            else if(MENU_CTRL_TYPE_DAYNAMICSTRING == pFunc->type)
            {
                FuncData.nItem = u32CurrentIndex;
                if (pFunc->MenuSettingFun)
                {
                    if((dEventID == UI_EVENT_RIGHT) || (dEventID == UI_EVENT_LEFT))
                    {
                        (pFunc->MenuSettingFun)(TRUE, 0, &FuncData, FALSE);
                    }
                    else
                    {
                        (pFunc->MenuSettingFun)(FALSE, 0, &FuncData, FALSE);
                    }
                }        

            }
        }
        else
        {
            if(UI_EVENT_RIGHT == dEventID)
            {
                dRet = Enter_Behavior();
            }
            else
            {
                GUI_FUNC_CALL(GEL_SendMsg(FocusItem_Handle, WM_PAINT, 0));
            }
        }

        if(dEventID!=0)
        break;
    }
    return dRet;
}
原文地址:https://www.cnblogs.com/jiangzhaowei/p/7358465.html