Lab 6 - How to Integrate an Embedded Wizard GUI Project With an MPLAB® X IDE Project
Introduction
This training module will guide you through the process of integrating Embedded Wizard project-generated code and its platform package into an MPLAB® X IDE project using the SAM9X75 Curiosity Wireless Kit . You will also learn the step-by-step procedure to add support for the Waveshare® 4-inch MIPI® round display within the MPLAB X IDE environment.
This document presents the final lab, showcasing the development of a full-fledged IoT application.
By the end of this module, you will have a working understanding of how to combine GUI applications developed in Embedded Wizard with a bare metal firmware project in MPLAB X IDE, and how to enable display output on a Waveshare 4-inch MIPI DSI® display using the SAM9X75 Curiosity Development Board.
This document is divided into three sections:
- Steps to develop an IoT Thermostat application using Embedded Wizard
- Add Waveshare display to the project graph and develop an MPLAB® Harmony Application
- Integrate Embedded Wizard generated code to an MPLAB Harmony application
Prerequisites
Follow these steps:
- Hardware Setup
- SAM9X75 Curiosity Wireless Kit - Wi-Fi® Quick Start Guide for MPLAB® Harmony v3 (follow steps 1-6)
- Lab 1 - How to Create an MPLAB X IDE Project
- Lab 2 - How to Integrate A Temperature Sensor to an MPLAB® X IDE Project
- Lab 3 - How to Integrate the RNBD Module to MPLAB X IDE to Establish Bluetooth® Communication
- Lab 4 - How to Integrate the WIxCS02 M.2 Wi-Fi® Module Card to an MPLAB® X IDE Project to Establish Wi-Fi Communication
- Lab 5 - How to Integrate MQTT to an MPLAB® X IDE Project to Publish and Subscribe Data To/From a Cloud Broker
Develop an IoT Thermostat Application Using Embedded Wizard
This section assumes that the reader has prior experience with Embedded Wizard GUI development. It is intended for developers who are already familiar with the basic concepts, tools, and workflow involved in creating graphical user interfaces using Embedded Wizard. The content will build upon that foundational knowledge, focusing on more advanced features, best practices or platform-specific implementations.
Download Embedded Wizard for the Target Platform Microchip SAM9X75 Curiosity LAN Kit.
Download the Embedded Wizard Build Environment for SAM9X75-Curiosity-WVGA.
Now launch Embedded Wizard and create a new project with the following settings:
Follow "Quick Tour - a Tutorial" to develop any Embedded Wizard-based GUI application.
Refer to SAM9X75 thermostat IoT application GUI developed using Embedded Wizard.
This application is designed in such a way that:
- The display will update every 10 seconds with the real-time temperature and humidity value read from Temp&Hum 13 Click board™ sensor.
- You can increase/decrease the brightness of the display.
- You can change the Mode of the Thermostat to HOT/COOL/OFF.
- Wi-Fi/Bluetooth communication can be enabled/disabled from the display.
- You can control the Mode of the Thermostat and get Status of the Thermostat via Bluetooth/Wi-Fi using MQTT.
The simulation output on the Embedded Wizard is as shown below:
After completing the creation of the GUI application, generate code to the directory ..Application/GeneratedCode.
This completes the code generation of the thermostat IoT application from the Embedded Wizard GUI.
Add Waveshare 4-inch MIPI round LCD to the Project Graph and Develop an MPLAB Harmony Application
Follow all the labs under the "Prerequisites" section and ensure that all the components required were added to the project graph and corresponding code is generated.
The next step is to add the Waveshare 4-inch MIPI round display to the project graph. To do this, from Device Resources, expand Graphics > Displays and select Waveshare 4inch DSI Round LCD.
Select Yes to the pop-up asking for Input System Service component auto activation.
Add the dependency for the Waveshare 4-inch DSI Round LCD as follows:
Add the DSI Display dependency from the Available Consumers as DSI (gfx_bridge_dsi_plib)
Add the DSI peripheral library (DPI) dependency from Available Consumers as LE XLCDC Driver
Add an extra instance for I2C.
Verify that the extra I2C driver instance was created.
Add Instance 1 of the I2C dependency from Active Consumer to Waveshare 4inch DSI Round LCD.
From the SAM9X75 Curiosity development board user guide, observe that DSI is interfaced via FLEXCOM6.
Now add the dependency for the Instance 1 of I2C as FLEXCOM 6 (flexcom6) as shown:
Now add RTC peripheral and GFX2D peripheral to the project graph. Graphics2D accelerator will be used by Embedded Wizard while rendering the images and the RTC library will be used by Embedded Wizard to set and read time from RTC.
Also, add the dependency of the GFX2D peripheral library to the LE GFX2D Graphics Processor. This completes the creation of the project graph for the SAM9X75 IoT Thermostat application.
Add the pin configurations. To do this, go to Project Graph > Plugins > Pin Configuration.
Configure the pins as follows:
- PA24 --> DSI_TWD --> FLEXCOM6_IO0
- PB16 --> DSI_TWC --> FLEXCOM6_IO1
Verify the settings under Waveshare 4inch DSI Round LCD as follows:
For LEXLCDC driver, perform the following configuration.
- Check the Enable Backlight PWM box.
- Enable only the Base Layer (this application uses only one hardware layer with Embedded Wizard).
- Check the Canvas Mode and Enable Interrupts boxes.
- Set the GCLK Clock, Source, as PLLA/2 and the Pixel Clock (HZ) as 50,000,000.
Now, enable the Pattern Generator in the DSI Display configuration to ensure the display is working properly by displaying the pattern on the DSI display.
Now, generate the code by clicking the Generate button. Wait until the code generation is complete.
Now, clean and build the application and debug it by following the steps outlined in Lab 7.
When you the run the application from MPLAB X IDE, you can observe the pattern being generated on the Waveshare 4-inch DSI round LCD.
Now, that you have verified the successful integration of the Waveshare 4-inch DSI round LCD with MPLAB X IDE, disable the Pattern Generator and generate the code.
The next step is to integrate the Embedded Wizard platform package and generated code into MPLAB X IDE.
How to Integrate Embedded Wizard-generated Code to an MPLAB Harmony Application
The next step is to add Embedded Wizard platform packages and generated code to the MPLAB X IDE. To do this, first download the Embedded Wizard Build Environment for SAM9X75-Curiosity-WVGA.
Unzip it and find the platform packages in the following directory:
The customized Embedded Wizard build environment for the Waveshare 4-inch round display is located in the Embedded_Wizard folder, which contains four sub-folders.
Application - Has two sub-folders:
- GeneratedCode - This folder is used to receive the generated code from the thermostat Embedded Wizard UI project.
- Source - This folder contains the main.c and ewmain.c files. There you will find the initialization of the system and the main loop to drive an Embedded Wizard GUI application. The ewconfig.h file contains general configuration settings for the target system.
- PlatformPackage - This folder contains the necessary source codes and/or libraries of the SAM9 Platform Package with the color format RGBA8888 and the Runtime Environment.
- TargetSpecific - This folder contains all configuration files and platform-specific (board support package - Microchip hardware drivers) source codes.
- Thermostat_IoT - This folder contains the thermostat GUI Embedded Wizard project.
Now, add Embedded_Wizard build environment to MPLAB X IDE. First, add the header files. To do this, go to Projects > Header Files > Add Existing Items from Folders. Select the Embedded_Wizard folder and choose Header Files (.h) files in the search pane.
Similarly, add the source files from this folder. To do this go to Projects > Header Files > Add Existing Items from Folders. Select the Embedded_Wizard folder and choose C Source Files (.c) files in the search pane.
Link the Embedded Wizard EWRTE (Embedded Wizard Run Time Engine - libewrte.a) and EWGFX (Embedded Wizard Graphics - libewgfx.a) libraries. Go to Projects > Libraries > Add Library/Object File and then choose libewrte.a and libewgfx.a from the PlatformPackage folder.
If you see a path-related error, for example:
- Unable to find Embedded Wizard related include paths
Then add the include directories as shown:
Add the application files, app_dsi.c, app_wincs02.c, app_rnbd.c, and temp_hum_13_click.c, for the SAM9X75 thermostat IoT application, to the MPLAB Harmony project. In the app_dsi.c file, notice that once the LCDC is initialized, the GUI gets fired up with a call to ew_init(). The graphics and interface keep updating regularly through the ew_process() function.
Clean and build the code. (See the sample application files for reference.)
Follow the steps outlined in Lab 7 to debug the IoT thermostat application.
You can also opt to run the application from a microSD® card by following the steps mentioned in Lab 8.
Summary
In this training, you developed, configured and built an MPLAB Harmony v3 IoT application using the SAM9X75 IoT thermostat application.