——來(lái)自迪文開(kāi)發(fā)者論壇
本期為大家推送迪文開(kāi)發(fā)者論壇獲獎(jiǎng)開(kāi)源案例——基于T5L智能屏的汽車抬頭顯示器方案。該方案采用COF智能屏,通過(guò)T5L CAN接口,實(shí)時(shí)獲取汽車OBDII診斷接口的數(shù)據(jù),并將接收到的車速和轉(zhuǎn)速數(shù)據(jù)同步顯示在屏幕上,為駕駛員在行車過(guò)程中提供直觀、便捷的視覺(jué)輔助。
UI素材展示
GUI工程設(shè)計(jì) C51工程設(shè)計(jì)
通過(guò)T5L CAN接口,獲取車速和轉(zhuǎn)速數(shù)據(jù),部分參考代碼如下:
void main(void){ T5LInit(); T0_Init(); // 定時(shí)器0初始化 EA = 1; //等待上電穩(wěn)定 TimerExtDelayMs(2000); GaugeViewInit(); while (1) { //obdii系統(tǒng)進(jìn)入識(shí)別 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); // 讀取轉(zhuǎn)速 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); // 讀取轉(zhuǎn)速 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); } }}
-
顯示器
+關(guān)注
關(guān)注
21文章
4970瀏覽量
139925 -
開(kāi)源
+關(guān)注
關(guān)注
3文章
3309瀏覽量
42471 -
智能屏幕
+關(guān)注
關(guān)注
0文章
65瀏覽量
3323
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論