查看: 4334|回复: 1

【智能家居挑战赛】+ 智家中控器 #2 GUI Guider生成lvgl

[复制链接]
  • TA的每日心情
    擦汗
    2024-11-7 09:48
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    35

    主题

    83

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    1252
    最后登录
    2025-8-5
    发表于 2021-4-20 16:55:13 | 显示全部楼层 |阅读模式
    1、安装GUI Guider并启动运行。插入首页欢迎图片,设置event,点击后启动首页
    1.PNG
    2. 依次添加选择页面Selection,空调,换气机,监控参数等,分别演示表格等参数,使用switch选项来控制灯的开关。这个过程不需要训练,就像word一样即插即用,编辑完以后启动模拟器simulator,效果如下
    digital.gif

    3、生成output代码,加入工程中,替代原来的范例页面,编译后下载到开发板。


    模拟器的伪启动代码如下,供参考
    1. // SPDX-License-Identifier: MIT
    2. // Copyright 2020-2021 NXP

    3. /**
    4. * @file main
    5. *
    6. */

    7. /*********************
    8. *      INCLUDES
    9. *********************/
    10. #define _DEFAULT_SOURCE /* needed for usleep() */
    11. #include <stdlib.h>
    12. #include <unistd.h>
    13. #define SDL_MAIN_HANDLED        /*To fix SDL's "undefined reference to WinMain" issue*/
    14. #include <SDL2/SDL.h>
    15. #include "lvgl/lvgl.h"
    16. #include "lv_drivers/display/monitor.h"
    17. #include "lv_drivers/indev/mouse.h"
    18. #include "lv_drivers/indev/mousewheel.h"
    19. #include "lv_drivers/indev/keyboard.h"
    20. #include "gui_guider.h"
    21. #include "events_init.h"
    22. #include "custom.h"


    23. /*********************
    24. *      DEFINES
    25. *********************/

    26. /*On OSX SDL needs different handling*/
    27. #if defined(__APPLE__) && defined(TARGET_OS_MAC)
    28. # if __APPLE__ && TARGET_OS_MAC
    29. #define SDL_APPLE
    30. # endif
    31. #endif

    32. /**********************
    33. *      TYPEDEFS
    34. **********************/

    35. /**********************
    36. *  STATIC PROTOTYPES
    37. **********************/
    38. static void hal_init(void);
    39. static int tick_thread(void * data);

    40. /**********************
    41. *  STATIC VARIABLES
    42. **********************/

    43. /**********************
    44. *      MACROS
    45. **********************/

    46. /**********************
    47. *   GLOBAL FUNCTIONS
    48. **********************/
    49. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"

    50. lv_ui guider_ui;

    51. int main(int argc, char ** argv)
    52. {
    53.     (void) argc;    /*Unused*/
    54.     (void) argv;    /*Unused*/

    55.     /*Initialize LittlevGL*/
    56.     lv_init();

    57.     /*Initialize the HAL (display, input devices, tick) for LittlevGL*/
    58.     hal_init();

    59.     /*Create a GUI-Guider app */
    60.         setup_ui(&guider_ui);
    61.     events_init(&guider_ui);
    62.     custom_init(&guider_ui);

    63.     while(1) {
    64.         /* Periodically call the lv_task handler.
    65.          * It could be done in a timer interrupt or an OS task too.*/
    66.         lv_task_handler();
    67.         usleep(5 * 1000);

    68. #ifdef SDL_APPLE
    69.         SDL_Event event;

    70.         while(SDL_PollEvent(&event)) {
    71. #if USE_MOUSE != 0
    72.             mouse_handler(&event);
    73. #endif

    74. #if USE_KEYBOARD
    75.             keyboard_handler(&event);
    76. #endif

    77. #if USE_MOUSEWHEEL != 0
    78.             mousewheel_handler(&event);
    79. #endif
    80.         }
    81. #endif
    82.     }

    83.     return 0;
    84. }

    85. /**********************
    86. *   STATIC FUNCTIONS
    87. **********************/

    88. /**
    89. * Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
    90. */
    91. static void hal_init(void)
    92. {
    93.     /* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
    94.     monitor_init();

    95.     /*Create a display buffer*/
    96.     static lv_disp_buf_t disp_buf1;
    97.     static lv_color_t buf1_1[480*10];
    98.     lv_disp_buf_init(&disp_buf1, buf1_1, NULL, 480*10);

    99.     /*Create a display*/
    100.     lv_disp_drv_t disp_drv;
    101.     lv_disp_drv_init(&disp_drv);            /*Basic initialization*/
    102.     disp_drv.buffer = &disp_buf1;
    103.     disp_drv.flush_cb = monitor_flush;    /*Used when `LV_VDB_SIZE != 0` in lv_conf.h (buffered drawing)*/
    104.     lv_disp_drv_register(&disp_drv);

    105.     /* Add the mouse as input device
    106.      * Use the 'mouse' driver which reads the PC's mouse*/
    107.     mouse_init();
    108.     lv_indev_drv_t indev_drv;
    109.     lv_indev_drv_init(&indev_drv);          /*Basic initialization*/
    110.     indev_drv.type = LV_INDEV_TYPE_POINTER;
    111.     indev_drv.read_cb = mouse_read;         /*This function will be called periodically (by the library) to get the mouse position and state*/
    112.     lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);

    113.     /* Tick init.
    114.      * You have to call 'lv_tick_inc()' in periodically to inform LittelvGL about how much time were elapsed
    115.      * Create an SDL thread to do this*/
    116.     SDL_CreateThread(tick_thread, "tick", NULL);
    117. }

    118. /**
    119. * A task to measure the elapsed time for LittlevGL
    120. * @param data unused
    121. * @return never return
    122. */
    123. static int tick_thread(void * data)
    124. {
    125.     (void)data;

    126.     while(1) {
    127.         SDL_Delay(5);   /*Sleep for 5 millisecond*/
    128.         lv_tick_inc(5); /*Tell LittelvGL that 5 milliseconds were elapsed*/
    129.     }

    130.     return 0;
    131. }
    复制代码











    该会员没有填写今日想说内容.
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2025-8-8 16:43
  • 签到天数: 1504 天

    连续签到: 1 天

    [LV.Master]伴坛终老

    97

    主题

    4692

    帖子

    12

    版主

    Rank: 7Rank: 7Rank: 7

    积分
    10093
    最后登录
    2025-8-8
    发表于 2021-4-20 17:21:01 | 显示全部楼层
    这样一个资源丰富的芯片,楼主居然没有跑RTOS
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-8-16 14:48 , Processed in 0.084304 second(s), 21 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表