<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[使用UIFlow2的M5GFX积木切换图片，图片组件崩溃问题]]></title><description><![CDATA[<p dir="auto">我在UIFlow2.3.3里使用M5GFX实现最简单的图片切换，频繁切换后发现，图片无法再切换，但系统还在运行，只是不能切换图片，怀疑应该是图片组件崩溃了。我尝试用gc.collect强制回收也没有效果，gc.mem_free监测发现内存一直持续减少。以下是我的UIFlow设计和相应的代码：<br />
import os, sys, io, gc<br />
import M5<br />
from M5 import *</p>
<p dir="auto">ImageSwitchFlag = None</p>
<p dir="auto">def GcCollectAndPrint():<br />
global ImageSwitchFlag<br />
gc.collect()<br />
print(gc.mem_free())<br />
pass</p>
<p dir="auto">def btnA_wasClicked_event(state):<br />
global ImageSwitchFlag<br />
if ImageSwitchFlag == 0:<br />
M5.Lcd.drawImage("/flash/res/img/RotaryBGBacklight.jpg", 0, 0)<br />
GcCollectAndPrint()<br />
ImageSwitchFlag = 1<br />
elif ImageSwitchFlag == 1:<br />
M5.Lcd.drawImage("/flash/res/img/RotaryBGBT.jpg", 0, 0)<br />
GcCollectAndPrint()<br />
ImageSwitchFlag = 0</p>
<p dir="auto">def setup():<br />
global ImageSwitchFlag</p>
<p dir="auto">M5.begin()<br />
Widgets.fillScreen(0x000000)</p>
<p dir="auto">BtnA.setCallback(type=BtnA.CB_TYPE.WAS_CLICKED, cb=btnA_wasClicked_event)</p>
<p dir="auto">ImageSwitchFlag = 0</p>
<p dir="auto">def loop():<br />
global ImageSwitchFlag<br />
M5.update()</p>
<p dir="auto">if name == 'main':<br />
try:<br />
setup()<br />
while True:<br />
loop()<br />
except (Exception, KeyboardInterrupt) as e:<br />
try:<br />
from utility import print_error_msg<br />
print_error_msg(e)<br />
except ImportError:<br />
print("please update to latest firmware")******</p>
<p dir="auto"><img src="/assets/uploads/files/1756081882278-c300437e-5262-492f-8008-95cb7b6230b1-image.png" alt="c300437e-5262-492f-8008-95cb7b6230b1-image.png" class=" img-fluid img-markdown" /> b442ffec-d9ce-4445-898c-4b8ffc3caa82-image.png</p>
]]></description><link>https://community.m5stack.com/topic/7778/使用uiflow2的m5gfx积木切换图片-图片组件崩溃问题</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 10:04:02 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7778.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Aug 2025 00:31:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 使用UIFlow2的M5GFX积木切换图片，图片组件崩溃问题 on Mon, 25 Aug 2025 07:16:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kuriko" aria-label="Profile: kuriko">@<bdi>kuriko</bdi></a> OKOK</p>
]]></description><link>https://community.m5stack.com/post/29839</link><guid isPermaLink="true">https://community.m5stack.com/post/29839</guid><dc:creator><![CDATA[zhumingqi]]></dc:creator><pubDate>Mon, 25 Aug 2025 07:16:46 GMT</pubDate></item><item><title><![CDATA[Reply to 使用UIFlow2的M5GFX积木切换图片，图片组件崩溃问题 on Mon, 25 Aug 2025 02:57:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zhumingqi" aria-label="Profile: zhumingqi">@<bdi>zhumingqi</bdi></a><br />
已知问题，会排期修复</p>
]]></description><link>https://community.m5stack.com/post/29838</link><guid isPermaLink="true">https://community.m5stack.com/post/29838</guid><dc:creator><![CDATA[kuriko]]></dc:creator><pubDate>Mon, 25 Aug 2025 02:57:43 GMT</pubDate></item></channel></rss>