43浏览
查看: 43|回复: 0

[Micropython] 尝鲜DFRobot ESP32-C5开发板,玩转LVGL Micropython

[复制链接]
本帖最后由 PY学习笔记 于 2025-8-25 14:55 编辑

近期,DFRobot 推出了全新开发板 FireBeetle 2 ESP32-C5。这块开发板搭载了 ESP32-C5 主控,集成 支持5GHz的Wi-Fi6(意思为可以连接5G网络),凭借强劲性能,令人眼前一亮。很荣幸能抢先体验这块开发板!
1.开发板介绍
FireBeetle 2 ESP32-C5有很多外设:
  • Type-C:USB接口
  • Charge:充电指示灯

    • 熄灭:未接入电源或已充满
    • 常亮: 充电中

  • 15/D13:板载LED引脚
  • RST:复位按键
  • 28/BOOT:IO28引脚/BOOT按键
  • BAT:锂电池接口,支持3.7~4.2V
  • lO1:电池电压检测引脚
  • 3V3_C:IO0控制3.3V电源输出,默认关闭,可高电平开启。
  • GDI:GDI显示屏接口
  • ESP32-C5:型号为ESP32-C5-WROOM-1模组

2.micropython编译
由于 MicroPython 官方尚未支持 ESP32-C5,支持尚需时日,我直接采用 GitHub PR 中某位大佬的半成品,稍作修改后,再集成到lvgl_micropython项目中,所以过程复杂,而且很多人并不想自行编译,所以这里,只放固件了(固件后期DF工作人员也会会放在文档中)。
3.烧录
参考《一文掌握ESP32固件烧录(flash)》,注意:
烧录地址为:0x002000
建议使用UART进行烧录,我这边无法使用USB烧录
烧录了较大的固件就无法刷较小的固件(因为现在还不支持擦除效果)
4.正式体验
注意:因为扩展板有问题,在测试之前请把扩展板拔下来。
1.普通MicroPython部分
LED测试:
  1. from machine import Pin
  2. import time
  3. led=Pin(15,Pin.OUT)
  4. while True:
  5.     led.on()
  6.     time.sleep(0.5)
  7.     led.off()
  8.     time.sleep(0.5)
复制代码

联网测试:
  1. import network,time
  2. SSID = 'SSID'
  3. PWD = 'PWD'
  4. def connect():
  5.     wlan = network.WLAN(network.STA_IF)
  6.     wlan.active(True)
  7.     if not wlan.isconnected():
  8.         print('esp32c5正在联网',end="")
  9.         wlan.connect(SSID, PWD)
  10.         while not wlan.isconnected():
  11.             print(".",end="")
  12.             time.sleep(1)
  13.     print('\n网络信息为: ', wlan.ifconfig())
  14. connect()
复制代码


联网扩展测试(串口与AI对话):
  1. import network
  2. import time
  3. import urequests
  4. import ujson,micropython,select,sys
  5. from machine import reset
  6. # ====== 配置部分 ======
  7. SSID = 'SSID'
  8. PASSWORD = 'PWD'
  9. API_KEY = "API-KEY"
  10. API_URL = "https://api.siliconflow.cn/v1/chat/completions"
  11. def connect_wifi():
  12.     wlan = network.WLAN(network.STA_IF)
  13.     wlan.active(True)
  14.     if not wlan.isconnected():
  15.         print('esp32c5正在联网',end="")
  16.         wlan.connect(SSID, PASSWORD)
  17.         while not wlan.isconnected():
  18.             print(".",end="")
  19.             time.sleep(1)
  20.     print('网络信息为: ', wlan.ifconfig())
  21.     print("连接成功!")
  22.     return wlan
  23. def api_request():
  24.     headers = {
  25.         "Authorization": "Bearer sk-fzvjpoldzvziuvdrvrjiadercddliahbfyohdrnfnnaedjmt",
  26.         "Content-Type": "application/json"
  27.     }
  28.    
  29.     micropython.kbd_intr(-1)
  30.     print("您:",end="")
  31.     while True:
  32.         
  33.         while sys.stdin in select.select([sys.stdin],[],[],0)[0]:
  34.             #print("您:",end="")
  35.             sp= sys.stdin.readline().replace("\n", "").replace(" ", "")
  36.             if sp != "":
  37.                 #sp = str(input("您:"))
  38.                 #print("您:"+sp)
  39.                 payload = {
  40.                 "model": "Qwen/Qwen3-8B",
  41.                 "messages": [  # 必须包含消息内容
  42.                     {"role": "system", "content": "你是我的AI助手qwen,你必须用中文回答且字数不超过85个,思考时间不超过1秒"},
  43.                     {"role": "user", "content": sp}
  44.                 ],
  45.                 "enable_thinking":False,
  46.                
  47.             }
  48.                 print("AI正在思考中...")
  49.                 #print("Payload:", payload)
  50.                 start_time = time.time()
  51.                 response = urequests.post(
  52.                     API_URL,
  53.                     headers=headers,
  54.                     data=ujson.dumps(payload).encode('utf-8'),
  55.                     #timeout=20
  56.                 )
  57.                 response_time = time.time() - start_time
  58.                 print(f"AI思考了{response_time:.1f}s")
  59.                 #print(f"\n[Response] Status: {response.status_code}")
  60.                 if response.status_code == 200:
  61.                     json_resp = response.json()
  62.                     print("AI回复:", json_resp['choices'][0]['message']['content'].replace("\n", ""))
  63.                 else:
  64.                     print("Error Response:", response.text)
  65.                     
  66.                 response.close()
  67.                 print("您:",end="")
  68.         
  69.    
  70. print("=== 启动系统 ===")
  71. connect_wifi()
  72. api_request()
复制代码


2.LVGL+MicroPython部分
先把屏幕的驱动下载进板子里(命名为screen.py),这里以ILI9488+GT911为主,其它的屏幕DF工作人员正在撰写对应文档,如果更新了即可下载:
  1. import lcd_bus
  2. from micropython import const
  3. import machine
  4. import lcd_utils
  5. # 创建SPI总线对象
  6. spi_bus = machine.SPI.Bus(
  7.     host=1,
  8.     mosi=24,
  9.     miso=25,
  10.     sck=23,
  11. )
  12. # 创建显示屏的SPI通信对象
  13. display_bus = lcd_bus.SPIBus(
  14.     spi_bus=spi_bus,
  15.     freq=40000000,
  16.     dc=8,
  17.     cs=27,
  18. )
  19. import ili9488
  20. import lvgl as lv
  21. import task_handler
  22. # 创建显示屏对象
  23. display = ili9488.ILI9488(
  24.     data_bus=display_bus,
  25.     display_width=320,
  26.     display_height=480,
  27.     backlight_pin=15,
  28.     reset_pin=26,
  29.     reset_state=ili9488.STATE_LOW,
  30.     color_space=lv.COLOR_FORMAT.RGB888,
  31.     color_byte_order=ili9488.BYTE_ORDER_RGB,
  32.     rgb565_byte_swap=True,
  33. )
  34. import i2c
  35. import task_handler
  36. import gt911
  37. # 初始化显示屏
  38. display.init()
  39. # 定义触摸屏的I2C通信参数
  40. i2c_bus = i2c.I2C.Bus(host=0, scl=10, sda=9, freq=400000, use_locks=False)
  41. print(i2c_bus.scan())
  42. touch_dev = i2c.I2C.Device(bus=i2c_bus, dev_id=0x5D, reg_bits=gt911.BITS)
  43. # 创建触摸屏设备对象
  44. indev = gt911.GT911(touch_dev)
  45. # 启用输入优先级
  46. indev.enable_input_priority()
  47. # 旋转显示
  48. display.set_rotation(lv.DISPLAY_ROTATION._270)
  49. # 打开屏幕背光
  50. display.set_backlight(1)
  51. th = task_handler.TaskHandler()
复制代码


滑块测试:
  1. import screen
  2. import lvgl as lv
  3. scrn = lv.screen_active()# 获取当前激活的屏幕对象
  4. scrn.set_style_bg_color(lv.color_hex(0x000000), 0)# 设置屏幕的背景颜色为黑色
  5. slider = lv.slider(scrn)# 创建一个滑块
  6. slider.set_size(200, 50)# 设置滑块的大小为宽度300,高50
  7. slider.center()# 将滑块居中显示
  8. label = lv.label(scrn)# 创建一个标签
  9. label.set_text('HELLO LVGL_MICROPYTHON!')# 标签内容
  10. label.align(lv.ALIGN.CENTER, 0, -50)# 将标签对齐到屏幕中心,并向上偏移50
复制代码


打砖块测试:
  1. import screen
  2. import lvgl as lv
  3. scrn = lv.screen_active()# 获取当前激活的屏幕对象
  4. scrn.set_style_bg_color(lv.color_hex(0x000000), 0)# 设置屏幕的背景颜色为黑色
  5. slider = lv.slider(scrn)# 创建一个滑块
  6. slider.set_size(200, 50)# 设置滑块的大小为宽度300,高50
  7. slider.center()# 将滑块居中显示
  8. label = lv.label(scrn)# 创建一个标签
  9. label.set_text('HELLO LVGL_MICROPYTHON!')# 标签内容
  10. label.align(lv.ALIGN.CENTER, 0, -50)# 将标签对齐到屏幕中心,并向上偏移50import screen, math, gc
  11. import lvgl as lv
  12. SCREEN_W = 480
  13. SCREEN_H = 320
  14. on_pad = True          # 球是否还在板上
  15. # ---------------- 物理参数 ----------------
  16. BALL_R   = 8               # 小球半径
  17. MAT_W    = 80
  18. MAT_H    = 15              # 薄板
  19. VEL_Y0   = -6              # 初始向上速度
  20. # ---------------- 全局对象 ----------------
  21. scrn = lv.screen_active()
  22. scrn.set_style_bg_color(lv.color_hex(0x000000), 0)
  23. # 容器(避免坐标系混乱)
  24. root = lv.obj(scrn)
  25. root.remove_style_all()
  26. root.set_size(SCREEN_W, SCREEN_H)
  27. root.center()
  28. # 弹力板
  29. mat = lv.obj(root)
  30. mat.set_size(MAT_W, MAT_H)
  31. mat.set_style_bg_color(lv.palette_main(lv.PALETTE.GREEN), 0)
  32. mat.set_y(SCREEN_H - MAT_H - 5)           # 固定高度
  33. # 小球
  34. ball = lv.obj(root)        # 用 obj 比 led 更易控制
  35. ball.set_size(BALL_R*2, BALL_R*2)
  36. ball.set_style_radius(BALL_R, 0)
  37. ball.set_style_bg_color(lv.palette_main(lv.PALETTE.ORANGE), 0)
  38. # 砖块
  39. BRICK_W = 31
  40. BRICK_H = 15
  41. BRICK_GAP = 2
  42. BRICK_COLS = SCREEN_W // (BRICK_W + BRICK_GAP)
  43. BRICK_ROWS = 5
  44. bricks = []
  45. for r in range(BRICK_ROWS):
  46.     for c in range(BRICK_COLS):
  47.         b = lv.obj(root)
  48.         b.set_size(BRICK_W, BRICK_H)
  49.         b.set_style_bg_color(
  50.             lv.palette_main(lv.PALETTE.BLUE if r % 2 else lv.PALETTE.RED), 0)
  51.         b.set_pos(c*(BRICK_W+BRICK_GAP),
  52.                   5 + r*(BRICK_H+BRICK_GAP))
  53.         bricks.append(b)
  54. # ---------------- 物理量 ----------------
  55. ball_x  = SCREEN_W // 2
  56. ball_y  = SCREEN_H - 50
  57. vx      = 0
  58. vy      = VEL_Y0
  59. game_over = False
  60. def reset_ball():
  61.     global ball_x, ball_y, vx, vy, game_over, on_pad
  62.     ball_x = mat.get_x() + MAT_W // 2      # 直接按板子位置算
  63.     ball_y = mat.get_y() - BALL_R
  64.     vx = 0
  65.     vy = VEL_Y0
  66.     game_over = False
  67.     on_pad = True          # 复位后球在板上
  68.     ball.set_pos(int(ball_x - BALL_R), int(ball_y - BALL_R))
  69. # ---------------- 定时器 ----------------
  70. def update_timer(t):
  71.     global ball_x, ball_y, vx, vy, game_over, on_pad
  72.     if game_over:
  73.         return
  74.     # 如果球还在板上,先让球水平跟着板子
  75.     if on_pad:
  76.         ball_x = mat.get_x() + MAT_W // 2
  77.         ball_y = mat.get_y() - BALL_R
  78.         ball.set_pos(int(ball_x - BALL_R), int(ball_y - BALL_R))
  79.         return
  80.     else:
  81.         # 原来的物理运动
  82.         ball_x += vx
  83.         ball_y += vy
  84.         # 边界反弹
  85.         if ball_x - BALL_R < 0 or ball_x + BALL_R > SCREEN_W:
  86.             vx = -vx
  87.             ball_x = max(BALL_R, min(SCREEN_W - BALL_R, ball_x))
  88.         if ball_y - BALL_R < 0:
  89.             vy = -vy
  90.             ball_y = BALL_R
  91.         # 掉出底部
  92.         if ball_y + BALL_R > SCREEN_H:
  93.             reset_ball()
  94.             return
  95.         # 与板碰撞
  96.         mat_left  = mat.get_x()
  97.         mat_right = mat_left + MAT_W
  98.         if (ball_y + BALL_R >= mat.get_y() and
  99.             ball_y - BALL_R <= mat.get_y() + MAT_H and
  100.             ball_x + BALL_R >= mat_left and
  101.             ball_x - BALL_R <= mat_right and
  102.             vy > 0):                 # 必须正在下落才反弹
  103.             hit_pos = (ball_x - mat_left) / MAT_W
  104.             vx = (hit_pos - 0.5) * 10
  105.             vy = -abs(vy)
  106.             ball_y = mat.get_y() - BALL_R
  107.         # ---------------- 碰撞检测 ----------------
  108.         to_delete = []                   # 1. 先收集要删的砖块
  109.         for brick in bricks:
  110.             bx, by = brick.get_x(), brick.get_y()
  111.             bw, bh = BRICK_W, BRICK_H
  112.             if (ball_x + BALL_R > bx and
  113.                 ball_x - BALL_R < bx + bw and
  114.                 ball_y + BALL_R > by and
  115.                 ball_y - BALL_R < by + bh):
  116.                 # 计算最小重叠方向
  117.                 overlap_l = (ball_x + BALL_R) - bx
  118.                 overlap_r = (bx + bw) - (ball_x - BALL_R)
  119.                 overlap_t = (ball_y + BALL_R) - by
  120.                 overlap_b = (by + bh) - (ball_y - BALL_R)
  121.                 min_overlap = min(overlap_l, overlap_r, overlap_t, overlap_b)
  122.                 if min_overlap == overlap_t or min_overlap == overlap_b:
  123.                     vy = -vy
  124.                 else:
  125.                     vx = -vx
  126.                 to_delete.append(brick)   # 2. 只记录,不立即删
  127.         # 3. 统一删除并回收
  128.         for brick in to_delete:
  129.             brick.delete()
  130.             bricks.remove(brick)
  131.         gc.collect()                      # 立即释放已删对象
  132.     # 4. 统一刷新显示
  133.     ball.set_pos(int(ball_x - BALL_R), int(ball_y - BALL_R))
  134. # ---------------- 触摸回调 ----------------
  135. def touch_cb(e):
  136.     global on_pad, vx, vy, ball_x, ball_y
  137.    
  138.     code = e.get_code()
  139.     point = lv.point_t()
  140.     screen.indev.get_point(point)
  141.    
  142.     # 板子移动逻辑(所有触摸状态都处理)
  143.     new_x = point.x - MAT_W // 2
  144.     new_x = max(0, min(SCREEN_W - MAT_W, new_x))
  145.     mat.set_x(new_x)
  146.    
  147.     # 球在板上时的同步处理
  148.     if code == lv.EVENT.PRESSING:
  149.         if on_pad == 1:
  150.             ball_x = new_x + MAT_W // 2
  151.             ball_y = mat.get_y() - BALL_R
  152.         else:
  153.             ball_x += vx
  154.             ball_y += vy
  155.             # 边界反弹
  156.             if ball_x - BALL_R < 0 or ball_x + BALL_R > SCREEN_W:
  157.                 vx = -vx
  158.                 ball_x = max(BALL_R, min(SCREEN_W - BALL_R, ball_x))
  159.             if ball_y - BALL_R < 0:
  160.                 vy = -vy
  161.                 ball_y = BALL_R
  162.             # 掉出底部
  163.             if ball_y + BALL_R > SCREEN_H:
  164.                 reset_ball()
  165.                 return
  166.             # 与板碰撞
  167.             mat_left  = mat.get_x()
  168.             mat_right = mat_left + MAT_W
  169.             if (ball_y + BALL_R >= mat.get_y() and
  170.                 ball_y - BALL_R <= mat.get_y() + MAT_H and
  171.                 ball_x + BALL_R >= mat_left and
  172.                 ball_x - BALL_R <= mat_right and
  173.                 vy > 0):                 # 必须正在下落才反弹
  174.                 hit_pos = (ball_x - mat_left) / MAT_W
  175.                 vx = (hit_pos - 0.5) * 10
  176.                 vy = -abs(vy)
  177.                 ball_y = mat.get_y() - BALL_R
  178.             # ---------------- 碰撞检测 ----------------
  179.             to_delete = []                   # 1. 先收集要删的砖块
  180.             for brick in bricks:
  181.                 bx, by = brick.get_x(), brick.get_y()
  182.                 bw, bh = BRICK_W, BRICK_H
  183.                 if (ball_x + BALL_R > bx and
  184.                     ball_x - BALL_R < bx + bw and
  185.                     ball_y + BALL_R > by and
  186.                     ball_y - BALL_R < by + bh):
  187.                     # 计算最小重叠方向
  188.                     overlap_l = (ball_x + BALL_R) - bx
  189.                     overlap_r = (bx + bw) - (ball_x - BALL_R)
  190.                     overlap_t = (ball_y + BALL_R) - by
  191.                     overlap_b = (by + bh) - (ball_y - BALL_R)
  192.                     min_overlap = min(overlap_l, overlap_r, overlap_t, overlap_b)
  193.                     if min_overlap == overlap_t or min_overlap == overlap_b:
  194.                         vy = -vy
  195.                     else:
  196.                         vx = -vx
  197.                     to_delete.append(brick)   # 2. 只记录,不立即删
  198.             # 3. 统一删除并回收
  199.             for brick in to_delete:
  200.                 brick.delete()
  201.                 bricks.remove(brick)
  202.             gc.collect()                      # 立即释放已删对象
  203.         ball.set_pos(int(ball_x - BALL_R), int(ball_y - BALL_R))
  204.         
  205.     # 仅PRESSED事件触发发射
  206.     elif code == lv.EVENT.PRESSED and on_pad == 1:
  207.         hit_pos = (ball_x - mat.get_x()) / MAT_W
  208.         vx = (hit_pos - 0.5) * 10
  209.         vy = VEL_Y0
  210.         on_pad = False
  211.         # 发射后立即更新一次位置
  212.         ball.set_pos(int(ball_x - BALL_R), int(ball_y - BALL_R))
  213. # 启动定时器
  214. lv.timer_create(update_timer, 50, None)
  215. root.add_event_cb(touch_cb, lv.EVENT.PRESSED, None)
  216. root.add_event_cb(touch_cb, lv.EVENT.PRESSING, None)
  217. reset_ball()
复制代码


时间表盘测试:
  1. import screen
  2. import time,gc
  3. import lvgl as lv
  4. from machine import Pin, Timer
  5. import math
  6. scrn = lv.screen_active()
  7. scrn.set_style_bg_color(lv.color_hex(0x000000), 0)
  8. class AnalogClock:
  9.     def __init__(self, parent):
  10.         self.scale = None
  11.         self.second_hand = None
  12.         self.minute_hand = None
  13.         self.hour_hand = None
  14.         # 获取当前时间
  15.         now = time.localtime()
  16.         self.hour = now[3] % 12  # 转换为12小时制
  17.         self.minute = now[4]
  18.         self.second = now[5]
  19.         self.create_clock(parent)
  20.         self.start_timer()
  21.     def create_clock(self, parent):
  22.         """创建模拟时钟组件"""
  23.         # 创建表盘主体(保持120x120大小)
  24.         self.scale = lv.scale(parent)
  25.         self.scale.set_size(200, 200)
  26.         self.scale.set_mode(lv.scale.MODE.ROUND_INNER)
  27.         
  28.         # 设置表盘样式(保持不变)
  29.         self.scale.set_style_bg_opa(lv.OPA._60, 0)
  30.         self.scale.set_style_bg_color(lv.color_hex(0x222222), 0)
  31.         self.scale.set_style_radius(lv.RADIUS_CIRCLE, 0)
  32.         self.scale.set_style_clip_corner(True, 0)
  33.         self.scale.center()
  34.         # 配置刻度系统(保持不变)
  35.         self.scale.set_label_show(True)
  36.         hour_labels = ["12", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", None]
  37.         self.scale.set_text_src(hour_labels)
  38.         self.scale.set_style_text_font(lv.font_montserrat_12, 0)
  39.         self.scale.set_total_tick_count(61)
  40.         self.scale.set_major_tick_every(5)
  41.         # 主刻度样式(保持不变)
  42.         style_indicator = lv.style_t()
  43.         style_indicator.init()
  44.         style_indicator.set_text_color(lv.color_hex(0xFFFFFF))
  45.         style_indicator.set_line_color(lv.color_hex(0xFFFFFF))
  46.         style_indicator.set_length(5)
  47.         style_indicator.set_line_width(2)
  48.         self.scale.add_style(style_indicator, lv.PART.INDICATOR)
  49.         # 次刻度样式(保持不变)
  50.         style_minor = lv.style_t()
  51.         style_minor.init()
  52.         style_minor.set_line_color(lv.color_hex(0xAAAAAA))
  53.         style_minor.set_length(3)
  54.         style_minor.set_line_width(1)
  55.         self.scale.add_style(style_minor, lv.PART.ITEMS)
  56.         # 表盘边框样式(保持不变)
  57.         style_main = lv.style_t()
  58.         style_main.init()
  59.         style_main.set_arc_color(lv.color_hex(0x222222))
  60.         style_main.set_arc_width(3)
  61.         self.scale.add_style(style_main, lv.PART.MAIN)
  62.         # 设置量程和角度(保持不变)
  63.         self.scale.set_range(0, 60)
  64.         self.scale.set_angle_range(360)
  65.         self.scale.set_rotation(270)
  66.         # 创建秒针(红色,长度90px,细线)
  67.         self.second_hand = lv.line(self.scale)
  68.         self.second_hand.set_style_line_width(1, 0)  # 更细的线宽
  69.         self.second_hand.set_style_line_rounded(True, 0)
  70.         self.second_hand.set_style_line_color(lv.color_hex(0xFFFFFF), 0)
  71.         # 创建分钟指针(蓝色,长度75px)
  72.         self.minute_hand = lv.line(self.scale)
  73.         self.minute_hand.set_style_line_width(3, 0)
  74.         self.minute_hand.set_style_line_rounded(True, 0)
  75.         self.minute_hand.set_style_line_color(lv.color_hex(0x00BFFF), 0)
  76.         # 创建小时指针(橙色,长度60px)
  77.         self.hour_hand = lv.line(self.scale)
  78.         self.hour_hand.set_style_line_width(5, 0)
  79.         self.hour_hand.set_style_line_rounded(True, 0)
  80.         self.hour_hand.set_style_line_color(lv.color_hex(0xFFA500), 0)
  81.         # 添加中心点(保持不变)
  82.         center = lv.obj(self.scale)
  83.         center.set_size(8, 8)  # 稍微减小中心点大小
  84.         center.center()
  85.         center.set_style_radius(lv.RADIUS_CIRCLE, 0)
  86.         center.set_style_bg_color(lv.color_hex(0xFFD700), 0)
  87.         center.set_style_bg_opa(lv.OPA.COVER, 0)
  88.         self.update_hands()
  89.     def update_hands(self):
  90.         """更新所有指针位置"""
  91.         # 秒针(90px长度)
  92.         lv.scale.set_line_needle_value(self.scale, self.second_hand, 90, self.second)
  93.         
  94.         # 分钟指针(75px长度)
  95.         lv.scale.set_line_needle_value(self.scale, self.minute_hand, 75, self.minute)
  96.         
  97.         # 小时指针(60px长度),考虑分钟偏移
  98.         hour_value = self.hour * 5 + (self.minute // 12)
  99.         lv.scale.set_line_needle_value(self.scale, self.hour_hand, 60, hour_value)
  100.     def timer_callback(self, timer):
  101.         """定时器回调(每秒更新)"""
  102.         # 获取当前时间
  103.         now = time.localtime()
  104.         self.hour = now[3] % 12
  105.         self.minute = now[4]
  106.         self.second = now[5]
  107.         
  108.         self.update_hands()
  109.         gc.collect()
  110.     def start_timer(self):
  111.         """启动硬件定时器(每秒触发)"""
  112.         self.timer = Timer(1)
  113.         self.timer.init(period=1000, mode=Timer.PERIODIC, callback=self.timer_callback)
  114. # 创建时钟实例
  115. clock = AnalogClock(scrn)
复制代码

5.效果



6.问题解答
尝鲜DFRobot ESP32-C5开发板,玩转LVGL Micropython图7

以上的问题是由于设备已经初始化一次了,不能重复初始化,将板子重启再次运行即可




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

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4 备案 沪公网安备31011502402448

© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail