使用 FRDM-MCXW71 板上的 LVGL 驱动 LCD-PAR-S035
此设置使用户能够通过串行终端与设备交互,并使用智能手机查看通过 IoT 工具箱发送到 LCD 的命令。
主板:FRDM-MCXW71、FRDM-MCXW7X
类别:图形、工业、无线连接
外设:显示器、I2C、SPI、UART
工具链:MCUXpresso IDE
内容
1.软件
此代码使用 MCUXpresso IDE v11.10 和 FRDM-MCXW71 SDK v2.16.0 实现。初始设计使用 LVGL v8.3.2 生成。
注意:要在 MCXW71 中使用任何无线示例,用户必须上传 NBU 镜像。此镜像位于以下 SDK 版本中:SDK_2_16_FRDM-MCXW71 > 中间件 > 无线 > ble_controller > bin > mcxw71_nbu_ble-..-.sb3。
2.硬件
需要以下板:
3. 设置
本节介绍使用 FRDM-MCXW71 板上的 LVGL 驱动 LCD-PAR-S035 的步骤。
3.1 导入项目
要将项目“w_uart”导入 MCUXpresso IDE,请参阅MCUXpresso IDE 11.10.0 用户指南(文档MCUXPRESSO-UG)。
注意:要在 IoT 工具箱中查看无线 UART,请在应用程序中更改 GAP 角色。按下 SW4,然后按下 SW2。
3.2 添加配置
在工作区中导入无线 UART 示例后,下一步是添加正确的配置以启用 LCD。
要将 OTAP LVGL 服务集成到您的应用程序中,您必须导入其他 SDK 示例中默认未包含的附加软件。此步骤可帮助您找到必须合并到项目中的文件,以便在您的应用程序中支持 LVGL 服务。
您的无线 UART 项目中必须导入 LVGL 文件夹中存在但不存在于无线 UART 中的文件夹和文件。例如,必须导入以下内容:
- 主板 > lvgl_support.c
- 主板 > lvgl_support.h
- 主板> RTE_Device.h
- cmsisdrivers > DriverCommon.h
- cmsisdrivers > DriverSPI.h
- 驱动程序> fsl_edma.c
- 驱动程序> fsl_edma.h
- 驱动程序> fsllpi2cedma.c
- 驱动程序> fsllpi2cedma.h
- 驱动程序> fsl_lpi2c.c
- 驱动程序> fsl_lpi2c.h
- 驱动程序> fsllpspicmsis.c
- 驱动程序> fsllpspicmsis.h
- 驱动程序> fsllpspiedma.c
- 驱动程序> fsllpspiedma.h
- 驱动程序> fsl_lpspi.c
- 驱动程序> fsl_lpspi.h
- 源> lv_conf.h
- 源代码> lvgldemoutils.c
- 源代码> lvgldemoutils.h
在 MCUXpresso IDE 中,导航至“项目”>“属性”。前往“C/C++ 构建”>“设置”>“工具设置”>“MCU C 编译器”>“包含”。点击“包含路径”文本框旁边的图标:
c
"${workspace_loc:/${ProjName}/source}"
"${workspace_loc:/${ProjName}/cmsis_drivers}"
"${workspace_loc:/${ProjName}/lvgl/lvgl/src/widgets}"
"${workspace_loc:/${ProjName}/generated/guider_customer_fonts}"
"${workspace_loc:/${ProjName}/generated/guider_fonts}"
"${workspace_loc:/${ProjName}/lvgl/lvgl}"
"${workspace_loc:/${ProjName}/lvgl/lvgl/src}"
"${workspace_loc:/${ProjName}/lvgl/lvgl/demos}"
"${workspace_loc:/${ProjName}/custom}"
"${workspace_loc:/${ProjName}/generated}"
"${workspace_loc:/${ProjName}/lcd}"
"${workspace_loc:/${ProjName}/lvgl}"
"${workspace_loc:/${ProjName}/touchpanel}"
另外,确保 LCDST7796SIPS 宏设置为 1:
3.3 代码
本节解释代码和文件的详细信息。
main.c 文件
在此文件中,添加声明、变量和包含内容以配置 LVGL 配置文件。
- 包括:
```c
include "lvgl.h"
include "lvgl_support.h"
include "gui_guider.h"
include "custom.h"
include"events_init.h"
include "pin_mux.h"
```
- 变量:
```c
/* 1 ms per tick. */
ifndef LVGLTICKMS
define LVGLTICKMS 1U
endif
/* lvtaskhandler is called every 5-tick. */
ifndef LVGLTASKPERIOD_TICK
define LVGLTASKPERIOD_TICK 5U
endif
static void DEMO_SetupTick(void);
if LVUSELOG
static void print_cb(const char *buf);
endif
static volatile uint32t stick = 0U;
static volatile bool s_lvglTaskPending = false;
lvui guiderui;
```
- 功能:
```c
static void DEMOSetupTick(void)
{
if (0 != SysTickConfig(SystemCoreClock / (LVGLTICKMS * 1000U)))
{
while (1)
;
}
}
void SysTickHandler(void)
{
stick++;
lvtickinc(LVGLTICKMS);
if ((s_tick % LVGL_TASK_PERIOD_TICK) == 0U)
{
s_lvglTaskPending = true;
}
}
```
在主函数中,需要调用正确的函数:
```c
int main(void)
{
.
.
.
CLOCK_EnableClock(kCLOCK_Dma0);
BOARD_InitPins_SPI0();
I2C0_InitPins();
DEMO_SetupTick();
lv_port_pre_init();
lv_init();
lv_port_disp_init();
lv_port_indev_init();
setup_ui(&guider_ui);
events_init(&guider_ui);
custom_init(&guider_ui);
.
.
.
while(TRUE)
{
.
.
.
OSA_EnableIRQGlobal();
while (!s_lvglTaskPending)
{
}
s_lvglTaskPending = false;
lv_task_handler();
}
```
wireless_uart.c文件
它是应用程序级别的主要源文件。此文件包含用于管理设备在创建连接之前、期间和之后执行的所有过程的信息。
- 变量:
```c
extern int setbtn;
extern int resetbtn;
extern int startbtn;
extern int stopbtn;
extern int setdatebtn;
extern int settimerbtn;
extern int timerinit;
extern uint8t currenttimerble[10];
extern uint8t currentdate_ble[20];
uint8t vecwelcome[30] = "rn====Kitchen Counter====rn";
uint8t vecsetbtn[30] = "rnSet button was pressedrn";
uint8t vecresetbtn[30] = "rnReset button was pressedrn";
uint8t vecstartbtn[30] = "rnStart button was pressedrn";
uint8t vecstopbtn[30] = "rnStop button was pressedrn";
uint8t vecsetdatebtn[40] = "rnthe date was set to: ";
uint8t vectimerbtn[40] = "rnthe timer was set to: ";
uint8t vectimerInit_btn[80] = "rnthe timer was stopped, press the RESET if you want to re-start the counterrn";
```
- 功能:
```c
void LVGL_CallBack()
{
(void)TM_InstallCallback((timer_handle_t)mLVGLId, LVGL_TimerCallback, NULL);
(void)TM_Start((timer_handle_t)mLVGLId,
(uint8_t)kTimerModeLowPowerTimer | (uint8_t)kTimerModeSingleShot, LVGLIntervalInMs_c);
}
void LVGLTimerCallback()
{
(void)LVGLbtn();
LVGLCallBack();
}
void LVGLinitdemo()
{
BleAppSendUartStream(&vecwelcome[0], 70U);
}
void LVGLbtn(void)
{
//display
if(setbtn == 1)
{
BleAppSendUartStream(&vecsetbtn[0], 30U);
setbtn = 0;
}
else if(resetbtn == 1)
{
BleAppSendUartStream(&vecresetbtn[0], 30U);
resetbtn = 0;
}
else if(startbtn == 1)
{
BleAppSendUartStream(&vecstartbtn[0], 30U);
startbtn = 0;
}
else if(stopbtn == 1)
{
BleAppSendUartStream(&vecstopbtn[0], 30U);
stopbtn = 0;
}
else if(setdatebtn == 1)
{
vecsetdatebtn[23]= '[';
vecsetdatebtn[24]= currentdateble[0];
vecsetdatebtn[25]= currentdateble[1];
vecsetdatebtn[26]= currentdateble[2];
vecsetdatebtn[27]= currentdateble[3];
vecsetdatebtn[28]= '/';
vecsetdatebtn[29]= currentdateble[5];
vecsetdatebtn[30]= currentdateble[6];
vecsetdatebtn[31]= '/';
vecsetdatebtn[32]= currentdateble[8];
vecsetdatebtn[33]= currentdateble[9];
vecsetdatebtn[34]= ']';
BleApp_SendUartStream(&vec_setdate_btn[0], 40U);
set_date_btn = 0;
}
else if(set_timer_btn == 1)
{
vec_timer_btn[23]= '[';
vec_timer_btn[24]= current_timer_ble[0];
vec_timer_btn[25]= current_timer_ble[1];
vec_timer_btn[26]= ':';
vec_timer_btn[27]= current_timer_ble[2];
vec_timer_btn[28]= current_timer_ble[3];
vec_timer_btn[29]= ':';
vec_timer_btn[30]= current_timer_ble[4];
vec_timer_btn[31]= current_timer_ble[5];
vec_timer_btn[32]= ']';
BleApp_SendUartStream(&vec_timer_btn[0], 40U);
set_timer_btn = 0;
}
else if(timer_init == 1)
{
BleApp_SendUartStream(&vec_timerInit_btn[0], 80U);
timer_init = 0;
}
}
```
在无线UART示例中使用LCD功能的目的是为了让用户能够以不同的方式与开发板交互。因此,需要在低功耗蓝牙功能中调用该函数。
用户必须在 BLE 状态机处理程序中调用 LCD 回调函数:
```c
static void BleAppStateMachineHandler
(
deviceIdt peerDeviceId,
appEventt event
)
{
uint16t tempMtu = 0;
union
{
uint8t *pUuidArray;
bleUuidt pUuidObj;
} temp; / MISRA rule 11.3 */
temp.pUuidArray = uuid_service_wireless_uart;
.
.
.
case mAppServiceDisc_c:
{
if (event == mAppEvt_ServiceDiscoveryComplete_c)
{
/* Moving to Running State*/
maPeerInformation[peerDeviceId].appState = mAppRunning_c;
//Display
LVGLinitdemo();
LVGL_CallBack();
.
.
.
default:
{
; /* No action required */
}
break;
}
}
}
```
4.结果
该测试用例示例旨在演示在测试无线 UART-LVGL 软件中的 LVGL 集成。
4.1 步骤
- 打开 IoT Toolbox 应用并选择无线 UART 演示。点击“扫描”按钮开始扫描合适的广告商。
- 与 NXP_WU 设备建立连接。然后,您的智能手机上将显示无线 UART 界面。
- 所有与 LCD 显示屏的交互都显示在无线 UART 控制台中。
5. 常见问题解答
6. 支持
如果您对 MCXW71 有任何疑问,请在我们的无线 MCU 社区中留言!这里。
项目元数据
有关此示例的内容/正确性的问题可以作为此 GitHub 存储库中的问题输入。
注意:有关 NXP 微控制器和预期功能差异的更多常规技术问题,请在NXP 社区论坛上输入您的问题。
来源:恩智浦appcodehub
1174
