Add resources and menu learning notes for MTK Development

Source: Internet
Author: User

MTK DevelopmentAdd resources andMenuLearning notes are the content to be introduced in this article, mainly to understandMTK DevelopmentSome of the operations in this section are an article published on the Alibaba Cloud website. Here, I would like to share with you.

By following this process, you can clearly clarify how to add resources andMenuTo know why. The following code is carried out on the 6235 platform. The code names of other platforms may be different. For details about how to add the code, refer to the writing of other code in the same file. In factMTKThe code needs to be modified very little, that is, to add in it. If you do not know how to add it, refer to the internal code.

Step 1: Add a program file. Assume that the program name you write is MyApp.

You need to add: MyAppProt. h (used to store all function declarations of this program, this header file is only loaded by the source files of this Program)

MyAppDefs. h is used to store some common resource ID definitions of this program)

MyAppTypes. h is used to store the types, structures, and constant definitions required by the program)

MyAppGprot. h is also used to store the function declaration, but this header file is loaded by other programs, that is, all declarations in this file are external interfaces)

Of course, there is also the source file my‑rc. c.

Note: These header files are generally placed under plutommi/MMI/MyApp/MyAppInc to facilitate code management.

Step 2: add files to the Project

The three files under make/plutommi/need to be modified

1. source file to be compiled by plutommilis

2. plutommiinc indicates the directory where the header file is located.

3. plutommipth indicates the directory where the source file is located.

Step 3: PROGRAM switch:

The compilation switch of MMI is generally placed in plutommi/customer/custResource/PLUTO_MMI/MMI_features_switchPLUTO.h.

Add as follows: # define _ MMI_MYAPP _ (_ ON _)

After the above Code is added, # ifdef _ MMI_MYAPP _ in other files _

 
 
  1. .............  
  2. .............  
  3. #endif 

The code is compiled.

Step 4: add an ID for the resource

After completing the above three steps, the next step is to add the ID, there are many types of resources, so there are some different ways to add the ID

1) Add the basic ID.

Before adding IDs, you must add a basic ID for this program, because the resource IDs of all programs are defined separately, but these IDs cannot conflict with each other, because each type of resource ID is in a value space), we need the basic ID to isolate the ID values of each program. The basic ID defines a range for a type of resource, unified Definition in plutommi/MMI/INC/MMIDataType. h Medium

For details, refer to the two macro definitions.

 
 
  1. /*  
  2.  * Use this macro two to declare resource id range between RESOURCE_BASE_ENUM_BEGIN()  
  3.  * and RESOURCE_BASE_ENUM_END()  
  4.  */  
  5. #define RESOURCE_BASE_RANGE(ap_id, count)/  
  6. ap_id,   /  
  7. GET_RESOURCE_BASE(ap_id) = ap_id,/  
  8. GET_RESOURCE_MAX(ap_id) = ap_id + count - 1  
  9.  
  10. /*  
  11.  * Use these tow macro to get the resource base and resource end  
  12.  */  
  13. #define GET_RESOURCE_BASE(id)   RESOURCE_BASE_##id  
  14. #define GET_RESOURCE_MAX(id)RESOURCE_BASE_##id##_END 

In this way, you can set the resource ID range by using the RESOURCE_BASE_RANGE (ap_id, count) statement,

 
 
  1. At the same time, GET_RESOURCE_BASE (ap_id) pays the ap_id to RESOURCE_BASE _ # id,

Finally, use a similar statement.

 
 
  1. #define MYAPP_BASE     
  2. ((U16)GET_RESOURCE_BASE(MYAPP)) 

The RESOURCE_BASE _ # id is paid to MYAPP_BASE.

Then, two types of code are added. One is to determine the resource ID range, and the other is to assign the range address to the ID of MYAPP_BASE.

2) Add the screen ID, that is, the screen serial number)

After adding the basic ID, we can use the basic ID to add our screen ID, which is defined in MYAPPDefs. h.

 
 
  1. typedef enum{  
  2. SCR_MYAPP-MAIN=MYAPP_BASE+1,  
  3. }SCREENID_LIST_MYAPP 

3) Add the string ID

The basic ID is also defined in MYAPPDefs. h.

 
 
  1. typedef enum  
  2. {  
  3. STR_MYAPP_HELLO = MYAPP_BASE + 1,  
  4. }STRINGID_LIST_MYAPP; 

4) add image ID

Same as above

5) Add a menu item ID

This is quite special. It is defined in plutommi/MMI/inc/GlobalMenuItems. h.

Step 5: Load Resources

The IDS and resources are defined in the above four steps. Now we need to load them to associate them.

1) loading of the main menu and level-1 menu

You need to modify and add in Res_MainMenu.c, which is prone to errors. Because multiple locations are prone to errors, you must first define the enumerated variable in the front of the file and then call the ADD_APPLICATION_MENUITEM function in void PopulateMainMenuRes (void.

2) loading of other menu items, string loading, and image loading

All are loaded in the populateMyAppRes function in plutommi/customer/custresource/pluto_mmi/res_mmi/Res_MyApp.c.

Note: The populateMyAppRes function is called by populateresdata( (, and populateresdate() under plutommi/MMI/Resource/populateres.c when mtk_resgenerator.exe is executed. This is the pre-compilation sequence of resource loading.

Step 6: Interaction

In the PlatformMenuActions of items areMenuItem control, the system does is to send a notification when this item is highlighted. Therefore, when each menu item is started, it notifies the system which function is used to receive the notification. SetHiliteHandler is used to do this. The first parameter is the menu item ID, the second parameter is the function pointer for receiving notifications. We usually create an initialization function for each program. This function runs only once at startup, for example, mmi_myapp_init. In this function, we will register all menu items of this program. Mmi_myapp_init is usually called in MMITask. c.

 
 
  1. For example: # ifdef _ MMI_MYAPP _
  2. # Include "MyAppGprot. h"
  3. # Endif
  4. Void InitAllApplication ()
  5. {
  6. # Ifdef _ MMI_MYAPP _
  7. Mmi_myapp_init ();
  8. # Endif
  9. }

The following is an implementation in my‑rc. c:

 
 
  1. void mmi_myapp_init(void)  
  2. {  
  3. SetHiliteHandler(MENU_ID_MYAPP_PRINT, mmi_myapp_hilite_print);  
  4. }  
  5. void mmi_myapp_hilite_print(void)  
  6. {  
  7.  SetLeftSoftkeyFunction(mmi_myapp_print_entry,KEY_EVENT_UP);  
  8. }  
  9. void mmi_myapp_print_entry(void)  
  10. {  
  11. .................  

Through the above six steps, various resources are basically defined and loaded. If you still don't understand it, you can contact my blog.

Summary:MTK DevelopmentAdd resources andMenuThe content of the study notes has been introduced. I hope this article will help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.