Step 11: Include Application Specific Source Code and Files
1
The following application files have been developed for this lab:
- app_sdcard_audio_task.c
- app_sdcard_audio_task.h
- app_display_task.c
- app_display_task.h
- decoder.c
- decoder.h
- app_audio_player_gui.h
Copy these files from the dev_files folder
apps/training/middleware/emwin_media_player/emwin_media_player_lab/dev_files
and paste into the folder
apps/training/middleware/dev/emwin_media_player/emwin_media_player_lab/firmware/src.
2
The below files were generated by the GUIBuilder utility. These files have been modified and contain application code to handle widget events and custom rendering of widgets.
- emwin_gui/audio_playerDLG.c
- emwin_gui/settings_windowDLG.c
Copy these files from the dev_files/emwin_gui folder
apps/training/middleware/emwin_media_player/emwin_media_player_lab/dev_files/emwin_gui
and paste into the folder
apps/training/middleware/dev/emwin_media_player/emwin_media_player_lab/firmware/src/emwin_gui
3
The below files are the image assets saved as C files by the BmpCvt utility. These files are not modified to contain application code.
- emwin_gui/image_background1_480_272.c
- emwin_gui/image_background2_480_272.c
- emwin_gui/muteButton_30_30.c
- emwin_gui/next_track_50_50.c
- emwin_gui/pauseButton_75_75.c
- emwin_gui/playButton_75_75.c
- emwin_gui/prev_track_50_50.c
- emwin_gui/repeat_off_40_40.c
- emwin_gui/repeat_on_40_40.c
- emwin_gui/repeat_single_40_40.c
- emwin_gui/settings_off_50_50.c
- emwin_gui/settings_on_50_50.c
- emwin_gui/shuffle_off_40_40.c
- emwin_gui/shuffle_on_40_40.c
- emwin_gui/un_muteButton_30_30.c
Copy these files from the dev_files/emwin_gui folder
apps/training/middleware/emwin_media_player/emwin_media_player_lab/dev_files/emwin_gui
and paste into the folder
apps/training/middleware/dev/emwin_media_player/emwin_media_player_lab/firmware/src/emwin_gui.
4
Add
- app_sdcard_audio_task.c
- app_display_task.c
- decoder.c
to Source Files->app by right click and select "Add Existing Items".
5
Add
- app_sdcard_audio_task.h
- app_display_task.h
- decoder.h
- app_audio_player_gui.h
to the Header Files > app by right clicking and selecting "Add Existing Items…"
6
Add
- emwin_gui/audio_playerDLG.c
- emwin_gui/settings_windowDLG.c
- emwin_gui/image_background1_480_272.c
- emwin_gui/image_background2_480_272.c
- emwin_gui/muteButton_30_30.c
- emwin_gui/next_track_50_50.c
- emwin_gui/pauseButton_75_75.c
- emwin_gui/playButton_75_75.c
- emwin_gui/prev_track_50_50.c
- emwin_gui/repeat_off_40_40.c
- emwin_gui/repeat_on_40_40.c
- emwin_gui/repeat_single_40_40.c
- emwin_gui/settings_off_50_50.c
- emwin_gui/settings_on_50_50.c
- emwin_gui/shuffle_off_40_40.c
- emwin_gui/shuffle_on_40_40.c
- emwin_gui/un_muteButton_30_30.c
to Source Files > app by right clicking and selecting "Add Existing Items from Folders…".
7
The files under the project should look like this:
8
Next, you need to tell the compiler about the path of the decoders and include files.
MHC provides Decoder functionality as part of the audio app: universal_audio_decoders. These can be found under this folder
../microchip/harmony/v1_08/apps/audio/universal_audio_decoders/firmware/src/audio_decoder
This may change in future and the decoders may be incorporated as part of the MHC framework, thereby not requiring this step.
- To include this path, right click on the project name "emwin_media_player_lin" the MPLAB X "Projects" pane and select Properties.
- In the "Categories" pane, select Conf:pic32mz_ef_sk_meb2 ▶ XC32 (Global Options) ▶ xc32-gcc.
- Now, click on the Option categories drop down menu and select the Preprocessing and Messages option.
- Click on the box beside Include directories.
and browse to the following path:
harmony-install-dir/apps/audio/universal_audio_decoders/firmware/src/audio_decoder
Select OK.
9
Modify app.c and app.h files.
You will add code to:
- Call the initialization routine for the display task
- Create mailbox for touch input
- Register initialization routines for screens with the SEGGER emWin GUI wrapper
- Set the starting screen
- Call the initialization routine for the SDCard Audio task
in APP_Initialize() routine.
10
You will add the task routines for
- APP_SDCARD_AUDIO_Tasks()
- APP_DISPLAY_Tasks()
in APP_Tasks() routine.
11
You will add the implementation for some of the utility routines called from the application tasks.
12
You will add an empty screen initialization routine above the void APP_Initialize ( void ) function. If needed, you may add initialization code here before the screen is initialized.
13
You will add an array of function pointers pointing to screen initialization routines for the screens.
14
You will add declarations for the utility functions in app.h
15
You will add the below enum definitions app.h
16
You will add the following member to the APP_DATA structure in app.h
17
An additional step is required here: you must include the app_sdcard_audio_task.h file in app.h. This is required because the decoder file wav.c depends on definitions present in other files and expects app.h to include those files. Including app_sdcard_audio_task.h in app.h will include all the relevant files needed by the decoder.
18
Finally, you need to add application specific definitions in the system_config.h file.
Open system_config.h
Replace the existing decoder buffer definitions with the below new definitions.
Then, add the following definitions
19