| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1673 人关注过本帖
标题:如何把这做成有延时100ms的
只看楼主 加入收藏
zzm参谋
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2021-9-23
收藏
 问题点数:0 回复次数:0 
如何把这做成有延时100ms的
firstin1=0
buttonVar1=0xffff
colorflag=0
--------------------------------------------------------------------
function colortemp()    --色温

    lastbutton1 = Get_One_DataVal(0x0800)   

    if buttonVar1~=lastbutton1
    then
        buttonVar1=lastbutton1
        firstin1=1
        colorflag=1
    end
    if firstin1==1
    then

        if 0<=buttonVar1 and buttonVar1<20
        then
            local databuff1={0x28,0x01,0x00,0x12,0xA3,0x72,0x50}
            local databuff2={0x28,0x01,0x00,0x12,0xC3,0x01,0xFF}
            local databuff3={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff4={0x28,0x01,0x00,0x12,0xFF,0xE7,0xFF}
            local databuff5={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff6={0x28,0x01,0x00,0x12,0xFF,0xE2,0xFF}
            if colorflag==1
            then
                SendUartData(databuff1,7)
            elseif colorflag==2
            then
                SendUartData(databuff2,7)
            elseif colorflag==3
            then
                SendUartData(databuff3,7)
            elseif colorflag==4
            then
                SendUartData(databuff4,7)
            elseif colorflag==5
            then
                SendUartData(databuff5,7)
            elseif colorflag==6
            then
                SendUartData(databuff6,7)
                firstin1=0
                colorflag=0
            end     
        elseif 20<=buttonVar1 and buttonVar1<40
        then
            local databuff1={0x28,0x01,0x00,0x12,0xA3,0x1D,0xFB}
            local databuff2={0x28,0x01,0x00,0x12,0xC3,0x01,0xFF}
            local databuff3={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff4={0x28,0x01,0x00,0x12,0xFF,0xE7,0xFF}
            local databuff5={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff6={0x28,0x01,0x00,0x12,0xFF,0xE2,0xFF}
            if colorflag==1
            then
                SendUartData(databuff1,7)
            elseif colorflag==2
            then
                SendUartData(databuff2,7)
            elseif colorflag==3
            then
                SendUartData(databuff3,7)
            elseif colorflag==4
            then
                SendUartData(databuff4,7)
            elseif colorflag==5
            then
                SendUartData(databuff5,7)
            elseif colorflag==6
            then
                SendUartData(databuff6,7)
                firstin1=0
                colorflag=0
            end
        elseif 40<=buttonVar1 and buttonVar1<60
        then
            local databuff1={0x28,0x01,0x00,0x12,0xA3,0xDD,0xBB}
            local databuff2={0x28,0x01,0x00,0x12,0xC3,0x00,0xFE}
            local databuff3={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff4={0x28,0x01,0x00,0x12,0xFF,0xE7,0xFF}
            local databuff5={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff6={0x28,0x01,0x00,0x12,0xFF,0xE2,0xFF}
            if colorflag==1
            then
                SendUartData(databuff1,7)
            elseif colorflag==2
            then
                SendUartData(databuff2,7)
            elseif colorflag==3
            then
                SendUartData(databuff3,7)
            elseif colorflag==4
            then
                SendUartData(databuff4,7)
            elseif colorflag==5
            then
                SendUartData(databuff5,7)
            elseif colorflag==6
            then
                SendUartData(databuff6,7)
                firstin1=0
                colorflag=0
            end

        elseif 60<=buttonVar1 and buttonVar1<80
        then
            local databuff1={0x28,0x01,0x00,0x12,0xA3,0xC7,0xA5}
            local databuff2={0x28,0x01,0x00,0x12,0xC3,0x00,0xFE}
            local databuff3={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff4={0x28,0x01,0x00,0x12,0xFF,0xE7,0xFF}
            local databuff5={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff6={0x28,0x01,0x00,0x12,0xFF,0xE2,0xFF}
            if colorflag==1
            then
                SendUartData(databuff1,7)
            elseif colorflag==2
            then
                SendUartData(databuff2,7)
            elseif colorflag==3
            then
                SendUartData(databuff3,7)
            elseif colorflag==4
            then
                SendUartData(databuff4,7)
            elseif colorflag==5
            then
                SendUartData(databuff5,7)
            elseif colorflag==6
            then
                SendUartData(databuff6,7)
                firstin1=0
                colorflag=0
            end

        elseif 80<=buttonVar1 and buttonVar1<=100
        then
            local databuff1={0x28,0x01,0x00,0x12,0xA3,0x99,0x77}
            local databuff2={0x28,0x01,0x00,0x12,0xC3,0x00,0xFE}
            local databuff3={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff4={0x28,0x01,0x00,0x12,0xFF,0xE7,0xFF}
            local databuff5={0x28,0x01,0x00,0x12,0xC1,0x08,0xFF}
            local databuff6={0x28,0x01,0x00,0x12,0xFF,0xE2,0xFF}
            if colorflag==1
            then
                SendUartData(databuff1,7)
            elseif colorflag==2
            then
                SendUartData(databuff2,7)
            elseif colorflag==3
            then
                SendUartData(databuff3,7)
            elseif colorflag==4
            then
                SendUartData(databuff4,7)
            elseif colorflag==5
            then
                SendUartData(databuff5,7)
            elseif colorflag==6
            then
                SendUartData(databuff6,7)
                firstin1=0
                colorflag=0
            end
 
        end

    end
    colorflag=colorflag+1
   
end

搜索更多相关主题的帖子: then if end and local 
2021-09-23 15:39
快速回复:如何把这做成有延时100ms的
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030783 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved