【开源获奖案例】基于T5L智能屏的万能红外控制器

            ——来自迪文开发者论坛

本期为大家推送迪文开发者论坛获奖开源案例——基于T5L智能屏的万能红外控制器。工程师通过T5L串口与红外传感器模块进行通讯,赋予屏幕红外遥控功能,使其能够学习并模拟家电的红外遥控信号,实现对空        调、电视机、投影仪、功放机等红外控制设备的精准控制,并实时显示设备状态。该方案不仅提升了设备控制的效率和精确度,也为用户带来了更加便捷的交互体验。用户通过屏幕,即可轻松管理和控制这些设备,显著提升了家居和工业自动化领域的便捷性和智能化水平。


演示视频

        


完整开发资料含迪文屏DGUS工程资料与C51代码,获取方式:

1. 前往迪文开发者论坛获取:http://inforum.dwin.com.cn:20080/forum.php?mod=viewthread&tid=10416&extra=

2. 微信公众号中回复“万能红外控制器”获取。



【UI素材展示】

12


GUI工程设计

GUI工程设计


C51工程设计

T5L串口与红外传感器模块进行数据交互,实现通过屏幕控制空调的部分参考代码如下:

    INIT_CPU();

    T2_Init();

    UART4_Init();

    EA=1;

void Process(void)

{

    OneMsHandle();

    TenMsHandle();

}

bool uartHandle(u8 *Tdata,u16 len)

{

    u8   writedata[2]={0,0};

    u8   PressKeyI[]  ="完成              ";

    u8   PreMacClose[]="请再按下关机键     ";

    if(!ReadYaoKongOper)

        return false;

    if(Tdata[0]!=0x68)

        return false;

    switch(Tdata[1])

{

        case 8://正常应答,可以不管

        break;

        case 0X0A://正常应答,可以不管

//                default://返回已经弄好的学习码

        memset(&IR_CmdPack,0,sizeof(IR_CmdPack));

        IR_CmdPack.Tok=0x5a;

        IR_CmdPack.len=len;

        memcpy(IR_CmdPack.cmddata,Tdata,len);

Write_Dgusii_Vp(0x5000,(u8*)&IR_CmdPack,sizeof(IR_CmdPack_s)/2);

T5L_Flash(WRITE_MOD,0x5000,0x800+2048*(ReadYaoKongOper-1),sizeof(IR_CmdPack_s)/2);

        if(ReadYaoKongOper==1)

        {

Write_Dgusii_Vp(0x2000,PreMacClose,strlen(PreMacClose)/2);

        SendLearnCodeId(7);

        ReadYaoKongOper=7;

        }

        else

        {

            ReadYaoKongOper=0;//操作完成

            Write_Dgusii_Vp(0x1200,writedata,1);//写显示logo

            Write_Dgusii_Vp(0x2000,PressKeyI,strlen(PressKeyI)/2);

        }

//                        UART4_SendStr(Tdata,len);

            break;

        }

    return true;

}

void RecordPageKeyPress(void)

{

#if 1

        u8 TouchKey[2]={0,0};

        u8   writedata[2]={0,0};

//        u8   learnCode[]={0x68 ,0x08 ,0x00, 0xFF, 0x10 ,0x00 ,0x0F, 0x16};

        u8   PressKeyI[]="请按下遥控按键";

        u8   PreMachStart[]="请按下遥控开机键";

        Read_Dgusii_Vp(0x1210,TouchKey,1);

        if(TouchKey[1]==0)

            return;

        if(!ReadYaoKongOper && TouchKey[1]<7)

{        //只有未学习的时候,操作学习码

        SendLearnCodeId(TouchKey[1]);

        if(TouchKey[1]<=8)

            writedata[1]=1<<(TouchKey[1]-1);

        Write_Dgusii_Vp(0x1200,writedata,1);//写显示logo

        ReadYaoKongOper=TouchKey[1];

        if(ReadYaoKongOper!=1)

            Write_Dgusii_Vp(0x2000,PressKeyI,strlen(PressKeyI)/2);

        else

            Write_Dgusii_Vp(0x2000,PreMachStart,strlen(PreMachStart)/2);

    }

    TouchKey[1]=0;

    Write_Dgusii_Vp(0x1210,TouchKey,1);//关闭触摸按键

#endif

}

void CtrPageKeyPress(void)

{

    u8 TouchKey[2]={0,0};

    u8 sendcmd[]={0x68 ,0x08 ,0x00 ,0xFF ,0x12, 0x00 ,0x11, 0x16};

    u8   MachStart[]="已开机";

    u8   MachClose[]="已关机";

    Read_Dgusii_Vp(0x1300,TouchKey,1);

    if(TouchKey[1]==0)

        return;

//        printf("CtrPageKeyPress\r\n");

    if(TouchKey[1]<7)

    {

        memset(&IR_CmdPack,0,sizeof(IR_CmdPack));

#if 0

T5L_Flash(READ_MOD,0x5000,0x800+2048*(TouchKey[1]-1),sizeof(IR_CmdPack_s)/2);

        Read_Dgusii_Vp(0x5000,(u8*)&IR_CmdPack,sizeof(IR_CmdPack_s)/2);

        if(IR_CmdPack.Tok==0x5a)

            UART4_SendStr(IR_CmdPack.cmddata,IR_CmdPack.len);

#else

        if(TouchKey[1]!=1)

        {

            sendcmd[5]=TouchKey[1]-1;

            sendcmd[6]=sendcmd[6]+sendcmd[5];

        }

        else

        {

            if(MachineST)

            {

                MachineST=0;

                TouchKey[1]=7;

                sendcmd[5]=TouchKey[1]-1;

                sendcmd[6]=sendcmd[6]+sendcmd[5];

                Write_Dgusii_Vp(0x2300,MachClose,strlen(MachClose)/2);

            }

            else

            {

                MachineST=1;

                sendcmd[5]=TouchKey[1]-1;

                sendcmd[6]=sendcmd[6]+sendcmd[5];

                Write_Dgusii_Vp(0x2300,MachStart,strlen(MachStart)/2);

            }

    }

    UART4_SendStr(sendcmd,sizeof(sendcmd));

#endif

//                printf("IR_CmdPack.Tok:%d",IR_CmdPack.Tok);

//                UART4_SendStr(&IR_CmdPack,10);

    }

    TouchKey[1]=0;

    Write_Dgusii_Vp(0x1300,TouchKey,1);//关闭触摸按键       

}