【开源获奖案例】基于T5L智能屏的汽车抬头显示器方案

        ——来自迪文开发者论坛

本期为大家推送迪文开发者论坛获奖开源案例——基于T5L智能屏的汽车抬头显示器方案。该方案采用COF智能屏,通过T5L CAN接口,实时获取汽车OBDII诊断接口的数据,并将接收到的车速和转速数据同步显示在屏幕上,为驾驶员在行车过程中提供直观、便捷的视觉辅助。

 

    【演示视频】

 

 

视频由论坛工程师实拍提供


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

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

2. 微信公众号中回复“汽车抬头显示器”获取。

 

UI素材展示

UI素材

 

【GUI工程设计】

  GUI工程设计

【程序代码设计

通过T5L CAN接口,获取车速和转速数据,部分参考代码如下:

void main(void)

{

    T5LInit();

    T0_Init(); // 定时器0初始化

    EA = 1;

    //等待上电稳定    

    TimerExtDelayMs(2000);

    GaugeViewInit();    

    while (1)

    {

        //obdii系统进入识别

        if (ObdiiSysEnter())

        {

            break;

        }

    }

    //HUD功能主入口

    GaugeViewFunc();

}

 

void GaugeViewFunc(void)

{

    uint8_t rawDataBuff[256];

    uint8_t resultBuff[5];

    float vehicleSpeed = 0;

    float rotateSpeed = 0;

    uint32_t tempData = 0;

    while (1)

    {

        memset(rawDataBuff, 0, 256);

        // 读取转速

        if (ObdiiReadPid(rawDataBuff, 2, 0x01, 0x0C))

        {

            ObdiiLdsCalResult(0x0C, rawDataBuff, resultBuff);

            tempData = resultBuff[3];

            tempData = resultBuff[2] + (tempData << 8);

            tempData = resultBuff[1] + (tempData << 8);

            tempData = resultBuff[0] + (tempData << 8);

            rotateSpeed = (float)tempData;

            GaugeViewRotateSpeedSet(rotateSpeed);

        }

        memset(rawDataBuff, 0, 256);

        // 读取车速

        if (ObdiiReadPid(rawDataBuff, 2, 0x01, 0x0D))

        {

            ObdiiLdsCalResult(0x0D, rawDataBuff, resultBuff);

            tempData = resultBuff[3];

            tempData = resultBuff[2] + (tempData << 8);

            tempData = resultBuff[1] + (tempData << 8);

            tempData = resultBuff[0] + (tempData << 8);

            vehicleSpeed = (float)tempData;

            GaugeViewPointerSet((uint8_t)vehicleSpeed);

            GaugeViewVehicleSpeedSet(vehicleSpeed);

        }

    }

}

void GaugeViewFunc(void)

{

    uint8_t rawDataBuff[256];

    uint8_t resultBuff[5];

    float vehicleSpeed = 0;

    float rotateSpeed = 0;

    uint32_t tempData = 0;

    while (1)

    {

    memset(rawDataBuff, 0, 256);

    // 读取转速

    if (ObdiiReadPid(rawDataBuff, 2, 0x01, 0x0C))

        {

        ObdiiLdsCalResult(0x0C, rawDataBuff, resultBuff);

        tempData = resultBuff[3];

        tempData = resultBuff[2] + (tempData << 8);

        tempData = resultBuff[1] + (tempData << 8);

        tempData = resultBuff[0] + (tempData << 8);

        rotateSpeed = (float)tempData;

        GaugeViewRotateSpeedSet(rotateSpeed);

        }

    memset(rawDataBuff, 0, 256);

    // 读取车速

    if (ObdiiReadPid(rawDataBuff, 2, 0x01, 0x0D))

        {

        ObdiiLdsCalResult(0x0D, rawDataBuff, resultBuff);

        tempData = resultBuff[3];

        tempData = resultBuff[2] + (tempData << 8);

        tempData = resultBuff[1] + (tempData << 8);

        tempData = resultBuff[0] + (tempData << 8);

        vehicleSpeed = (float)tempData;

        GaugeViewPointerSet((uint8_t)vehicleSpeed);

        GaugeViewVehicleSpeedSet(vehicleSpeed);

        }

    }

}