• 方案介绍
  • 附件下载
  • 相关推荐
申请入驻 产业图谱

【代码库】使用 FRDM-MCXW71 板上的 LVGL 驱动 LCD-PAR-S035

09/02 17:09
1174
加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论

dm-mcxw71-driving-lcd-wireless-uart-main.zip

共1个文件

使用 FRDM-MCXW71 板上的 LVGL 驱动 LCD-PAR-S035

此设置使用户能够通过串行终端与设备交互,并使用智能手机查看通过 IoT 工具箱发送到 LCD 的命令。

主板:FRDM-MCXW71、FRDM-MCXW7X

类别:图形、工业、无线连接

外设:显示器、I2C、SPI、UART

工具链:MCUXpresso IDE

内容

  1. 软件
  2. 硬件
  3. 设置
  4. 结果
  5. 常见问题解答
  6. 支持
  7. 修订历史记录

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 != SysTick
Config(SystemCoreClock / (LVGLTICKMS * 1000U)))
{
while (1)
;
}
}

void SysTickHandler(void)
{
s
tick++;
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 reset
btn;
extern int startbtn;
extern int stop
btn;
extern int setdatebtn;
extern int settimerbtn;
extern int timerinit;
extern uint8
t currenttimerble[10];
extern uint8t currentdate_ble[20];

uint8t vecwelcome[30] = "rn====Kitchen Counter====rn";
uint8t vecsetbtn[30] = "rnSet button was pressedrn";
uint8
t vecresetbtn[30] = "rnReset button was pressedrn";
uint8t vecstartbtn[30] = "rnStart button was pressedrn";
uint8
t vecstopbtn[30] = "rnStop button was pressedrn";
uint8t vecsetdatebtn[40] = "rnthe date was set to: ";
uint8
t 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)LVGL
btn();
LVGLCallBack();
}
void LVGL
initdemo()
{
BleApp
SendUartStream(&vecwelcome[0], 70U);
}
void LVGL
btn(void)
{
//display
if(setbtn == 1)
{
BleApp
SendUartStream(&vecsetbtn[0], 30U);
setbtn = 0;
}
else if(reset
btn == 1)
{
BleAppSendUartStream(&vecresetbtn[0], 30U);
reset
btn = 0;
}
else if(startbtn == 1)
{
BleApp
SendUartStream(&vecstartbtn[0], 30U);
startbtn = 0;
}
else if(stop
btn == 1)
{
BleAppSendUartStream(&vecstopbtn[0], 30U);
stop
btn = 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
(
deviceId
t peerDeviceId,
appEventt event
)
{
uint16
t tempMtu = 0;
union
{
uint8t *pUuidArray;
bleUuid
t 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 步骤

  1. 打开 IoT Toolbox 应用并选择无线 UART 演示。点击“扫描”按钮开始扫描合适的广告商。

  1. NXP_WU 设备建立连接。然后,您的智能手机上将显示无线 UART 界面。

  1. 所有与 LCD 显示屏的交互都显示在无线 UART 控制台中。

5. 常见问题解答

6. 支持

如果您对 MCXW71 有任何疑问,请在我们的无线 MCU 社区中留言!这里

项目元数据

董事会徽章 董事会徽章

类别徽章 类别徽章 类别徽章

周边徽章 周边徽章 周边徽章 周边徽章

工具链徽章

有关此示例的内容/正确性的问题可以作为此 GitHub 存储库中的问题输入。

注意​:有关 NXP 微控制器和预期功能差异的更多常规技术问题,请在NXP 社区论坛上输入您的问题。

在 YouTube 上关注我们 在 LinkedIn 上关注我们 在 Facebook 上关注我们 在 Twitter 上关注我们

来源:恩智浦appcodehub

  • dm-mcxw71-driving-lcd-wireless-uart-main.zip
    下载
恩智浦

恩智浦

恩智浦半导体创立于2006年,其前身为荷兰飞利浦公司于1953年成立的半导体事业部,总部位于荷兰埃因霍温。恩智浦2010年在美国纳斯达克上市。恩智浦2010年在美国纳斯达克上市。恩智浦半导体致力于打造全球化解决方案,实现智慧生活,安全连结。

恩智浦半导体创立于2006年,其前身为荷兰飞利浦公司于1953年成立的半导体事业部,总部位于荷兰埃因霍温。恩智浦2010年在美国纳斯达克上市。恩智浦2010年在美国纳斯达克上市。恩智浦半导体致力于打造全球化解决方案,实现智慧生活,安全连结。收起

查看更多

相关推荐