本期为大家推送迪文开发者论坛获奖开源案例——基于T5L智能屏的汽车抬头显示器方案。该方案采用COF智能屏,通过T5L CAN接口,实时获取汽车OBDII诊断接口的数据,并将接收到的车速和转速数据同步显示在屏幕上,为驾驶员在行车过程中提供直观、便捷的视觉辅助。
UI素材展示
GUI工程设计 C51工程设计
通过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); } }}
-
显示器
+关注
关注
21文章
4944浏览量
139809 -
开源
+关注
关注
3文章
3244浏览量
42384 -
智能屏幕
+关注
关注
0文章
65浏览量
3313
发布评论请先 登录
相关推荐
评论