移远EC600U-CN开发板 11.17

主界面:

*代码

def getData(evt):
    getDataBtn =  evt.get_code()           
    if getDataBtn == lv.EVENT.CLICKED:
        uart1 = UART(UART.UART2,9600, 8, 0, 1, 0)
        uart1.write("\x03\x03\x00\x40\x00\x04""44\x3F")
        time.sleep(1)
        arr = uart1.read(13)
        for i in arr:
            print(((hex(int(i))).upper()[2:]),end=' ')
        zhuodu = int(str((hex(int(arr[3]))).upper()[2:])+str((hex(int(arr[4]))).upper()[2:])+str((hex(int(arr[5]))).upper()[2:])+str((hex(int(arr[6]))).upper()[2:]),16)
        zengyi = int(str((hex(int(arr[7]))).upper()[2:])+str((hex(int(arr[8]))).upper()[2:])+str((hex(int(arr[9]))).upper()[2:])+str((hex(int(arr[10]))).upper()[2:]),16)
        print(zhuodu)
        label.set_text(str(zhuodu/1000))
        arc.set_value(int(zhuodu/10))
        print(zengyi)
        label3.set_text(str(zengyi))
        arc1.set_value(int(zengyi/1000))
        uart1.close()
        time.sleep(1)
def event_cb(evt):
    arc = evt.get_target()
    current_value = '{:.2f}'.format(float(arc.get_value())/100)
    print(current_value)
    label.set_text(str(current_value))

def event_cb1(evt):
    arc1 = evt.get_target()
    current_value = arc1.get_value()
    label3.set_text(str(current_value))

mainInterface = lv.obj()            #主界面
mainInterface.set_size(480,854)

label = lv.label(mainInterface)
label.set_long_mode(lv.label.LONG.WRAP)
label.set_recolor(True)   
label.set_text("#0000ff 远# #ff00ff 感#")

self_myfont_cn = lv.font_load("U:/alibabapuhuiti-20.bin")       #文字设置
mainInterface.set_style_text_font(self_myfont_cn, 0)

label.set_width(150)
label.set_style_text_align(lv.ALIGN.CENTER,0)
label.align(lv.ALIGN.TOP_LEFT,20,10)

btn = lv.btn(mainInterface) 
btn.align(lv.ALIGN.TOP_LEFT,20,30)
labelbtn = lv.label(btn)
labelbtn.set_text('端口设置')
  
btn.add_event_cb(event_handler,lv.EVENT.ALL,None)

arc = lv.arc(mainInterface)
arc.set_end_angle(200)
arc.set_size(150,150)
arc.align(lv.ALIGN.CENTER,-120,0)
arc.add_event_cb(event_cb, lv.EVENT.VALUE_CHANGED, None)
arc.set_range(0,3000)
label = lv.label(arc)
label.set_text("0%")

label2 = lv.label(mainInterface)
label2.align(lv.ALIGN.CENTER,-120,0)
label2.set_text("平均浊度值")

arc1 = lv.arc(mainInterface)
arc1.set_size(150,150)
arc1.align(lv.ALIGN.CENTER,120,0)
arc1.add_event_cb(event_cb1, lv.EVENT.VALUE_CHANGED, None)
arc1.set_range(0,200000)
label3 = lv.label(arc1)
label3.set_text("0%")

label4 = lv.label(mainInterface)
label4.align(lv.ALIGN.CENTER,120,0)
label4.set_text("平均增益值")

getDataBtn = lv.btn(mainInterface)  #获取数据按钮
getDataBtn.align(lv.ALIGN.BOTTOM_MID,0,-40)
getDataBtnLabel = lv.label(getDataBtn)
getDataBtnLabel.set_text('获取数据')
getDataBtn.add_event_cb(getData,lv.EVENT.ALL, None)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值