本系列图文连载,第4话
书接上回
GUI-Guider帮我们生成的代码有两个文件夹
需要改两个地方
1.打开 generated文件夹,需要将天气站例子里的guider_fonts文件夹复制过来,不然会报错(这里可能很好改,我懒得鼓捣)
把天气站案例demos里的lvgl demo都删了,没用
2.把天气站案例中的,AiPi-Eyes_weather\demos\240X320_ui 下的这两个文件夹删掉,换成刚才生成的
打开vscode,将images文件夹下的 图片.c 打开
将方框框住的这块代码删掉,改成一行,不然也会报错
到此,生成的代码就改完了
下面的内容纯属个人瞎搞,望大佬提供更好的方法
接着改main.c 文件
由于小安派貌似强制要求留个wifi_event_handler函数
反正,改成这样就能编译成功
- /****************************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership. The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
- /****************************************************************************
- * Included Files
- ****************************************************************************/
- #include "FreeRTOS.h"
- #include "task.h"
- #include "timers.h"
- #include <lwip/tcpip.h>
- #include <lwip/sockets.h>
- #include <lwip/netdb.h>
- #include "sntp.h"
- #include "bl_fw_api.h"
- #include "wifi_mgmr_ext.h"
- #include "wifi_mgmr.h"
- #include "bflb_irq.h"
- #include "bflb_uart.h"
- #include "bflb_l1c.h"
- #include "bflb_mtimer.h"
- #include "bl616_glb.h"
- #include "rfparam_adapter.h"
- #include "board.h"
- #define DBG_TAG "MAIN"
- #include "log.h"
- #include "lv_conf.h"
- #include "lvgl.h"
- #include "lv_port_disp.h"
- #include "lv_port_indev.h"
- #include "demos/lv_demos.h"
- #include "lcd.h"
- #include "portable.h"
- //#include "fhost.h"
- #include "gui_guider.h"
- #include "custom.h"
- #include "easyflash.h"
- #include "bflb_mtd.h"
- extern xQueueHandle queue;
- /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
- //#define WIFI_STACK_SIZE (1536)
- #define TASK_PRIORITY_FW (16)
- /****************************************************************************
- * Private Types
- ****************************************************************************/
- /****************************************************************************
- * Private Data
- ****************************************************************************/
- static struct bflb_device_s* uart0;
- static uint32_t sta_ConnectStatus = 0;
- extern void shell_init_with_task(struct bflb_device_s* shell);
- extern int es8388_voice_init(void);
- extern int audio_init(void);
- extern int audio_pcm_init(void);
- extern void play_voice_open(void);
- extern void play_voice_close(void);
- static int bl61x_get_heap_size(void);
- /****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
- /****************************************************************************
- * Functions
- ****************************************************************************/
-
- /* lvgl log cb */
- void lv_log_print_g_cb(const char* buf)
- {
- printf("[LVGL] %s", buf);
- }
- static TaskHandle_t lvgl_TaskHandle;
- #define LVGL_STACK_SIZE 1024
- #define LVGL_TASK_PRIORITY 15
- void lvgl_task(void* param)
- {
- while (1)
- {
- lv_task_handler();
- vTaskDelay(1);
- // bflb_mtimer_delay_ms(1);
- }
- }
- void io2_set(uint8_t value)
- {
- struct bflb_device_s* gpio;
- gpio = bflb_device_get_by_name("gpio");
- bflb_gpio_init(gpio, GPIO_PIN_2, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
- if (value)
- {
- bflb_gpio_set(gpio, GPIO_PIN_2);
- }
- else
- {
- bflb_gpio_reset(gpio, GPIO_PIN_2);
- }
- }
-
- static void bl61x_show_heap_size_task(void* arg)
- {
- while (1) {
- LOG_F("[%s:%d]heap_size-------> %d\r\n", DBG_TAG, __LINE__, bl61x_get_heap_size());
- vTaskDelay(3000/portTICK_PERIOD_MS);
- }
- }
- void wifi_event_handler(uint32_t code)
- {
- }
- lv_ui guider_ui;
- int main(void)
- {
- board_init();
- // audio_init();
- // audio_pcm_init();
- // es8388_voice_init();
- // uart0 = bflb_device_get_by_name("uart0");
- // shell_init_with_task(uart0);
- // printf("HeapSize:%d\r\n",xPortGetFreeHeapSize());
- tcpip_init(NULL, NULL);
-
- //lwip_sntp_init();
- //init easyflash
- bflb_mtd_init();
- easyflash_init();
- /* lvgl init */
- lv_log_register_print_cb(lv_log_print_g_cb);
- lv_init();
- lv_port_disp_init();
- lv_port_indev_init();
- setup_ui(&guider_ui);
- printf("lv_task_handler\r\n");
- // lv_task_handler();
- custom_init(&guider_ui);
- printf("lvgl success\r\n");
- xTaskCreate(lvgl_task, (char*)"lvgl", LVGL_STACK_SIZE, NULL, LVGL_TASK_PRIORITY, &lvgl_TaskHandle);
- xTaskCreate(bl61x_show_heap_size_task, (char*)"heap", 1024, NULL, 2, NULL);
- // printf("HeapSize:%d\r\n",xPortGetFreeHeapSize());
- vTaskStartScheduler();
- // while (1) {
- // lv_task_handler();
- // bflb_mtimer_delay_ms(1);
- // }
- while (1) {
- // printf("\r\n[%s] heap size ------------------- %d\r\n", __func__, xPortGetFreeHeapSize());
- vTaskDelay(5000/portTICK_RATE_MS);
- }
- }
- static int bl61x_get_heap_size(void)
- {
- struct meminfo info1 = { 0 };
- struct meminfo info2 = { 0 };
- uint32_t total_free_size = 0;
- // return xPortGetFreeHeapSize();
- bflb_mem_usage(KMEM_HEAP, &info1);
- bflb_mem_usage(PMEM_HEAP, &info2);
- total_free_size = info1.free_size + info2.free_size;
- return total_free_size;
- }
复制代码 因为,不用连wifi,我看泽哥教程 零基础开发小安派-Eyes-S1【入门篇】——工程文件架构 里提到,要改 flash_prog_cfg.ini 文件
- [cfg]
- # 0: no erase, 1:programmed section erase, 2: chip erase
- erase = 1
- # skip mode set first para is skip addr, second para is skip len, multi-segment region with ; separated
- skip_mode = 0x0, 0x0
- # 0: not use isp mode, #1: isp mode
- boot2_isp_mode = 0
- [FW]
- filedir = ./build/build_out/Eyes_$(CHIPNAME).bin
- address = 0x10000
复制代码 默认,整个界面显示会顺时针旋转90度(默认的是竖屏)
由于,我粘到快递盒上是横屏,还需要改 lcd_conf_user.h 文件
注释掉 #define LCD_ROTATED_NONE
根据需要选择要旋转的角度
好像就没有需要改的地方了吧,如果你们编译报错的话,直接下载我胡乱改好的吧
make编译,make flash COMX=COMXX 烧录到小安派
强调一下,编译的时候,心里默念 “厉不厉害,你坤哥” 有助于编译一次成功
|
-
|