Step 6.1: Rename the Screen Name
1
Open MPLAB® Harmony Graphics Composer (MHGC). To do this, expand the Harmony Framework Configuration > Graphics Library > Harmony Graphics Library selection tree, and check the Use Graphics Library? box. Click the Execute button beside Create a Design With MPLAB Harmony Graphics Composer.
2
Change the screen name from Screen1 to "MchpMainScreen". Find the Graphics Composer Management tab in the bottom left pane and double-click on the Screen1 name to change it.
You are not changing any of the properties of the screen, so keep the screen properties shown in the Graphics Composer Properties tab in the top-right pane.
Step 6.2: Import Images and Fonts (Assets)
Import the following images and fonts. These will be used for the display objects created in the "Add Primitive Objects" step below.
- Images:
- The Microchip logo will be applied to the LogoImage primitive object.
- An image of the Flash drive will be applied to the ThumbdriveImage primitive object.
- Two images will be applied to the VolButton widget. One for mute off (play) and one for mute on.
- System Font:
- Arial font, 14 pt for ASCII numbers 32 to 127. This will be used for multiple schemes in the design.
- Arial font, 18 pt for ASCII number 94. This will be used for the ScrollUpScheme and applied to the ScrollUpButton widget.
1
Copy the Icons folder from this folder:
apps/training/middleware/thumb_drive_player/thumb_drive_player_lab/dev_files
to this one:
apps/training/middleware/dev/thumb_drive_player/thumb_drive_player_lab.
2
In the bottom left pane, in the Graphics Composer Management tab, click on the Assets sub tab.
b
Import System Font Arial 14 pt from 32 ASCII to 127 ASCII.
Click on Edit Import Ranges and select the required character range. This is an important feature that enables you to import only the characters you need, thereby limiting the amount of memory needed to store the font.
- Start Index indicates the starting ASCII value of the character.
- End Index indicates the last ASCII value of the character.
Alternatively, the range can be provided by Start Character and End Character.
Step 6.3 - Create Schemes (assign standard colors and fonts)
Create schemes to standardize the look and feel (fonts, colors, styles) of the user interface. These will be used for the display widgets created in the "Add Widget Objects" step below.
- TrackListScheme
- Applied to TrackListBox, ScrollDownButton and VolSlider.
- VolumeButtonScheme
- Applied to VolButton
- ScrollUpScheme
- Applied to ScrollUpButton
- MessageTextScheme
- Applied to MessageTextBox
1
In the bottom left pane, in the Graphics Composer Management tab, click on the Schemes sub tab. A default scheme is present.
Step 6.4 - Add Primitive Objects (rectangle, image, text)
Design the following primitive objects:
- BgRectangle: Rectangle with a gradient shade at the top of the screen
- LogoImage: Image of Microchip logo at the top of the screen
- ThumbdriveImage: Image of Flash drive
- AppNameText: Text to display the application name
1
BgRectangle:
a
In the Graphics Composer Tool Box (top left pane), under the Primitives group, left-click and drag Rectangle onto the Graphic Composer Screen tab.
Step 6.5 - Add Widget Objects (list-box, buttons, slider)
Design the following widgets:
- TrackListBox: List Box to populate the audio track list
- ScrollUpButton: Button to scroll items up in the TrackListBox
- ScrollDownButton: Button to scroll items down in the TrackListBox
- VolSlider: Slider to control the audio volume level
- VolButton: Button for mute on/off
- MessageTextBox: Static text to display application messages.
1
TrackListBox
a
Left click and drag List Box to the Graphic Composer Screen tab.
c
Notice that the list box event Touched is checked. Click on the Browse button to add/edit action to the list box event.
f
The custom code switches to the selected random track so that the selected random track is played.
2
ScrollUpButton:
a
Left click and drag Button to the Graphic Composer Screen tab.
c
Notice that the button event Released is checked. Click on the Browse button to add a custom action to the button event.
3
ScrollDownButton:
a
In the Graphics Composer Tool Box, left-click and drag Button onto the Graphic Composer Screen tab.
c
Notice that the button event Released is checked. Click on the Browse button to add a custom action to the button event.
d
4
VolSlider:
a
In the Graphics Composer Tool Box, left-click and drag Slider onto the Graphic Composer Screen tab.
c
Notice that the slider events Incremented and Decremented are checked. Click on the Browse button to add a custom action to the slider events.
d
An Event Editor window will open. Click on the Add button to add an action to the slider Incremented event.
5
VolButton:
a
In the Graphics Composer Tool Box, left-click and drag Button onto the Graphic Composer Screen tab.
c
Notice that the button events Pressed and Released are checked. Also notice that the button has enabled the Toggle option. This option allows the button to be used as an On/Off button. Also, notice the default state is "Pressed". The Pressed state corresponds to Mute Off, and the Released state corresponds to Mute On.
Click the browse button to add a custom action to the button events.
6
MessageTextBox:
a
In the Graphics Composer Tool Box, left-click and drag Static Text onto the Graphic Composer Screen tab.
Step 6.6 - Configure the Graphics display and Graphics Touch Driver
Enable the touch control feature of the graphics display on the MEB II board.
1
In MHC's Options tab, expand the Harmony Framework Configuration > Drivers > Graphics Displays > Use Graphics Display? selection tree. Notice the display has been correctly selected for you (MEB II uses a 4.3 inch, WQVGA display by NewHaven).
2
Expand Graphics Displays > Display Settings. You will keep all settings as is.
[[include :xsi:image:ras |file=image_75.png |max-width=500px]]
The Display Settings have values specific to the display (4.3 inch, WQVGA display by NewHaven). These include horizontal and vertical timing parameters and others. For details refer to the display datasheet.
3
Configure the display Touch driver (MTCH6301) to use I²C Driver Instance 1.
Note I²C driver instance 1 hasn't been created yet. You will do this a couple of steps from now.
Expand the Harmony Framework Configuration > Drivers > Touch > MTCH6301 > Use the MTCH6301 Driver? selection tree.
Keep all options the same, except for the "I2C driver module index". Change this to use "DRV_I2C_INDEX_1" (I2C Driver Instance 1).
[[include :xsi:image:ras |file=image_76.png |max-width=500px]]
4
Verify/set the I/O pins used by Touch driver using the Graphical Pin Manager.
The touch driver uses PIC32 external interrupts source 1 for touch events. Select MHC's Pin Diagram tab, and in the lower pane, select MHC's Pin Table tab.
Map the External Interrupt 1 signal to pin RE8 as shown in this image. For schematic, refer to the "MEB II User’s Guide".
Step 6.7 - Enable Touchscreen Control using I2C
1
Add a new client and driver instance for the existing I²C driver.
In Step 2 of this tutorial, you created a Dynamic I²C driver and created a client for this driver. You also configured an I²C driver instance (I²C Driver Instance 0) for this client. This client and instance are used by the AK4953 audio CODEC.
In this step, you will add another client and instance (I²C Driver Instance 1) for this driver for the display Touch driver (MTCH6301).
Expand the Harmony Framework Configuration > Drivers > I2C > Use I2C Driver? selection tree.
a
Modify Number of I2C Driver Clients and Number of I2C Driver Instances to 2.
b
You configured I2C Driver Instance 0 in audio_player_lab1. Just verify Use Bit Bang I2C Implementation is still unchecked.
c
Expand I2C Driver Instance 1, and make sure Use Bit Bang I2C Implementation? is unchecked. Since you are using the PIC32 I²C peripherals, you do not want to use the bit banged driver implementation.
d
Retain I2C_ID_1 as the I2C Module ID.
I2C_ID_1 refers to the PIC32 I²C1 peripheral (using pins SCL1 & SDA1). These pins are connected to the display touch controller on the MEB II board.
e
Retain default value DRV_I2C_MODE_MASTER as Operation Mode. The PIC32 I²C module 1 will be the Master, and the Touch MTCH6301 interface will be the Slave.
f
Change value for Master Interrupt Priority and Master Interrupt Sub-priority as INT_PRIORITY_LEVEL4 and INT_SUBPRIORITY_LEVEL0 respectively. Lower priority for touch events is OK as this will not be occurring very frequently.
g
Change value for Error Interrupt Priority and Error Interrupt Sub-priority as INT_PRIORITY_LEVEL4 and INT_SUBPRIORITY_LEVEL0 respectively.
h
The Baud Rate generator clock is configured for 100 MHz. This is derived from the Peripheral bus 2 clock frequency generated from the 198 MHz system clock.
i
Retain the default value of 50 KHz for I2C CLOCK FREQUENCY.
j
Retain the Slew Rate Control as unchecked. This function enables the I²C module to use high-frequency signaling, allowing it to use the 400 kHz and 1 MHz signaling rates.
Step 6.8 - Enable the Graphics Touch System Service
Table of Contents
|