@kuriko OKOK
Posts made by zhumingqi
-
使用UIFlow2的M5GFX积木切换图片,图片组件崩溃问题
我在UIFlow2.3.3里使用M5GFX实现最简单的图片切换,频繁切换后发现,图片无法再切换,但系统还在运行,只是不能切换图片,怀疑应该是图片组件崩溃了。我尝试用gc.collect强制回收也没有效果,gc.mem_free监测发现内存一直持续减少。以下是我的UIFlow设计和相应的代码:
import os, sys, io, gc
import M5
from M5 import *ImageSwitchFlag = None
def GcCollectAndPrint():
global ImageSwitchFlag
gc.collect()
print(gc.mem_free())
passdef btnA_wasClicked_event(state):
global ImageSwitchFlag
if ImageSwitchFlag == 0:
M5.Lcd.drawImage("/flash/res/img/RotaryBGBacklight.jpg", 0, 0)
GcCollectAndPrint()
ImageSwitchFlag = 1
elif ImageSwitchFlag == 1:
M5.Lcd.drawImage("/flash/res/img/RotaryBGBT.jpg", 0, 0)
GcCollectAndPrint()
ImageSwitchFlag = 0def setup():
global ImageSwitchFlagM5.begin()
Widgets.fillScreen(0x000000)BtnA.setCallback(type=BtnA.CB_TYPE.WAS_CLICKED, cb=btnA_wasClicked_event)
ImageSwitchFlag = 0
def loop():
global ImageSwitchFlag
M5.update()if name == 'main':
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")******b442ffec-d9ce-4445-898c-4b8ffc3caa82-image.png
-
RE: UiFlow 2.0 discuss(how-to, bug, feature request or sometings)
Today, I updated the UIFlow to V2.3.4, and burned V2.3.4 firmware as well. Then I tested that image component again with M5GFX in UIFlow 2.3.4. But the issue still exists. After I switch two JPG pics with one image component for sometime, the memory will reduced continiously. Finally, the system will break out. And I try to use gc.collect() after every drawImage(), but it's not useful.
Here is my design and python code:
import os, sys, io, gc
import M5
from M5 import *ImageSwitchFlag = None
def GcCollectAndPrint():
global ImageSwitchFlag
gc.collect()
print(gc.mem_free())
passdef btnA_wasClicked_event(state):
global ImageSwitchFlag
if ImageSwitchFlag == 0:
M5.Lcd.drawImage("/flash/res/img/RotaryBGBacklight.jpg", 0, 0)
GcCollectAndPrint()
ImageSwitchFlag = 1
elif ImageSwitchFlag == 1:
M5.Lcd.drawImage("/flash/res/img/RotaryBGBT.jpg", 0, 0)
GcCollectAndPrint()
ImageSwitchFlag = 0def setup():
global ImageSwitchFlagM5.begin()
Widgets.fillScreen(0x000000)BtnA.setCallback(type=BtnA.CB_TYPE.WAS_CLICKED, cb=btnA_wasClicked_event)
ImageSwitchFlag = 0
def loop():
global ImageSwitchFlag
M5.update()if name == 'main':
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")****** -
RE: UiFlow 2.0 discuss(how-to, bug, feature request or sometings)
I tested more UI design. And I found that the memory leak only happens when I use image component and switch images frequently. Is that a UIFlow2.3.3 bug or my design is incorrect?
-
RE: How to solve the UI memory leak?
I tested more UI design. And I found that the memory leak only happens when I use image component and switch images frequently. Is that a UIFlow2.3.3 bug or my design is incorrect?
-
RE: UiFlow 2.0 discuss(how-to, bug, feature request or sometings)
I used UIFlow2 to devleop a simple UI demo, and I monitor the free memory with gc.mem_free(). I found the free memory reduced continiously though I called gc.collect() every loop. Finally, the UI can not update again, but the loop still was running.
-
How to solve the UI memory leak?
I used UIFlow2.3.3 to develop a simple UI demo. There is only one image widget to switch 2 JPG images every second. When I monitor the memory with gc.mem_free, I found the memory reduced continiously. And finally, the image switching was stop, but the loop was running. I wonder how to solve the UI memory leak? Here is my python code:
import os, sys, io
import M5
from M5 import *
import timeimage0 = None
oldData14 = NoneImgFlag = None
def setup():
global image0, oldData14, ImgFlagM5.begin()
Widgets.fillScreen(0x000000)
image0 = Widgets.Image("/flash/res/img/default.jpg", 0, 0, scale_x=1, scale_y=1)image0.setImage("/flash/res/img/RotaryBGBacklight.jpg")
ImgFlag = 0def loop():
global image0, oldData14, ImgFlag
M5.update()
if (time.localtime())[5] != oldData14:
PrintFreeMem()
oldData14 = (time.localtime())[5]
if ImgFlag == 0:
image0.setImage("/flash/res/img/RotaryBGBT.jpg")
ImgFlag = 1
elif ImgFlag == 1:
image0.setImage("/flash/res/img/RotaryBGBacklight.jpg")
ImgFlag = 0
else:
passdef PrintFreeMem():
print("Free mem:", gc.mem_free())if name == 'main':
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")And my UIFlow2 design:
-
RE: UIFlow2.3.3 can not save project or create new project or delete any project
@kuriko It was recover. Thank you.
-
UIFlow2.3.3 can not save project or create new project or delete any project
This morning I can save project normally. This afternoon I try to delete some images from project files, but I failed. And then I try to save the project, also failed. Finally, I found that I can not operate anything successfully online. I just save the project to local firstly.