1315 views|0 replies

6841

Posts

11

Resources
The OP
 

[Mill MYB-YT507 development board trial experience] Python displays memory and CPU real-time status 2 [Copy link]

 

Fixed data has been presented before. Now change the data source to display data dynamically:

1. Import the psutil module: import psutil

2. Modify the bar function:

def bar_base() -> str:
    myarr = psutil.cpu_percent(percpu=True)
    myarr.append(psutil.virtual_memory().percent)
    print(myarr)
    c = (
        Bar()
        .add_xaxis(["CPU1", "CPU2","CPU3","CPU4","内存"])
        .add_yaxis('', myarr)
        .set_global_opts(yaxis_opts=opts.AxisOpts(min_=1, max_=100))
        .set_global_opts(title_opts=opts.TitleOpts(title="Bar-基本示例", subtitle="我是副标题"))
    )
    return c.dump_options()

3. Update server.py to the development board, and then open the web page:

You can then dynamically display the memory and CPU usage of the development board.

I’m too busy at work now, so I can only get up early and stay up late to write some articles. . . .

This post is from Domestic Chip Exchange
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>
Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list