【小熊带你玩转小安派】让我们来点亮屏幕(下)

[复制链接]
查看3285 | 回复21 | 2023-9-9 20:47:23 | 显示全部楼层 |阅读模式
本系列图文连载,第4话

书接上回

GUI-Guider帮我们生成的代码有两个文件夹
1.png
需要改两个地方
1.打开 generated文件夹,需要将天气站例子里的guider_fonts文件夹复制过来,不然会报错(这里可能很好改,我懒得鼓捣)
2.png
4.png
3.png
把天气站案例demos里的lvgl demo都删了,没用

2.把天气站案例中的,AiPi-Eyes_weather\demos\240X320_ui 下的这两个文件夹删掉,换成刚才生成的

打开vscode,将images文件夹下的 图片.c 打开
5.png
将方框框住的这块代码删掉,改成一行,不然也会报错
  1. #include "lvgl.h"
复制代码


到此,生成的代码就改完了


                               
登录/注册后可看大图



下面的内容纯属个人瞎搞,望大佬提供更好的方法

接着改main.c 文件
由于小安派貌似强制要求留个wifi_event_handler函数
反正,改成这样就能编译成功
  1. /****************************************************************************
  2. *
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements.  See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.  The
  6. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance with the
  8. * License.  You may obtain a copy of the License at
  9. *
  10. *   http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
  15. * License for the specific language governing permissions and limitations
  16. * under the License.
  17. *
  18. ****************************************************************************/

  19. /****************************************************************************
  20.   * Included Files
  21.   ****************************************************************************/

  22. #include "FreeRTOS.h"
  23. #include "task.h"
  24. #include "timers.h"

  25. #include <lwip/tcpip.h>
  26. #include <lwip/sockets.h>
  27. #include <lwip/netdb.h>
  28. #include "sntp.h"

  29. #include "bl_fw_api.h"
  30. #include "wifi_mgmr_ext.h"
  31. #include "wifi_mgmr.h"

  32. #include "bflb_irq.h"
  33. #include "bflb_uart.h"
  34. #include "bflb_l1c.h"
  35. #include "bflb_mtimer.h"

  36. #include "bl616_glb.h"
  37. #include "rfparam_adapter.h"

  38. #include "board.h"


  39. #define DBG_TAG "MAIN"
  40. #include "log.h"


  41. #include "lv_conf.h"
  42. #include "lvgl.h"

  43. #include "lv_port_disp.h"
  44. #include "lv_port_indev.h"

  45. #include "demos/lv_demos.h"

  46. #include "lcd.h"
  47. #include "portable.h"
  48.   //#include "fhost.h"
  49. #include "gui_guider.h"
  50. #include "custom.h"
  51. #include "easyflash.h"
  52. #include "bflb_mtd.h"
  53. extern xQueueHandle queue;
  54. /****************************************************************************
  55. * Pre-processor Definitions
  56. ****************************************************************************/

  57. //#define WIFI_STACK_SIZE     (1536)
  58. #define TASK_PRIORITY_FW    (16)

  59. /****************************************************************************
  60.   * Private Types
  61.   ****************************************************************************/

  62.   /****************************************************************************
  63.    * Private Data
  64.    ****************************************************************************/

  65. static struct bflb_device_s* uart0;

  66. static uint32_t sta_ConnectStatus = 0;

  67. extern void shell_init_with_task(struct bflb_device_s* shell);
  68. extern int es8388_voice_init(void);
  69. extern int audio_init(void);
  70. extern int audio_pcm_init(void);
  71. extern void play_voice_open(void);
  72. extern void play_voice_close(void);
  73. static int bl61x_get_heap_size(void);
  74. /****************************************************************************
  75. * Private Function Prototypes
  76. ****************************************************************************/

  77. /****************************************************************************
  78.   * Functions
  79.   ****************************************************************************/


  80. /* lvgl log cb */
  81. void lv_log_print_g_cb(const char* buf)
  82. {
  83.     printf("[LVGL] %s", buf);
  84. }

  85. static TaskHandle_t lvgl_TaskHandle;
  86. #define LVGL_STACK_SIZE 1024
  87. #define LVGL_TASK_PRIORITY 15

  88. void lvgl_task(void* param)
  89. {

  90.     while (1)
  91.     {
  92.         lv_task_handler();
  93.         vTaskDelay(1);
  94.         // bflb_mtimer_delay_ms(1);
  95.     }
  96. }

  97. void io2_set(uint8_t value)
  98. {
  99.     struct bflb_device_s* gpio;
  100.     gpio = bflb_device_get_by_name("gpio");
  101.     bflb_gpio_init(gpio, GPIO_PIN_2, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
  102.     if (value)
  103.     {
  104.         bflb_gpio_set(gpio, GPIO_PIN_2);
  105.     }
  106.     else
  107.     {
  108.         bflb_gpio_reset(gpio, GPIO_PIN_2);
  109.     }

  110. }


  111. static void bl61x_show_heap_size_task(void* arg)
  112. {

  113.     while (1) {
  114.         LOG_F("[%s:%d]heap_size-------> %d\r\n", DBG_TAG, __LINE__, bl61x_get_heap_size());
  115.         vTaskDelay(3000/portTICK_PERIOD_MS);
  116.     }
  117. }

  118. void wifi_event_handler(uint32_t code)
  119. {
  120. }
  121. lv_ui guider_ui;

  122. int main(void)
  123. {

  124.     board_init();
  125.     // audio_init();
  126.     // audio_pcm_init();
  127.     // es8388_voice_init();

  128.     // uart0 = bflb_device_get_by_name("uart0");
  129.     // shell_init_with_task(uart0);

  130.     // printf("HeapSize:%d\r\n",xPortGetFreeHeapSize());
  131.     tcpip_init(NULL, NULL);
  132.    
  133.     //lwip_sntp_init();
  134.     //init easyflash
  135.     bflb_mtd_init();
  136.     easyflash_init();
  137.     /* lvgl init */
  138.     lv_log_register_print_cb(lv_log_print_g_cb);
  139.     lv_init();
  140.     lv_port_disp_init();
  141.     lv_port_indev_init();

  142.     setup_ui(&guider_ui);

  143.     printf("lv_task_handler\r\n");
  144.     // lv_task_handler();
  145.     custom_init(&guider_ui);
  146.     printf("lvgl success\r\n");
  147.     xTaskCreate(lvgl_task, (char*)"lvgl", LVGL_STACK_SIZE, NULL, LVGL_TASK_PRIORITY, &lvgl_TaskHandle);
  148.     xTaskCreate(bl61x_show_heap_size_task, (char*)"heap", 1024, NULL, 2, NULL);
  149.     // printf("HeapSize:%d\r\n",xPortGetFreeHeapSize());

  150.     vTaskStartScheduler();

  151.     // while (1) {
  152.     //     lv_task_handler();
  153.     //     bflb_mtimer_delay_ms(1);
  154.     // }

  155.     while (1) {
  156.         // printf("\r\n[%s] heap size ------------------- %d\r\n", __func__, xPortGetFreeHeapSize());
  157.         vTaskDelay(5000/portTICK_RATE_MS);
  158.     }
  159. }
  160. static int bl61x_get_heap_size(void)
  161. {
  162.     struct meminfo info1 = { 0 };
  163.     struct meminfo info2 = { 0 };
  164.     uint32_t total_free_size = 0;
  165.     // return xPortGetFreeHeapSize();

  166.     bflb_mem_usage(KMEM_HEAP, &info1);
  167.     bflb_mem_usage(PMEM_HEAP, &info2);

  168.     total_free_size = info1.free_size + info2.free_size;

  169.     return total_free_size;
  170. }
复制代码
因为,不用连wifi,我看泽哥教程 零基础开发小安派-Eyes-S1【入门篇】——工程文件架构 里提到,要改 flash_prog_cfg.ini 文件
  1. [cfg]
  2. # 0: no erase, 1:programmed section erase, 2: chip erase
  3. erase = 1
  4. # skip mode set first para is skip addr, second para is skip len, multi-segment region with ; separated
  5. skip_mode = 0x0, 0x0
  6. # 0: not use isp mode, #1: isp mode
  7. boot2_isp_mode = 0

  8. [FW]
  9. filedir = ./build/build_out/Eyes_$(CHIPNAME).bin
  10. address = 0x10000
复制代码
默认,整个界面显示会顺时针旋转90度(默认的是竖屏)
由于,我粘到快递盒上是横屏,还需要改 lcd_conf_user.h 文件
注释掉 #define LCD_ROTATED_NONE
根据需要选择要旋转的角度
6.png

好像就没有需要改的地方了吧,如果你们编译报错的话,直接下载我胡乱改好的吧
make编译,make flash COMX=COMXX 烧录到小安派
QQ图片20230909205948.jpg

强调一下,编译的时候,心里默念 “厉不厉害,你坤哥” 有助于编译一次成功
4.png

本帖被以下淘专辑推荐:

  • · LVGL|主题: 19, 订阅: 2
知足常乐
回复

使用道具 举报

ifwz1729 | 2023-9-9 20:51:39 | 显示全部楼层
上一篇发错版块了,发到DIY经验分享了
知足常乐
回复 支持 反对

使用道具 举报

ifwz1729 | 2023-9-9 21:07:33 | 显示全部楼层
QQ图片20230909212050.jpg
知足常乐
回复 支持 反对

使用道具 举报

ai_mcu | 2023-9-9 22:56:38 来自手机 | 显示全部楼层
半夜打卡一下
明天总会更好
回复 支持 反对

使用道具 举报

WYG | 2023-9-9 23:35:31 | 显示全部楼层
打卡学习
回复

使用道具 举报

王乐乐 | 2023-9-10 08:45:41 | 显示全部楼层
666
回复

使用道具 举报

可乐klelee | 2023-9-10 09:39:51 | 显示全部楼层
牛的牛的
回复

使用道具 举报

翁vjk | 2023-9-10 10:03:05 | 显示全部楼层
打卡学习一下
回复 支持 反对

使用道具 举报

jkernet | 2023-9-10 10:53:10 来自手机 | 显示全部楼层
学习打卡
回复

使用道具 举报

Ject | 2023-9-10 10:55:10 | 显示全部楼层
学习一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则