To compile locally, you need to obtain a template project:

The download address of template projects: https://github.com/wireless-tag-com/8ms-esp32

1. Open the downloaded template project in VS Code (8ms-esp32-main).

2. Files analysis.

  • main—It contains its own source code, which is mainly modified by the user
  • components—Library files and device driver files
  • partitions_8ms.csv—Partition table
  • CMakeLists.txt—The main file about building a project
  • sdkconfig—Project configuration file

3. The code analysis of a template project.

/**
 * @description: 系统创建的第一个任务调用的功能函数
 */
void app_main()
{
    user_nvs_init(); //nvs flassh 初始化
    //If you want to use a task to create the graphic, you NEED to create a Pinned task
    //Otherwise there can be problem such as memory corruption and so on
    xTaskCreatePinnedToCore(deviceTask, "device", 4096 * 2, NULL, 0, NULL, 0); // 创建线程
    xTaskCreatePinnedToCore(blocklyTask, "blockly", 4096 * 2, NULL, 0, NULL, 1);// 创建线程
    xTaskCreatePinnedToCore(guiTask, "gui", 4096 * 2, NULL, 0, NULL, 1);// 创建线程
}
void guiTask(void *pvParameter){
 //剪切了部份代码
 lv_qm_ui_entry(); // UI 入口函数
    while (1)
    {
        vTaskDelay(10 / portTICK_PERIOD_MS); // 延时
        //Try to lock the semaphore, if success, call lvgl stuff
        if (xSemaphoreTake(xGuiSemaphore, (TickType_t)10) == pdTRUE)
        {
            lv_qm_ui_loop();  // 积木逻辑入口函数
            lv_task_handler();
            xSemaphoreGive(xGuiSemaphore);
        }
    }
}
/**
 * @brief:UI 入口函数
 * 可以添加个人显示的函数
 */
void lv_qm_ui_entry(void)
{
    LV_FONT_DECLARE(ali_font_16); //声明字体
    lv_font_montserrat_16 = ali_font_16;

    main_screen = lv_obj_create(NULL, NULL); //画布创建

    init_function(); // 积木的函数初始化
}
/**
 * @brief:
 *  如需使用: #define BLOCKLY_INIT
 */
void init_function()
{
#ifdef BLOCKLY_INIT
    blockly_init();
#endif
}

/**
 * @brief 
 * 如需使用: #define BLOCKLY_LOOP 
 */
void lv_qm_ui_loop(void)
{
#ifdef BLOCKLY_LOOP
    blockly_loop();
#endif
}

4. Download the project from 8ms.xyz and compile it locally.

  1. Delete the CMakeLists.txt and component.mk files in the main folder of the source code downloaded from the 8ms platform.
  2. Copy the main folder to the 8ms-esp32-main folder—Replace the target files.
  3. Open the 8ms-esp32-main folder in VS Code and click to compile.

文档更新时间: 2021-01-12 11:38   作者:plj